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