r7061: initial property settings
[ctsim.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl Must reset CDPATH so that bash's cd does not print to stdout
4 dnl CDPATH=
5
6 AC_INIT
7 AC_CONFIG_SRCDIR([src/ctsim.cpp])
8 AM_MAINTAINER_MODE
9 AM_INIT_AUTOMAKE(ctsim,4.2.4)
10 AM_CONFIG_HEADER(config.h)
11
12 dnl Checks for programs.
13 AC_PROG_AWK
14 AC_PROG_INSTALL
15 AC_PROG_MAKE_SET
16 AC_PROG_RANLIB
17
18 AC_PROG_CC
19 AC_PROG_CXX
20 AC_C_BIGENDIAN
21
22 AC_PATH_PROG(wxconfig,wx-config)
23
24 dnl Check for C operation
25 AC_CANONICAL_HOST 
26 AC_C_INLINE
27 AC_CHECK_SIZEOF(short, 2)
28 AC_CHECK_SIZEOF(int, 4)
29 AC_CHECK_SIZEOF(long, 4)
30 AC_CHECK_SIZEOF(float, 4)
31 AC_CHECK_SIZEOF(double, 8)
32
33 dnl Add define templates
34
35 dnl Checks for libraries.
36 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ;  AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
37 AC_CHECK_LIB(m, sin)
38 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
39 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
40 AC_CHECK_LIB(readline, main, [readline=true; 
41                  AC_DEFINE([HAVE_READLINE],1,[Readline library])],
42                  [readline=false], [-lcurses])  
43 wxwin=false
44 AC_CHECK_LIB(wx_gtk-2.4, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
45 AC_CHECK_LIB(wx_mac-2.4, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
46 AC_CHECK_LIB(fftw, fftw_one, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false])
47 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -lXt -lXext])
48 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
49
50 if test "$zlib" = "true" ; then
51   AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG,1,[PNG library])], [png=false], [-lz -lm])
52 fi
53
54 dnl Checks for header files.
55 AC_HEADER_STDC
56 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)
57
58 dnl Checks for typedefs, structures, and compiler characteristics.
59 AC_C_CONST
60 AC_TYPE_OFF_T
61 AC_TYPE_SIZE_T
62 AC_STRUCT_TM
63
64 dnl Checks for library functions.
65 AC_FUNC_VPRINTF
66 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
67 AC_CHECK_FUNC(basename)
68 AC_CHECK_FUNC(setjmp)
69 AC_CHECK_FUNC(setpriority)
70 AC_CHECK_FUNC(time)
71 AC_CHECK_FUNC(gettimeofday)
72 AC_CHECK_FUNC(getopt, [ getopt=true ], [ getopt=false ])
73
74 if test "${OSTYPE}" = "cygwin" ; then
75   getopt_long=false
76 else
77   AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
78 fi
79
80 if test "${getopt_long}" = "false" ; then
81   my_includes="$my_includes -I../getopt"
82   AC_DEFINE(HAVE_GETOPT_LONG,1,[getopt_long library])
83   ctlibs_base="$ctlibs_base -lgetopt"
84   LDFLAGS="$LDFLAGS -L../getopt"
85   AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
86 fi
87
88 if test "${readline}" = "true" ; then
89   ctlibs_base="$ctlibs_base -lreadline"
90   if test "${ncurses}" = "true"; then
91     ctlibs_base="$ctlibs_base -lncurses"
92   elif test "${curses}" = "true"; then
93     ctlibs_base="$ctlibs_base -lcurses"
94   fi
95 fi
96
97 dnl Check for debug mode
98 AC_MSG_CHECKING([debug])
99 AC_ARG_ENABLE(debug,
100 [  --enable-debug          Turn on debugging],
101 [case "${enableval}" in
102   yes) debug=true 
103        AC_MSG_RESULT(yes)
104        ;;
105   no)  debug=false 
106        AC_MSG_RESULT(no)
107        ;;
108   *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug]) 
109        ;;
110 esac],
111 [debug=false; AC_MSG_RESULT(no)])
112 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
113
114 if test "$datadir" != "" ; then
115   CPPFLAGS="$CPPFLAGS -DDATADIR=\"\\\"$datadir\\\"\""
116 fi
117 dnl CFLAGS="$CFLAGS -I/usr/local/include"
118 dnl LDFLAGS="$LDFLAGS -L/usr/local/lib"
119
120 if test "$debug" = "true" ; then
121   CFLAGS="$CFLAGS -g -DDEBUG"
122   AC_DEFINE(DEBUG,1,[turn on debugging])
123 else
124   CFLAGS="$CFLAGS -O2 -DNDEBUG -fomit-frame-pointer"
125   AC_DEFINE(NDEBUG,1,[no debugging])
126 fi
127
128 if test "${pthread}" = "true" ; then
129 dnl  CFLAGS="$CFLAGS -D_REENTRANT"
130   AC_DEFINE(HAVE_WXTHREADS,1,[have wxthreads library])
131 fi
132
133 AC_MSG_CHECKING(sstream)
134  if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
135      test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ||
136      test -f /usr/include/gcc/darwin/3.1/g++-v3/sstream ]; then
137    AC_DEFINE(HAVE_SSTREAM,1,[sstream header])
138    AC_MSG_RESULT(yes)
139   else
140    AC_MSG_RESULT(no)
141  fi
142
143
144 CFLAGS="$CFLAGS -Wall"
145 AC_MSG_CHECKING(whether to enable verbose warnings)
146 AC_ARG_ENABLE(verbose-warnings,
147 [  --enable-verbose-warnings
148                           Enable verbose compiler warnings.],
149 [ case "$enableval" in
150   yes)
151     AC_MSG_RESULT(yes)
152     CFLAGS="$CFLAGS -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wredundant-decls"
153     ;;
154   *)
155     AC_MSG_RESULT(no)
156     ;;
157   esac ], AC_MSG_RESULT(no)
158 )
159
160 AC_MSG_CHECKING(static executables)
161 AC_ARG_ENABLE(static,
162 [  --enable-static
163                             Enable static executables.],
164 [ case "$enableval" in
165   yes)
166     AC_MSG_RESULT(yes)
167     CFLAGS="$CFLAGS --static"
168     ;;
169   *)
170     AC_MSG_RESULT(no)
171     ;;
172   esac ], AC_MSG_RESULT(no)
173 )
174
175 dnl Set LAM path
176 AC_ARG_WITH(lam,
177 [  --with-lam[=PATH]         Set path of LAM MPI ],
178 [    if test "$withval" != "no" ; then
179          trylamdir=$withval
180      fi ]
181 )
182
183 if test "$withval" != "no" ; then
184   if test "$prefix" != "NONE" ; then
185      trylamdir="$trylamdir $prefix"
186   fi
187
188   AC_MSG_CHECKING([for LAM MPI installation])
189   for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
190     if test -x "$testlamdir/bin/hcp" ; then
191       if test "$testlamdir" != "/usr"; then     
192         LDFLAGS="$LDFLAGS -L$testlamdir/lib"
193         CFLAGS="$CFLAGS -I$testlamdir/include"
194       fi
195       CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
196       lamdir="$testlamdir"
197       AC_SUBST(lamdir)
198       mpienable="true"
199       AC_SUBST(mpienable)
200       break
201     fi
202   done
203   AC_MSG_RESULT($lamdir)
204 else
205   AC_MSG_RESULT([no])
206 fi
207
208
209 dnl Set CTN path
210 AC_ARG_WITH(ctn,
211 [  --with-ctn[=PATH]         Set path of CTN DICOM library ],
212 [    if test "$withval" != "no" ; then
213          tryctndir=$withval
214      fi ]
215 )
216
217 if test "$withval" == "no" -o "$withval" == "NONE" ; then
218   AC_MSG_CHECKING([for CTN DICOM installation])
219   AC_MSG_RESULT([disabled])
220 else
221   AC_MSG_CHECKING([for CTN DICOM installation])
222   for testctndir in $tryctndir/lib /usr/local/lib /usr/local/ctn/lib /usr/lib /usr/ctn/lib /usr/lib/ctn /opt/ctn/lib ; do
223     if test -f "$testctndir/libctn.a" ; then
224       LDFLAGS="$LDFLAGS -L$testctndir"
225       ctnlib="true"
226       break
227     fi
228   done
229   for testctndir in $tryctndir/include /usr/local/include /usr/local/ctn/include /usr/include /usr/include/ctn /usr/ctn/include /opt/ctn/include ; do
230     if test -f "$testctndir/ctn_os.h" ; then
231       CFLAGS="$CFLAGS -I$testctndir"
232       ctninclude="true"
233       break
234     fi
235   done
236   if test "$ctnlib" == "true" -a "$ctninclude" == "true" ; then
237       ctn="true"
238       AC_DEFINE(HAVE_CTN_DICOM,1,[ctn dicom library])
239       AC_MSG_RESULT([yes])
240   else
241     AC_MSG_RESULT([no])
242   fi
243 fi
244
245 dnl Set CPU
246 AC_MSG_CHECKING([for CPU specification])
247 AC_ARG_WITH(mcpu,
248 [  --with-mcpu[=CPU]         Set name of CPU for gcc -mcpu])
249
250 if test "$withval" == "no" -o "$withval" == "yes" -o "$withval" == ""; then
251   AC_MSG_RESULT([no])
252 else
253   AC_MSG_RESULT([$withval])
254   CFLAGS="$CFLAGS -mcpu=$withval"
255 fi
256
257 AC_MSG_CHECKING([for web access])
258 dnl Set cgi-bin directory
259 AC_ARG_WITH(cgibin-dir, [  --with-cgibin-dir=PATH  Set path of CGI binaries directory ], 
260 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
261
262 AC_ARG_WITH(cgibin-url, [  --with-cgibin-url=PATH  Set URL path of CGI binaries ], 
263 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
264
265 AC_ARG_WITH(webdata-dir, [  --with-webdata-dir=PATH Set path of webdata], 
266 [ webdatadir=$withval ; AC_SUBST(webdatadir)  ] )
267
268 AC_ARG_WITH(webdata-url, [  --with-webdata-url=PATH Set URL path of webdata], 
269 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
270
271 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH    Set directory of html files], 
272 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
273
274 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
275   cgiprograms="ctsim.cgi ctsim.conf"
276   AC_SUBST(cgiprograms)
277 fi
278
279 if test -n "$htmldir" ; then
280   htmldata=simulate.html
281   AC_SUBST(htmldata)
282 fi
283 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
284
285 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
286   webenabled=true
287   AC_SUBST(webenabled)
288   AC_MSG_RESULT([yes])
289   if test -z "$cgibindir" ; then
290     AC_MSG_ERROR([--with-cgibin-dir not set for web access])
291   elif test -z "$cgibinurl" ; then
292     AC_MSG_ERROR([--with-cgibin-url not set for web access])
293   elif test -z "$webdatadir" ; then
294     AC_MSG_ERROR([--with-webdata-dir not set for web access])
295   elif test -z "$webdataurl" ; then
296     AC_MSG_ERROR([--with-webdata-url not set for web access])
297   elif test -z "$htmldir" ; then
298     AC_MSG_ERROR([--with-html-dir not set for web access])
299   fi
300 else
301   AC_MSG_RESULT([no])
302 fi
303
304 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
305
306 dnl Prepare to support X.  If the user gave the command-line option
307 dnl --without-x, AC_PATH_XTRA will set no_x to "yes".  Otherwise, it will
308 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
309 dnl flags to X_LIBS.  It also checks for system-specific X libraries, and
310 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate.  (The former
311 dnl is where "-lSM -lICE" goes, in X11R6.)  We define the X_TOOLKIT_LIBS
312 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
313 dnl supported, we'll concatenate the whole lot of these into a command line
314 dnl for libtool.  See, e.g., the libplot_la_LIBADD line in
315 dnl libplot/Makefile.am.
316
317 AC_PATH_XTRA
318 AC_SUBST(X_CFLAGS)
319 dnl Following five are concatenated together into a linker specification.
320 AC_SUBST(X_LIBS)
321 AC_SUBST(X_TOOLKIT_LIBS)
322 AC_SUBST(X_PRE_LIBS)
323 AC_SUBST(X_BASIC_LIBS)
324 AC_SUBST(X_EXTRA_LIBS)
325
326 X_TOOLKIT_LIBS="-lXt"
327 X_BASIC_LIBS="-lXext -lX11 -lXmu"
328
329 dnl Check whether libXt has thread support.  Some platforms may have
330 dnl pthread support in libc, but no thread support in libXt/libX11.
331 our_saved_LDFLAGS="$LDFLAGS"
332 LDFLAGS="$X_LIBS $LDFLAGS"
333 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT,1,[x thread supported]), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
334 LDFLAGS="$our_saved_LDFLAGS"
335
336 dnl Our Makefile.am files test the automake variable NO_X to determine
337 dnl whether X should be supported.
338 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
339
340 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
341 AC_SUBST(my_includes)
342
343 LDFLAGS="$LDFLAGS -L/usr/local/lib"
344
345 AC_MSG_CHECKING([for X])
346 if test "$no_x" != "yes" ; then
347   AC_DEFINE(HAVE_X11,1,[X11 system])
348   LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
349   my_includes="$my_includes -I/usr/X11R6/include"
350   ctlib_graphics="$ctlibs_base -lctgraphics"
351   AC_MSG_RESULT(yes)
352   ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
353   if test "$libgl" = "true" ; then
354     # Removed "-lglut" for Mac OS X compilation
355     ctlib_graphics="$ctlib_graphics -lGL -lGLU"
356     if test "$wxwin" = "true" ; then
357       if [ "$wx_gtk" ]; then 
358         ctlib_graphics="$ctlib_graphics -lwx_gtk_gl-2.4"
359       elif [ "$wx_mac" ]; then
360         ctlib_graphics="$ctlib_graphics -lwx_mac_gl-2.4"
361       fi
362     fi
363   fi
364   if test "$wxwin" = "true" ; then
365     AC_DEFINE(HAVE_SGP,1,[use sgp library])
366     AM_CONDITIONAL(HAVE_SGP, test 1==1)
367   fi
368 else
369   AC_MSG_RESULT(no)
370 fi
371
372 if test "$png" = "true" ; then
373   ctlibs_tools="$ctlibs_tools -lpng"
374 fi
375 if test "$zlib" = "true" ; then
376   ctlibs_tools="$ctlibs_tools -lz"
377 fi
378 if test "$fftw" = "true" ; then
379   ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
380 fi
381 if test "$ctn" = "true"; then
382   ctlibs_tools="$ctlibs_tools -lctn"
383 fi
384
385 dnl Check for dmalloc
386 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
387 AC_MSG_CHECKING([for enable-dmalloc])
388 AC_ARG_ENABLE(dmalloc,
389 [  --enable-dmalloc        Use dmalloc memory allocation],
390 [case "${enableval}" in
391   yes) usedmalloc=true 
392        AC_MSG_RESULT(yes)
393        ;;
394   no)  usedmalloc=false 
395        AC_MSG_RESULT(no)
396        ;;
397   *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc]) 
398        ;;
399 esac],
400 [usedmalloc=false; AC_MSG_RESULT(no)])
401
402 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
403   ctlibs_tools="$ctlibs_tools -ldmallocxx"
404   AC_DEFINE(HAVE_DMALLOC,1,[dmalloc library])
405   AC_MSG_RESULT(Using dmalloc)
406 fi
407
408 dnl Check for efence
409 AC_CHECK_LIB(efence, main, [efence=true], [efence=false])
410 AC_MSG_CHECKING([for enable-efence])
411 AC_ARG_ENABLE(efence,
412 [  --enable-efence        Use ElectricFence memory allocation],
413 [case "${enableval}" in
414   yes) useefence=true 
415        AC_MSG_RESULT(yes)
416        ;;
417   no)  useefence=false 
418        AC_MSG_RESULT(no)
419        ;;
420   *) AC_MSG_RESULT([bad value ${enableval} for --enable-efence]) 
421        ;;
422 esac],
423 [useefence=false; AC_MSG_RESULT(no)])
424
425 if test "$efence" = "true" -a "$useefence" = "true" ; then
426   ctlibs_tools="$ctlibs_tools -lefence"
427   AC_DEFINE(HAVE_EFENCE,1,[efence library])
428   AC_MSG_RESULT(Using efence)
429 fi
430
431 if test "$wxwin" = "true" ; then
432   if [ "$wx_gtk" = "true" ] || [ "$wx_mac" == "true" ] ; then   
433     wxcflags=`$wxconfig --cflags`
434     wxlibs=`$wxconfig --libs`
435   else
436         wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
437         wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
438   fi
439   CFLAGS="$CFLAGS -I../include $wxcflags"
440   ctlib_graphics="$ctlib_graphics $wxlibs"
441   AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
442 fi
443 AC_SUBST(wxcflags)
444 AC_SUBST(wxlibs)
445
446 dnl Setting projet libraries and includes
447 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim" 
448 ctlibs="$ctlibs_base -lctsim $ctlib_graphics -lctsupport $ctlibs_tools"
449 AC_SUBST(ctlibs)
450
451 if test -n "$lamdir" ; then
452   lamprograms="ctsimtext-lam"
453   AC_SUBST(lamprograms)
454   lamdefs="$CFLAGS"
455   AC_SUBST(lamdefs)
456 fi
457
458 CXXFLAGS="$CFLAGS"
459
460 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])
461
462 AC_OUTPUT