r64: *** empty log message ***
[ctsim.git] / configure.in
1 IZEOFdnl Process this file with autoconf to produce a configure script.
2
3 dnl Must reset CDPATH so that bash's cd does not print to stdout
4 dnl CDPATH=
5
6 AC_INIT(src/ctrec.c)
7 AM_INIT_AUTOMAKE(ctsim,0.5.4-b3)
8 AM_CONFIG_HEADER(config.h)
9
10 dnl Checks for programs.
11 AC_PROG_AWK
12 AC_PROG_INSTALL
13 AC_PROG_MAKE_SET
14 AC_PROG_RANLIB
15 AC_PROG_CC
16 AC_PROG_CXX
17
18
19 dnl AC_MSG_CHECKING([that the compiler works])
20 dnl AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],     AC_MSG_RESULT(yes),     AC_MSG_RESULT(no)     AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.),     AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.))
21
22 dnl Check for C operation
23 AC_CANONICAL_HOST 
24 AC_C_BIGENDIAN
25 AC_C_INLINE
26 AC_CHECK_SIZEOF(short, 2)
27 AC_CHECK_SIZEOF(int, 4)
28 AC_CHECK_SIZEOF(long, 4)
29 AC_CHECK_SIZEOF(float, 4)
30 AC_CHECK_SIZEOF(double, 8)
31
32 AC_MSG_CHECKING(endian)
33
34 case "$host_cpu" in
35 i386* | i486* | i586* | i686* | vax*) 
36    endian=low 
37    CFLAGS="$CFLAGS -DENDIAN_LOW=1 -DENDIAN_HIGH=0"
38    AC_MSG_RESULT(low) 
39    ;;
40 sparc*  | mot* | ia64*) 
41   endian=high 
42    CFLAGS="$CFLAGS -DENDIAN_LOW=0 -DENDIAN_HIGH=1"
43   AC_MSG_RESULT(high) 
44   ;;
45 *) 
46   AC_MSG_WARN([Unknown host cpu $host_cpu. Can't set endian])
47   ;;
48 esac
49
50 dnl Checks for libraries.
51 AC_CHECK_LIB(z, main, 
52 [
53   zlib="true"
54 ],
55
56   zlib="false"
57   AC_MSG_WARN([zlib missing. Will need zlib for PNG support])
58 ])
59 AC_CHECK_LIB(m, main)
60 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
61 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
62 AC_CHECK_LIB(g2, main, [g2=true], [g2=false])
63  
64 dnl Checks for header files.
65 AC_HEADER_STDC
66 AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h sys/fcntl.h setjmp.h stdarg.h stddef.h sys/types.h sys/stat.h string.h ctype.h math.h stdio.h netinet/in.h inttypes.h sys/param.h stdint.h stdlib.h g2.h)
67
68 dnl Checks for typedefs, structures, and compiler characteristics.
69 AC_C_CONST
70 AC_TYPE_OFF_T
71 AC_TYPE_SIZE_T
72 AC_STRUCT_TM
73
74 dnl Checks for library functions.
75 AC_FUNC_VPRINTF
76 AC_CHECK_FUNCS(strtod strtol snprintf htonl)
77 AC_CHECK_FUNC(basename)
78 AC_CHECK_FUNC(setjmp)
79 if ${OSTYPE} == "cygwin" ; then
80   getopt_long=false
81 else
82   AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
83 fi
84 if test getopt_long == "false" ; then
85   my_includes="$myincludes -I../getopt"
86   AC_DEFINE(HAVE_GETOPT_LONG)
87   ctlibs_base="$ctlibs_base -lgetopt"
88   LDFLAGS="$LDFLAGS -L../getopt"
89   AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
90 fi
91
92
93 AC_ADD_GCC_CFLAGS([-Wall])
94 AC_MSG_CHECKING(whether to enable verbose warnings)
95 AC_ARG_ENABLE(verbose-warnings,
96 [  --enable-verbose-warnings
97                           Enable verbose compiler warnings.],
98 [ case "$enableval" in
99   yes)
100     AC_MSG_RESULT(yes)
101     AC_ADD_GCC_CFLAGS([-W])
102     AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
103     AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
104     AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
105     AC_ADD_GCC_CFLAGS([-pedantic])
106     AC_ADD_GCC_CFLAGS([-Wredundant-decls])
107
108     ;;
109   *)
110     AC_MSG_RESULT(no)
111     ;;
112   esac ], AC_MSG_RESULT(no)
113 )
114
115 dnl Check for debug mode
116 AC_ARG_ENABLE(debug,
117 [  --enable-debug          Turn on debugging],
118 [case "${enableval}" in
119   yes) debug=true 
120        CFLAGS="$CFLAGS -g"
121        ;;
122   no)  debug=false 
123        CFLAGS="$CFLAGS -O2"
124        ;;
125   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) 
126        ;;
127 esac],[debug=false])
128 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
129
130 dnl Set PNG directory     
131 AC_MSG_CHECKING([for PNG library installation])
132 AC_ARG_WITH(png,
133 [  --with-png[=PATH]       Set path of lib PNG installation ],
134 [
135      if test "$withval" != "no" ; then
136          trypngdir=$withval
137          if test "$prefix" != "NONE" ; then
138          trypngdir="$trypngdir $prefix"
139        fi
140      fi
141 ]
142 )
143
144 if test "$withval" != "no" -a "$zlib" = "true" ; then
145   for testpngdir in "." $trypngdir /usr/local /usr /opt ; do
146     if test -f "$testpngdir/lib/libpng.a" ; then
147       if test ! -f "$testpngdir/include/png.h" ; then
148         AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
149       else
150           grep PNG_LIBPNG_VER_STRING "$testpngdir/include/png.h" | grep 9 > /dev/null 
151           if test "$?" = "0" ; then
152             AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
153           fi
154       fi
155       LDFLAGS="$LDFLAGS -L$testpngdir/lib"
156       CFLAGS="$CFLAGS -I$testpngdir/include"
157       pngdir="$testpngdir"
158       AC_DEFINE(HAVE_PNG)
159       break
160     elif test -f "$testpngdir/libpng.a" ; then
161       if test ! -f "$testpngdir/png.h" ; then
162         AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
163       else
164           grep PNG_LIBPNG_VER_STRING "$testpngdir/png.h" | grep 9 > /dev/null 
165           if test "$?" = "0" ; then
166             AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
167           fi
168       fi
169       LDFLAGS="$LDFLAGS -L$testpngdir"
170       CFLAGS="$CFLAGS -I$testpngdir"
171       pngdir="$testpngdir"
172       AC_DEFINE(HAVE_PNG)
173       break
174     fi
175   done
176   AC_MSG_RESULT($pngdir)
177   AM_CONDITIONAL(HAVE_PNG, test -n "$pngdir")
178 else
179   AC_MSG_RESULT([no])
180 fi
181
182 dnl Set LAM path
183 AC_ARG_WITH(lam,
184 [  --with-lam[=PATH]       Set path of LAM MPI ],
185 [    if test "$withval" != "no" ; then
186          trylamdir=$withval
187      fi ]
188 )
189
190 if test "$withval" != "no" ; then
191   if test "$prefix" != "NONE" ; then
192      trylamdir="$trylamdir $prefix"
193   fi
194
195   AC_MSG_CHECKING([for LAM MPI installation])
196   for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
197     if test -x "$testlamdir/bin/hcc" ; then
198       LDFLAGS="$LDFLAGS -L$testlamdir/lib"
199       CFLAGS="$CFLAGS -I$testlamdir/include"
200       lamdir="$testlamdir"
201       AC_SUBST(lamdir)
202       mpienable="true"
203       AC_SUBST(mpienable)
204       break
205     fi
206   done
207   AC_MSG_RESULT($lamdir)
208 else
209   AC_MSG_RESULT([no])
210 fi
211
212 AC_MSG_CHECKING([for web access])
213 dnl Set cgi-bin directory
214 AC_ARG_WITH(cgibin-dir, [  --with-cgibin-dir=PATH  Set path of CGI binaries directory ], 
215 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
216
217 AC_ARG_WITH(cgibin-url, [  --with-cgibin-url=PATH  Set URL path of CGI binaries ], 
218 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
219
220 AC_ARG_WITH(webdata-dir, [  --with-webdata-dir=PATH Set path of webdata], 
221 [ webdatadir=$withval ; AC_SUBST(webdatadir)  ] )
222
223 AC_ARG_WITH(webdata-url, [  --with-webdata-url=PATH Set URL path of webdata], 
224 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
225
226 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH    Set directory of html files], 
227 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
228
229 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
230   cgiprograms="ctsim.cgi ctsim.conf"
231   AC_SUBST(cgiprograms)
232 fi
233
234 if test -n "$htmldir" ; then
235   htmldata=simulate.html
236   AC_SUBST(htmldata)
237 fi
238 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
239
240 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
241   webenabled=true
242   AC_SUBST(webenabled)
243   AC_MSG_RESULT([yes])
244   if test -z "$cgibindir" ; then
245     AC_MSG_ERROR([--with-cgibin-dir not set for web access])
246   elif test -z "$cgibinurl" ; then
247     AC_MSG_ERROR([--with-cgibin-url not set for web access])
248   elif test -z "$webdatadir" ; then
249     AC_MSG_ERROR([--with-webdata-dir not set for web access])
250   elif test -z "$webdataurl" ; then
251     AC_MSG_ERROR([--with-webdata-url not set for web access])
252   elif test -z "$htmldir" ; then
253     AC_MSG_ERROR([--with-html-dir not set for web access])
254   fi
255 else
256   AC_MSG_RESULT([no])
257 fi
258
259 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
260
261 dnl Prepare to support X.  If the user gave the command-line option
262 dnl --without-x, AC_PATH_XTRA will set no_x to "yes".  Otherwise, it will
263 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
264 dnl flags to X_LIBS.  It also checks for system-specific X libraries, and
265 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate.  (The former
266 dnl is where "-lSM -lICE" goes, in X11R6.)  We define the X_TOOLKIT_LIBS
267 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
268 dnl supported, we'll concatenate the whole lot of these into a command line
269 dnl for libtool.  See, e.g., the libplot_la_LIBADD line in
270 dnl libplot/Makefile.am.
271
272 AC_PATH_XTRA
273 AC_SUBST(X_CFLAGS)
274 dnl Following five are concatenated together into a linker specification.
275 AC_SUBST(X_LIBS)
276 AC_SUBST(X_TOOLKIT_LIBS)
277 AC_SUBST(X_PRE_LIBS)
278 AC_SUBST(X_BASIC_LIBS)
279 AC_SUBST(X_EXTRA_LIBS)
280
281 X_TOOLKIT_LIBS="-lXt"
282 X_BASIC_LIBS="-lXext -lX11"
283
284 dnl Check whether libXt has thread support.  Some platforms may have
285 dnl pthread support in libc, but no thread support in libXt/libX11.
286 our_saved_LDFLAGS="$LDFLAGS"
287 LDFLAGS="$X_LIBS $LDFLAGS"
288 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
289 LDFLAGS="$our_saved_LDFLAGS"
290
291 dnl Check in -lXext for double buffering extensions to X11, and check
292 dnl whether appropriate header files are present.  (Some systems have one
293 dnl but not the other.)
294 our_saved_LDFLAGS="$LDFLAGS"
295 LDFLAGS="$X_LIBS $LDFLAGS"
296 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
297 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
298 LDFLAGS="$our_saved_LDFLAGS"
299 our_saved_CPPFLAGS="$CPPFLAGS"
300 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
301 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
302 CPPFLAGS="$our_saved_CPPFLAGS"
303
304 dnl Our Makefile.am files test the automake variable NO_X to determine
305 dnl whether X should be supported.
306 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
307
308 my_includes="$my_includes -I../include -I.."
309 AC_SUBST(my_includes)
310
311 AC_MSG_CHECKING([interactive graphics])
312 if test "x$no_x" != "xyes" ; then
313   AC_DEFINE(HAVE_SGP)
314   AC_DEFINE(HAVE_X11)
315   AM_CONDITIONAL(HAVE_SGP, test 1==1)
316   LDFLAGS="$LDFLAGS -L../libezplot -L../libgraph -L/usr/X11R6/lib"
317   ctlibs_base="$ctlibs_base -lezplot -lgraph $X_BASIC_LIBS $X_TOOLKIT_LIBS"
318   AC_MSG_RESULT(yes)
319 else
320   AC_MSG_RESULT(no)
321 fi
322
323 dnl Setting projet libraries and includes
324 LDFLAGS="$LDFLAGS -L../libkmath -L../libk -L../libcio -L../libir" 
325 ctlibs_base="$ctlibs_base -lkmath -lk -lcio"
326 if test -n "$pngdir" ; then
327   ctlibs_base="$ctlibs_base -lpng"
328 fi
329 if test "$zlib" = "true" ; then
330   ctlibs_base="$ctlibs_base -lz"
331 fi
332 if test "$g2" = "true" ; then
333   ctlibs_base="$ctlibs_base -lg2"
334 fi
335
336 ctlibs="-lir $ctlibs_base"
337
338 AC_SUBST(ctlibs)
339
340 if test -n "$lamdir" ; then
341   ctlamlibs="-lir_lam $ctlibs_base"
342   lamprograms="ctrec-lam phm2sdf-lam phm2rs-lam"
343   AC_SUBST(lamprograms)
344   AC_SUBST(ctlamlibs)
345 fi
346
347 AC_OUTPUT(Makefile libezplot/Makefile src/Makefile libgraph/Makefile libkmath/Makefile Makefile libk/Makefile libir/Makefile libcio/Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile src/sample-ctrec.sh cgi-bin/ctsim.conf)