1 dnl Process this file with autoconf to produce a configure script.
3 dnl Must reset CDPATH so that bash's cd does not print to stdout
7 AM_INIT_AUTOMAKE(ctsim,2.0.5)
8 AM_CONFIG_HEADER(config.h)
10 dnl Checks for programs.
16 CFLAGS="$CFLAGS -I/usr/local/include"
17 LDFLAGS="$LDFLAGS -L/usr/local/lib"
22 AC_PATH_PROG(wxconfig,wx-config)
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.))
27 dnl Check for C operation
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)
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])])
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])
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])
48 if test "$zlib" = "true" ; then
49 AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
52 dnl Checks for header files.
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 sstream)
56 dnl Checks for typedefs, structures, and compiler characteristics.
62 dnl Checks for library functions.
64 AC_CHECK_FUNCS(strtod strtol snprintf htonl usleep vsprintf vsnprintf)
65 AC_CHECK_FUNC(basename)
67 AC_CHECK_FUNC(setpriority)
69 AC_CHECK_FUNC(gettimeofday)
71 if test "${OSTYPE}" = "cygwin" ; then
74 AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
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)
85 dnl Check for debug mode
86 AC_MSG_CHECKING([debug])
88 [ --enable-debug Turn on debugging],
89 [case "${enableval}" in
96 *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug])
99 [debug=false; AC_MSG_RESULT(no)])
100 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
102 if test "$debug" = "true" ; then
103 dnl AC_ADD_GCC_CFLAGS([-g -DDEBUG])
107 dnl AC_ADD_GCC_CFLAGS([-g -O2 -DNDEBUG])
108 CFLAGS="-g -O3 -DNDEBUG"
113 AC_ADD_GCC_CFLAGS([-Wall])
114 AC_MSG_CHECKING(whether to enable verbose warnings)
115 AC_ARG_ENABLE(verbose-warnings,
116 [ --enable-verbose-warnings
117 Enable verbose compiler warnings.],
118 [ case "$enableval" in
121 AC_ADD_GCC_CFLAGS([-W])
122 AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
123 AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
124 AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
125 AC_ADD_GCC_CFLAGS([-pedantic])
126 AC_ADD_GCC_CFLAGS([-Wredundant-decls])
132 esac ], AC_MSG_RESULT(no)
135 AC_MSG_CHECKING(static executables)
136 AC_ARG_ENABLE(static,
138 Enable static executables.],
139 [ case "$enableval" in
142 AC_ADD_GCC_CFLAGS([--static])
147 esac ], AC_MSG_RESULT(no)
152 [ --with-lam[=PATH] Set path of LAM MPI ],
153 [ if test "$withval" != "no" ; then
158 if test "$withval" != "no" ; then
159 if test "$prefix" != "NONE" ; then
160 trylamdir="$trylamdir $prefix"
163 AC_MSG_CHECKING([for LAM MPI installation])
164 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
165 if test -x "$testlamdir/bin/hcc" ; then
166 if test "$testlamdir" != "/usr"; then
167 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
168 CFLAGS="$CFLAGS -I$testlamdir/include"
177 AC_MSG_RESULT($lamdir)
182 AC_MSG_CHECKING([for web access])
183 dnl Set cgi-bin directory
184 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
185 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
187 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
188 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
190 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
191 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
193 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
194 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
196 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
197 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
199 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
200 cgiprograms="ctsim.cgi ctsim.conf"
201 AC_SUBST(cgiprograms)
204 if test -n "$htmldir" ; then
205 htmldata=simulate.html
208 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
210 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
214 if test -z "$cgibindir" ; then
215 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
216 elif test -z "$cgibinurl" ; then
217 AC_MSG_ERROR([--with-cgibin-url not set for web access])
218 elif test -z "$webdatadir" ; then
219 AC_MSG_ERROR([--with-webdata-dir not set for web access])
220 elif test -z "$webdataurl" ; then
221 AC_MSG_ERROR([--with-webdata-url not set for web access])
222 elif test -z "$htmldir" ; then
223 AC_MSG_ERROR([--with-html-dir not set for web access])
229 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
231 dnl Prepare to support X. If the user gave the command-line option
232 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
233 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
234 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
235 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
236 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
237 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
238 dnl supported, we'll concatenate the whole lot of these into a command line
239 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
240 dnl libplot/Makefile.am.
244 dnl Following five are concatenated together into a linker specification.
246 AC_SUBST(X_TOOLKIT_LIBS)
248 AC_SUBST(X_BASIC_LIBS)
249 AC_SUBST(X_EXTRA_LIBS)
251 X_TOOLKIT_LIBS="-lXt"
252 X_BASIC_LIBS="-lXext -lX11"
254 dnl Check whether libXt has thread support. Some platforms may have
255 dnl pthread support in libc, but no thread support in libXt/libX11.
256 our_saved_LDFLAGS="$LDFLAGS"
257 LDFLAGS="$X_LIBS $LDFLAGS"
258 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
259 LDFLAGS="$our_saved_LDFLAGS"
261 dnl Check in -lXext for double buffering extensions to X11, and check
262 dnl whether appropriate header files are present. (Some systems have one
263 dnl but not the other.)
264 our_saved_LDFLAGS="$LDFLAGS"
265 LDFLAGS="$X_LIBS $LDFLAGS"
266 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
267 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
268 LDFLAGS="$our_saved_LDFLAGS"
269 our_saved_CPPFLAGS="$CPPFLAGS"
270 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
271 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
272 CPPFLAGS="$our_saved_CPPFLAGS"
274 dnl Our Makefile.am files test the automake variable NO_X to determine
275 dnl whether X should be supported.
276 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
278 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
279 AC_SUBST(my_includes)
281 LDFLAGS="$LDFLAGS -L/usr/local/lib"
283 AC_MSG_CHECKING([for X])
284 if test "$no_x" != "yes" ; then
286 AM_CONDITIONAL(HAVE_SGP, test 1==1)
288 LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
289 ctlibs_graphics="$ctlibs_base -lctgraphics"
291 if test "$g2" = "true" ; then
292 ctlibs_graphics="$ctlibs_graphics -lg2"
295 ctlibs_graphics="$ctlibs_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
297 if test "$wxwin" = "true" ; then
299 AM_CONDITIONAL(HAVE_SGP, test 1==1)
304 if test "$png" = "true" ; then
305 ctlibs_tools="$ctlibs_tools -lpng"
307 if test "$zlib" = "true" ; then
308 ctlibs_tools="$ctlibs_tools -lz"
310 if test "$fftw" = "true" ; then
311 ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
314 dnl Check for dmalloc
315 AC_CHECK_LIB(dmallocxx, main, [dmallocxx=true], [dmallocxx=false])
316 AC_MSG_CHECKING([for enable-dmalloc])
317 AC_ARG_ENABLE(dmalloc,
318 [ --enable-dmalloc Use dmalloc memory allocation],
319 [case "${enableval}" in
326 *) AC_MSG_RESULT([bad value ${enableval} for --enable-dmalloc])
329 [usedmalloc=false; AC_MSG_RESULT(no)])
331 if test "$dmallocxx" = "true" -a "$usedmalloc" = "true" ; then
332 ctlibs_tools="$ctlibs_tools -ldmallocxx"
333 AC_DEFINE(HAVE_DMALLOC)
334 AC_MSG_RESULT(Using dmalloc)
337 if test "$wxwin" = "true" ; then
338 if test "$wx_gtk" = "true" ; then
339 wxcflags=`$wxconfig --cflags`
340 wxlibs=`$wxconfig --libs`
342 wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
343 wxlibs="-lwx -lglui -ljpeg -lxpm -lzlib -ltiff"
345 CFLAGS="$CFLAGS -I../include $wxcflags"
346 ctlibs_graphics="$ctlibs_graphics $wxlibs"
347 AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
352 dnl Setting projet libraries and includes
353 LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim"
354 ctlibs="$ctlibs_base -lctsim $ctlibs_graphics -lctsupport $ctlibs_tools"
357 if test -n "$lamdir" ; then
358 lamprograms="pjrec-lam phm2if-lam phm2pj-lam"
359 AC_SUBST(lamprograms)
366 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)