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,3.0.0beta1)
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"
22 AC_PATH_PROG(wxconfig,wx-config)
24 dnl AC_MSG_CHECKING([that the compiler works])
25 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.))
27 dnl Check for C operation
30 AC_CHECK_SIZEOF(short, 2)
31 AC_CHECK_SIZEOF(int, 4)
32 AC_CHECK_SIZEOF(long, 4)
33 AC_CHECK_SIZEOF(float, 4)
34 AC_CHECK_SIZEOF(double, 8)
36 dnl Checks for libraries.
37 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
39 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
40 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
41 AC_CHECK_LIB(g2, main, [g2=true], [g2=false])
42 AC_CHECK_LIB(readline, main, [readline=true; AC_DEFINE(HAVE_READLINE)], [readline=false])
43 AC_CHECK_LIB(ncurses, main, [ncurses=true; AC_DEFINE(HAVE_NCURSES)], [ncurses=false])
44 AC_CHECK_LIB(curses, main, [curses=true; AC_DEFINE(HAVE_CURSES)], [curses=false])
46 AC_CHECK_LIB(wx_gtk, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS)])
47 AC_CHECK_LIB(wx, main, [wxwin=true; wx_msw=true; AC_DEFINE(HAVE_WXWINDOWS)])
48 AC_CHECK_LIB(hdf5, main, [hdf5=true], [hdf5=false], -lz)
49 AC_CHECK_LIB(fftw, fftw_one, [fftw=true; AC_DEFINE(HAVE_FFTW)], [fftw=false])
51 if test "$zlib" = "true" ; then
52 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
55 dnl Checks for header files.
57 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 readline.h readline/readline.h)
59 dnl Checks for typedefs, structures, and compiler characteristics.
65 dnl Checks for library functions.
67 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
68 AC_CHECK_FUNC(basename)
70 AC_CHECK_FUNC(setpriority)
72 AC_CHECK_FUNC(gettimeofday)
74 if test "${OSTYPE}" = "cygwin" ; then
77 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
80 if test "${getopt_long}" = "false" ; then
81 my_includes="$my_includes -I../getopt"
82 AC_DEFINE(HAVE_GETOPT_LONG)
83 ctlibs_base="$ctlibs_base -lgetopt"
84 LDFLAGS="$LDFLAGS -L../getopt"
85 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
88 if test "${readline}" = "true" ; then
89 ctlibs_base="$ctlibs_base -lreadline"
90 if test "${ncurses}" = "true"; then
91 ctlibs_base="$ctlibs_base -lncurses"
92 elif test "${curses}" = "true"; then
93 ctlibs_base="$ctlibs_base -lcurses"
97 dnl Check for debug mode
98 AC_MSG_CHECKING([debug])
100 [ --enable-debug Turn on debugging],
101 [case "${enableval}" in
108 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
111 [debug=false; AC_MSG_RESULT(no)])
112 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
114 if test "$debug" = "true" ; then
115 dnl AC_ADD_GCC_CFLAGS([-g -DDEBUG])
119 dnl AC_ADD_GCC_CFLAGS([-O2 -DNDEBUG])
120 CFLAGS="-O3 -DNDEBUG"
124 AC_MSG_CHECKING(sstream)
125 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
126 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ]; then
127 AC_DEFINE(HAVE_SSTREAM)
133 AC_ADD_GCC_CFLAGS([-Wall])
134 AC_MSG_CHECKING(whether to enable verbose warnings)
135 AC_ARG_ENABLE(verbose-warnings,
136 [ --enable-verbose-warnings
137 Enable verbose compiler warnings.],
138 [ case "$enableval" in
141 AC_ADD_GCC_CFLAGS([-W])
142 AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
143 AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
144 AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
145 AC_ADD_GCC_CFLAGS([-pedantic])
146 AC_ADD_GCC_CFLAGS([-Wredundant-decls])
152 esac ], AC_MSG_RESULT(no)
155 AC_MSG_CHECKING(static executables)
156 AC_ARG_ENABLE(static,
158 Enable static executables.],
159 [ case "$enableval" in
162 AC_ADD_GCC_CFLAGS([--static])
167 esac ], AC_MSG_RESULT(no)
172 [ --with-lam[=PATH] Set path of LAM MPI ],
173 [ if test "$withval" != "no" ; then
178 if test "$withval" != "no" ; then
179 if test "$prefix" != "NONE" ; then
180 trylamdir="$trylamdir $prefix"
183 AC_MSG_CHECKING([for LAM MPI installation])
184 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
185 if test -x "$testlamdir/bin/hcp" ; then
186 if test "$testlamdir" != "/usr"; then
187 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
188 CFLAGS="$CFLAGS -I$testlamdir/include"
190 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
198 AC_MSG_RESULT($lamdir)
203 AC_MSG_CHECKING([for web access])
204 dnl Set cgi-bin directory
205 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
206 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
208 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
209 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
211 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
212 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
214 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
215 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
217 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
218 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
220 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
221 cgiprograms="ctsim.cgi ctsim.conf"
222 AC_SUBST(cgiprograms)
225 if test -n "$htmldir" ; then
226 htmldata=simulate.html
229 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
231 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
235 if test -z "$cgibindir" ; then
236 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
237 elif test -z "$cgibinurl" ; then
238 AC_MSG_ERROR([--with-cgibin-url not set for web access])
239 elif test -z "$webdatadir" ; then
240 AC_MSG_ERROR([--with-webdata-dir not set for web access])
241 elif test -z "$webdataurl" ; then
242 AC_MSG_ERROR([--with-webdata-url not set for web access])
243 elif test -z "$htmldir" ; then
244 AC_MSG_ERROR([--with-html-dir not set for web access])
250 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
252 dnl Prepare to support X. If the user gave the command-line option
253 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
254 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
255 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
256 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
257 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
258 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
259 dnl supported, we'll concatenate the whole lot of these into a command line
260 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
261 dnl libplot/Makefile.am.
265 dnl Following five are concatenated together into a linker specification.
267 AC_SUBST(X_TOOLKIT_LIBS)
269 AC_SUBST(X_BASIC_LIBS)
270 AC_SUBST(X_EXTRA_LIBS)
272 X_TOOLKIT_LIBS="-lXt"
273 X_BASIC_LIBS="-lXext -lX11"
275 dnl Check whether libXt has thread support. Some platforms may have
276 dnl pthread support in libc, but no thread support in libXt/libX11.
277 our_saved_LDFLAGS="$LDFLAGS"
278 LDFLAGS="$X_LIBS $LDFLAGS"
279 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
280 LDFLAGS="$our_saved_LDFLAGS"
282 dnl Check in -lXext for double buffering extensions to X11, and check
283 dnl whether appropriate header files are present. (Some systems have one
284 dnl but not the other.)
285 our_saved_LDFLAGS="$LDFLAGS"
286 LDFLAGS="$X_LIBS $LDFLAGS"
287 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
288 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
289 LDFLAGS="$our_saved_LDFLAGS"
290 our_saved_CPPFLAGS="$CPPFLAGS"
291 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
292 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
293 CPPFLAGS="$our_saved_CPPFLAGS"
295 dnl Our Makefile.am files test the automake variable NO_X to determine
296 dnl whether X should be supported.
297 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
299 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
300 AC_SUBST(my_includes)
302 LDFLAGS="$LDFLAGS -L/usr/local/lib"
304 AC_MSG_CHECKING([for X])
305 if test "$no_x" != "yes" ; then
307 AM_CONDITIONAL(HAVE_SGP, test 1==1)
309 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
310 ctlibs_graphics="$ctlibs_base -lctgraphics"
312 if test "$g2" = "true" ; then
313 ctlibs_graphics="$ctlibs_graphics -lg2"
316 ctlibs_graphics="$ctlibs_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
318 if test "$wxwin" = "true" ; then
320 AM_CONDITIONAL(HAVE_SGP, test 1==1)
325 if test "$png" = "true" ; then
326 ctlibs_tools="$ctlibs_tools -lpng"
328 if test "$zlib" = "true" ; then
329 ctlibs_tools="$ctlibs_tools -lz"
331 if test "$fftw" = "true" ; then
332 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
335 dnl Check for dmalloc
336 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
337 AC_MSG_CHECKING([for enable-dmalloc])
338 AC_ARG_ENABLE(dmalloc,
339 [ --enable-dmalloc Use dmalloc memory allocation],
340 [case "${enableval}" in
347 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
350 [usedmalloc=false; AC_MSG_RESULT(no)])
352 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
353 ctlibs_tools="$ctlibs_tools -ldmallocxx"
354 AC_DEFINE(HAVE_DMALLOC)
355 AC_MSG_RESULT(Using dmalloc)
358 if test "$wxwin" = "true" ; then
359 if test "$wx_gtk" = "true" ; then
360 wxcflags=`$wxconfig --cflags`
361 wxlibs=`$wxconfig --libs`
363 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
364 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
366 CFLAGS="$CFLAGS -I../include $wxcflags"
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="ctsimtext-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)