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 AC_CONFIG_SRCDIR([src/ctsim.cpp])
8 AM_INIT_AUTOMAKE(ctsim,4.0.2)
9 AM_CONFIG_HEADER(config.h)
11 dnl Checks for programs.
21 AC_PATH_PROG(wxconfig,wx-config)
23 dnl Check for C operation
26 AC_CHECK_SIZEOF(short, 2)
27 AC_CHECK_SIZEOF(int, 4)
28 AC_CHECK_SIZEOF(long, 4)
29 AC_CHECK_SIZEOF(float, 4)
30 AC_CHECK_SIZEOF(double, 8)
32 dnl Add define templates
34 dnl Checks for libraries.
35 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
37 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
38 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
39 AC_CHECK_LIB(readline, main, [readline=true;
40 AC_DEFINE([HAVE_READLINE],1,[Readline library])],
41 [readline=false], [-lcurses])
43 AC_CHECK_LIB(wx_gtk-2.4, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
44 AC_CHECK_LIB(wx_mac-2.4, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
45 AC_CHECK_LIB(fftw, fftw_one, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false])
46 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -lXt -lXext])
47 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
49 if test "$zlib" = "true" ; then
50 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG,1,[PNG library])], [png=false], [-lz -lm])
53 dnl Checks for header files.
55 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)
57 dnl Checks for typedefs, structures, and compiler characteristics.
63 dnl Checks for library functions.
65 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
66 AC_CHECK_FUNC(basename)
68 AC_CHECK_FUNC(setpriority)
70 AC_CHECK_FUNC(gettimeofday)
71 AC_CHECK_FUNC(getopt, [ getopt=true ], [ getopt=false ])
73 if test "${OSTYPE}" = "cygwin" ; then
76 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
79 if test "${getopt_long}" = "false" ; then
80 my_includes="$my_includes -I../getopt"
81 AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
82 ctlibs_base="$ctlibs_base -lgetopt"
83 LDFLAGS="$LDFLAGS -L../getopt"
84 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
87 if test "${readline}" = "true" ; then
88 ctlibs_base="$ctlibs_base -lreadline"
89 if test "${ncurses}" = "true"; then
90 ctlibs_base="$ctlibs_base -lncurses"
91 elif test "${curses}" = "true"; then
92 ctlibs_base="$ctlibs_base -lcurses"
96 dnl Check for debug mode
97 AC_MSG_CHECKING([debug])
99 [ --enable-debug Turn on debugging],
100 [case "${enableval}" in
107 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
110 [debug=false; AC_MSG_RESULT(no)])
111 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
113 if test "$datadir" != "" ; then
114 CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
116 dnl CFLAGS="$CFLAGS -I/usr/local/include"
117 dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"
119 if test "$debug" = "true" ; then
120 CFLAGS="$CFLAGS -g -DDEBUG"
121 AC_DEFINE(DEBUG,1,[turn on debugging])
123 CFLAGS="$CFLAGS -O3 -DNDEBUG -fomit-frame-pointer -funroll-loops"
124 AC_DEFINE(NDEBUG,1,[no debugging])
127 if test "${pthread}" = "true" ; then
128 dnl CFLAGS="$CFLAGS -D_REENTRANT"
129 AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
132 AC_MSG_CHECKING(sstream)
133 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
134 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ||
135 test -f /usr/include/gcc/darwin/3.1/g++-v3/sstream ]; then
136 AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
143 CFLAGS="$CFLAGS -Wall"
144 AC_MSG_CHECKING(whether to enable verbose warnings)
145 AC_ARG_ENABLE(verbose-warnings,
146 [ --enable-verbose-warnings
147 Enable verbose compiler warnings.],
148 [ case "$enableval" in
151 CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
156 esac ], AC_MSG_RESULT(no)
159 AC_MSG_CHECKING(static executables)
160 AC_ARG_ENABLE(static,
162 Enable static executables.],
163 [ case "$enableval" in
166 CFLAGS="$CFLAGS --static"
171 esac ], AC_MSG_RESULT(no)
176 [ --with-lam[=PATH] Set path of LAM MPI ],
177 [ if test "$withval" != "no" ; then
182 if test "$withval" != "no" ; then
183 if test "$prefix" != "NONE" ; then
184 trylamdir="$trylamdir $prefix"
187 AC_MSG_CHECKING([for LAM MPI installation])
188 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
189 if test -x "$testlamdir/bin/hcp" ; then
190 if test "$testlamdir" != "/usr"; then
191 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
192 CFLAGS="$CFLAGS -I$testlamdir/include"
194 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
202 AC_MSG_RESULT($lamdir)
210 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
211 [ if test "$withval" != "no" ; then
216 if test "$withval" == "no" -o "$withval" == "NONE" ; then
217 AC_MSG_CHECKING([for CTN DICOM installation])
218 AC_MSG_RESULT([disabled])
220 AC_MSG_CHECKING([for CTN DICOM installation])
221 for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
222 if test -f "$testctndir/libctn.a" ; then
223 LDFLAGS="$LDFLAGS -L$testctndir"
228 for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
229 if test -f "$testctndir/ctn_os.h" ; then
230 CFLAGS="$CFLAGS -I$testctndir"
235 if test "$ctnlib" == "true" -a "$ctninclude" == "true" ; then
237 AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
245 AC_MSG_CHECKING([for CPU specification])
247 [ --with-mcpu[=CPU] Set name of CPU for gcc -mcpu])
249 if test "$withval" == "" -o test "$withval" == "no" -o test "$withval" == "yes" ; then
252 AC_MSG_RESULT([$withval])
253 CFLAGS="$CFLAGS -mcpu=$withval"
256 AC_MSG_CHECKING([for web access])
257 dnl Set cgi-bin directory
258 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
259 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
261 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
262 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
264 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
265 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
267 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
268 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
270 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
271 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
273 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
274 cgiprograms="ctsim.cgi ctsim.conf"
275 AC_SUBST(cgiprograms)
278 if test -n "$htmldir" ; then
279 htmldata=simulate.html
282 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
284 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
288 if test -z "$cgibindir" ; then
289 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
290 elif test -z "$cgibinurl" ; then
291 AC_MSG_ERROR([--with-cgibin-url not set for web access])
292 elif test -z "$webdatadir" ; then
293 AC_MSG_ERROR([--with-webdata-dir not set for web access])
294 elif test -z "$webdataurl" ; then
295 AC_MSG_ERROR([--with-webdata-url not set for web access])
296 elif test -z "$htmldir" ; then
297 AC_MSG_ERROR([--with-html-dir not set for web access])
303 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
305 dnl Prepare to support X. If the user gave the command-line option
306 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
307 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
308 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
309 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
310 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
311 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
312 dnl supported, we'll concatenate the whole lot of these into a command line
313 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
314 dnl libplot/Makefile.am.
318 dnl Following five are concatenated together into a linker specification.
320 AC_SUBST(X_TOOLKIT_LIBS)
322 AC_SUBST(X_BASIC_LIBS)
323 AC_SUBST(X_EXTRA_LIBS)
325 X_TOOLKIT_LIBS="-lXt"
326 X_BASIC_LIBS="-lXext -lX11 -lXmu"
328 dnl Check whether libXt has thread support. Some platforms may have
329 dnl pthread support in libc, but no thread support in libXt/libX11.
330 our_saved_LDFLAGS="$LDFLAGS"
331 LDFLAGS="$X_LIBS $LDFLAGS"
332 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT,1,[x thread supported]), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
333 LDFLAGS="$our_saved_LDFLAGS"
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
346 AC_DEFINE(HAVE_X11,1,[X11 system])
347 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
348 my_includes="$my_includes -I/usr/X11R6/include"
349 ctlib_graphics="$ctlibs_base -lctgraphics"
351 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
352 if test "$libgl" = "true" ; then
353 # Removed "-lglut" for Mac OS X compilation
354 ctlib_graphics="$ctlib_graphics -lGL -lGLU"
355 if test "$wxwin" = "true" ; then
356 if [ "$wx_gtk" ]; then
357 ctlib_graphics="$ctlib_graphics -lwx_gtk_gl-2.4"
358 elif [ "$wx_mac" ]; then
359 ctlib_graphics="$ctlib_graphics -lwx_mac_gl-2.4"
363 if test "$wxwin" = "true" ; then
364 AC_DEFINE(HAVE_SGP,1,[use sgp library])
365 AM_CONDITIONAL(HAVE_SGP, test 1==1)
371 if test "$png" = "true" ; then
372 ctlibs_tools="$ctlibs_tools -lpng"
374 if test "$zlib" = "true" ; then
375 ctlibs_tools="$ctlibs_tools -lz"
377 if test "$fftw" = "true" ; then
378 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
380 if test "$ctn" = "true"; then
381 ctlibs_tools="$ctlibs_tools -lctn"
384 dnl Check for dmalloc
385 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
386 AC_MSG_CHECKING([for enable-dmalloc])
387 AC_ARG_ENABLE(dmalloc,
388 [ --enable-dmalloc Use dmalloc memory allocation],
389 [case "${enableval}" in
396 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
399 [usedmalloc=false; AC_MSG_RESULT(no)])
401 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
402 ctlibs_tools="$ctlibs_tools -ldmallocxx"
403 AC_DEFINE(HAVE_DMALLOC,1,[dmalloc library])
404 AC_MSG_RESULT(Using dmalloc)
408 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
409 AC_MSG_CHECKING([for enable-efence])
410 AC_ARG_ENABLE(efence,
411 [ --enable-efence Use ElectricFence memory allocation],
412 [case "${enableval}" in
419 *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence])
422 [useefence=false; AC_MSG_RESULT(no)])
424 if test "$efence" = "true" -a "$useefence" = "true" ; then
425 ctlibs_tools="$ctlibs_tools -lefence"
426 AC_DEFINE(HAVE_EFENCE,1,[efence library])
427 AC_MSG_RESULT(Using efence)
430 if test "$wxwin" = "true" ; then
431 if [ "$wx_gtk" = "true" ] || [ "$wx_mac" == "true" ] ; then
432 wxcflags=`$wxconfig --cflags`
433 wxlibs=`$wxconfig --libs`
435 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
436 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
438 CFLAGS="$CFLAGS -I../include $wxcflags"
439 ctlib_graphics="$ctlib_graphics $wxlibs"
440 AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
445 dnl Setting projet libraries and includes
446 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
447 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
450 if test -n "$lamdir" ; then
451 lamprograms="ctsimtext-lam"
452 AC_SUBST(lamprograms)
459 AC_CONFIG_FILES([Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/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])