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,0.5.2-b5)
8 AM_CONFIG_HEADER(config.h)
10 dnl Checks for programs.
18 dnl Checks for libraries.
25 AC_MSG_WARN([zlib missing. Will need zlib for PNG support])
28 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
29 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
31 dnl Checks for header files.
33 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)
35 dnl Checks for typedefs, structures, and compiler characteristics.
41 dnl Checks for library functions.
43 AC_CHECK_FUNCS(strtod strtol)
44 AC_CHECK_FUNC(basename)
46 AC_CHECK_FUNC(getopt_long,
52 my_includes="$myincludes -I../getopt"
53 AC_DEFINE(HAVE_GETOPT_LONG)
54 ctlibs_base="$ctlibs_base -lgetopt"
55 LDFLAGS="$LDFLAGS -L../getopt"
56 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
60 AC_ADD_GCC_CFLAGS([-Wall])
61 AC_MSG_CHECKING(whether to enable verbose warnings)
62 AC_ARG_ENABLE(verbose-warnings,
63 [ --enable-verbose-warnings
64 Enable verbose compiler warnings.],
65 [ case "$enableval" in
68 AC_ADD_GCC_CFLAGS([-W])
69 AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
70 AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
71 AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
72 AC_ADD_GCC_CFLAGS([-pedantic])
73 AC_ADD_GCC_CFLAGS([-Wredundant-decls])
79 esac ], AC_MSG_RESULT(no)
82 dnl Check for debug mode
84 [ --enable-debug Turn on debugging],
85 [case "${enableval}" in
88 *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
90 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
93 AC_MSG_CHECKING([for PNG library installation])
95 [ --with-png[=PATH] Set path of lib PNG installation ],
97 if test "$withval" != "no" ; then
99 if test "$prefix" != "NONE" ; then
100 trypngdir="$trypngdir $prefix"
106 if test "$withval" != "no" -a "$zlib" = "true" ; then
107 for testpngdir in "." $trypngdir /usr/local /usr /opt ; do
108 if test -f "$testpngdir/lib/libpng.a" ; then
109 if test ! -f "$testpngdir/include/png.h" ; then
110 AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
112 grep PNG_LIBPNG_VER_STRING "$testpngdir/include/png.h" | grep 9 > /dev/null
113 if test "$?" = "0" ; then
114 AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
117 LDFLAGS="$LDFLAGS -L$testpngdir/lib"
118 CFLAGS="$CFLAGS -I$testpngdir/include"
122 elif test -f "$testpngdir/libpng.a" ; then
123 if test ! -f "$testpngdir/png.h" ; then
124 AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
126 grep PNG_LIBPNG_VER_STRING "$testpngdir/png.h" | grep 9 > /dev/null
127 if test "$?" = "0" ; then
128 AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
131 LDFLAGS="$LDFLAGS -L$testpngdir"
132 CFLAGS="$CFLAGS -I$testpngdir"
138 AC_MSG_RESULT($pngdir)
139 AM_CONDITIONAL(HAVE_PNG, test -n "$pngdir")
146 [ --with-lam[=PATH] Set path of LAM MPI ],
147 [ if test "$withval" != "no" ; then
152 if test "$withval" != "no" ; then
153 if test "$prefix" != "NONE" ; then
154 trylamdir="$trylamdir $prefix"
157 AC_MSG_CHECKING([for LAM MPI installation])
158 for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
159 if test -x "$testlamdir/bin/hcc" ; then
160 LDFLAGS="$LDFLAGS -L$testlamdir/lib"
161 CFLAGS="$CFLAGS -I$testlamdir/include"
169 AC_MSG_RESULT($lamdir)
172 AC_MSG_CHECKING([for web access])
173 dnl Set cgi-bin directory
174 AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ],
175 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
177 AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ],
178 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
180 AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata],
181 [ webdatadir=$withval ; AC_SUBST(webdatadir) ] )
183 AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata],
184 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
186 AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files],
187 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
189 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
190 cgiprograms="ctsim.cgi ctsim.conf"
191 AC_SUBST(cgiprograms)
194 if test -n "$htmldir" ; then
195 htmldata=simulate.html
198 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
200 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
204 if test -z "$cgibindir" ; then
205 AC_MSG_ERROR([--with-cgibin-dir not set for web access])
206 elif test -z "$cgibinurl" ; then
207 AC_MSG_ERROR([--with-cgibin-url not set for web access])
208 elif test -z "$webdatadir" ; then
209 AC_MSG_ERROR([--with-webdata-dir not set for web access])
210 elif test -z "$webdataurl" ; then
211 AC_MSG_ERROR([--with-webdata-url not set for web access])
212 elif test -z "$htmldir" ; then
213 AC_MSG_ERROR([--with-html-dir not set for web access])
219 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
221 dnl Prepare to support X. If the user gave the command-line option
222 dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will
223 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
224 dnl flags to X_LIBS. It also checks for system-specific X libraries, and
225 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former
226 dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS
227 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
228 dnl supported, we'll concatenate the whole lot of these into a command line
229 dnl for libtool. See, e.g., the libplot_la_LIBADD line in
230 dnl libplot/Makefile.am.
234 dnl Following five are concatenated together into a linker specification.
236 AC_SUBST(X_TOOLKIT_LIBS)
238 AC_SUBST(X_BASIC_LIBS)
239 AC_SUBST(X_EXTRA_LIBS)
241 X_TOOLKIT_LIBS="-lXt"
242 X_BASIC_LIBS="-lXext -lX11"
244 dnl Check whether libXt has thread support. Some platforms may have
245 dnl pthread support in libc, but no thread support in libXt/libX11.
246 our_saved_LDFLAGS="$LDFLAGS"
247 LDFLAGS="$X_LIBS $LDFLAGS"
248 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
249 LDFLAGS="$our_saved_LDFLAGS"
251 dnl Check in -lXext for double buffering extensions to X11, and check
252 dnl whether appropriate header files are present. (Some systems have one
253 dnl but not the other.)
254 our_saved_LDFLAGS="$LDFLAGS"
255 LDFLAGS="$X_LIBS $LDFLAGS"
256 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
257 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
258 LDFLAGS="$our_saved_LDFLAGS"
259 our_saved_CPPFLAGS="$CPPFLAGS"
260 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
261 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
262 CPPFLAGS="$our_saved_CPPFLAGS"
264 dnl Our Makefile.am files test the automake variable NO_X to determine
265 dnl whether X should be supported.
266 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
268 my_includes="$my_includes -I../include -I.."
269 AC_SUBST(my_includes)
271 if test "x$no_x" != "xyes" ; then
272 AC_DEFINE(HAVE_INTERACTIVE_GRAPHICS)
273 AM_CONDITIONAL(HAVE_INTERACTIVE_GRAPHICS, test 1==1)
274 LDFLAGS="$LDFLAGS -L../libezplot -L../libgraph"
275 ctlibs_base="$ctlibs_base -lezplot -lgraph"
278 dnl Setting projet libraries and includes
279 LDFLAGS="$LDFLAGS -L../libkmath -L../libk -L../libcio -L../libir"
280 ctlibs_base="$ctlibs_base -lkmath -lk -lcio"
281 if test -n "$pngdir" ; then
282 ctlibs_base="$ctlibs_base -lpng"
284 if test "$zlib" = "true" ; then
285 ctlibs_base="$ctlibs_base -lz"
287 ctlibs="-lir $ctlibs_base"
291 if test -n "$lamdir" ; then
292 ctlamlibs="-lir_lam $ctlibs_base"
293 lamprograms="ctrec-lam phm2sdf-lam phm2rs-lam"
294 AC_SUBST(lamprograms)
298 AC_OUTPUT(Makefile libezplot/Makefile src/Makefile libgraph/Makefile libkmath/Makefile Makefile libk/Makefile libir/Makefile libcio/Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile src/sample-ctrec.sh cgi-bin/ctsim.conf)