Update to wx3.0, add SSE optimizations based on target_cpu, fix compile warnings
[ctsim.git] / configure.ac
index cdd5ef5f7f9ea636100ea25a57bb0fad4a7b53bb..b3cf1c2599b7e48b3955d981445f0d0a1cfa9e32 100644 (file)
@@ -27,8 +27,13 @@ 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([CTSim], [5.2.0], [ctsim-users@kpe.io], [ctsim], [http://www.ctsim.org/])
+AC_INIT([CTSim], [6.0.0], [ctsim-users@kpe.io], [ctsim], [http://www.ctsim.org/])
 AC_CONFIG_SRCDIR([src/ctsim.cpp])
+AC_CONFIG_MACRO_DIR([scripts])
+dnl permit auxiliary scripts directory (e.g. config.sub, config.guess, install-sh)
+AC_CONFIG_AUX_DIR(scripts/)
+
+AC_CANONICAL_TARGET
 AM_MAINTAINER_MODE
 AM_INIT_AUTOMAKE
 AM_CONFIG_HEADER(config.h)
@@ -77,8 +82,8 @@ if test "$hasx11gtk2" = "true" ; then
   CFLAGS="${CFLAGS} ${g76GTK_CFLAGS} ${GLIB_CFLAGS}"
 fi
 
-AC_CHECK_LIB(wx_gtk2u_core-2.8, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])], [], [-L/usr/lib64 -L/usr/lib ${GTK_LIBS} ${GLIB_LIBS} ])
-AC_CHECK_LIB(wx_mac_core-2.8, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
+AC_CHECK_LIB(wx_gtk2u_core-3.0, main, [wxwin=true; wx_gtk=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])], [], [-L/usr/lib64 -L/usr/lib ${GTK_LIBS} ${GLIB_LIBS} ])
+AC_CHECK_LIB(wx_mac_core-3.0, main, [wxwin=true; wx_mac=true; AC_DEFINE(HAVE_WXWINDOWS,1,[wxwindows library])])
 AC_CHECK_LIB(fftw3, fftw_malloc, [fftw=true; AC_DEFINE(HAVE_FFTW,1,[FFTW library])], [fftw=false], [-L/usr/lib64 -L/usr/lib])
 AC_CHECK_LIB(GL, main, [libgl=true], [libgl=false], [-L/usr/X11R6/lib -L/usr/X11R6/lib64])
 AC_CHECK_LIB(pthread, main, [pthread=true], [pthread=false])
@@ -122,6 +127,32 @@ if test "${getopt_long}" = "false" ; then
 fi
 AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test "$GETOPTLONG"="1")
 
+case $target_cpu in
+    i386|i486|i586|i686|x86|x86_64)
+        AX_EXT
+        if [ test "$ax_cv_have_sse41_ext" = yes && test "$ac_cv_header_smmintrin_h" = yes ]; then
+            # SSE4.1/2 extensions
+            ARCH_OPTION='-msse4.1'
+        elif [ test "$ax_cv_have_sse3_ext" = yes && test "$ac_cv_header_pmmintrin_h" = yes ]; then
+            ARCH_OPTION='-msse3'
+        elif [ test "$ax_cv_have_sse2_ext" = yes && test "$ac_cv_header_emmintrin_h" = yes ]; then
+            ARCH_OPTION='-msse2'
+        else
+            ARCH_OPTION="-ffast-math"
+        fi;;
+    powerpc*)
+        ARCH_OPTION="-fno-common -faltivec";;
+    armv1*|armv2*|armv3*|armv4*|armv5*|armv6*)
+        ARCH_OPTION="-ffast-math";;
+    armv7*|armv8*)
+        ARCH_OPTION="-ffast-math -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4";;
+    *)
+        # unknown architecture : use portable C version
+        ARCH_OPTION="";;
+esac
+CPPFLAGS="$CPPFLAGS $ARCH_OPTION"
+CXXFLAGS="$CPPFLAGS $ARCH_OPTION"
+
 if test "${readline}" = "true" ; then
   ctlibs_base="$ctlibs_base -lreadline"
   if test "${ncurses}" = "true"; then
@@ -354,7 +385,6 @@ dnl whether X should be supported.
 AM_CONDITIONAL(NO_X, test "x$with_x" = "xno")
 
 my_includes="$my_includes -I../include -I.. -I/usr/local/include"
-AC_SUBST(my_includes)
 
 LDFLAGS="$LDFLAGS -L/usr/local/lib"
 
@@ -362,12 +392,13 @@ AC_MSG_CHECKING([for X])
 if test "$with_x" != "no" && test "$wxwin" = "true"; then
   AC_DEFINE(HAVE_X11,1,[X11 system])
   LDFLAGS="$LDFLAGS -L../libctgraphics -L/usr/X11R6/lib -L/usr/X11R6/lib64"
-  my_includes="$my_includes -I/usr/X11R6/include"
+  my_includes="$my_includes -I/usr/X11R6/include -I/usr/include/X11"
   ctlib_graphics="$ctlibs_base -lctgraphics"
   AC_MSG_RESULT(yes)
   ctlib_graphics="$ctlib_graphics $X_BASIC_LIBS $X_TOOLKIT_LIBS"
+  wx_cppflags="`$wxconfig --cppflags`"
   if test "$libgl" = "true" ; then
-    # Removed "-lglut" for Mac OS X compilation
+    dnl  Removed "-lglut" for Mac OS X compilation
     ctlib_graphics="$ctlib_graphics -lGL -lGLU"
     if test "$wxwin" = "true" ; then
        wxdebug=""
@@ -375,9 +406,10 @@ if test "$with_x" != "no" && test "$wxwin" = "true"; then
          wxdebug="--debug"
        fi  
       if test "x$wx_gtk" != "x" ; then
-       ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=2.8  --libs std,gl` ${GTK_LIBS} ${GLIB_LIBS}"
+       ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=3.0  --libs std,gl` ${GTK_LIBS} ${GLIB_LIBS}"
+       
       elif test "x$wx_mac" != "x" ; then
-        ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=2.8 --libs std,gl`"
+        ctlib_graphics="$ctlib_graphics `$wxconfig $wxdebug --version=3.0 --libs std,gl`"
       fi
     fi
   fi
@@ -451,7 +483,7 @@ fi
 
 if test "$wxwin" = "true" ; then
   if test "$wx_gtk" = "true"  -o "$wx_mac" = "true" ; then
-    wxcflags=`$wxconfig $wxdebug --cxxflags --version=2.8`
+    wxcflags=`$wxconfig $wxdebug --cxxflags --version=3.0`
     #wxlibs=`$wxconfig --libs`
   else
        wxcflags="-D__WXMSW__ -D__WIN32__ -D__GNUWIN32__"
@@ -478,6 +510,9 @@ fi
 
 CXXFLAGS="$CFLAGS"
 
+AC_SUBST(my_includes)
+AC_SUBST(wx_cppflags)
+
 AC_CONFIG_FILES([Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/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 src/Makefile helical/Makefile helical/sample-helical.sh])
 
 AC_OUTPUT