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