* m4/ax_compiler_vendor.m4: New file.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 28 Aug 2008 18:47:47 +0000 (20:47 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 28 Aug 2008 18:47:47 +0000 (20:47 +0200)
* THIRDPARTY: Updated.
* configure.ac (AX_COMPILER_VENDOR): Added, we check for the compiler
vendor and set the required compiler flags accordingly.

THIRDPARTY
configure.ac
m4/ax_compiler_vendor.m4 [new file with mode: 0644]

index 72405f576fc4e41cd373326754c5e5ebe7e6520c..24002d4bbc24ec4430e40614fed4f8428dc113c4 100644 (file)
@@ -108,7 +108,7 @@ that contains a configuration script generated by Autoconf, under
 the same distribution terms as the rest of that program.
 
 
-* m4/{ac_prog_javac.m4,ac_prog_javac_works.m4}
+* m4/{ac_prog_jar.m4,ac_prog_javac.m4,ac_prog_javac_works.m4,ax_compiler_vendor.m4}
 
 The http://ac-archive.sourceforge.net/ website states this about the
 copyright:
index 9f76066eb93a193b9f6189d2f724dd386e357001..08753b86e5afc55181df10a1886ca12b8ddc813b 100644 (file)
@@ -35,20 +35,7 @@ AM_CONFIG_HEADER([config.h])
 AC_PREFIX_DEFAULT(/usr/local/cacao)
 
 
-dnl Set optimization and debugging for all architectures and systems.
-if test x"$CFLAGS" = "x"; then
-    OPT_CFLAGS="-g -O0"
-else
-    OPT_CFLAGS=$CFLAGS
-fi
-
-if test x"$CXXFLAGS" = "x"; then
-    OPT_CXXFLAGS="-g -O0"
-else
-    OPT_CXXFLAGS=$CXXFLAGS
-fi
-
-dnl system type
+dnl Host CPU type.
 case "$host_cpu" in
 alpha | alphaev56 | alphapca56 )
     ARCH_DIR="alpha"
@@ -126,25 +113,22 @@ xdspcore )
     ;;
 
 * )
-    AC_MSG_ERROR($host_cpu systems are not supported at this time)
+    AC_MSG_ERROR([$host_cpu systems are currently not supported.])
     ;;
 esac
 
-dnl host type
+
+dnl Host operating system type.
 case "$host_os" in
 *cygwin* )
     OS_DIR="cygwin"
     OS_FLAGS="-D__WINDOWS__ -D__CYGWIN__"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *darwin* )
     OS_DIR="darwin"
     OS_FLAGS="-D__DARWIN__"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
@@ -152,24 +136,18 @@ dnl Must be BEFORE *freebsd*.
 *kfreebsd*-gnu)
     OS_DIR="freebsd"
     OS_FLAGS="-D__FREEBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *freebsd* )
     OS_DIR="freebsd"
     OS_FLAGS="-D__FREEBSD__ -D_XOPEN_SOURCE_EXTENDED"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *irix* )
     OS_DIR="irix"
     OS_FLAGS="-D__IRIX__"
-    CC_FLAGS=""
-    CXX_FLAGS=""
     INTRP_CFLAGS="$ARCH_FLAGS $OS_FLAGS"
     ;;
 
@@ -177,24 +155,18 @@ dnl Must be BEFORE *linux*.
 *uclinux | *elf )
     OS_DIR="uclinux"
     OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *linux* | *Linux* )
     OS_DIR="linux"
     OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *netbsd* )
     OS_DIR="netbsd"
     OS_FLAGS="-D__NETBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
@@ -204,18 +176,57 @@ dnl Must be BEFORE *linux*.
     dnl not set when cpp is called with -std=c99, therefore we add them
     dnl here.
     OS_FLAGS="-D__SOLARIS__ -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_BSD_SOURCE"
-    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE=600"
-    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    CC_FLAGS="-D_XOPEN_SOURCE=600"
+    CXX_FLAGS="-D_XOPEN_SOURCE=500"
     INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 * )
+    AC_MSG_ERROR([$host_os operating systems are currently not supported.])
     ;;
 esac
 
 
-dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
-dnl we set it properly at the end of this file
+dnl Set optimization and debugging for all architectures and systems.
+dnl NOTE: Setting the CFLAGS/CXXFLAGS only works before calling AC_PROG_CC/AC_PROG_CXX.
+if test x"$CFLAGS" = "x"; then
+    OPT_CFLAGS="-g -O0"
+else
+    OPT_CFLAGS=$CFLAGS
+fi
+
+if test x"$CXXFLAGS" = "x"; then
+    OPT_CXXFLAGS="-g -O0"
+else
+    OPT_CXXFLAGS=$CXXFLAGS
+fi
+
+dnl Check for compiler.
+AC_PROG_CC
+AC_PROG_CXX
+
+dnl Check compiler vendor.
+AX_COMPILER_VENDOR
+
+dnl Set compiler flags depending on the compiler vendor.
+case "$ax_cv_c_compiler_vendor" in
+gnu )
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long $CC_FLAGS"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long $CXX_FLAGS"
+    ;;
+
+sun )
+    CC_FLAGS="-xc99 $CC_FLAGS"
+    CXX_FLAGS="$CXX_FLAGS"
+    ;;
+
+* )    
+    AC_MSG_ERROR([$ax_cv_c_compiler_vendor compilers are currently not supported.])
+    ;;
+esac
+
+dnl Temporary set the CFLAGS for configure tests (e.g. inline keyword)
+dnl we set it properly at the end of this file.
 CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
 CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
 
@@ -230,10 +241,7 @@ AC_SUBST(JAVA_ARCH)
 AC_SUBST(OS_DIR)
 AC_SUBST(USE_SCHEDULER)
 
-
 dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_CXX
 AM_PROG_AS
 AC_PROG_LD
 AC_PROG_LD_GNU
@@ -287,7 +295,6 @@ AC_STRUCT_TM
 
 dnl Checks for libraries (NOTE: Should be done before function checks,
 dnl as some functions may be in libraries we check for).
-
 case "${OS_DIR}" in
     solaris )
          AC_CHECK_LIB([socket], [gethostname],, [AC_MSG_ERROR(cannot find libsocket)])
diff --git a/m4/ax_compiler_vendor.m4 b/m4/ax_compiler_vendor.m4
new file mode 100644 (file)
index 0000000..a1da61e
--- /dev/null
@@ -0,0 +1,33 @@
+dnl Taken from http://ac-archive.sourceforge.net/
+
+dnl @synopsis AX_COMPILER_VENDOR
+dnl
+dnl @summary find the vendor (gnu, intel, etc.) of the C/C++ compiler
+dnl
+dnl Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm,
+dnl sun, hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi,
+dnl microsoft, watcom, etc. The vendor is returned in the cache
+dnl variable $ax_cv_c_compiler_vendor for C and
+dnl $ax_cv_cxx_compiler_vendor for C++.
+dnl
+dnl @category C
+dnl @category Cxx
+dnl @author Steven G. Johnson <stevenj@alum.mit.edu> with Matteo Frigo
+dnl @version 2005-05-30
+dnl @license GPLWithACException
+
+AC_DEFUN([AX_COMPILER_VENDOR],
+[
+AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+ [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
+  # note: don't check for gcc first since some other compilers define __GNUC__
+  for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
+    vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
+#if !($vencpp)
+      thisisanerror;
+#endif
+])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
+  done
+ ])
+])