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