r3: Initial revision
[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/ctrec.c)
7 AM_INIT_AUTOMAKE(ctsim,0.5.0)
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 AC_PROG_CC
16
17 dnl Checks for libraries.
18 AC_CHECK_LIB(z, main, 
19 [
20   zlib="true"
21 ],
22
23   zlib="false"
24   AC_MSG_WARN([zlib missing. Will need zlib for PNG support])
25 ])
26 AC_CHECK_LIB(m, main)
27  
28 dnl Checks for header files.
29 AC_HEADER_STDC
30 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)
31
32 dnl Checks for typedefs, structures, and compiler characteristics.
33 AC_C_CONST
34 AC_TYPE_OFF_T
35 AC_TYPE_SIZE_T
36 AC_STRUCT_TM
37
38 dnl Checks for library functions.
39 AC_FUNC_VPRINTF
40 AC_CHECK_FUNCS(strtod strtol)
41 AC_CHECK_FUNC(basename)
42 AC_CHECK_FUNC(setjmp)
43 AC_CHECK_FUNC(getopt_long,
44 [
45   getopt_long=true
46 ],
47 [
48   getopt_long=false
49   my_includes="$myincludes -I../getopt"
50   AC_DEFINE(HAVE_GETOPT_LONG)
51   ctlibs_base="$ctlibs_base -lgetopt"
52   LDFLAGS="$LDFLAGS -L../getopt"
53   AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
54 ])
55
56
57 AC_ADD_GCC_CFLAGS([-Wall])
58 AC_MSG_CHECKING(whether to enable verbose warnings)
59 AC_ARG_ENABLE(verbose-warnings,
60 [  --enable-verbose-warnings
61                           Enable verbose compiler warnings.],
62 [ case "$enableval" in
63   yes)
64     AC_MSG_RESULT(yes)
65     AC_ADD_GCC_CFLAGS([-W])
66     AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
67     AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
68     AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
69     AC_ADD_GCC_CFLAGS([-pedantic])
70     AC_ADD_GCC_CFLAGS([-Wredundant-decls])
71
72     ;;
73   *)
74     AC_MSG_RESULT(no)
75     ;;
76   esac ], AC_MSG_RESULT(no)
77 )
78
79 dnl Check for debug mode
80 AC_ARG_ENABLE(debug,
81 [  --enable-debug          Turn on debugging],
82 [case "${enableval}" in
83   yes) debug=true ;;
84   no)  debug=false ;;
85   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
86 esac],[debug=false])
87 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
88
89 dnl Set PNG directory     
90 AC_MSG_CHECKING([for PNG library installation])
91 AC_ARG_WITH(png,
92 [  --with-png[=PATH]       Set path of lib PNG installation ],
93 [
94      if test "$withval" != "no" ; then
95          trypngdir=$withval
96          if test "$prefix" != "NONE" ; then
97          trypngdir="$trypngdir $prefix"
98        fi
99      fi
100 ]
101 )
102
103 if test "$withval" != "no" -a "$zlib" = "true" ; then
104   for testpngdir in "." $trypngdir /usr/local /usr /opt ; do
105     if test -f "$testpngdir/lib/libpng.a" ; then
106       if test ! -f "$testpngdir/include/png.h" ; then
107         AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
108       else
109           grep PNG_LIBPNG_VER_STRING "$testpngdir/include/png.h" | grep 9 > /dev/null 
110           if test "$?" = "0" ; then
111             AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
112           fi
113       fi
114       LDFLAGS="$LDFLAGS -L$testpngdir/lib"
115       CFLAGS="$CFLAGS -I$testpngdir/include"
116       pngdir="$testpngdir"
117       AC_DEFINE(HAVE_PNG)
118       break
119     elif test -f "$testpngdir/libpng.a" ; then
120       if test ! -f "$testpngdir/png.h" ; then
121         AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
122       else
123           grep PNG_LIBPNG_VER_STRING "$testpngdir/png.h" | grep 9 > /dev/null 
124           if test "$?" = "0" ; then
125             AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
126           fi
127       fi
128       LDFLAGS="$LDFLAGS -L$testpngdir"
129       CFLAGS="$CFLAGS -I$testpngdir"
130       pngdir="$testpngdir"
131       AC_DEFINE(HAVE_PNG)
132       break
133     fi
134   done
135   AC_MSG_RESULT($pngdir)
136   AM_CONDITIONAL(HAVE_PNG, test -n "$pngdir")
137 else
138   AC_MSG_RESULT([no])
139 fi
140
141 dnl Set LAM path
142 AC_ARG_WITH(lam,
143 [  --with-lam[=PATH]       Set path of LAM MPI ],
144 [    if test "$withval" != "no" ; then
145          trylamdir=$withval
146      fi ]
147 )
148
149 if test "$withval" != "no" ; then
150   if test "$prefix" != "NONE" ; then
151      trylamdir="$trylamdir $prefix"
152   fi
153
154   AC_MSG_CHECKING([for LAM MPI installation])
155   for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
156     if test -x "$testlamdir/bin/hcc" ; then
157       LDFLAGS="$LDFLAGS -L$testlamdir/lib"
158       CFLAGS="$CFLAGS -I$testlamdir/include"
159       lamdir="$testlamdir"
160       AC_SUBST(lamdir)
161       break
162     fi
163   done
164   AC_MSG_RESULT($lamdir)
165 fi
166
167 AC_MSG_CHECKING([for web access])
168 dnl Set cgi-bin directory
169 AC_ARG_WITH(cgibin-dir, [  --with-cgibin-dir=PATH  Set path of CGI binaries directory ], 
170 [ cgibindir=$withval ; AC_SUBST(cgibindir) ] )
171
172 AC_ARG_WITH(cgibin-url, [  --with-cgibin-url=PATH  Set URL path of CGI binaries ], 
173 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
174
175 AC_ARG_WITH(webdata-dir, [  --with-webdata-dir=PATH Set path of webdata], 
176 [ webdatadir=$withval ; AC_SUBST(webdatadir)  ] )
177
178 AC_ARG_WITH(webdata-url, [  --with-webdata-url=PATH Set URL path of webdata], 
179 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
180
181 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH    Set directory of html files], 
182 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
183
184 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
185   cgiprograms=ctsim.cgi
186   AC_SUBST(cgiprograms)
187 fi
188
189 if test -n "$htmldir" ; then
190   htmldata=ctsim.html
191   AC_SUBST(htmldata)
192 fi
193 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
194
195 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
196   webenabled=true
197   AC_SUBST(webenabled)
198   AC_MSG_RESULT([yes])
199   if test -z "$cgibindir" ; then
200     AC_MSG_ERROR([--with-cgibin-dir not set for web access])
201   elif test -z "$cgibinurl" ; then
202     AC_MSG_ERROR([--with-cgibin-url not set for web access])
203   elif test -z "$webdatadir" ; then
204     AC_MSG_ERROR([--with-webdata-dir not set for web access])
205   elif test -z "$webdataurl" ; then
206     AC_MSG_ERROR([--with-webdata-url not set for web access])
207   elif test -z "$htmldir" ; then
208     AC_MSG_ERROR([--with-html-dir not set for web access])
209   fi
210 else
211   AC_MSG_RESULT([no])
212 fi
213
214 dnl Setting projet libraries and includes
215 LDFLAGS="$LDFLAGS -L../libezplot -L../libgraph -L../libkmath -L../libk -L../libcio -L../libir" 
216 ctlibs_base="$ctlibs_base -lezplot -lgraph -lkmath -lk -lcio"
217 if test -n "$pngdir" ; then
218   ctlibs_base="$ctlibs_base -lpng"
219 fi
220 if test "$zlib" = "true" ; then
221   ctlibs_base="$ctlibs_base -lz"
222 fi
223 ctlibs="-lir $ctlibs_base"
224
225 AC_SUBST(ctlibs)
226
227 if test -n "$lamdir" ; then
228   ctlamlibs="-lir_lam $ctlibs_base"
229   lamprograms="ctrec-lam phm2sdf-lam phm2rs-lam"
230   AC_SUBST(lamprograms)
231   AC_SUBST(ctlamlibs)
232 fi
233
234 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
235
236 dnl Prepare to support X.  If the user gave the command-line option
237 dnl --without-x, AC_PATH_XTRA will set no_x to "yes".  Otherwise, it will
238 dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker
239 dnl flags to X_LIBS.  It also checks for system-specific X libraries, and
240 dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate.  (The former
241 dnl is where "-lSM -lICE" goes, in X11R6.)  We define the X_TOOLKIT_LIBS
242 dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be
243 dnl supported, we'll concatenate the whole lot of these into a command line
244 dnl for libtool.  See, e.g., the libplot_la_LIBADD line in
245 dnl libplot/Makefile.am.
246
247 AC_PATH_XTRA
248 AC_SUBST(X_CFLAGS)
249 dnl Following five are concatenated together into a linker specification.
250 AC_SUBST(X_LIBS)
251 AC_SUBST(X_TOOLKIT_LIBS)
252 AC_SUBST(X_PRE_LIBS)
253 AC_SUBST(X_BASIC_LIBS)
254 AC_SUBST(X_EXTRA_LIBS)
255
256 X_TOOLKIT_LIBS="-lXt"
257 X_BASIC_LIBS="-lXext -lX11"
258
259 dnl Check whether libXt has thread support.  Some platforms may have
260 dnl pthread support in libc, but no thread support in libXt/libX11.
261 our_saved_LDFLAGS="$LDFLAGS"
262 LDFLAGS="$X_LIBS $LDFLAGS"
263 AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS)
264 LDFLAGS="$our_saved_LDFLAGS"
265
266 dnl Check in -lXext for double buffering extensions to X11, and check
267 dnl whether appropriate header files are present.  (Some systems have one
268 dnl but not the other.)
269 our_saved_LDFLAGS="$LDFLAGS"
270 LDFLAGS="$X_LIBS $LDFLAGS"
271 AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
272 AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS")
273 LDFLAGS="$our_saved_LDFLAGS"
274 our_saved_CPPFLAGS="$CPPFLAGS"
275 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
276 AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h)
277 CPPFLAGS="$our_saved_CPPFLAGS"
278
279 dnl Our Makefile.am files test the automake variable NO_X to determine
280 dnl whether X should be supported.
281 AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
282
283 my_includes="$my_includes -I../include -I.."
284 AC_SUBST(my_includes)
285
286 AM_CONDITIONAL(HAVE_INTERACTIVE_GRAPHICS, test 1==0)
287
288 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/ctsim.html html/Makefile include/Makefile getopt/Makefile src/sample-ctrec.sh)