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,3.5.6)
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.2, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
44 AC_CHECK_LIB(fftw, fftw_one, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false])
45 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -lXt -lXext])
46 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
48 if test "$zlib" = "true" ; then
49 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG,1,[PNG library])], [png=false])
52 dnl Checks for header files.
54 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)
56 dnl Checks for typedefs, structures, and compiler characteristics.
62 dnl Checks for library functions.
64 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
65 AC_CHECK_FUNC(basename)
67 AC_CHECK_FUNC(setpriority)
69 AC_CHECK_FUNC(gettimeofday)
71 if test "${OSTYPE}" = "cygwin" ; then
74 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
77 if test "${getopt_long}" = "false" ; then
78 my_includes="$my_includes -I../getopt"
79 AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
80 ctlibs_base="$ctlibs_base -lgetopt"
81 LDFLAGS="$LDFLAGS -L../getopt"
82 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
85 if test "${readline}" = "true" ; then
86 ctlibs_base="$ctlibs_base -lreadline"
87 if test "${ncurses}" = "true"; then
88 ctlibs_base="$ctlibs_base -lncurses"
89 elif test "${curses}" = "true"; then
90 ctlibs_base="$ctlibs_base -lcurses"
94 dnl Check for debug mode
95 AC_MSG_CHECKING([debug])
97 [ --enable-debug Turn on debugging],
98 [case "${enableval}" in
105 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
108 [debug=false; AC_MSG_RESULT(no)])
109 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
111 if test "$datadir" != "" ; then
112 CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
114 dnl CFLAGS="$CFLAGS -I/usr/local/include"
115 dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"
117 if test "$debug" = "true" ; then
118 CFLAGS="$CFLAGS -g -DDEBUG"
119 AC_DEFINE(DEBUG,1,[turn on debugging])
121 CFLAGS="$CFLAGS -O3 -DNDEBUG -fomit-frame-pointer -funroll-loops"
122 AC_DEFINE(NDEBUG,1,[no debugging])
125 if test "${pthread}" = "true" ; then
126 dnl CFLAGS="$CFLAGS -D_REENTRANT"
127 AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
130 AC_MSG_CHECKING(sstream)
131 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
132 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ]; then
133 AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
139 CFLAGS="$CFLAGS -Wall"
140 AC_MSG_CHECKING(whether to enable verbose warnings)
141 AC_ARG_ENABLE(verbose-warnings,
142 [ --enable-verbose-warnings
143 Enable verbose compiler warnings.],
144 [ case "$enableval" in
147 CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
152 esac ], AC_MSG_RESULT(no)
155 AC_MSG_CHECKING(static executables)
156 AC_ARG_ENABLE(static,
158 Enable static executables.],
159 [ case "$enableval" in
162 CFLAGS="$CFLAGS --static"
167 esac ], AC_MSG_RESULT(no)
172 [ --with-lam[=PATH] Set path of LAM MPI ],
173 [ if test "$withval" != "no" ; then
178 if test "$withval" != "no" ; then
179 if test "$prefix" != "NONE" ; then
180 trylamdir="$trylamdir $prefix"
183 AC_MSG_CHECKING([for LAM MPI installation])
184 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
185 if test -x "$testlamdir/bin/hcp" ; then
186 if test "$testlamdir" != "/usr"; then
187 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
188 CFLAGS="$CFLAGS -I$testlamdir/include"
190 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
198 AC_MSG_RESULT($lamdir)
206 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
207 [ if test "$withval" != "no" ; then
212 if test "$withval" == "no" -o "$withval" == "NONE" ; then
213 AC_MSG_CHECKING([for CTN DICOM installation])
214 AC_MSG_RESULT([disabled])
216 AC_MSG_CHECKING([for CTN DICOM installation])
217 for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
218 if test -f "$testctndir/libctn.a" ; then
219 LDFLAGS="$LDFLAGS -L$testctndir"
224 for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
225 if test -f "$testctndir/ctn_os.h" ; then
226 CFLAGS="$CFLAGS -I$testctndir"
231 if test "$ctnlib" == "true" -a "$ctninclude" == "true" ; then
233 AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
240 AC_MSG_CHECKING([for web access])
241 dnl Set cgi-bin directory
242 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
243 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
245 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
246 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
248 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
249 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
251 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
252 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
254 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
255 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
257 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
258 cgiprograms="ctsim.cgi ctsim.conf"
259 AC_SUBST(cgiprograms)
262 if test -n "$htmldir" ; then
263 htmldata=simulate.html
266 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
268 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
272 if test -z "$cgibindir" ; then
273 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
274 elif test -z "$cgibinurl" ; then
275 AC_MSG_ERROR([--with-cgibin-url not set for web access])
276 elif test -z "$webdatadir" ; then
277 AC_MSG_ERROR([--with-webdata-dir not set for web access])
278 elif test -z "$webdataurl" ; then
279 AC_MSG_ERROR([--with-webdata-url not set for web access])
280 elif test -z "$htmldir" ; then
281 AC_MSG_ERROR([--with-html-dir not set for web access])
287 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
289 dnl Prepare to support X. If the user gave the command-line option
290 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
291 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
292 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
293 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
294 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
295 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
296 dnl supported, we'll concatenate the whole lot of these into a command line
297 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
298 dnl libplot/Makefile.am.
302 dnl Following five are concatenated together into a linker specification.
304 AC_SUBST(X_TOOLKIT_LIBS)
306 AC_SUBST(X_BASIC_LIBS)
307 AC_SUBST(X_EXTRA_LIBS)
309 X_TOOLKIT_LIBS="-lXt"
310 X_BASIC_LIBS="-lXext -lX11 -lXmu"
312 dnl Check whether libXt has thread support. Some platforms may have
313 dnl pthread support in libc, but no thread support in libXt/libX11.
314 our_saved_LDFLAGS="$LDFLAGS"
315 LDFLAGS="$X_LIBS $LDFLAGS"
316 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT,1,[x thread supported]), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
317 LDFLAGS="$our_saved_LDFLAGS"
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$no_x" = "xyes")
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 "$no_x" != "yes" ; then
330 AC_DEFINE(HAVE_X11,1,[X11 system])
331 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
332 ctlib_graphics="$ctlibs_base -lctgraphics"
334 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
335 if test "$libgl" = "true" ; then
336 ctlib_graphics="$ctlib_graphics -lglut -lGL -lGLU"
337 if test "$wxwin" = "true" ; then
338 ctlib_graphics="$ctlib_graphics -lwx_gtk_gl-2.2"
341 if test "$wxwin" = "true" ; then
342 AC_DEFINE(HAVE_SGP,1,[use sgp library])
343 AM_CONDITIONAL(HAVE_SGP, test 1==1)
349 if test "$png" = "true" ; then
350 ctlibs_tools="$ctlibs_tools -lpng"
352 if test "$zlib" = "true" ; then
353 ctlibs_tools="$ctlibs_tools -lz"
355 if test "$fftw" = "true" ; then
356 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
358 if test "$ctn" = "true"; then
359 ctlibs_tools="$ctlibs_tools -lctn"
362 dnl Check for dmalloc
363 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
364 AC_MSG_CHECKING([for enable-dmalloc])
365 AC_ARG_ENABLE(dmalloc,
366 [ --enable-dmalloc Use dmalloc memory allocation],
367 [case "${enableval}" in
374 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
377 [usedmalloc=false; AC_MSG_RESULT(no)])
379 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
380 ctlibs_tools="$ctlibs_tools -ldmallocxx"
381 AC_DEFINE(HAVE_DMALLOC,1,[dmalloc library])
382 AC_MSG_RESULT(Using dmalloc)
386 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
387 AC_MSG_CHECKING([for enable-efence])
388 AC_ARG_ENABLE(efence,
389 [ --enable-efence Use ElectricFence memory allocation],
390 [case "${enableval}" in
397 *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence])
400 [useefence=false; AC_MSG_RESULT(no)])
402 if test "$efence" = "true" -a "$useefence" = "true" ; then
403 ctlibs_tools="$ctlibs_tools -lefence"
404 AC_DEFINE(HAVE_EFENCE,1,[efence library])
405 AC_MSG_RESULT(Using efence)
408 if test "$wxwin" = "true" ; then
409 if test "$wx_gtk" = "true" ; then
410 wxcflags=`$wxconfig --cflags`
411 wxlibs=`$wxconfig --libs`
413 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
414 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
416 CFLAGS="$CFLAGS -I../include $wxcflags"
417 ctlib_graphics="$ctlib_graphics $wxlibs"
418 AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
423 dnl Setting projet libraries and includes
424 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
425 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
428 if test -n "$lamdir" ; then
429 lamprograms="ctsimtext-lam"
430 AC_SUBST(lamprograms)
437 AC_CONFIG_FILES([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])