r79: *** 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.cpp)
7 AM_INIT_AUTOMAKE(ctsim,0.6.0-b1)
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 AC_PROG_CXX
17
18
19 dnl AC_MSG_CHECKING([that the compiler works])
20 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.))
21
22 dnl Check for C operation
23 AC_CANONICAL_HOST 
24 AC_C_INLINE
25 AC_CHECK_SIZEOF(short, 2)
26 AC_CHECK_SIZEOF(int, 4)
27 AC_CHECK_SIZEOF(long, 4)
28 AC_CHECK_SIZEOF(float, 4)
29 AC_CHECK_SIZEOF(double, 8)
30
31 dnl ---------------------------------------------------------------------------
32 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
33 dnl from wxGTK (www.wxwindows.org) - LGPL license
34 dnl ---------------------------------------------------------------------------
35
36 AC_DEFUN(WX_C_BIGENDIAN,
37 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
38 [ac_cv_c_bigendian=unknown
39 # See if sys/param.h defines the BYTE_ORDER macro.
40 AC_TRY_COMPILE([#include <sys/types.h>
41 #include <sys/param.h>], [
42 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
43  bogus endian macros
44 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
45 AC_TRY_COMPILE([#include <sys/types.h>
46 #include <sys/param.h>], [
47 #if BYTE_ORDER != BIG_ENDIAN
48  not big endian
49 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
50 if test $ac_cv_c_bigendian = unknown; then
51 AC_TRY_RUN([main () {
52   /* Are we little or big endian?  From Harbison&Steele.  */
53   union
54   {
55     long l;
56     char c[sizeof (long)];
57   } u;
58   u.l = 1;
59   exit (u.c[sizeof (long) - 1] == 1);
60 }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes, ac_cv_c_bigendian=unknown)
61 fi])
62 if test $ac_cv_c_bigendian = unknown; then
63   AC_MSG_WARN([Assuming little-endian target machine - this may be overriden by adding the line "ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'}" 
64 to config.cache file])
65 fi
66 if test $ac_cv_c_bigendian = yes; then
67   AC_DEFINE(WORDS_BIGENDIAN)
68 fi
69 ])
70
71 WX_C_BIGENDIAN
72
73
74 dnl Checks for libraries.
75 AC_CHECK_LIB(z, main, [ zlib="true" ], [ zlib="false" ;  AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
76 AC_CHECK_LIB(m, main)
77 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
78 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
79 AC_CHECK_LIB(g2, main, [g2=true], [g2=false])
80 if test "$zlib" = "true" ; then
81   AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
82 fi
83 AC_CHECK_LIB(wx_gtk, main, [wxwin=true; wx_gtk=true], [wxwin=false])
84 AC_CHECK_LIB(wx_msw, main, [wxwin=true; wx_msw=true], [wxwin=false])
85
86 dnl Checks for header files.
87 AC_HEADER_STDC
88 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)
89
90 dnl Checks for typedefs, structures, and compiler characteristics.
91 AC_C_CONST
92 AC_TYPE_OFF_T
93 AC_TYPE_SIZE_T
94 AC_STRUCT_TM
95
96 dnl Checks for library functions.
97 AC_FUNC_VPRINTF
98 AC_CHECK_FUNCS(strtod strtol snprintf htonl)
99 AC_CHECK_FUNC(basename)
100 AC_CHECK_FUNC(setjmp)
101 if test "${OSTYPE}" = "cygwin" ; then
102   getopt_long=false
103 else
104   AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
105 fi
106 if test "${getopt_long}" = "false" ; then
107   my_includes="$myincludes -I../getopt"
108   AC_DEFINE(HAVE_GETOPT_LONG)
109   ctlibs_base="$ctlibs_base -lgetopt"
110   LDFLAGS="$LDFLAGS -L../getopt"
111   AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
112 fi
113
114
115 AC_ADD_GCC_CFLAGS([-Wall])
116 AC_MSG_CHECKING(whether to enable verbose warnings)
117 AC_ARG_ENABLE(verbose-warnings,
118 [  --enable-verbose-warnings
119                           Enable verbose compiler warnings.],
120 [ case "$enableval" in
121   yes)
122     AC_MSG_RESULT(yes)
123     AC_ADD_GCC_CFLAGS([-W])
124     AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast])
125     AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return])
126     AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes])
127     AC_ADD_GCC_CFLAGS([-pedantic])
128     AC_ADD_GCC_CFLAGS([-Wredundant-decls])
129
130     ;;
131   *)
132     AC_MSG_RESULT(no)
133     ;;
134   esac ], AC_MSG_RESULT(no)
135 )
136
137 dnl Check for debug mode
138 AC_ARG_ENABLE(debug,
139 [  --enable-debug          Turn on debugging],
140 [case "${enableval}" in
141   yes) debug=true 
142        CFLAGS="$CFLAGS -g"
143        ;;
144   no)  debug=false 
145        CFLAGS="$CFLAGS -O2"
146        ;;
147   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) 
148        ;;
149 esac],[debug=false])
150 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
151
152 dnl Set LAM path
153 AC_ARG_WITH(lam,
154 [  --with-lam[=PATH]       Set path of LAM MPI ],
155 [    if test "$withval" != "no" ; then
156          trylamdir=$withval
157      fi ]
158 )
159
160 if test "$withval" != "no" ; then
161   if test "$prefix" != "NONE" ; then
162      trylamdir="$trylamdir $prefix"
163   fi
164
165   AC_MSG_CHECKING([for LAM MPI installation])
166   for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do
167     if test -x "$testlamdir/bin/hcc" ; then
168       LDFLAGS="$LDFLAGS -L$testlamdir/lib"
169       CFLAGS="$CFLAGS -I$testlamdir/include"
170       lamdir="$testlamdir"
171       AC_SUBST(lamdir)
172       mpienable="true"
173       AC_SUBST(mpienable)
174       break
175     fi
176   done
177   AC_MSG_RESULT($lamdir)
178 else
179   AC_MSG_RESULT([no])
180 fi
181
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) ] )
186
187 AC_ARG_WITH(cgibin-url, [  --with-cgibin-url=PATH  Set URL path of CGI binaries ], 
188 [ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] )
189
190 AC_ARG_WITH(webdata-dir, [  --with-webdata-dir=PATH Set path of webdata], 
191 [ webdatadir=$withval ; AC_SUBST(webdatadir)  ] )
192
193 AC_ARG_WITH(webdata-url, [  --with-webdata-url=PATH Set URL path of webdata], 
194 [ webdataurl=$withval ; AC_SUBST(webdataurl) ] )
195
196 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH    Set directory of html files], 
197 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
198
199 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
200   cgiprograms="ctsim.cgi ctsim.conf"
201   AC_SUBST(cgiprograms)
202 fi
203
204 if test -n "$htmldir" ; then
205   htmldata=simulate.html
206   AC_SUBST(htmldata)
207 fi
208 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
209
210 if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then
211   webenabled=true
212   AC_SUBST(webenabled)
213   AC_MSG_RESULT([yes])
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])
224   fi
225 else
226   AC_MSG_RESULT([no])
227 fi
228
229 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
230
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.
241
242 AC_PATH_XTRA
243 AC_SUBST(X_CFLAGS)
244 dnl Following five are concatenated together into a linker specification.
245 AC_SUBST(X_LIBS)
246 AC_SUBST(X_TOOLKIT_LIBS)
247 AC_SUBST(X_PRE_LIBS)
248 AC_SUBST(X_BASIC_LIBS)
249 AC_SUBST(X_EXTRA_LIBS)
250
251 X_TOOLKIT_LIBS="-lXt"
252 X_BASIC_LIBS="-lXext -lX11"
253
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"
260
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"
273
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")
277
278 my_includes="$my_includes -I../include -I.."
279 AC_SUBST(my_includes)
280
281 AC_MSG_CHECKING([interactive graphics])
282 if test "$no_x" != "yes" ; then
283   AC_DEFINE(HAVE_X11)
284   AC_DEFINE(HAVE_SGP)
285   AM_CONDITIONAL(HAVE_SGP, test 1==1)
286   LDFLAGS="$LDFLAGS -L../libezplot -L../libgraph -L/usr/X11R6/lib"
287   ctlibs_base="$ctlibs_base -lezplot -lgraph $X_BASIC_LIBS $X_TOOLKIT_LIBS"
288   AC_MSG_RESULT(yes)
289 else
290   AC_MSG_RESULT(no)
291 fi
292
293 dnl Setting projet libraries and includes
294 LDFLAGS="$LDFLAGS -L../libkmath -L../libk -L../libcio -L../libir" 
295 ctlibs_base="$ctlibs_base -lkmath -lk -lcio"
296 if test "$png" = "true" ; then
297   ctlibs_base="$ctlibs_base -lpng"
298 fi
299 if test "$zlib" = "true" ; then
300   ctlibs_base="$ctlibs_base -lz"
301 fi
302 if test "$g2" = "true" ; then
303   ctlibs_base="$ctlibs_base -lg2"
304 fi
305
306 ctlibs="-lir $ctlibs_base"
307
308 AC_SUBST(ctlibs)
309
310 if test -n "$lamdir" ; then
311   ctlamlibs="-lir_lam $ctlibs_base"
312   lamprograms="ctrec-lam phm2sdf-lam phm2rs-lam"
313   AC_SUBST(lamprograms)
314   AC_SUBST(ctlamlibs)
315 fi
316
317 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)