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])
9 AM_INIT_AUTOMAKE(ctsim,5.0.0)
10 AM_CONFIG_HEADER(config.h)
17 dnl Checks for programs.
27 AC_PATH_PROG(wxconfig,wx-config)
29 dnl Check for C operation
32 AC_CHECK_SIZEOF(short, 2)
33 AC_CHECK_SIZEOF(int, 4)
34 AC_CHECK_SIZEOF(long, 4)
35 AC_CHECK_SIZEOF(float, 4)
36 AC_CHECK_SIZEOF(double, 8)
38 dnl Add define templates
40 dnl Checks for libraries.
41 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
43 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
44 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
45 AC_CHECK_LIB(readline, main, [readline=true;
46 AC_DEFINE([HAVE_READLINE],1,[Readline library])],
47 [readline=false], [-lcurses])
49 AC_CHECK_LIB(gtk-x11-2.0, main, [hasx11gtk2=true], [])
50 if test "x$hasx11gtk2" = "x" ; then
51 AC_MSG_NOTICE([Does not have X11 GTK2])
52 AC_DEFUN([AM_PATH_GLIB_2_0], [])
53 AC_DEFUN([AM_PATH_GTK_2_0], [])
55 if test "$hasx11gtk2" = "true" ; then
56 AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR(You should get glib 2.0.0 or better.))
57 AM_PATH_GTK_2_0(2.0.0,havegtk_am=yes,havegtk_am=no)
58 CFLAGS="${CFLAGS} ${g76GTK_CFLAGS} ${GLIB_CFLAGS}"
61 AC_CHECK_LIB(wx_gtk2u_core-2.8, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])], [], [-L/usr/lib64 -L/usr/lib ${GTK_LIBS} ${GLIB_LIBS} ])
62 AC_CHECK_LIB(wx_mac_core-2.8, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
63 AC_CHECK_LIB(fftw3, fftw_malloc, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false], [-L/usr/lib64 -L/usr/lib])
64 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -L/usr/X11R6/lib64])
65 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
67 if test "$zlib" = "true" ; then
68 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG,1,[PNG library])], [png=false], [-L/opt/local/lib -lz -lm])
71 dnl Checks for header files.
73 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)
75 dnl Checks for typedefs, structures, and compiler characteristics.
81 dnl Checks for library functions.
83 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf basename setjmp setpriority time gettimeofday getenv)
84 AC_CHECK_FUNC(basename)
86 AC_CHECK_FUNC(setpriority)
88 AC_CHECK_FUNC(gettimeofday)
89 AC_CHECK_FUNC(getopt, [ getopt=true ], [ getopt=false ])
91 if test "${OSTYPE}" = "cygwin" ; then
94 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
97 if test "${getopt_long}" = "false" ; then
98 my_includes="$my_includes -I../getopt"
99 AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
100 ctlibs_base="$ctlibs_base -lgetopt"
101 LDFLAGS="$LDFLAGS -L../getopt"
104 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test "$GETOPTLONG"="1")
106 if test "${readline}" = "true" ; then
107 ctlibs_base="$ctlibs_base -lreadline"
108 if test "${ncurses}" = "true"; then
109 ctlibs_base="$ctlibs_base -lncurses"
110 elif test "${curses}" = "true"; then
111 ctlibs_base="$ctlibs_base -lcurses"
115 dnl Check for debug mode
116 AC_MSG_CHECKING([debug])
118 [ --enable-debug Turn on debugging],
119 [case "${enableval}" in
126 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
129 [debug=false; AC_MSG_RESULT(no)])
130 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
132 if test "$datadir" != "" ; then
133 CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
135 dnl CFLAGS="$CFLAGS -I/usr/local/include"
136 dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"
138 if test "$debug" = "true" ; then
139 CFLAGS="$CFLAGS -g -DDEBUG"
140 AC_DEFINE(DEBUG,1,[turn on debugging])
142 CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
143 AC_DEFINE(NDEBUG,1,[no debugging])
146 if test "${pthread}" = "true" ; then
147 dnl CFLAGS="$CFLAGS -D_REENTRANT"
148 AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
151 AC_MSG_CHECKING(sstream)
152 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
153 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ||
154 test -f /usr/include/gcc/darwin/3.1/g++-v3/sstream ]; then
155 AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
162 CFLAGS="$CFLAGS -Wall"
163 AC_MSG_CHECKING(whether to enable verbose warnings)
164 AC_ARG_ENABLE(verbose-warnings,
165 [ --enable-verbose-warnings
166 Enable verbose compiler warnings.],
167 [ case "$enableval" in
170 CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
175 esac ], AC_MSG_RESULT(no)
178 AC_MSG_CHECKING(static executables)
179 AC_ARG_ENABLE(static,
181 Enable static executables.],
182 [ case "$enableval" in
185 CFLAGS="$CFLAGS --static"
190 esac ], AC_MSG_RESULT(no)
195 [ --with-lam[=PATH] Set path of LAM MPI ],
196 [ if test "$withval" != "no" ; then
201 if test "$withval" != "no" ; then
202 if test "$prefix" != "NONE" ; then
203 trylamdir="$trylamdir $prefix"
206 AC_MSG_CHECKING([for LAM MPI installation])
207 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
208 if test -x "$testlamdir/bin/hcp" ; then
209 if test "$testlamdir" != "/usr"; then
210 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
211 CFLAGS="$CFLAGS -I$testlamdir/include"
213 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
221 AC_MSG_RESULT($lamdir)
229 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
230 [ if test "$withval" != "no" ; then
235 if test "$withval" == "no" -o "$withval" == "NONE" ; then
236 AC_MSG_CHECKING([for CTN DICOM installation])
237 AC_MSG_RESULT([disabled])
239 AC_MSG_CHECKING([for CTN DICOM installation])
240 for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
241 if test -f "$testctndir/libctn.a" ; then
242 LDFLAGS="$LDFLAGS -L$testctndir"
247 for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
248 if test -f "$testctndir/ctn_os.h" ; then
249 CFLAGS="$CFLAGS -I$testctndir"
254 if test "$ctnlib" == "true" -a "$ctninclude" == "true" ; then
256 AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
264 AC_MSG_CHECKING([for CPU specification])
266 [ --with-mcpu[=CPU] Set name of CPU for gcc -mcpu])
268 if test "$withval" == "no" -o "$withval" == "yes" -o "$withval" == ""; then
271 AC_MSG_RESULT([$withval])
272 CFLAGS="$CFLAGS -mcpu=$withval"
275 AC_MSG_CHECKING([for web access])
276 dnl Set cgi-bin directory
277 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
278 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
280 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
281 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
283 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
284 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
286 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
287 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
289 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
290 [ html_%dir=$withval ; AC_SUBST(htmldir) ] )
292 if test "x$cgibindir" != "x" -o "x$cgibinurl" != "x" ; then
293 cgiprograms="ctsim.cgi ctsim.conf"
294 AC_SUBST(cgiprograms)
297 if test "x$html_dir" = "x" ; then
298 htmldata=simulate.html
301 AM_CONDITIONAL(USE_HTML, test "x$html_dir" = "x")
303 if test "x$cgibindir" != "x" -o "x$cgibinurl" != "x" -o "x$webdatadir" != "x" -o "x$webdataurl" != "x" -o "x$html_dir" != "x" ; then
307 if test "x$cgibindir" = "x" ; then
308 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
309 elif test "x$cgibinurl" = "x" ; then
310 AC_MSG_ERROR([--with-cgibin-url not set for web access])
311 elif test "x$webdatadir" = "x" ; then
312 AC_MSG_ERROR([--with-webdata-dir not set for web access])
313 elif test "x$webdataurl" = "x" ; then
314 AC_MSG_ERROR([--with-webdata-url not set for web access])
315 elif test "x$html_dir" = "x" ; then
316 AC_MSG_ERROR([--with-html-dir not set for web access])
322 AM_CONDITIONAL(USE_LAM, test "x$lamdir" != "x")
326 dnl Following five are concatenated together into a linker specification.
328 AC_SUBST(X_TOOLKIT_LIBS)
330 AC_SUBST(X_BASIC_LIBS)
331 AC_SUBST(X_EXTRA_LIBS)
333 dnl Our Makefile.am files test the automake variable NO_X to determine
334 dnl whether X should be supported.
335 AM_CONDITIONAL(NO_X, test "x$with_x" = "xno")
337 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
338 AC_SUBST(my_includes)
340 LDFLAGS="$LDFLAGS -L/usr/local/lib"
342 AC_MSG_CHECKING([for X])
343 if test "$with_x" != "no" && test "$wxwin" = "true"; then
344 AC_DEFINE(HAVE_X11,1,[X11 system])
345 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib -L/usr/X11R6/lib64"
346 my_includes="$my_includes -I/usr/X11R6/include"
347 ctlib_graphics="$ctlibs_base -lctgraphics"
349 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
350 if test "$libgl" = "true" ; then
351 # Removed "-lglut" for Mac OS X compilation
352 ctlib_graphics="$ctlib_graphics -lGL -lGLU"
353 if test "$wxwin" = "true" ; then
355 if test "$debug" = "true"; then
358 if test "x$wx_gtk" != "x" ; then
359 ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=2.8 --libs` -lwx_gtk2u_gl-2.8 ${GTK_LIBS} ${GLIB_LIBS}"
360 elif test "x$wx_mac" != "x" ; then
361 ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=2.8 --libs` -lwx_macu_gl-2.8"
365 if test "$wxwin" = "true" ; then
366 AC_DEFINE(HAVE_SGP,1,[use sgp library])
372 AM_CONDITIONAL(HAVE_SGP, test "$wxwin" = "true")
374 if test "$png" = "true" ; then
375 ctlibs_tools="$ctlibs_tools -lpng"
377 if test "$zlib" = "true" ; then
378 ctlibs_tools="$ctlibs_tools -lz"
380 if test "$fftw" = "true" ; then
381 ctlibs_tools="$ctlibs_tools -lfftw3"
383 if test "$ctn" = "true"; then
384 ctlibs_tools="$ctlibs_tools -lctn"
387 dnl Check for dmalloc
388 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
389 AC_MSG_CHECKING([for enable-dmalloc])
390 AC_ARG_ENABLE(dmalloc,
391 [ --enable-dmalloc Use dmalloc memory allocation],
392 [case "${enableval}" in
399 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
402 [usedmalloc=false; AC_MSG_RESULT(no)])
404 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
405 ctlibs_tools="$ctlibs_tools -ldmallocxx"
406 AC_DEFINE(HAVE_DMALLOC,1,[dmalloc library])
407 AC_MSG_RESULT(Using dmalloc)
411 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
412 AC_MSG_CHECKING([for enable-efence])
413 AC_ARG_ENABLE(efence,
414 [ --enable-efence Use ElectricFence memory allocation],
415 [case "${enableval}" in
422 *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence])
425 [useefence=false; AC_MSG_RESULT(no)])
427 if test "$efence" = "true" -a "$useefence" = "true" ; then
428 ctlibs_tools="$ctlibs_tools -lefence"
429 AC_DEFINE(HAVE_EFENCE,1,[efence library])
430 AC_MSG_RESULT(Using efence)
433 if test "$wxwin" = "true" ; then
434 if test "$wx_gtk" = "true" -o "$wx_mac" = "true" ; then
435 wxcflags=`$wxconfig $wxdebug --cxxflags --version=2.8`
436 #wxlibs=`$wxconfig --libs`
438 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
439 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
441 CFLAGS="$CFLAGS -I../include $wxcflags"
442 ctlib_graphics="$ctlib_graphics $wxlibs"
446 AM_CONDITIONAL(HAVE_WXWINDOWS, test "$wxwin"="true")
448 dnl Setting projet libraries and includes
449 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
450 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
453 if test "x$lamdir" != "x" ; then
454 lamprograms="ctsimtext-lam"
455 AC_SUBST(lamprograms)
462 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])