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.5.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"
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(readline, main, [readline=true; AC_DEFINE(HAVE_READLINE)], [readline=false], [-lcurses])
42 AC_CHECK_LIB(ncurses, main, [ncurses=true; AC_DEFINE(HAVE_NCURSES)], [ncurses=false])
43 AC_CHECK_LIB(curses, main, [curses=true; AC_DEFINE(HAVE_CURSES)], [curses=false])
45 AC_CHECK_LIB(wx_gtk-2.2, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS)])
46 AC_CHECK_LIB(wx, main, [wxwin=true; wx_msw=true; AC_DEFINE(HAVE_WXWINDOWS)])
47 AC_CHECK_LIB(hdf4, main, [hdf4=true], [hdf4=false], -lz)
48 AC_CHECK_LIB(fftw, fftw_one, [fftw=true; AC_DEFINE(HAVE_FFTW)], [fftw=false])
49 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -lXt -lXext])
50 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
52 if test "$zlib" = "true" ; then
53 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
56 dnl Checks for header files.
58 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 assert.h sys/time.h sys/resource.h sys/time.h readline.h readline/readline.h)
60 dnl Checks for typedefs, structures, and compiler characteristics.
66 dnl Checks for library functions.
68 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
69 AC_CHECK_FUNC(basename)
71 AC_CHECK_FUNC(setpriority)
73 AC_CHECK_FUNC(gettimeofday)
75 if test "${OSTYPE}" = "cygwin" ; then
78 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
81 if test "${pthread}" = "true" ; then
82 AC_ADD_GCC_CFLAGS([-pthread -D_REENTRANT])
83 AC_DEFINE(HAVE_WXTHREADS)
86 if test "${getopt_long}" = "false" ; then
87 my_includes="$my_includes -I../getopt"
88 AC_DEFINE(HAVE_GETOPT_LONG)
89 ctlibs_base="$ctlibs_base -lgetopt"
90 LDFLAGS="$LDFLAGS -L../getopt"
91 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
94 if test "${readline}" = "true" ; then
95 ctlibs_base="$ctlibs_base -lreadline"
96 if test "${ncurses}" = "true"; then
97 ctlibs_base="$ctlibs_base -lncurses"
98 elif test "${curses}" = "true"; then
99 ctlibs_base="$ctlibs_base -lcurses"
103 dnl Check for debug mode
104 AC_MSG_CHECKING([debug])
106 [ --enable-debug Turn on debugging],
107 [case "${enableval}" in
114 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
117 [debug=false; AC_MSG_RESULT(no)])
118 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
120 if test "$debug" = "true" ; then
121 dnl AC_ADD_GCC_CFLAGS([-g -DDEBUG])
125 dnl AC_ADD_GCC_CFLAGS([-O2 -fexpensive-optimizations -DNDEBUG])
126 CFLAGS="-O3 -DNDEBUG -fomit-frame-pointer"
130 AC_MSG_CHECKING(sstream)
131 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
132 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ]; then
133 AC_DEFINE(HAVE_SSTREAM)
139 AC_ADD_GCC_CFLAGS([-Wall])
140 AC_MSG_CHECKING(whether to enable verbose warnings)
141 AC_ARG_ENABLE(verbose-warnings,
142 [ --enable-verbose-warnings
143 Enable verbose compiler warnings.],
144 [ case "$enableval" in
147 AC_ADD_GCC_CFLAGS([-W])
148 AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
149 AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
150 AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
151 AC_ADD_GCC_CFLAGS([-pedantic])
152 AC_ADD_GCC_CFLAGS([-Wredundant-decls])
158 esac ], AC_MSG_RESULT(no)
161 AC_MSG_CHECKING(static executables)
162 AC_ARG_ENABLE(static,
164 Enable static executables.],
165 [ case "$enableval" in
168 AC_ADD_GCC_CFLAGS([--static])
173 esac ], AC_MSG_RESULT(no)
178 [ --with-lam[=PATH] Set path of LAM MPI ],
179 [ if test "$withval" != "no" ; then
184 if test "$withval" != "no" ; then
185 if test "$prefix" != "NONE" ; then
186 trylamdir="$trylamdir $prefix"
189 AC_MSG_CHECKING([for LAM MPI installation])
190 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
191 if test -x "$testlamdir/bin/hcp" ; then
192 if test "$testlamdir" != "/usr"; then
193 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
194 CFLAGS="$CFLAGS -I$testlamdir/include"
196 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
204 AC_MSG_RESULT($lamdir)
212 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
213 [ if test "$withval" != "no" ; then
218 if test "$withval" != "no" ; then
219 if test "$prefix" != "NONE" ; then
220 tryctndir="$tryctndir $prefix"
223 AC_MSG_CHECKING([for CTN DICOM installation])
224 for testctndir in "." $tryctndir /usr/local /usr/local/ctn /usr /usr/ctn /opt /opt/ctn ; do
225 if test -f "$testctndir/lib/libctn.a" ; then
226 if test "$testctndir" != "/usr"; then
227 LDFLAGS="$LDFLAGS -L$testctndir/lib"
228 CFLAGS="$CFLAGS -I$testctndir/include"
232 AC_DEFINE(HAVE_CTN_DICOM)
236 AC_MSG_RESULT($ctndir)
243 AC_MSG_CHECKING([for web access])
244 dnl Set cgi-bin directory
245 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
246 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
248 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
249 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
251 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
252 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
254 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
255 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
257 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
258 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
260 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
261 cgiprograms="ctsim.cgi ctsim.conf"
262 AC_SUBST(cgiprograms)
265 if test -n "$htmldir" ; then
266 htmldata=simulate.html
269 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
271 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
275 if test -z "$cgibindir" ; then
276 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
277 elif test -z "$cgibinurl" ; then
278 AC_MSG_ERROR([--with-cgibin-url not set for web access])
279 elif test -z "$webdatadir" ; then
280 AC_MSG_ERROR([--with-webdata-dir not set for web access])
281 elif test -z "$webdataurl" ; then
282 AC_MSG_ERROR([--with-webdata-url not set for web access])
283 elif test -z "$htmldir" ; then
284 AC_MSG_ERROR([--with-html-dir not set for web access])
290 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
292 dnl Prepare to support X. If the user gave the command-line option
293 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
294 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
295 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
296 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
297 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
298 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
299 dnl supported, we'll concatenate the whole lot of these into a command line
300 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
301 dnl libplot/Makefile.am.
305 dnl Following five are concatenated together into a linker specification.
307 AC_SUBST(X_TOOLKIT_LIBS)
309 AC_SUBST(X_BASIC_LIBS)
310 AC_SUBST(X_EXTRA_LIBS)
312 X_TOOLKIT_LIBS="-lXt"
313 X_BASIC_LIBS="-lXext -lX11 -lXmu"
315 dnl Check whether libXt has thread support. Some platforms may have
316 dnl pthread support in libc, but no thread support in libXt/libX11.
317 our_saved_LDFLAGS="$LDFLAGS"
318 LDFLAGS="$X_LIBS $LDFLAGS"
319 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
320 LDFLAGS="$our_saved_LDFLAGS"
322 dnl Check in -lXext for double buffering extensions to X11, and check
323 dnl whether appropriate header files are present. (Some systems have one
324 dnl but not the other.)
325 our_saved_LDFLAGS="$LDFLAGS"
326 LDFLAGS="$X_LIBS $LDFLAGS"
327 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
328 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
329 LDFLAGS="$our_saved_LDFLAGS"
330 our_saved_CPPFLAGS="$CPPFLAGS"
331 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
332 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
333 CPPFLAGS="$our_saved_CPPFLAGS"
335 dnl Our Makefile.am files test the automake variable NO_X to determine
336 dnl whether X should be supported.
337 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
339 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
340 AC_SUBST(my_includes)
342 LDFLAGS="$LDFLAGS -L/usr/local/lib"
344 AC_MSG_CHECKING([for X])
345 if test "$no_x" != "yes" ; then
347 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
348 ctlib_graphics="$ctlibs_base -lctgraphics"
350 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
351 if test "$libgl" = "true" ; then
352 ctlib_graphics="$ctlib_graphics -lglut -lGL -lGLU"
353 if test "$wxwin" = "true" ; then
354 ctlib_graphics="$ctlib_graphics -lwx_gtk_gl-2.2"
357 if test "$wxwin" = "true" ; then
359 AM_CONDITIONAL(HAVE_SGP, test 1==1)
365 if test "$png" = "true" ; then
366 ctlibs_tools="$ctlibs_tools -lpng"
368 if test "$zlib" = "true" ; then
369 ctlibs_tools="$ctlibs_tools -lz"
371 if test "$fftw" = "true" ; then
372 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
374 if test "$ctn" = "true"; then
375 ctlibs_tools="$ctlibs_tools -lctn"
378 dnl Check for dmalloc
379 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
380 AC_MSG_CHECKING([for enable-dmalloc])
381 AC_ARG_ENABLE(dmalloc,
382 [ --enable-dmalloc Use dmalloc memory allocation],
383 [case "${enableval}" in
390 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
393 [usedmalloc=false; AC_MSG_RESULT(no)])
395 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
396 ctlibs_tools="$ctlibs_tools -ldmallocxx"
397 AC_DEFINE(HAVE_DMALLOC)
398 AC_MSG_RESULT(Using dmalloc)
402 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
403 AC_MSG_CHECKING([for enable-efence])
404 AC_ARG_ENABLE(efence,
405 [ --enable-efence Use ElectricFence memory allocation],
406 [case "${enableval}" in
413 *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence])
416 [useefence=false; AC_MSG_RESULT(no)])
418 if test "$efence" = "true" -a "$useefence" = "true" ; then
419 ctlibs_tools="$ctlibs_tools -lefence"
420 AC_DEFINE(HAVE_EFENCE)
421 AC_MSG_RESULT(Using efence)
424 if test "$wxwin" = "true" ; then
425 if test "$wx_gtk" = "true" ; then
426 wxcflags=`$wxconfig --cflags`
427 wxlibs=`$wxconfig --libs`
429 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
430 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
432 CFLAGS="$CFLAGS -I../include $wxcflags"
433 ctlib_graphics="$ctlib_graphics $wxlibs"
434 AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
439 dnl Setting projet libraries and includes
440 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
441 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
444 if test -n "$lamdir" ; then
445 lamprograms="ctsimtext-lam"
446 AC_SUBST(lamprograms)
453 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 helical/Makefile helical/sample-helical.sh)