1 dnl Process this file with autoconf to produce a configure script.
3 dnl Must reset CDPATH so that bash's cd does not print to stdout
7 AM_INIT_AUTOMAKE(ctsim,2.0.0b12)
8 AM_CONFIG_HEADER(config.h)
10 dnl Checks for programs.
17 AC_PATH_PROG(wxconfig,wx-config)
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.))
22 dnl Check for C operation
25 AC_CHECK_SIZEOF(short, 2)
26 AC_CHECK_SIZEOF(int, 4)
27 AC_CHECK_SIZEOF(long, 4)
28 AC_CHECK_SIZEOF(float, 4)
29 AC_CHECK_SIZEOF(double, 8)
31 dnl ---------------------------------------------------------------------------
32 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
33 dnl from wxGTK (www.wxwindows.org) - LGPL license
34 dnl ---------------------------------------------------------------------------
36 AC_DEFUN(WX_C_BIGENDIAN,
37 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
38 [ac_cv_c_bigendian=unknown
39 # See if sys/param.h defines the BYTE_ORDER macro.
40 AC_TRY_COMPILE([#include <sys/types.h>
41 #include <sys/param.h>], [
42 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
44 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
45 AC_TRY_COMPILE([#include <sys/types.h>
46 #include <sys/param.h>], [
47 #if BYTE_ORDER != BIG_ENDIAN
49 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
50 if test $ac_cv_c_bigendian = unknown; then
52 /* Are we little or big endian? From Harbison&Steele. */
56 char c[sizeof (long)];
59 exit (u.c[sizeof (long) - 1] == 1);
60 }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes, ac_cv_c_bigendian=unknown)
62 if test $ac_cv_c_bigendian = unknown; then
63 AC_MSG_WARN([Assuming little-endian target machine - this may be overriden by adding the line "ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'}"
64 to config.cache file])
66 if test $ac_cv_c_bigendian = yes; then
67 AC_DEFINE(WORDS_BIGENDIAN)
74 dnl Checks for libraries.
75 AC_CHECK_LIB(z, main, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
77 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
78 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
79 AC_CHECK_LIB(g2, main, [g2=true], [g2=false])
81 AC_CHECK_LIB(wx_gtk, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS)])
82 AC_CHECK_LIB(wx_msw, main, [wxwin=true; wx_msw=true; AC_DEFINE(HAVE_WXWINDOWS)])
83 AC_CHECK_LIB(hdf5, main, [hdf5=true], [hdf5=false], -lz)
84 AC_CHECK_LIB(fftw, main, [fftw=true; AC_DEFINE(HAVE_FFTW)], [fftw=false])
86 if test "$zlib" = "true" ; then
87 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
90 dnl Checks for header files.
92 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 assert.h sys/time.h sys/resource.h)
94 dnl Checks for typedefs, structures, and compiler characteristics.
100 dnl Checks for library functions.
102 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep)
103 AC_CHECK_FUNC(basename)
104 AC_CHECK_FUNC(setjmp)
105 AC_CHECK_FUNC(setpriority)
107 if test "${OSTYPE}" = "cygwin" ; then
110 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
112 if test "${getopt_long}" = "false" ; then
113 my_includes="$myincludes -I../getopt"
114 AC_DEFINE(HAVE_GETOPT_LONG)
115 ctlibs_base="$ctlibs_base -lgetopt"
116 LDFLAGS="$LDFLAGS -L../getopt"
117 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
120 dnl Check for debug mode
121 AC_MSG_CHECKING([debug])
123 [ --enable-debug Turn on debugging],
124 [case "${enableval}" in
131 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
134 [debug=false; AC_MSG_RESULT(no)])
135 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
137 if test "$debug" = "true" ; then
138 dnl AC_ADD_GCC_CFLAGS([-g -DDEBUG])
142 dnl AC_ADD_GCC_CFLAGS([-g -O2 -DNDEBUG])
143 CFLAGS="-g -O3 -DNDEBUG"
148 AC_ADD_GCC_CFLAGS([-Wall])
149 AC_MSG_CHECKING(whether to enable verbose warnings)
150 AC_ARG_ENABLE(verbose-warnings,
151 [ --enable-verbose-warnings
152 Enable verbose compiler warnings.],
153 [ case "$enableval" in
156 AC_ADD_GCC_CFLAGS([-W])
157 AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
158 AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
159 AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
160 AC_ADD_GCC_CFLAGS([-pedantic])
161 AC_ADD_GCC_CFLAGS([-Wredundant-decls])
167 esac ], AC_MSG_RESULT(no)
170 AC_MSG_CHECKING(static executables)
171 AC_ARG_ENABLE(static,
173 Enable static executables.],
174 [ case "$enableval" in
177 AC_ADD_GCC_CFLAGS([--static])
182 esac ], AC_MSG_RESULT(no)
187 [ --with-lam[=PATH] Set path of LAM MPI ],
188 [ if test "$withval" != "no" ; then
193 if test "$withval" != "no" ; then
194 if test "$prefix" != "NONE" ; then
195 trylamdir="$trylamdir $prefix"
198 AC_MSG_CHECKING([for LAM MPI installation])
199 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
200 if test -x "$testlamdir/bin/hcc" ; then
201 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
202 CFLAGS="$CFLAGS -I$testlamdir/include"
210 AC_MSG_RESULT($lamdir)
215 AC_MSG_CHECKING([for web access])
216 dnl Set cgi-bin directory
217 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
218 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
220 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
221 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
223 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
224 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
226 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
227 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
229 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
230 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
232 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
233 cgiprograms="ctsim.cgi ctsim.conf"
234 AC_SUBST(cgiprograms)
237 if test -n "$htmldir" ; then
238 htmldata=simulate.html
241 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
243 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
247 if test -z "$cgibindir" ; then
248 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
249 elif test -z "$cgibinurl" ; then
250 AC_MSG_ERROR([--with-cgibin-url not set for web access])
251 elif test -z "$webdatadir" ; then
252 AC_MSG_ERROR([--with-webdata-dir not set for web access])
253 elif test -z "$webdataurl" ; then
254 AC_MSG_ERROR([--with-webdata-url not set for web access])
255 elif test -z "$htmldir" ; then
256 AC_MSG_ERROR([--with-html-dir not set for web access])
262 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
264 dnl Prepare to support X. If the user gave the command-line option
265 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
266 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
267 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
268 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
269 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
270 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
271 dnl supported, we'll concatenate the whole lot of these into a command line
272 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
273 dnl libplot/Makefile.am.
277 dnl Following five are concatenated together into a linker specification.
279 AC_SUBST(X_TOOLKIT_LIBS)
281 AC_SUBST(X_BASIC_LIBS)
282 AC_SUBST(X_EXTRA_LIBS)
284 X_TOOLKIT_LIBS="-lXt"
285 X_BASIC_LIBS="-lXext -lX11"
287 dnl Check whether libXt has thread support. Some platforms may have
288 dnl pthread support in libc, but no thread support in libXt/libX11.
289 our_saved_LDFLAGS="$LDFLAGS"
290 LDFLAGS="$X_LIBS $LDFLAGS"
291 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
292 LDFLAGS="$our_saved_LDFLAGS"
294 dnl Check in -lXext for double buffering extensions to X11, and check
295 dnl whether appropriate header files are present. (Some systems have one
296 dnl but not the other.)
297 our_saved_LDFLAGS="$LDFLAGS"
298 LDFLAGS="$X_LIBS $LDFLAGS"
299 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
300 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
301 LDFLAGS="$our_saved_LDFLAGS"
302 our_saved_CPPFLAGS="$CPPFLAGS"
303 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
304 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
305 CPPFLAGS="$our_saved_CPPFLAGS"
307 dnl Our Makefile.am files test the automake variable NO_X to determine
308 dnl whether X should be supported.
309 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
311 my_includes="$my_includes -I../include -I.."
312 AC_SUBST(my_includes)
314 AC_MSG_CHECKING([interactive graphics])
315 if test "$no_x" != "yes" ; then
318 AM_CONDITIONAL(HAVE_SGP, test 1==1)
319 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
320 ctlibs_graphics="$ctlibs_base -lctgraphics"
322 if test "$g2" = "true" ; then
323 ctlibs_graphics="$ctlibs_graphics -lg2"
325 ctlibs_graphics="$ctlibs_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
330 if test "$png" = "true" ; then
331 ctlibs_tools="$ctlibs_tools -lpng"
333 if test "$zlib" = "true" ; then
334 ctlibs_tools="$ctlibs_tools -lz"
336 if test "$fftw" = "true" ; then
337 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
340 dnl Check for dmalloc
341 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
342 AC_MSG_CHECKING([for enable-dmalloc])
343 AC_ARG_ENABLE(dmalloc,
344 [ --enable-dmalloc Use dmalloc memory allocation],
345 [case "${enableval}" in
352 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
355 [usedmalloc=false; AC_MSG_RESULT(no)])
357 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
358 ctlibs_tools="$ctlibs_tools -ldmallocxx"
359 AC_DEFINE(HAVE_DMALLOC)
360 AC_MSG_RESULT(Using dmalloc)
363 if test "$wxwin" = "true" ; then
364 wxcflags=`$wxconfig --cflags`
365 CFLAGS="$CFLAGS -I../include $wxcflags"
366 wxlibs=`$wxconfig --libs`
367 ctlibs_graphics="$ctlibs_graphics $wxlibs"
368 AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
373 dnl Setting projet libraries and includes
374 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
375 ctlibs="$ctlibs_base -lctsim $ctlibs_graphics -lctsupport $ctlibs_tools"
378 if test -n "$lamdir" ; then
379 lamprograms="pjrec-lam phm2if-lam phm2pj-lam"
380 AC_SUBST(lamprograms)
387 AC_OUTPUT(Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile doc/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile)