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 CPPFLAGS='$(CPPFLAGS) -DDATADIR="$(datadir)"'
17 CFLAGS="$CFLAGS -I/usr/local/include"
18 LDFLAGS="$LDFLAGS -L/usr/local/lib"
23 AC_PATH_PROG(wxconfig,wx-config)
25 dnl AC_MSG_CHECKING([that the compiler works])
26 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.))
28 dnl Check for C operation
31 AC_CHECK_SIZEOF(short, 2)
32 AC_CHECK_SIZEOF(int, 4)
33 AC_CHECK_SIZEOF(long, 4)
34 AC_CHECK_SIZEOF(float, 4)
35 AC_CHECK_SIZEOF(double, 8)
37 dnl Checks for libraries.
38 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
40 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
41 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
42 AC_CHECK_LIB(readline, main, [readline=true; AC_DEFINE(HAVE_READLINE)], [readline=false], [-lcurses])
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-2.2, 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(hdf4, main, [hdf4=true], [hdf4=false], -lz)
49 AC_CHECK_LIB(fftw, fftw_one, [fftw=true; AC_DEFINE(HAVE_FFTW)], [fftw=false])
50 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -lXt -lXext])
51 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
53 if test "$zlib" = "true" ; then
54 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
57 dnl Checks for header files.
59 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)
61 dnl Checks for typedefs, structures, and compiler characteristics.
67 dnl Checks for library functions.
69 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
70 AC_CHECK_FUNC(basename)
72 AC_CHECK_FUNC(setpriority)
74 AC_CHECK_FUNC(gettimeofday)
76 if test "${OSTYPE}" = "cygwin" ; then
79 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
82 if test "${getopt_long}" = "false" ; then
83 my_includes="$my_includes -I../getopt"
84 AC_DEFINE(HAVE_GETOPT_LONG)
85 ctlibs_base="$ctlibs_base -lgetopt"
86 LDFLAGS="$LDFLAGS -L../getopt"
87 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
90 if test "${readline}" = "true" ; then
91 ctlibs_base="$ctlibs_base -lreadline"
92 if test "${ncurses}" = "true"; then
93 ctlibs_base="$ctlibs_base -lncurses"
94 elif test "${curses}" = "true"; then
95 ctlibs_base="$ctlibs_base -lcurses"
99 dnl Check for debug mode
100 AC_MSG_CHECKING([debug])
102 [ --enable-debug Turn on debugging],
103 [case "${enableval}" in
110 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
113 [debug=false; AC_MSG_RESULT(no)])
114 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
116 if test "$debug" = "true" ; then
120 CFLAGS="-O3 -DNDEBUG -fomit-frame-pointer"
124 if test "${pthread}" = "true" ; then
125 CFLAGS="$FLAGS -pthread -D_REENTRANT"
126 AC_DEFINE(HAVE_WXTHREADS)
129 AC_MSG_CHECKING(sstream)
130 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
131 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ]; then
132 AC_DEFINE(HAVE_SSTREAM)
138 CFLAGS="$CFLAGS -Wall"
139 AC_MSG_CHECKING(whether to enable verbose warnings)
140 AC_ARG_ENABLE(verbose-warnings,
141 [ --enable-verbose-warnings
142 Enable verbose compiler warnings.],
143 [ case "$enableval" in
146 CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
151 esac ], AC_MSG_RESULT(no)
154 AC_MSG_CHECKING(static executables)
155 AC_ARG_ENABLE(static,
157 Enable static executables.],
158 [ case "$enableval" in
161 CFLAGS="$CFLAGS --static"
166 esac ], AC_MSG_RESULT(no)
171 [ --with-lam[=PATH] Set path of LAM MPI ],
172 [ if test "$withval" != "no" ; then
177 if test "$withval" != "no" ; then
178 if test "$prefix" != "NONE" ; then
179 trylamdir="$trylamdir $prefix"
182 AC_MSG_CHECKING([for LAM MPI installation])
183 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
184 if test -x "$testlamdir/bin/hcp" ; then
185 if test "$testlamdir" != "/usr"; then
186 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
187 CFLAGS="$CFLAGS -I$testlamdir/include"
189 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
197 AC_MSG_RESULT($lamdir)
205 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
206 [ if test "$withval" != "no" ; then
211 if test "$withval" != "no" ; then
212 if test "$prefix" != "NONE" ; then
213 tryctndir="$tryctndir $prefix"
216 AC_MSG_CHECKING([for CTN DICOM installation])
217 for testctndir in "." $tryctndir /usr/local /usr/local/ctn /usr /usr/ctn /opt /opt/ctn ; do
218 if test -f "$testctndir/lib/libctn.a" ; then
219 if test "$testctndir" != "/usr"; then
220 LDFLAGS="$LDFLAGS -L$testctndir/lib"
221 CFLAGS="$CFLAGS -I$testctndir/include"
225 AC_DEFINE(HAVE_CTN_DICOM)
229 AC_MSG_RESULT($ctndir)
235 AC_MSG_CHECKING([for web access])
236 dnl Set cgi-bin directory
237 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
238 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
240 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
241 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
243 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
244 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
246 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
247 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
249 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
250 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
252 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
253 cgiprograms="ctsim.cgi ctsim.conf"
254 AC_SUBST(cgiprograms)
257 if test -n "$htmldir" ; then
258 htmldata=simulate.html
261 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
263 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
267 if test -z "$cgibindir" ; then
268 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
269 elif test -z "$cgibinurl" ; then
270 AC_MSG_ERROR([--with-cgibin-url not set for web access])
271 elif test -z "$webdatadir" ; then
272 AC_MSG_ERROR([--with-webdata-dir not set for web access])
273 elif test -z "$webdataurl" ; then
274 AC_MSG_ERROR([--with-webdata-url not set for web access])
275 elif test -z "$htmldir" ; then
276 AC_MSG_ERROR([--with-html-dir not set for web access])
282 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
284 dnl Prepare to support X. If the user gave the command-line option
285 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
286 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
287 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
288 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
289 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
290 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
291 dnl supported, we'll concatenate the whole lot of these into a command line
292 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
293 dnl libplot/Makefile.am.
297 dnl Following five are concatenated together into a linker specification.
299 AC_SUBST(X_TOOLKIT_LIBS)
301 AC_SUBST(X_BASIC_LIBS)
302 AC_SUBST(X_EXTRA_LIBS)
304 X_TOOLKIT_LIBS="-lXt"
305 X_BASIC_LIBS="-lXext -lX11 -lXmu"
307 dnl Check whether libXt has thread support. Some platforms may have
308 dnl pthread support in libc, but no thread support in libXt/libX11.
309 our_saved_LDFLAGS="$LDFLAGS"
310 LDFLAGS="$X_LIBS $LDFLAGS"
311 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
312 LDFLAGS="$our_saved_LDFLAGS"
314 dnl Check in -lXext for double buffering extensions to X11, and check
315 dnl whether appropriate header files are present. (Some systems have one
316 dnl but not the other.)
317 our_saved_LDFLAGS="$LDFLAGS"
318 LDFLAGS="$X_LIBS $LDFLAGS"
319 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
320 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
321 LDFLAGS="$our_saved_LDFLAGS"
322 our_saved_CPPFLAGS="$CPPFLAGS"
323 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
324 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
325 CPPFLAGS="$our_saved_CPPFLAGS"
327 dnl Our Makefile.am files test the automake variable NO_X to determine
328 dnl whether X should be supported.
329 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
331 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
332 AC_SUBST(my_includes)
334 LDFLAGS="$LDFLAGS -L/usr/local/lib"
336 AC_MSG_CHECKING([for X])
337 if test "$no_x" != "yes" ; then
339 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
340 ctlib_graphics="$ctlibs_base -lctgraphics"
342 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
343 if test "$libgl" = "true" ; then
344 ctlib_graphics="$ctlib_graphics -lglut -lGL -lGLU"
345 if test "$wxwin" = "true" ; then
346 ctlib_graphics="$ctlib_graphics -lwx_gtk_gl-2.2"
349 if test "$wxwin" = "true" ; then
351 AM_CONDITIONAL(HAVE_SGP, test 1==1)
357 if test "$png" = "true" ; then
358 ctlibs_tools="$ctlibs_tools -lpng"
360 if test "$zlib" = "true" ; then
361 ctlibs_tools="$ctlibs_tools -lz"
363 if test "$fftw" = "true" ; then
364 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
366 if test "$ctn" = "true"; then
367 ctlibs_tools="$ctlibs_tools -lctn"
370 dnl Check for dmalloc
371 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
372 AC_MSG_CHECKING([for enable-dmalloc])
373 AC_ARG_ENABLE(dmalloc,
374 [ --enable-dmalloc Use dmalloc memory allocation],
375 [case "${enableval}" in
382 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
385 [usedmalloc=false; AC_MSG_RESULT(no)])
387 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
388 ctlibs_tools="$ctlibs_tools -ldmallocxx"
389 AC_DEFINE(HAVE_DMALLOC)
390 AC_MSG_RESULT(Using dmalloc)
394 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
395 AC_MSG_CHECKING([for enable-efence])
396 AC_ARG_ENABLE(efence,
397 [ --enable-efence Use ElectricFence memory allocation],
398 [case "${enableval}" in
405 *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence])
408 [useefence=false; AC_MSG_RESULT(no)])
410 if test "$efence" = "true" -a "$useefence" = "true" ; then
411 ctlibs_tools="$ctlibs_tools -lefence"
412 AC_DEFINE(HAVE_EFENCE)
413 AC_MSG_RESULT(Using efence)
416 if test "$wxwin" = "true" ; then
417 if test "$wx_gtk" = "true" ; then
418 wxcflags=`$wxconfig --cflags`
419 wxlibs=`$wxconfig --libs`
421 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
422 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
424 CFLAGS="$CFLAGS -I../include $wxcflags"
425 ctlib_graphics="$ctlib_graphics $wxlibs"
426 AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
431 dnl Setting projet libraries and includes
432 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
433 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
436 if test -n "$lamdir" ; then
437 lamprograms="ctsimtext-lam"
438 AC_SUBST(lamprograms)
445 AC_OUTPUT(Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/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)