r328: *** empty log message ***
[ctsim.git] / configure.in
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(src/ctsim.cpp)
7 AM_INIT_AUTOMAKE(ctsim,3.0.0alpha1)
8 AM_CONFIG_HEADER(config.h)
9
10 dnl Checks for programs.
11 AC_PROG_AWK
12 AC_PROG_INSTALL
13 AC_PROG_MAKE_SET
14 AC_PROG_RANLIB
15
16 CFLAGS="$CFLAGS -I/usr/local/include"
17 LDFLAGS="$LDFLAGS -L/usr/local/lib"
18 AC_PROG_CC
19 AC_PROG_CXX
20 AC_C_BIGENDIAN
21
22 AC_PATH_PROG(wxconfig,wx-config)
23
24 dnl AC_MSG_CHECKING([that the compiler works])
25 dnl AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],     AC_MSG_RESULT(yes),     AC_MSG_RESULT(no)     AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.),     AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.))
26
27 dnl Check for C operation
28 AC_CANONICAL_HOST 
29 AC_C_INLINE
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)
35
36 dnl Checks for libraries.
37 AC_CHECK_LIB(z, deflate, [ zlib="true" ], [ zlib="false" ;  AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
38 AC_CHECK_LIB(m, sin)
39 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
40 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
41 AC_CHECK_LIB(g2, main, [g2=true], [g2=false])
42 wxwin=false
43 AC_CHECK_LIB(wx_gtk, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS)])
44 AC_CHECK_LIB(wx, main, [wxwin=true; wx_msw=true; AC_DEFINE(HAVE_WXWINDOWS)])
45 AC_CHECK_LIB(hdf5, main, [hdf5=true], [hdf5=false], -lz)
46 AC_CHECK_LIB(fftw, fftw_one, [fftw=true; AC_DEFINE(HAVE_FFTW)], [fftw=false])
47
48 if test "$zlib" = "true" ; then
49   AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
50 fi
51
52 dnl Checks for header files.
53 AC_HEADER_STDC
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 g2.h assert.h sys/time.h sys/resource.h sys/time.h)
55
56 dnl Checks for typedefs, structures, and compiler characteristics.
57 AC_C_CONST
58 AC_TYPE_OFF_T
59 AC_TYPE_SIZE_T
60 AC_STRUCT_TM
61
62 dnl Checks for library functions.
63 AC_FUNC_VPRINTF
64 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
65 AC_CHECK_FUNC(basename)
66 AC_CHECK_FUNC(setjmp)
67 AC_CHECK_FUNC(setpriority)
68 AC_CHECK_FUNC(time)
69 AC_CHECK_FUNC(gettimeofday)
70
71 if test "${OSTYPE}" = "cygwin" ; then
72   getopt_long=false
73 else
74   AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
75 fi
76
77 if test "${getopt_long}" = "false" ; then
78   my_includes="$my_includes -I../getopt"
79   AC_DEFINE(HAVE_GETOPT_LONG)
80   ctlibs_base="$ctlibs_base -lgetopt"
81   LDFLAGS="$LDFLAGS -L../getopt"
82   AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
83 fi
84
85 dnl Check for debug mode
86 AC_MSG_CHECKING([debug])
87 AC_ARG_ENABLE(debug,
88 [  --enable-debug          Turn on debugging],
89 [case "${enableval}" in
90   yes) debug=true 
91        AC_MSG_RESULT(yes)
92        ;;
93   no)  debug=false 
94        AC_MSG_RESULT(no)
95        ;;
96   *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug]) 
97        ;;
98 esac],
99 [debug=false; AC_MSG_RESULT(no)])
100 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
101
102 if test "$debug" = "true" ; then
103 dnl  AC_ADD_GCC_CFLAGS([-g -DDEBUG])
104   CFLAGS="-g -DDEBUG"
105   AC_DEFINE(DEBUG)
106 else
107 dnl  AC_ADD_GCC_CFLAGS([-g -O2 -DNDEBUG])
108   CFLAGS="-g -O3 -DNDEBUG"
109   AC_DEFINE(NDEBUG)
110 fi
111
112 AC_MSG_CHECKING(sstream)
113  if [ test -f /usr/include/sstream || test -f /usr/include/g++/sstream ||
114      test -f /usr/include/g++-2/sstream || test -f /usr/include/g++-3/sstream ]; then
115   AC_DEFINE(HAVE_SSTREAM)
116   AC_MSG_RESULT(yes)
117 fi
118 AC_MSG_RESULT(no)
119
120
121 AC_ADD_GCC_CFLAGS([-Wall])
122 AC_MSG_CHECKING(whether to enable verbose warnings)
123 AC_ARG_ENABLE(verbose-warnings,
124 [  --enable-verbose-warnings
125                           Enable verbose compiler warnings.],
126 [ case "$enableval" in
127   yes)
128     AC_MSG_RESULT(yes)
129     AC_ADD_GCC_CFLAGS([-W])
130     AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
131     AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
132     AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
133     AC_ADD_GCC_CFLAGS([-pedantic])
134     AC_ADD_GCC_CFLAGS([-Wredundant-decls])
135
136     ;;
137   *)
138     AC_MSG_RESULT(no)
139     ;;
140   esac ], AC_MSG_RESULT(no)
141 )
142
143 AC_MSG_CHECKING(static executables)
144 AC_ARG_ENABLE(static,
145 [  --enable-static
146                           Enable static executables.],
147 [ case "$enableval" in
148   yes)
149     AC_MSG_RESULT(yes)
150     AC_ADD_GCC_CFLAGS([--static])
151     ;;
152   *)
153     AC_MSG_RESULT(no)
154     ;;
155   esac ], AC_MSG_RESULT(no)
156 )
157
158 dnl Set LAM path
159 AC_ARG_WITH(lam,
160 [  --with-lam[=PATH]       Set path of LAM MPI ],
161 [    if test "$withval" != "no" ; then
162          trylamdir=$withval
163      fi ]
164 )
165
166 if test "$withval" != "no" ; then
167   if test "$prefix" != "NONE" ; then
168      trylamdir="$trylamdir $prefix"
169   fi
170
171   AC_MSG_CHECKING([for LAM MPI installation])
172   for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
173     if test -x "$testlamdir/bin/hcp" ; then
174       if test "$testlamdir" != "/usr"; then     
175         LDFLAGS="$LDFLAGS -L$testlamdir/lib"
176         CFLAGS="$CFLAGS -I$testlamdir/include"
177       fi
178       CFLAGS="$CFLAGS -I$testlamdir/include/mpi2c++"
179       lamdir="$testlamdir"
180       AC_SUBST(lamdir)
181       mpienable="true"
182       AC_SUBST(mpienable)
183       break
184     fi
185   done
186   AC_MSG_RESULT($lamdir)
187 else
188   AC_MSG_RESULT([no])
189 fi
190
191 AC_MSG_CHECKING([for web access])
192 dnl Set cgi-bin directory
193 AC_ARG_WITH(cgibin-dir, [  --with-cgibin-dir=PATH  Set path of CGI binaries directory ], 
194 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
195
196 AC_ARG_WITH(cgibin-url, [  --with-cgibin-url=PATH  Set URL path of CGI binaries ], 
197 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
198
199 AC_ARG_WITH(webdata-dir, [  --with-webdata-dir=PATH Set path of webdata], 
200 [ webdatadir=$withval ; AC_SUBST(webdatadir)  ] )
201
202 AC_ARG_WITH(webdata-url, [  --with-webdata-url=PATH Set URL path of webdata], 
203 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
204
205 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH    Set directory of html files], 
206 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
207
208 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
209   cgiprograms="ctsim.cgi ctsim.conf"
210   AC_SUBST(cgiprograms)
211 fi
212
213 if test -n "$htmldir" ; then
214   htmldata=simulate.html
215   AC_SUBST(htmldata)
216 fi
217 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
218
219 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
220   webenabled=true
221   AC_SUBST(webenabled)
222   AC_MSG_RESULT([yes])
223   if test -z "$cgibindir" ; then
224     AC_MSG_ERROR([--with-cgibin-dir not set for web access])
225   elif test -z "$cgibinurl" ; then
226     AC_MSG_ERROR([--with-cgibin-url not set for web access])
227   elif test -z "$webdatadir" ; then
228     AC_MSG_ERROR([--with-webdata-dir not set for web access])
229   elif test -z "$webdataurl" ; then
230     AC_MSG_ERROR([--with-webdata-url not set for web access])
231   elif test -z "$htmldir" ; then
232     AC_MSG_ERROR([--with-html-dir not set for web access])
233   fi
234 else
235   AC_MSG_RESULT([no])
236 fi
237
238 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
239
240 dnl Prepare to support X.  If the user gave the command-line option
241 dnl --without-x, AC_PATH_XTRA will set no_x to "yes".  Otherwise, it will
242 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
243 dnl flags to X_LIBS.  It also checks for system-specific X libraries, and
244 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate.  (The former
245 dnl is where "-lSM -lICE" goes, in X11R6.)  We define the X_TOOLKIT_LIBS
246 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
247 dnl supported, we'll concatenate the whole lot of these into a command line
248 dnl for libtool.  See, e.g., the libplot_la_LIBADD line in
249 dnl libplot/Makefile.am.
250
251 AC_PATH_XTRA
252 AC_SUBST(X_CFLAGS)
253 dnl Following five are concatenated together into a linker specification.
254 AC_SUBST(X_LIBS)
255 AC_SUBST(X_TOOLKIT_LIBS)
256 AC_SUBST(X_PRE_LIBS)
257 AC_SUBST(X_BASIC_LIBS)
258 AC_SUBST(X_EXTRA_LIBS)
259
260 X_TOOLKIT_LIBS="-lXt"
261 X_BASIC_LIBS="-lXext -lX11"
262
263 dnl Check whether libXt has thread support.  Some platforms may have
264 dnl pthread support in libc, but no thread support in libXt/libX11.
265 our_saved_LDFLAGS="$LDFLAGS"
266 LDFLAGS="$X_LIBS $LDFLAGS"
267 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
268 LDFLAGS="$our_saved_LDFLAGS"
269
270 dnl Check in -lXext for double buffering extensions to X11, and check
271 dnl whether appropriate header files are present.  (Some systems have one
272 dnl but not the other.)
273 our_saved_LDFLAGS="$LDFLAGS"
274 LDFLAGS="$X_LIBS $LDFLAGS"
275 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
276 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
277 LDFLAGS="$our_saved_LDFLAGS"
278 our_saved_CPPFLAGS="$CPPFLAGS"
279 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
280 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
281 CPPFLAGS="$our_saved_CPPFLAGS"
282
283 dnl Our Makefile.am files test the automake variable NO_X to determine
284 dnl whether X should be supported.
285 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
286
287 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
288 AC_SUBST(my_includes)
289
290 LDFLAGS="$LDFLAGS -L/usr/local/lib"
291
292 AC_MSG_CHECKING([for X])
293 if test "$no_x" != "yes" ; then
294   AC_DEFINE(HAVE_SGP)
295   AM_CONDITIONAL(HAVE_SGP, test 1==1)
296   AC_DEFINE(HAVE_X11)
297   LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
298   ctlibs_graphics="$ctlibs_base -lctgraphics"
299   AC_MSG_RESULT(yes)
300   if test "$g2" = "true" ; then
301   ctlibs_graphics="$ctlibs_graphics -lg2"
302   AC_DEFINE(HAVE_G2)
303   fi    
304   ctlibs_graphics="$ctlibs_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
305 else
306   if test "$wxwin" = "true" ; then
307     AC_DEFINE(HAVE_SGP)
308     AM_CONDITIONAL(HAVE_SGP, test 1==1)
309   fi
310   AC_MSG_RESULT(no)
311 fi
312
313 if test "$png" = "true" ; then
314   ctlibs_tools="$ctlibs_tools -lpng"
315 fi
316 if test "$zlib" = "true" ; then
317   ctlibs_tools="$ctlibs_tools -lz"
318 fi
319 if test "$fftw" = "true" ; then
320   ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
321 fi
322
323 dnl Check for dmalloc
324 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
325 AC_MSG_CHECKING([for enable-dmalloc])
326 AC_ARG_ENABLE(dmalloc,
327 [  --enable-dmalloc        Use dmalloc memory allocation],
328 [case "${enableval}" in
329   yes) usedmalloc=true 
330        AC_MSG_RESULT(yes)
331        ;;
332   no)  usedmalloc=false 
333        AC_MSG_RESULT(no)
334        ;;
335   *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc]) 
336        ;;
337 esac],
338 [usedmalloc=false; AC_MSG_RESULT(no)])
339
340 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
341   ctlibs_tools="$ctlibs_tools -ldmallocxx"
342   AC_DEFINE(HAVE_DMALLOC)
343   AC_MSG_RESULT(Using dmalloc)
344 fi
345
346 if test "$wxwin" = "true" ; then
347   if test "$wx_gtk" = "true" ; then     
348     wxcflags=`$wxconfig --cflags`
349     wxlibs=`$wxconfig --libs`
350   else
351         wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
352    wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
353   fi
354   CFLAGS="$CFLAGS -I../include $wxcflags"
355   ctlibs_graphics="$ctlibs_graphics $wxlibs"
356   AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
357 fi
358 AC_SUBST(wxcflags)
359 AC_SUBST(wxlibs)
360
361 dnl Setting projet libraries and includes
362 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim" 
363 ctlibs="$ctlibs_base -lctsim $ctlibs_graphics -lctsupport $ctlibs_tools"
364 AC_SUBST(ctlibs)
365
366 if test -n "$lamdir" ; then
367   lamprograms="pjrec-lam phm2if-lam phm2pj-lam"
368   AC_SUBST(lamprograms)
369   lamdefs="$CFLAGS"
370   AC_SUBST(lamdefs)
371 fi
372
373 CXXFLAGS="$CFLAGS"
374
375 AC_OUTPUT(Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile doc/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)