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.0)
8 AM_CONFIG_HEADER(config.h)
10 dnl Checks for programs.
16 CFLAGS="$CFLAGS -I/usr/local/include"
17 LDFLAGS="$LDFLAGS -L/usr/local/lib"
20 AC_PATH_PROG(wxconfig,wx-config)
22 dnl AC_MSG_CHECKING([that the compiler works])
23 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.))
25 dnl Check for C operation
28 AC_CHECK_SIZEOF(short, 2)
29 AC_CHECK_SIZEOF(int, 4)
30 AC_CHECK_SIZEOF(long, 4)
31 AC_CHECK_SIZEOF(float, 4)
32 AC_CHECK_SIZEOF(double, 8)
34 dnl ---------------------------------------------------------------------------
35 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
36 dnl from wxGTK (www.wxwindows.org) - LGPL license
37 dnl ---------------------------------------------------------------------------
39 AC_DEFUN(WX_C_BIGENDIAN,
40 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
41 [ac_cv_c_bigendian=unknown
42 # See if sys/param.h defines the BYTE_ORDER macro.
43 AC_TRY_COMPILE([#include <sys/types.h>
44 #include <sys/param.h>], [
45 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
47 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
48 AC_TRY_COMPILE([#include <sys/types.h>
49 #include <sys/param.h>], [
50 #if BYTE_ORDER != BIG_ENDIAN
52 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
53 if test $ac_cv_c_bigendian = unknown; then
55 /* Are we little or big endian? From Harbison&Steele. */
59 char c[sizeof (long)];
62 exit (u.c[sizeof (long) - 1] == 1);
63 }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes, ac_cv_c_bigendian=unknown)
65 if test $ac_cv_c_bigendian = unknown; then
66 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'}"
67 to config.cache file])
69 if test $ac_cv_c_bigendian = yes; then
70 AC_DEFINE(WORDS_BIGENDIAN)
77 dnl Checks for libraries.
78 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
80 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
81 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
82 AC_CHECK_LIB(g2, main, [g2=true], [g2=false])
84 AC_CHECK_LIB(wx_gtk, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS)])
85 AC_CHECK_LIB(wx, main, [wxwin=true; wx_msw=true; AC_DEFINE(HAVE_WXWINDOWS)])
86 AC_CHECK_LIB(hdf5, main, [hdf5=true], [hdf5=false], -lz)
87 AC_CHECK_LIB(fftw, fftw_one, [fttw=true; AC_DEFINE(HAVE_FFTW)], [fftw=false])
89 if test "$zlib" = "true" ; then
90 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
93 dnl Checks for header files.
95 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 sys/time.h)
97 dnl Checks for typedefs, structures, and compiler characteristics.
103 dnl Checks for library functions.
105 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
106 AC_CHECK_FUNC(basename)
107 AC_CHECK_FUNC(setjmp)
108 AC_CHECK_FUNC(setpriority)
110 AC_CHECK_FUNC(gettimeofday)
112 if test "${OSTYPE}" = "cygwin" ; then
115 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
118 if test "${getopt_long}" = "false" ; then
119 my_includes="$my_includes -I../getopt"
120 AC_DEFINE(HAVE_GETOPT_LONG)
121 ctlibs_base="$ctlibs_base -lgetopt"
122 LDFLAGS="$LDFLAGS -L../getopt"
123 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
126 dnl Check for debug mode
127 AC_MSG_CHECKING([debug])
129 [ --enable-debug Turn on debugging],
130 [case "${enableval}" in
137 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
140 [debug=false; AC_MSG_RESULT(no)])
141 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
143 if test "$debug" = "true" ; then
144 dnl AC_ADD_GCC_CFLAGS([-g -DDEBUG])
148 dnl AC_ADD_GCC_CFLAGS([-g -O2 -DNDEBUG])
149 CFLAGS="-g -O3 -DNDEBUG"
154 AC_ADD_GCC_CFLAGS([-Wall])
155 AC_MSG_CHECKING(whether to enable verbose warnings)
156 AC_ARG_ENABLE(verbose-warnings,
157 [ --enable-verbose-warnings
158 Enable verbose compiler warnings.],
159 [ case "$enableval" in
162 AC_ADD_GCC_CFLAGS([-W])
163 AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
164 AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
165 AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
166 AC_ADD_GCC_CFLAGS([-pedantic])
167 AC_ADD_GCC_CFLAGS([-Wredundant-decls])
173 esac ], AC_MSG_RESULT(no)
176 AC_MSG_CHECKING(static executables)
177 AC_ARG_ENABLE(static,
179 Enable static executables.],
180 [ case "$enableval" in
183 AC_ADD_GCC_CFLAGS([--static])
188 esac ], AC_MSG_RESULT(no)
193 [ --with-lam[=PATH] Set path of LAM MPI ],
194 [ if test "$withval" != "no" ; then
199 if test "$withval" != "no" ; then
200 if test "$prefix" != "NONE" ; then
201 trylamdir="$trylamdir $prefix"
204 AC_MSG_CHECKING([for LAM MPI installation])
205 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
206 if test -x "$testlamdir/bin/hcc" ; then
207 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
208 CFLAGS="$CFLAGS -I$testlamdir/include"
216 AC_MSG_RESULT($lamdir)
221 AC_MSG_CHECKING([for web access])
222 dnl Set cgi-bin directory
223 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
224 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
226 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
227 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
229 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
230 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
232 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
233 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
235 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
236 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
238 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
239 cgiprograms="ctsim.cgi ctsim.conf"
240 AC_SUBST(cgiprograms)
243 if test -n "$htmldir" ; then
244 htmldata=simulate.html
247 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
249 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
253 if test -z "$cgibindir" ; then
254 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
255 elif test -z "$cgibinurl" ; then
256 AC_MSG_ERROR([--with-cgibin-url not set for web access])
257 elif test -z "$webdatadir" ; then
258 AC_MSG_ERROR([--with-webdata-dir not set for web access])
259 elif test -z "$webdataurl" ; then
260 AC_MSG_ERROR([--with-webdata-url not set for web access])
261 elif test -z "$htmldir" ; then
262 AC_MSG_ERROR([--with-html-dir not set for web access])
268 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
270 dnl Prepare to support X. If the user gave the command-line option
271 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
272 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
273 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
274 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
275 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
276 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
277 dnl supported, we'll concatenate the whole lot of these into a command line
278 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
279 dnl libplot/Makefile.am.
283 dnl Following five are concatenated together into a linker specification.
285 AC_SUBST(X_TOOLKIT_LIBS)
287 AC_SUBST(X_BASIC_LIBS)
288 AC_SUBST(X_EXTRA_LIBS)
290 X_TOOLKIT_LIBS="-lXt"
291 X_BASIC_LIBS="-lXext -lX11"
293 dnl Check whether libXt has thread support. Some platforms may have
294 dnl pthread support in libc, but no thread support in libXt/libX11.
295 our_saved_LDFLAGS="$LDFLAGS"
296 LDFLAGS="$X_LIBS $LDFLAGS"
297 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
298 LDFLAGS="$our_saved_LDFLAGS"
300 dnl Check in -lXext for double buffering extensions to X11, and check
301 dnl whether appropriate header files are present. (Some systems have one
302 dnl but not the other.)
303 our_saved_LDFLAGS="$LDFLAGS"
304 LDFLAGS="$X_LIBS $LDFLAGS"
305 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
306 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
307 LDFLAGS="$our_saved_LDFLAGS"
308 our_saved_CPPFLAGS="$CPPFLAGS"
309 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
310 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
311 CPPFLAGS="$our_saved_CPPFLAGS"
313 dnl Our Makefile.am files test the automake variable NO_X to determine
314 dnl whether X should be supported.
315 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
317 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
318 AC_SUBST(my_includes)
320 LDFLAGS="$LDFLAGS -L/usr/local/lib"
322 AC_MSG_CHECKING([for X])
323 if test "$no_x" != "yes" ; then
325 AM_CONDITIONAL(HAVE_SGP, test 1==1)
327 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
328 ctlibs_graphics="$ctlibs_base -lctgraphics"
330 if test "$g2" = "true" ; then
331 ctlibs_graphics="$ctlibs_graphics -lg2"
334 ctlibs_graphics="$ctlibs_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
336 if test "$wxwin" = "true" ; then
338 AM_CONDITIONAL(HAVE_SGP, test 1==1)
343 if test "$png" = "true" ; then
344 ctlibs_tools="$ctlibs_tools -lpng"
346 if test "$zlib" = "true" ; then
347 ctlibs_tools="$ctlibs_tools -lz"
349 if test "$fftw" = "true" ; then
350 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
353 dnl Check for dmalloc
354 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
355 AC_MSG_CHECKING([for enable-dmalloc])
356 AC_ARG_ENABLE(dmalloc,
357 [ --enable-dmalloc Use dmalloc memory allocation],
358 [case "${enableval}" in
365 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
368 [usedmalloc=false; AC_MSG_RESULT(no)])
370 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
371 ctlibs_tools="$ctlibs_tools -ldmallocxx"
372 AC_DEFINE(HAVE_DMALLOC)
373 AC_MSG_RESULT(Using dmalloc)
376 if test "$wxwin" = "true" ; then
377 if test "$wx_gtk" = "true" ; then
378 wxcflags=`$wxconfig --cflags`
379 wxlibs=`$wxconfig --libs`
381 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
382 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
384 CFLAGS="$CFLAGS -I../include $wxcflags"
385 ctlibs_graphics="$ctlibs_graphics $wxlibs"
386 AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
391 dnl Setting projet libraries and includes
392 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
393 ctlibs="$ctlibs_base -lctsim $ctlibs_graphics -lctsupport $ctlibs_tools"
396 if test -n "$lamdir" ; then
397 lamprograms="pjrec-lam phm2if-lam phm2pj-lam"
398 AC_SUBST(lamprograms)
405 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)