r145: *** empty log message ***
[ctsim.git] / configure.in
index b70c3f982a339ad0f64debf651b6da2d54ec0a31..7c27a3e1dc58d18e6516834f9e49de4f62ae72fc 100644 (file)
@@ -3,8 +3,8 @@ dnl Process this file with autoconf to produce a configure script.
 dnl Must reset CDPATH so that bash's cd does not print to stdout
 dnl CDPATH=
 
-AC_INIT(src/ctrec.c)
-AM_INIT_AUTOMAKE(ctsim,0.5.1)
+AC_INIT(src/ctsim.cpp)
+AM_INIT_AUTOMAKE(ctsim,2.0.0-b4)
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
@@ -13,23 +13,83 @@ AC_PROG_INSTALL
 AC_PROG_MAKE_SET
 AC_PROG_RANLIB
 AC_PROG_CC
+AC_PROG_CXX
+AC_PATH_PROG(wxconfig,wx-config)
+
+dnl AC_MSG_CHECKING([that the compiler works])
+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.))
+
+dnl Check for C operation
+AC_CANONICAL_HOST 
+AC_C_INLINE
+AC_CHECK_SIZEOF(short, 2)
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(long, 4)
+AC_CHECK_SIZEOF(float, 4)
+AC_CHECK_SIZEOF(double, 8)
+
+dnl ---------------------------------------------------------------------------
+dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
+dnl from wxGTK (www.wxwindows.org) - LGPL license
+dnl ---------------------------------------------------------------------------
+
+AC_DEFUN(WX_C_BIGENDIAN,
+[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
+[ac_cv_c_bigendian=unknown
+# See if sys/param.h defines the BYTE_ORDER macro.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
+if test $ac_cv_c_bigendian = unknown; then
+AC_TRY_RUN([main () {
+  /* Are we little or big endian?  From Harbison&Steele.  */
+  union
+  {
+    long l;
+    char c[sizeof (long)];
+  } u;
+  u.l = 1;
+  exit (u.c[sizeof (long) - 1] == 1);
+}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes, ac_cv_c_bigendian=unknown)
+fi])
+if test $ac_cv_c_bigendian = unknown; then
+  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'}" 
+to config.cache file])
+fi
+if test $ac_cv_c_bigendian = yes; then
+  AC_DEFINE(WORDS_BIGENDIAN)
+fi
+])
+
+WX_C_BIGENDIAN
+
 
 dnl Checks for libraries.
-AC_CHECK_LIB(z, main, 
-[
-  zlib="true"
-],
-[ 
-  zlib="false"
-  AC_MSG_WARN([zlib missing. Will need zlib for PNG support])
-])
+AC_CHECK_LIB(z, main, [ zlib="true" ], [ zlib="false" ;  AC_MSG_WARN([zlib missing. Will need zlib for PNG support])])
 AC_CHECK_LIB(m, main)
 AC_CHECK_LIB(curses, main, [curses=true], [curses=false])
 AC_CHECK_LIB(ncurses, main, [ncurses=true], [ncurses=false])
+AC_CHECK_LIB(g2, main, [g2=true], [g2=false])
+wxwin=false
+AC_CHECK_LIB(wx_gtk, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS)])
+AC_CHECK_LIB(wx_msw, main, [wxwin=true; wx_msw=true; AC_DEFINE(HAVE_WXWINDOWS)])
+AC_CHECK_LIB(dmallocxx, main, [dmalloc=true], [dmalloc=false])
+AC_CHECK_LIB(fftw, main, [fftw=true; AC_DEFINE(HAVE_FFTW)], [fftw=false])
+
+if test "$zlib" = "true" ; then
+  AC_CHECK_LIB(png, main, [png=true ; AC_DEFINE(HAVE_PNG)], [png=false])
+fi
+
 dnl Checks for header files.
 AC_HEADER_STDC
-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)
+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)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -39,22 +99,21 @@ AC_STRUCT_TM
 
 dnl Checks for library functions.
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(strtod strtol)
+AC_CHECK_FUNCS(strtod strtol snprintf htonl)
 AC_CHECK_FUNC(basename)
 AC_CHECK_FUNC(setjmp)
-AC_CHECK_FUNC(getopt_long,
-[
-  getopt_long=true
-],
-[
+if test "${OSTYPE}" = "cygwin" ; then
   getopt_long=false
+else
+  AC_CHECK_FUNC(getopt_long, [ getopt_long=true ], [ getopt_long=false ])
+fi
+if test "${getopt_long}" = "false" ; then
   my_includes="$myincludes -I../getopt"
   AC_DEFINE(HAVE_GETOPT_LONG)
   ctlibs_base="$ctlibs_base -lgetopt"
   LDFLAGS="$LDFLAGS -L../getopt"
   AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1)
-])
-
+fi
 
 AC_ADD_GCC_CFLAGS([-Wall])
 AC_MSG_CHECKING(whether to enable verbose warnings)
@@ -79,65 +138,28 @@ AC_ARG_ENABLE(verbose-warnings,
 )
 
 dnl Check for debug mode
+AC_MSG_CHECKING([debug])
 AC_ARG_ENABLE(debug,
 [  --enable-debug          Turn on debugging],
 [case "${enableval}" in
-  yes) debug=true ;;
-  no)  debug=false ;;
-  *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
-esac],[debug=false])
+  yes) debug=true 
+       AC_MSG_RESULT(yes)
+       ;;
+  no)  debug=false 
+       AC_MSG_RESULT(no)
+       ;;
+  *) AC_MSG_RESULT([bad value ${enableval} for --enable-debug]) 
+       ;;
+esac],
+[debug=false; AC_MSG_RESULT(no)])
 AM_CONDITIONAL(DEBUG, test "$debug" = "true")
 
-dnl Set PNG directory     
-AC_MSG_CHECKING([for PNG library installation])
-AC_ARG_WITH(png,
-[  --with-png[=PATH]       Set path of lib PNG installation ],
-[
-     if test "$withval" != "no" ; then
-         trypngdir=$withval
-         if test "$prefix" != "NONE" ; then
-         trypngdir="$trypngdir $prefix"
-       fi
-     fi
-]
-)
-
-if test "$withval" != "no" -a "$zlib" = "true" ; then
-  for testpngdir in "." $trypngdir /usr/local /usr /opt ; do
-    if test -f "$testpngdir/lib/libpng.a" ; then
-      if test ! -f "$testpngdir/include/png.h" ; then
-        AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
-      else
-          grep PNG_LIBPNG_VER_STRING "$testpngdir/include/png.h" | grep 9 > /dev/null 
-          if test "$?" = "0" ; then
-            AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
-          fi
-      fi
-      LDFLAGS="$LDFLAGS -L$testpngdir/lib"
-      CFLAGS="$CFLAGS -I$testpngdir/include"
-      pngdir="$testpngdir"
-      AC_DEFINE(HAVE_PNG)
-      break
-    elif test -f "$testpngdir/libpng.a" ; then
-      if test ! -f "$testpngdir/png.h" ; then
-        AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation])
-      else
-          grep PNG_LIBPNG_VER_STRING "$testpngdir/png.h" | grep 9 > /dev/null 
-          if test "$?" = "0" ; then
-            AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade])
-          fi
-      fi
-      LDFLAGS="$LDFLAGS -L$testpngdir"
-      CFLAGS="$CFLAGS -I$testpngdir"
-      pngdir="$testpngdir"
-      AC_DEFINE(HAVE_PNG)
-      break
-    fi
-  done
-  AC_MSG_RESULT($pngdir)
-  AM_CONDITIONAL(HAVE_PNG, test -n "$pngdir")
+if test "$debug" = "true" ; then
+  AC_ADD_GCC_CFLAGS([-g -DDEBUG])
+  AC_DEFINE(DEBUG)
 else
-  AC_MSG_RESULT([no])
+  AC_ADD_GCC_CFLAGS([-g -O3 -DNDEBUG --fast-math])
+  AC_DEFINE(NDEBUG)
 fi
 
 dnl Set LAM path
@@ -160,10 +182,14 @@ if test "$withval" != "no" ; then
       CFLAGS="$CFLAGS -I$testlamdir/include"
       lamdir="$testlamdir"
       AC_SUBST(lamdir)
+      mpienable="true"
+      AC_SUBST(mpienable)
       break
     fi
   done
   AC_MSG_RESULT($lamdir)
+else
+  AC_MSG_RESULT([no])
 fi
 
 AC_MSG_CHECKING([for web access])
@@ -184,12 +210,12 @@ AC_ARG_WITH(html-dir, [  --with-html-dir=PATH    Set directory of html files],
 [ htmldir=$withval ; AC_SUBST(htmldir) ] )
 
 if test -n "$cgibindir" -o -n "$cgibinurl" ; then
-  cgiprograms=ctsim.cgi
+  cgiprograms="ctsim.cgi ctsim.conf"
   AC_SUBST(cgiprograms)
 fi
 
 if test -n "$htmldir" ; then
-  htmldata=ctsim.html
+  htmldata=simulate.html
   AC_SUBST(htmldata)
 fi
 AM_CONDITIONAL(USE_HTML, test -n "$htmldir")
@@ -213,26 +239,6 @@ else
   AC_MSG_RESULT([no])
 fi
 
-dnl Setting projet libraries and includes
-LDFLAGS="$LDFLAGS -L../libezplot -L../libgraph -L../libkmath -L../libk -L../libcio -L../libir" 
-ctlibs_base="$ctlibs_base -lezplot -lgraph -lkmath -lk -lcio"
-if test -n "$pngdir" ; then
-  ctlibs_base="$ctlibs_base -lpng"
-fi
-if test "$zlib" = "true" ; then
-  ctlibs_base="$ctlibs_base -lz"
-fi
-ctlibs="-lir $ctlibs_base"
-
-AC_SUBST(ctlibs)
-
-if test -n "$lamdir" ; then
-  ctlamlibs="-lir_lam $ctlibs_base"
-  lamprograms="ctrec-lam phm2sdf-lam phm2rs-lam"
-  AC_SUBST(lamprograms)
-  AC_SUBST(ctlamlibs)
-fi
-
 AM_CONDITIONAL(USE_LAM, test -n "$lamdir")
 
 dnl Prepare to support X.  If the user gave the command-line option
@@ -285,6 +291,52 @@ AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes")
 my_includes="$my_includes -I../include -I.."
 AC_SUBST(my_includes)
 
-AM_CONDITIONAL(HAVE_INTERACTIVE_GRAPHICS, test 1==0)
+AC_MSG_CHECKING([interactive graphics])
+if test "$no_x" != "yes" ; then
+  AC_DEFINE(HAVE_X11)
+  AC_DEFINE(HAVE_SGP)
+  AM_CONDITIONAL(HAVE_SGP, test 1==1)
+  LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib"
+  ctlibs_graphics="$ctlibs_base -lctgraphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+
+if test "$png" = "true" ; then
+  ctlibs_tools="$ctlibs_tools -lpng"
+fi
+if test "$zlib" = "true" ; then
+  ctlibs_tools="$ctlibs_tools -lz"
+fi
+if test "$g2" = "true" ; then
+  ctlibs_tools="$ctlibs_tools -lg2"
+fi
+
+if test "$fftw" = "true" ; then
+  ctlibs_tools="$ctlibs_tools -lrfftw -lfftw"
+fi
+
+dnl Setting projet libraries and includes
+LDFLAGS="$LDFLAGS -L../libctsupport -L../libctsim" 
+ctlibs="$ctlibs_base -lctsim $ctlibs_graphics -lctsupport $ctlibs_tools"
+AC_SUBST(ctlibs)
+
+if test "$wxwin" = "true" ; then
+  wxcflags=`$wxconfig --cflags`
+  CFLAGS="$CFLAGS -I../include $wxcflags"
+  wxlibs=`$wxconfig --libs`
+  wxlibs="$wxlibs $ctlibs"
+  AM_CONDITIONAL(HAVE_WXWINDOWS, test 1==1 )
+fi
+AC_SUBST(wxcflags)
+AC_SUBST(wxlibs)
+
+if test -n "$lamdir" ; then
+  lamprograms="pjrec-lam phm2if-lam phm2pj-lam"
+  AC_SUBST(lamprograms)
+fi
+
+CXXFLAGS="$CFLAGS"
 
-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)
+AC_OUTPUT(Makefile src/Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/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)