1 dnl *****************************************************************************
2 dnl FILE IDENTIFICATION
4 dnl Purpose: Top-level routines of CTSim program
5 dnl Programmer: Kevin Rosenberg
6 dnl Date Started: July 2000
8 dnl This is part of the CTSim program
9 dnl Copyright (c) 1983-2009 Kevin Rosenberg
11 dnl This program is free software; you can redistribute it and/or modify
12 dnl it under the terms of the GNU General Public License (version 2) as
13 dnl published by the Free Software Foundation.
15 dnl This program is distributed in the hope that it will be useful,
16 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
17 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 dnl GNU General Public License for more details.
20 dnl You should have received a copy of the GNU General Public License
21 dnl along with this program; if not, write to the Free Software
22 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 dnl****************************************************************************/
25 dnl Process this file with autoconf to produce a configure script.
27 dnl Must reset CDPATH so that bash's cd does not print to stdout
30 AC_INIT([CTSim], [6.0.0], [ctsim-users@kpe.io], [ctsim], [http://www.ctsim.org/])
31 AC_CONFIG_SRCDIR([src/ctsim.cpp])
32 AC_CONFIG_MACRO_DIR([scripts])
33 dnl permit auxiliary scripts directory (e.g. config.sub, config.guess, install-sh)
34 AC_CONFIG_AUX_DIR(scripts/)
39 AM_CONFIG_HEADER(config.h)
41 dnl Checks for programs.
51 AC_PATH_PROG(wxconfig,wx-config)
53 dnl Check for C operation
56 AC_CHECK_SIZEOF(short, 2)
57 AC_CHECK_SIZEOF(int, 4)
58 AC_CHECK_SIZEOF(long, 4)
59 AC_CHECK_SIZEOF(float, 4)
60 AC_CHECK_SIZEOF(double, 8)
62 dnl Add define templates
64 dnl Checks for libraries.
65 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ; AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
67 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
68 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
69 AC_CHECK_LIB(readline, main, [readline=true;
70 AC_DEFINE([HAVE_READLINE],1,[Readline library])],
71 [readline=false], [-lcurses])
73 AC_CHECK_LIB(gtk-x11-2.0, main, [hasx11gtk2=true], [])
74 if test "x$hasx11gtk2" = "x" ; then
75 AC_MSG_NOTICE([Does not have X11 GTK2])
76 AC_DEFUN([AM_PATH_GLIB_2_0], [])
77 AC_DEFUN([AM_PATH_GTK_2_0], [])
79 if test "$hasx11gtk2" = "true" ; then
80 AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR(You should get glib 2.0.0 or better.))
81 AM_PATH_GTK_2_0(2.0.0,havegtk_am=yes,havegtk_am=no)
82 CFLAGS="${CFLAGS} ${g76GTK_CFLAGS} ${GLIB_CFLAGS}"
85 AC_CHECK_LIB(wx_gtk2u_core-3.0, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])], [], [-L/usr/lib64 -L/usr/lib ${GTK_LIBS} ${GLIB_LIBS} ])
86 AC_CHECK_LIB(wx_mac_core-3.0, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
87 AC_CHECK_LIB(fftw3, fftw_malloc, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false], [-L/usr/lib64 -L/usr/lib])
88 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -L/usr/X11R6/lib64])
89 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
91 if test "$zlib" = "true" ; then
92 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG,1,[PNG library])], [png=false], [-L/opt/local/lib -lz -lm])
95 dnl Checks for header files.
97 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)
99 dnl Checks for typedefs, structures, and compiler characteristics.
105 dnl Checks for library functions.
107 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf basename setjmp setpriority time gettimeofday getenv)
108 AC_CHECK_FUNC(basename)
109 AC_CHECK_FUNC(setjmp)
110 AC_CHECK_FUNC(setpriority)
112 AC_CHECK_FUNC(gettimeofday)
113 AC_CHECK_FUNC(getopt, [ getopt=true ], [ getopt=false ])
115 if test "${OSTYPE}" = "cygwin" ; then
118 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
121 if test "${getopt_long}" = "false" ; then
122 my_includes="$my_includes -I../getopt"
123 AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
124 ctlibs_base="$ctlibs_base -lgetopt"
125 LDFLAGS="$LDFLAGS -L../getopt"
128 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test "$GETOPTLONG"="1")
131 i386|i486|i586|i686|x86|x86_64)
133 if [ test "$ax_cv_have_sse41_ext" = yes && test "$ac_cv_header_smmintrin_h" = yes ]; then
134 # SSE4.1/2 extensions
135 ARCH_OPTION='-msse4.1'
136 elif [ test "$ax_cv_have_sse3_ext" = yes && test "$ac_cv_header_pmmintrin_h" = yes ]; then
138 elif [ test "$ax_cv_have_sse2_ext" = yes && test "$ac_cv_header_emmintrin_h" = yes ]; then
141 ARCH_OPTION="-ffast-math"
144 ARCH_OPTION="-fno-common -faltivec";;
145 armv1*|armv2*|armv3*|armv4*|armv5*|armv6*)
146 ARCH_OPTION="-ffast-math";;
148 ARCH_OPTION="-ffast-math -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4";;
150 # unknown architecture : use portable C version
153 CPPFLAGS="$CPPFLAGS $ARCH_OPTION"
154 CXXFLAGS="$CPPFLAGS $ARCH_OPTION"
156 if test "${readline}" = "true" ; then
157 ctlibs_base="$ctlibs_base -lreadline"
158 if test "${ncurses}" = "true"; then
159 ctlibs_base="$ctlibs_base -lncurses"
160 elif test "${curses}" = "true"; then
161 ctlibs_base="$ctlibs_base -lcurses"
165 dnl Check for debug mode
166 AC_MSG_CHECKING([debug])
168 [ --enable-debug Turn on debugging],
169 [case "${enableval}" in
176 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
179 [debug=false; AC_MSG_RESULT(no)])
180 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
182 if test "$datadir" != "" ; then
183 CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
185 dnl CFLAGS="$CFLAGS -I/usr/local/include"
186 dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"
188 if test "$debug" = "true" ; then
189 CFLAGS="$CFLAGS -g -O0 -DDEBUG"
190 AC_DEFINE(DEBUG,1,[turn on debugging])
192 CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
193 AC_DEFINE(NDEBUG,1,[no debugging])
196 if test "${pthread}" = "true" ; then
197 dnl CFLAGS="$CFLAGS -D_REENTRANT"
198 AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
201 AC_MSG_CHECKING(sstream)
202 if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
203 test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ||
204 test -f /usr/include/gcc/darwin/3.1/g++-v3/sstream ]; then
205 AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
212 CFLAGS="$CFLAGS -Wall"
213 AC_MSG_CHECKING(whether to enable verbose warnings)
214 AC_ARG_ENABLE(verbose-warnings,
215 [ --enable-verbose-warnings
216 Enable verbose compiler warnings.],
217 [ case "$enableval" in
220 CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
225 esac ], AC_MSG_RESULT(no)
228 AC_MSG_CHECKING(static executables)
229 AC_ARG_ENABLE(static,
231 Enable static executables.],
232 [ case "$enableval" in
235 CFLAGS="$CFLAGS --static"
240 esac ], AC_MSG_RESULT(no)
245 [ --with-lam[=PATH] Set path of LAM MPI ],
246 [ if test "$withval" != "no" ; then
251 if test "$withval" != "no" ; then
252 if test "$prefix" != "NONE" ; then
253 trylamdir="$trylamdir $prefix"
256 AC_MSG_CHECKING([for LAM MPI installation])
257 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
258 if test -x "$testlamdir/bin/hcp" ; then
259 if test "$testlamdir" != "/usr"; then
260 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
261 CFLAGS="$CFLAGS -I$testlamdir/include"
263 CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
271 AC_MSG_RESULT($lamdir)
279 [ --with-ctn[=PATH] Set path of CTN DICOM library ],
280 [ if test "$withval" != "no" ; then
285 if test "$withval" = "no" -o "$withval" = "NONE" ; then
286 AC_MSG_CHECKING([for CTN DICOM installation])
287 AC_MSG_RESULT([disabled])
289 AC_MSG_CHECKING([for CTN DICOM installation])
290 for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
291 if test -f "$testctndir/libctn.a" ; then
292 LDFLAGS="$LDFLAGS -L$testctndir"
297 for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
298 if test -f "$testctndir/ctn_os.h" ; then
299 CFLAGS="$CFLAGS -I$testctndir"
304 if test "$ctnlib" = "true" -a "$ctninclude" = "true" ; then
306 AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
314 AC_MSG_CHECKING([for CPU specification])
316 [ --with-mcpu[=CPU] Set name of CPU for gcc -mcpu])
318 if test "$withval" = "no" -o "$withval" = "yes" -o "$withval" = ""; then
321 AC_MSG_RESULT([$withval])
322 CFLAGS="$CFLAGS -mcpu=$withval"
325 AC_MSG_CHECKING([for web access])
326 dnl Set cgi-bin directory
327 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
328 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
330 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
331 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
333 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
334 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
336 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
337 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
339 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
340 [ html_%dir=$withval ; AC_SUBST(htmldir) ] )
342 if test "x$cgibindir" != "x" -o "x$cgibinurl" != "x" ; then
343 cgiprograms="ctsim.cgi ctsim.conf"
344 AC_SUBST(cgiprograms)
347 if test "x$html_dir" = "x" ; then
348 htmldata=simulate.html
351 AM_CONDITIONAL(USE_HTML, test "x$html_dir" = "x")
353 if test "x$cgibindir" != "x" -o "x$cgibinurl" != "x" -o "x$webdatadir" != "x" -o "x$webdataurl" != "x" -o "x$html_dir" != "x" ; then
357 if test "x$cgibindir" = "x" ; then
358 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
359 elif test "x$cgibinurl" = "x" ; then
360 AC_MSG_ERROR([--with-cgibin-url not set for web access])
361 elif test "x$webdatadir" = "x" ; then
362 AC_MSG_ERROR([--with-webdata-dir not set for web access])
363 elif test "x$webdataurl" = "x" ; then
364 AC_MSG_ERROR([--with-webdata-url not set for web access])
365 elif test "x$html_dir" = "x" ; then
366 AC_MSG_ERROR([--with-html-dir not set for web access])
372 AM_CONDITIONAL(USE_LAM, test "x$lamdir" != "x")
376 dnl Following five are concatenated together into a linker specification.
378 AC_SUBST(X_TOOLKIT_LIBS)
380 AC_SUBST(X_BASIC_LIBS)
381 AC_SUBST(X_EXTRA_LIBS)
383 dnl Our Makefile.am files test the automake variable NO_X to determine
384 dnl whether X should be supported.
385 AM_CONDITIONAL(NO_X, test "x$with_x" = "xno")
387 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
389 LDFLAGS="$LDFLAGS -L/usr/local/lib"
391 AC_MSG_CHECKING([for X])
392 if test "$with_x" != "no" && test "$wxwin" = "true"; then
393 AC_DEFINE(HAVE_X11,1,[X11 system])
394 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib -L/usr/X11R6/lib64"
395 my_includes="$my_includes -I/usr/X11R6/include -I/usr/include/X11"
396 ctlib_graphics="$ctlibs_base -lctgraphics"
398 ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
399 wx_cppflags="`$wxconfig --cppflags`"
400 if test "$libgl" = "true" ; then
401 dnl Removed "-lglut" for Mac OS X compilation
402 ctlib_graphics="$ctlib_graphics -lGL -lGLU"
403 if test "$wxwin" = "true" ; then
405 if test "$debug" = "true"; then
408 if test "x$wx_gtk" != "x" ; then
409 ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=3.0 --libs std,gl` ${GTK_LIBS} ${GLIB_LIBS}"
411 elif test "x$wx_mac" != "x" ; then
412 ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=3.0 --libs std,gl`"
416 if test "$wxwin" = "true" ; then
417 AC_DEFINE(HAVE_SGP,1,[use sgp library])
423 AM_CONDITIONAL(HAVE_SGP, test "$wxwin" = "true")
425 if test "$png" = "true" ; then
426 ctlibs_tools="$ctlibs_tools -lpng"
428 if test "$zlib" = "true" ; then
429 ctlibs_tools="$ctlibs_tools -lz"
431 if test "$fftw" = "true" ; then
432 ctlibs_tools="$ctlibs_tools -lfftw3"
434 if test "$ctn" = "true"; then
435 ctlibs_tools="$ctlibs_tools -lctn"
438 dnl Check for dmalloc
439 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
440 AC_MSG_CHECKING([for enable-dmalloc])
441 AC_ARG_ENABLE(dmalloc,
442 [ --enable-dmalloc Use dmalloc memory allocation],
443 [case "${enableval}" in
450 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
453 [usedmalloc=false; AC_MSG_RESULT(no)])
455 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
456 ctlibs_tools="$ctlibs_tools -ldmallocxx"
457 AC_DEFINE(HAVE_DMALLOC,1,[dmalloc library])
458 AC_MSG_RESULT(Using dmalloc)
462 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
463 AC_MSG_CHECKING([for enable-efence])
464 AC_ARG_ENABLE(efence,
465 [ --enable-efence Use ElectricFence memory allocation],
466 [case "${enableval}" in
473 *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence])
476 [useefence=false; AC_MSG_RESULT(no)])
478 if test "$efence" = "true" -a "$useefence" = "true" ; then
479 ctlibs_tools="$ctlibs_tools -lefence"
480 AC_DEFINE(HAVE_EFENCE,1,[efence library])
481 AC_MSG_RESULT(Using efence)
484 if test "$wxwin" = "true" ; then
485 if test "$wx_gtk" = "true" -o "$wx_mac" = "true" ; then
486 wxcflags=`$wxconfig $wxdebug --cxxflags --version=3.0`
487 #wxlibs=`$wxconfig --libs`
489 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
490 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
492 CFLAGS="$CFLAGS -I../include $wxcflags"
493 ctlib_graphics="$ctlib_graphics $wxlibs"
497 AM_CONDITIONAL(HAVE_WXWINDOWS, test "$wxwin"="true")
499 dnl Setting projet libraries and includes
500 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
501 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
504 if test "x$lamdir" != "x" ; then
505 lamprograms="ctsimtext-lam"
506 AC_SUBST(lamprograms)
513 AC_SUBST(my_includes)
514 AC_SUBST(wx_cppflags)
516 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])