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)
15 AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR(You should get glib 2.0.0 or better.))
16 AM_PATH_GTK_2_0(2.0.0,havegtk=yes,havegtk=no)
18 CFLAGS="${CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS}"
20 dnl Checks for programs.
30 AC_PATH_PROG(wxconfig,wx-config)
32 dnl Check for C operation
35 AC_CHECK_SIZEOF(short, 2)
36 AC_CHECK_SIZEOF(int, 4)
37 AC_CHECK_SIZEOF(long, 4)
38 AC_CHECK_SIZEOF(float, 4)
39 AC_CHECK_SIZEOF(double, 8)
41 dnl Add define templates
43 dnl Checks for libraries.
44 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
46 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
47 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
48 AC_CHECK_LIB(readline, main, [readline=true;
49 AC_DEFINE([HAVE_READLINE],1,[Readline library])],
50 [readline=false], [-lcurses])
52 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} ])
53 AC_CHECK_LIB(wx_mac-2.8, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
54 AC_CHECK_LIB(fftw3, fftw_malloc, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false], [-L/usr/lib64 -L/usr/lib])
55 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -L/usr/X11R6/lib64])
56 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
58 if test "$zlib" = "true" ; then
59 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG,1,[PNG library])], [png=false], [-lz -lm])
62 dnl Checks for header files.
64 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)
66 dnl Checks for typedefs, structures, and compiler characteristics.
72 dnl Checks for library functions.
74 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf basename setjmp setpriority time gettimeofday getenv)
75 AC_CHECK_FUNC(basename)
77 AC_CHECK_FUNC(setpriority)
79 AC_CHECK_FUNC(gettimeofday)
80 AC_CHECK_FUNC(getopt, [ getopt=true ], [ getopt=false ])
82 if test "${OSTYPE}" = "cygwin" ; then
85 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
88 if test "${getopt_long}" = "false" ; then
89 my_includes="$my_includes -I../getopt"
90 AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
91 ctlibs_base="$ctlibs_base -lgetopt"
92 LDFLAGS="$LDFLAGS -L../getopt"
95 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test "$GETOPTLONG"="1")
97 if test "${readline}" = "true" ; then
98 ctlibs_base="$ctlibs_base -lreadline"
99 if test "${ncurses}" = "true"; then
100 ctlibs_base="$ctlibs_base -lncurses"
101 elif test "${curses}" = "true"; then
102 ctlibs_base="$ctlibs_base -lcurses"
106 dnl Check for debug mode
107 AC_MSG_CHECKING([debug])
109 [ --enable-debug Turn on debugging],
110 [case "${enableval}" in
117 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
120 [debug=false; AC_MSG_RESULT(no)])
121 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
123 if test "$datadir" != "" ; then
124 CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
126 dnl CFLAGS="$CFLAGS -I/usr/local/include"
127 dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"
129 if test "$debug" = "true" ; then
130 CFLAGS="$CFLAGS -g -DDEBUG"
131 AC_DEFINE(DEBUG,1,[turn on debugging])
133 CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
134 AC_DEFINE(NDEBUG,1,[no debugging])
137 if test "${pthread}" = "true" ; then
138 dnl CFLAGS="$CFLAGS -D_REENTRANT"
139 AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
142 AC_MSG_CHECKING(sstream)
143 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
144 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ||
145 test -f /usr/include/gcc/darwin/3.1/g++-v3/sstream ]; then
146 AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
153 CFLAGS="$CFLAGS -Wall"
154 AC_MSG_CHECKING(whether to enable verbose warnings)
155 AC_ARG_ENABLE(verbose-warnings,
156 [ --enable-verbose-warnings
157 Enable verbose compiler warnings.],
158 [ case "$enableval" in
161 CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
166 esac ], AC_MSG_RESULT(no)
169 AC_MSG_CHECKING(static executables)
170 AC_ARG_ENABLE(static,
172 Enable static executables.],
173 [ case "$enableval" in
176 CFLAGS="$CFLAGS --static"
181 esac ], AC_MSG_RESULT(no)
186 [ --with-lam[=PATH] Set path of LAM MPI ],
187 [ if test "$withval" != "no" ; then
192 if test "$withval" != "no" ; then
193 if test "$prefix" != "NONE" ; then
194 trylamdir="$trylamdir $prefix"
197 AC_MSG_CHECKING([for LAM MPI installation])
198 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
199 if test -x "$testlamdir/bin/hcp" ; then
200 if test "$testlamdir" != "/usr"; then
201 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
202 CFLAGS="$CFLAGS -I$testlamdir/include"
204 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
212 AC_MSG_RESULT($lamdir)
220 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
221 [ if test "$withval" != "no" ; then
226 if test "$withval" == "no" -o "$withval" == "NONE" ; then
227 AC_MSG_CHECKING([for CTN DICOM installation])
228 AC_MSG_RESULT([disabled])
230 AC_MSG_CHECKING([for CTN DICOM installation])
231 for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
232 if test -f "$testctndir/libctn.a" ; then
233 LDFLAGS="$LDFLAGS -L$testctndir"
238 for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
239 if test -f "$testctndir/ctn_os.h" ; then
240 CFLAGS="$CFLAGS -I$testctndir"
245 if test "$ctnlib" == "true" -a "$ctninclude" == "true" ; then
247 AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
255 AC_MSG_CHECKING([for CPU specification])
257 [ --with-mcpu[=CPU] Set name of CPU for gcc -mcpu])
259 if test "$withval" == "no" -o "$withval" == "yes" -o "$withval" == ""; then
262 AC_MSG_RESULT([$withval])
263 CFLAGS="$CFLAGS -mcpu=$withval"
266 AC_MSG_CHECKING([for web access])
267 dnl Set cgi-bin directory
268 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
269 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
271 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
272 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
274 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
275 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
277 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
278 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
280 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
281 [ html_%dir=$withval ; AC_SUBST(htmldir) ] )
283 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
284 cgiprograms="ctsim.cgi ctsim.conf"
285 AC_SUBST(cgiprograms)
288 if test -n "$html_dir" ; then
289 htmldata=simulate.html
292 AM_CONDITIONAL(USE_HTML, test -n "$html_dir")
294 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$html_dir" ; then
298 if test -z "$cgibindir" ; then
299 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
300 elif test -z "$cgibinurl" ; then
301 AC_MSG_ERROR([--with-cgibin-url not set for web access])
302 elif test -z "$webdatadir" ; then
303 AC_MSG_ERROR([--with-webdata-dir not set for web access])
304 elif test -z "$webdataurl" ; then
305 AC_MSG_ERROR([--with-webdata-url not set for web access])
306 elif test -z "$html_dir" ; then
307 AC_MSG_ERROR([--with-html-dir not set for web access])
313 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
317 dnl Following five are concatenated together into a linker specification.
319 AC_SUBST(X_TOOLKIT_LIBS)
321 AC_SUBST(X_BASIC_LIBS)
322 AC_SUBST(X_EXTRA_LIBS)
324 dnl Our Makefile.am files test the automake variable NO_X to determine
325 dnl whether X should be supported.
326 AM_CONDITIONAL(NO_X, test "x$with_x" = "xno")
328 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
329 AC_SUBST(my_includes)
331 LDFLAGS="$LDFLAGS -L/usr/local/lib"
333 AC_MSG_CHECKING([for X])
334 if test "$with_x" != "no" && test "$wxwin" = "true"; then
335 AC_DEFINE(HAVE_X11,1,[X11 system])
336 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib -L/usr/X11R6/lib64"
337 my_includes="$my_includes -I/usr/X11R6/include"
338 ctlib_graphics="$ctlibs_base -lctgraphics"
340 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
341 if test "$libgl" = "true" ; then
342 # Removed "-lglut" for Mac OS X compilation
343 ctlib_graphics="$ctlib_graphics -lGL -lGLU"
344 if test "$wxwin" = "true" ; then
346 if test "$debug" = "true"; then
349 if [ "$wx_gtk" ]; then
350 ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --libs --version=2.8` -lwx_gtk2u_gl-2.8 ${GTK_LIBS} ${GLIB_LIBS}"
351 elif [ "$wx_mac" ]; then
352 ctlib_graphics="$ctlib_graphics -lwx_mac_gl-2.8"
356 if test "$wxwin" = "true" ; then
357 AC_DEFINE(HAVE_SGP,1,[use sgp library])
363 AM_CONDITIONAL(HAVE_SGP, test "$wxwin" = "true")
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 -lfftw3"
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,1,[dmalloc library])
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,1,[efence library])
421 AC_MSG_RESULT(Using efence)
424 if test "$wxwin" = "true" ; then
425 if [ "$wx_gtk" = "true" ] || [ "$wx_mac" = "true" ] ; then
426 wxcflags=`$wxconfig $wxdebug --cxxflags --version=2.8`
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"
437 AM_CONDITIONAL(HAVE_WXWINDOWS, test "$wxwin"="true")
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_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])