@@ -66,8 +66,9 @@ m4_define([serial_tests], [m4_esyscmd_s([
6666 awk '{split ($NF,a,"."); if (a[ 1] >= 2 || (a[ 1] == 1 && a[ 2] >= 13)) { print "serial-tests" }}'
6767] ) ] )
6868
69- AC_PREREQ ( 2.59 )
70- AC_INIT ( [ FORM] , FORM_VERSION , [ https://github.com/vermaseren/form/issues] )
69+ AC_PREREQ ( [ 2.59] )
70+ AC_INIT ( [ FORM] , [ FORM_VERSION] , [ https://github.com/vermaseren/form/issues] )
71+ AC_CONFIG_MACRO_DIR ( [ m4] )
7172AC_CONFIG_SRCDIR ( [ sources/form3.h] )
7273AC_CONFIG_HEADERS ( [ config.h] )
7374AC_CONFIG_AUX_DIR ( [ build-aux] )
@@ -96,8 +97,18 @@ AC_PROG_CXX([g++ c++ icpc])
9697AC_PROG_LN_S
9798
9899# Checks for header files
99- AC_HEADER_STDC
100- AC_HEADER_TIME
100+ # NOTE: autoconf>=2.70 has started to warn obsolete macros.
101+ # We check if AC_CHECK_INCLUDES_DEFAULT (introduced in 2.70) is available
102+ # and switch to the new code if possible.
103+ m4_ifdef ( [ AC_CHECK_INCLUDES_DEFAULT] ,
104+ [ AC_CHECK_INCLUDES_DEFAULT
105+ AC_PROG_EGREP
106+ AC_CHECK_HEADERS_ONCE ( [ sys/time.h] )
107+ AC_DEFINE ( [ TIME_WITH_SYS_TIME] ,
108+ [ 1] ,
109+ [ Define to 1 if you can safely include both <sys/time.h> and <time.h>. This macro is obsolete.] ) ] ,
110+ [ AC_HEADER_STDC
111+ AC_HEADER_TIME ] )
101112AC_CHECK_HEADERS ( [ fcntl.h limits.h sys/file.h] )
102113
103114AC_LANG_PUSH ( [ C++] )
@@ -160,17 +171,20 @@ case $host_os in
160171 ;;
161172esac
162173case $host_cpu in
163- i?86 )
174+ i586 )
164175 print_cpu="Pentium"
165176 ;;
177+ i686 )
178+ print_cpu="Pentium Pro"
179+ ;;
166180 x86_64 )
167181 print_cpu="Opteron"
168182 ;;
169183 alpha* )
170184 print_cpu="Alpha"
171185 ;;
172186 * )
173- print_cpu="UNKNOWN CPU"
187+ print_cpu="UNKNOWN CPU ($host_cpu) "
174188 ;;
175189esac
176190
@@ -730,6 +744,13 @@ AC_ARG_ENABLE([sanitize],
730744 [ enable_sanitize=no] ) ] ,
731745 [ enable_sanitize=no] )
732746
747+ # Check for extra compiler warnings
748+ AC_ARG_ENABLE ( [ extra-warning] ,
749+ [ AS_HELP_STRING ( [ --enable-extra-warning] ,
750+ [ enable extra compiler warnings @<:@ default=no@:>@ ] ) ] ,
751+ [ enable_extra_warning=yes] ,
752+ [ enable_extra_warning=no] )
753+
733754# Optimization/debugging flags
734755AC_ARG_VAR ( [ COMPILEFLAGS] , [ Compiler flags for release versions] )
735756AC_ARG_VAR ( [ LINKFLAGS] , [ Linker flags for release versions] )
@@ -738,36 +759,45 @@ AC_ARG_VAR([DEBUGLINKFLAGS], [Linker flags for debugging versions])
738759TOOL_LIBS=
739760DEBUGTOOL_LIBS=
740761
762+ # AX_HANDLE_EXTRA_WARNING(COMPILEFLAGS)
763+ # -------------------------------------
764+ AC_DEFUN ( [ AX_HANDLE_EXTRA_WARNING] ,
765+ [ if test "x$enable_extra_warning" = xno; then
766+ # Too many misleading indentation in the FORM source code.
767+ AX_CHECK_COMPILE_FLAG ( [ -Wno-misleading-indentation] ,
768+ [ $1 ="$$1 -Wno-misleading-indentation"] )
769+ # Too many false positives.
770+ # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
771+ AX_CHECK_COMPILE_FLAG ( [ -Wno-stringop-overflow] ,
772+ [ $1 ="$$1 -Wno-stringop-overflow"] )
773+ fi[ ] dnl
774+ ] )
775+
741776my_test_COMPILEFLAGS=${COMPILEFLAGS+set}
742777if test "$my_test_COMPILEFLAGS" != set; then
743778 if test "x$vendor" = xgnu; then
744779 # We don't use -pedantic option because of horrible warnings.
745- COMPILEFLAGS="-Wall -Wextra -Wpadded -O3"
780+ COMPILEFLAGS="-Wall -Wextra -Wpadded"
781+ AX_HANDLE_EXTRA_WARNING([ COMPILEFLAGS] )
782+ # Enable optimizations.
783+ COMPILEFLAGS="$COMPILEFLAGS -O3"
746784 if test "x$enable_profile" != xgprof; then
747785 # -pg conflicts with -fomit-frame-pointer.
748786 COMPILEFLAGS="$COMPILEFLAGS -fomit-frame-pointer"
749787 fi
750788 if test "x$enable_native" = xyes; then
751- # Check for -march=native.
752- AC_MSG_CHECKING ( [ whether compiler accepts -march=native] )
753- ok=no
754- save_CFLAGS=$CFLAGS
755- CFLAGS="$CFLAGS -march=native"
756- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( ) ] , [ ok=yes] )
757- CFLAGS=$save_CFLAGS
758- AC_MSG_RESULT ( $ok )
759- if test "x$ok" = xyes; then
760- COMPILEFLAGS="$COMPILEFLAGS -march=native"
761- else
762- if test "x$print_data_model" = xILP32; then
789+ # Use -march=native if available.
790+ AX_CHECK_COMPILE_FLAG ( [ -march=native] ,
791+ [ COMPILEFLAGS="$COMPILEFLAGS -march=native"] ,
792+ [ if test "x$print_data_model" = xILP32; then
763793 if test "x$print_cpu" = xPentium; then
764- # NOTE: In a strict sense, i686 must be used for Pentium Pro or later.
794+ COMPILEFLAGS="$COMPILEFLAGS -march=i586"
795+ elif test "x$print_cpu" = 'xPentium Pro'; then
765796 COMPILEFLAGS="$COMPILEFLAGS -march=i686"
766797 elif test "x$print_cpu" = xOpteron; then
767798 COMPILEFLAGS="$COMPILEFLAGS -march=opteron"
768799 fi
769- fi
770- fi
800+ fi] )
771801 fi
772802 # Profiling option.
773803 if test "x$enable_profile" = xgprof; then
809839my_test_DEBUGCOMPILEFLAGS=${DEBUGCOMPILEFLAGS+set}
810840if test "$my_test_DEBUGCOMPILEFLAGS" != set && test "x$enable_debug" = xyes; then
811841 if test "x$vendor" = xgnu; then
812- DEBUGCOMPILEFLAGS='-g3 - Wall -Wextra'
842+ DEBUGCOMPILEFLAGS='-Wall -Wextra'
813843 if test "x$enable_sanitize" = xno; then
814844 # UBSan puts many paddings (at least in gcc 5.3).
815845 DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -Wpadded"
816846 fi
817- # Check for -Og.
818- AC_MSG_CHECKING ( [ whether compiler accepts -Og] )
819- ok=no
820- save_CFLAGS=$CFLAGS
821- CFLAGS="$CFLAGS -Og"
822- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( ) ] , [ ok=yes] )
823- CFLAGS=$save_CFLAGS
824- AC_MSG_RESULT ( $ok )
825- if test "x$ok" = xyes; then
826- DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -Og"
827- else
828- DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -O0"
829- fi
847+ AX_HANDLE_EXTRA_WARNING([ DEBUGCOMPILEFLAGS] )
848+ # Check for -Og. If it doesn't work then use -O0.
849+ AX_CHECK_COMPILE_FLAG ( [ -Og] ,
850+ [ DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -Og"] ,
851+ [ DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -O0"] )
852+ # Debugging information.
853+ DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -g3"
830854 # Coverage option.
831855 if test "x$enable_coverage" = xyes; then
832856 DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -coverage"
@@ -840,31 +864,13 @@ if test "$my_test_DEBUGCOMPILEFLAGS" != set && test "x$enable_debug" = xyes; the
840864 else
841865 tmp_sanitize=$enable_sanitize,$san
842866 fi
843- AC_MSG_CHECKING ( [ whether compiler accepts -fsanitize=$tmp_sanitize] )
844- ok=no
845- save_CFLAGS=$CFLAGS
846- CFLAGS="$CFLAGS -fsanitize=$tmp_sanitize"
847- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( ) ] , [ ok=yes] )
848- CFLAGS=$save_CFLAGS
849- AC_MSG_RESULT ( $ok )
850- if test "x$ok" = xyes; then
851- enable_sanitize=$tmp_sanitize
852- fi
867+ AX_CHECK_COMPILE_FLAG ( [ -fsanitize=$tmp_sanitize] , [ enable_sanitize=$tmp_sanitize] )
853868 done
854869 if test "x$enable_sanitize" = x; then
855870 enable_sanitize=failed
856871 fi
857872 elif test "x$enable_sanitize" != xno; then
858- AC_MSG_CHECKING ( [ whether compiler accepts -fsanitize=$enable_sanitize] )
859- ok=no
860- save_CFLAGS=$CFLAGS
861- CFLAGS="$CFLAGS -fsanitize=$enable_sanitize"
862- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( ) ] , [ ok=yes] )
863- CFLAGS=$save_CFLAGS
864- AC_MSG_RESULT ( $ok )
865- if test "x$ok" != xyes; then
866- enable_sanitize=failed
867- fi
873+ AX_CHECK_COMPILE_FLAG ( [ -fsanitize=$enable_sanitize] , [ ] , [ enable_sanitize=failed] )
868874 fi
869875 if test "x$enable_sanitize" = xfailed; then
870876 AC_MSG_FAILURE ( [ test for sanitizer failed. Give --disable-sanitize if you want to compile without sanitizer] )
0 commit comments