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