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,4.3.4)
10 AM_CONFIG_HEADER(config.h)
12 dnl Checks for programs.
22 AC_PATH_PROG(wxconfig,wxgtk-2.4-config)
23 if [ ! "$wxconfig" ]; then
24 AC_PATH_PROG(wxconfig,wx-config)
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 Add define templates
38 dnl Checks for libraries.
39 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
41 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
42 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
43 AC_CHECK_LIB(readline, main, [readline=true;
44 AC_DEFINE([HAVE_READLINE],1,[Readline library])],
45 [readline=false], [-lcurses])
47 AC_CHECK_LIB(wx_gtk-2.4, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])], [], [-L/usr/lib64 -L/usr/lib `gtk-config --libs` `glib-config --libs glib gmodule gthread` ])
48 AC_CHECK_LIB(wx_mac-2.4, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
49 AC_CHECK_LIB(fftw3, fftw_malloc, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false], [-L/usr/lib64 -L/usr/lib])
50 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -L/usr/X11R6/lib64])
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,1,[PNG library])], [png=false], [-lz -lm])
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 basename setjmp setpriority time gettimeofday getenv)
70 AC_CHECK_FUNC(basename)
72 AC_CHECK_FUNC(setpriority)
74 AC_CHECK_FUNC(gettimeofday)
75 AC_CHECK_FUNC(getopt, [ getopt=true ], [ getopt=false ])
77 if test "${OSTYPE}" = "cygwin" ; then
80 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
83 if test "${getopt_long}" = "false" ; then
84 my_includes="$my_includes -I../getopt"
85 AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
86 ctlibs_base="$ctlibs_base -lgetopt"
87 LDFLAGS="$LDFLAGS -L../getopt"
90 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test "$GETOPTLONG"="1")
92 if test "${readline}" = "true" ; then
93 ctlibs_base="$ctlibs_base -lreadline"
94 if test "${ncurses}" = "true"; then
95 ctlibs_base="$ctlibs_base -lncurses"
96 elif test "${curses}" = "true"; then
97 ctlibs_base="$ctlibs_base -lcurses"
101 dnl Check for debug mode
102 AC_MSG_CHECKING([debug])
104 [ --enable-debug Turn on debugging],
105 [case "${enableval}" in
112 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
115 [debug=false; AC_MSG_RESULT(no)])
116 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
118 if test "$datadir" != "" ; then
119 CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
121 dnl CFLAGS="$CFLAGS -I/usr/local/include"
122 dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"
124 if test "$debug" = "true" ; then
125 CFLAGS="$CFLAGS -g -DDEBUG"
126 AC_DEFINE(DEBUG,1,[turn on debugging])
128 CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
129 AC_DEFINE(NDEBUG,1,[no debugging])
132 if test "${pthread}" = "true" ; then
133 dnl CFLAGS="$CFLAGS -D_REENTRANT"
134 AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
137 AC_MSG_CHECKING(sstream)
138 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
139 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ||
140 test -f /usr/include/gcc/darwin/3.1/g++-v3/sstream ]; then
141 AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
148 CFLAGS="$CFLAGS -Wall"
149 AC_MSG_CHECKING(whether to enable verbose warnings)
150 AC_ARG_ENABLE(verbose-warnings,
151 [ --enable-verbose-warnings
152 Enable verbose compiler warnings.],
153 [ case "$enableval" in
156 CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
161 esac ], AC_MSG_RESULT(no)
164 AC_MSG_CHECKING(static executables)
165 AC_ARG_ENABLE(static,
167 Enable static executables.],
168 [ case "$enableval" in
171 CFLAGS="$CFLAGS --static"
176 esac ], AC_MSG_RESULT(no)
181 [ --with-lam[=PATH] Set path of LAM MPI ],
182 [ if test "$withval" != "no" ; then
187 if test "$withval" != "no" ; then
188 if test "$prefix" != "NONE" ; then
189 trylamdir="$trylamdir $prefix"
192 AC_MSG_CHECKING([for LAM MPI installation])
193 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
194 if test -x "$testlamdir/bin/hcp" ; then
195 if test "$testlamdir" != "/usr"; then
196 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
197 CFLAGS="$CFLAGS -I$testlamdir/include"
199 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
207 AC_MSG_RESULT($lamdir)
215 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
216 [ if test "$withval" != "no" ; then
221 if test "$withval" == "no" -o "$withval" == "NONE" ; then
222 AC_MSG_CHECKING([for CTN DICOM installation])
223 AC_MSG_RESULT([disabled])
225 AC_MSG_CHECKING([for CTN DICOM installation])
226 for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
227 if test -f "$testctndir/libctn.a" ; then
228 LDFLAGS="$LDFLAGS -L$testctndir"
233 for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
234 if test -f "$testctndir/ctn_os.h" ; then
235 CFLAGS="$CFLAGS -I$testctndir"
240 if test "$ctnlib" == "true" -a "$ctninclude" == "true" ; then
242 AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
250 AC_MSG_CHECKING([for CPU specification])
252 [ --with-mcpu[=CPU] Set name of CPU for gcc -mcpu])
254 if test "$withval" == "no" -o "$withval" == "yes" -o "$withval" == ""; then
257 AC_MSG_RESULT([$withval])
258 CFLAGS="$CFLAGS -mcpu=$withval"
261 AC_MSG_CHECKING([for web access])
262 dnl Set cgi-bin directory
263 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
264 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
266 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
267 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
269 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
270 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
272 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
273 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
275 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
276 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
278 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
279 cgiprograms="ctsim.cgi ctsim.conf"
280 AC_SUBST(cgiprograms)
283 if test -n "$htmldir" ; then
284 htmldata=simulate.html
287 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
289 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
293 if test -z "$cgibindir" ; then
294 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
295 elif test -z "$cgibinurl" ; then
296 AC_MSG_ERROR([--with-cgibin-url not set for web access])
297 elif test -z "$webdatadir" ; then
298 AC_MSG_ERROR([--with-webdata-dir not set for web access])
299 elif test -z "$webdataurl" ; then
300 AC_MSG_ERROR([--with-webdata-url not set for web access])
301 elif test -z "$htmldir" ; then
302 AC_MSG_ERROR([--with-html-dir not set for web access])
308 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
312 dnl Following five are concatenated together into a linker specification.
314 AC_SUBST(X_TOOLKIT_LIBS)
316 AC_SUBST(X_BASIC_LIBS)
317 AC_SUBST(X_EXTRA_LIBS)
319 dnl Our Makefile.am files test the automake variable NO_X to determine
320 dnl whether X should be supported.
321 AM_CONDITIONAL(NO_X, test "x$with_x" = "xno")
323 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
324 AC_SUBST(my_includes)
326 LDFLAGS="$LDFLAGS -L/usr/local/lib"
328 AC_MSG_CHECKING([for X])
329 if test "$with_x" != "no" && test "$wxwin" = "true"; then
330 AC_DEFINE(HAVE_X11,1,[X11 system])
331 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib -L/usr/X11R6/lib64"
332 my_includes="$my_includes -I/usr/X11R6/include"
333 ctlib_graphics="$ctlibs_base -lctgraphics"
335 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
336 if test "$libgl" = "true" ; then
337 # Removed "-lglut" for Mac OS X compilation
338 ctlib_graphics="$ctlib_graphics -lGL -lGLU"
339 if test "$wxwin" = "true" ; then
340 if [ "$wx_gtk" ]; then
341 ctlib_graphics="$ctlib_graphics `wx-config --libs` -lwx_gtk_gl-2.4 `gtk-config --libs` `glib-config --libs glib gmodule gthread`"
342 elif [ "$wx_mac" ]; then
343 ctlib_graphics="$ctlib_graphics -lwx_mac_gl-2.4"
347 if test "$wxwin" = "true" ; then
348 AC_DEFINE(HAVE_SGP,1,[use sgp library])
354 AM_CONDITIONAL(HAVE_SGP, test "$wxwin" = "true")
356 if test "$png" = "true" ; then
357 ctlibs_tools="$ctlibs_tools -lpng"
359 if test "$zlib" = "true" ; then
360 ctlibs_tools="$ctlibs_tools -lz"
362 if test "$fftw" = "true" ; then
363 ctlibs_tools="$ctlibs_tools -lfftw3"
365 if test "$ctn" = "true"; then
366 ctlibs_tools="$ctlibs_tools -lctn"
369 dnl Check for dmalloc
370 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
371 AC_MSG_CHECKING([for enable-dmalloc])
372 AC_ARG_ENABLE(dmalloc,
373 [ --enable-dmalloc Use dmalloc memory allocation],
374 [case "${enableval}" in
381 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
384 [usedmalloc=false; AC_MSG_RESULT(no)])
386 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
387 ctlibs_tools="$ctlibs_tools -ldmallocxx"
388 AC_DEFINE(HAVE_DMALLOC,1,[dmalloc library])
389 AC_MSG_RESULT(Using dmalloc)
393 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
394 AC_MSG_CHECKING([for enable-efence])
395 AC_ARG_ENABLE(efence,
396 [ --enable-efence Use ElectricFence memory allocation],
397 [case "${enableval}" in
404 *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence])
407 [useefence=false; AC_MSG_RESULT(no)])
409 if test "$efence" = "true" -a "$useefence" = "true" ; then
410 ctlibs_tools="$ctlibs_tools -lefence"
411 AC_DEFINE(HAVE_EFENCE,1,[efence library])
412 AC_MSG_RESULT(Using efence)
415 if test "$wxwin" = "true" ; then
416 if [ "$wx_gtk" = "true" ] || [ "$wx_mac" == "true" ] ; then
417 wxcflags=`$wxconfig --cflags`
418 wxlibs=`$wxconfig --libs`
420 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
421 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
423 CFLAGS="$CFLAGS -I../include $wxcflags"
424 ctlib_graphics="$ctlib_graphics $wxlibs"
428 AM_CONDITIONAL(HAVE_WXWINDOWS, test "$wxwin"="true")
430 dnl Setting projet libraries and includes
431 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
432 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
435 if test -n "$lamdir" ; then
436 lamprograms="ctsimtext-lam"
437 AC_SUBST(lamprograms)
444 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])