refactoring of COMPILER_BASIC_OPTS

pull/1/head
Yang Tse 17 years ago
parent 94d2a28698
commit ce7c807846
  1. 231
      m4/cares-compilers.m4

@ -129,7 +129,7 @@ AC_DEFUN([CARES_CHECK_COMPILER_HP], [
CURL_CHECK_DEF([__HP_cc], [], [silent]) CURL_CHECK_DEF([__HP_cc], [], [silent])
if test "$curl_cv_have_def___HP_cc" = "yes"; then if test "$curl_cv_have_def___HP_cc" = "yes"; then
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
compiler_id="HPC" compiler_id="HPUXC"
flags_dbg_all="-g -s" flags_dbg_all="-g -s"
flags_dbg_yes="-g" flags_dbg_yes="-g"
flags_dbg_off="-s" flags_dbg_off="-s"
@ -235,6 +235,64 @@ AC_DEFUN([CARES_CHECK_COMPILER_SUN], [
]) ])
dnl CARES_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
dnl -------------------------------------------------
dnl Verify if the C compiler seems to work with the
dnl settings that are 'active' at the time the test
dnl is performed.
AC_DEFUN([CARES_COMPILER_WORKS_IFELSE], [
dnl compilation capability verification
tmp_compiler_works="unknown"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
]],[[
int i = 1;
return i;
]])
],[
tmp_compiler_works="yes"
],[
tmp_compiler_works="no"
])
dnl linking capability verification
if test "$tmp_compiler_works" = "yes"; then
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
]],[[
int i = 1;
return i;
]])
],[
tmp_compiler_works="yes"
],[
tmp_compiler_works="no"
])
fi
dnl only do runtime verification when not cross-compiling
if test "x$cross_compiling" != "xyes" &&
test "$tmp_compiler_works" = "yes"; then
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
]],[[
int i = 0;
exit(i);
]])
],[
tmp_compiler_works="yes"
],[
tmp_compiler_works="no"
])
fi
dnl branch upon test result
if test "$tmp_compiler_works" = "yes"; then
ifelse($1,,:,[$1])
ifelse($2,,,[else
$2])
fi
])
dnl CARES_SET_COMPILER_BASIC_OPTS dnl CARES_SET_COMPILER_BASIC_OPTS
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Sets compiler specific options/flags which do not dnl Sets compiler specific options/flags which do not
@ -244,57 +302,108 @@ dnl options.
AC_DEFUN([CARES_SET_COMPILER_BASIC_OPTS], [ AC_DEFUN([CARES_SET_COMPILER_BASIC_OPTS], [
AC_REQUIRE([CARES_CHECK_COMPILER])dnl AC_REQUIRE([CARES_CHECK_COMPILER])dnl
# #
if test "$compiler_id" = "DECC"; then if test "$compiler_id" != "unknown"; then
dnl Select strict ANSI C compiler mode #
CFLAGS="$CFLAGS -std1" tmp_save_CPPFLAGS="$CPPFLAGS"
dnl Turn off optimizer ANSI C aliasing rules tmp_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -noansi_alias" tmp_CPPFLAGS=""
dnl Generate warnings for missing function prototypes tmp_CFLAGS=""
CFLAGS="$CFLAGS -warnprotos" #
dnl Change some warnings into fatal errors case "$compiler_id" in
CFLAGS="$CFLAGS -msg_fatal toofewargs,toomanyargs" #
fi DECC)
# #
if test "$compiler_id" = "HPC"; then dnl Select strict ANSI C compiler mode
dnl Disallow run-time dereferencing of null pointers tmp_CFLAGS="$tmp_CFLAGS -std1"
CFLAGS="$CFLAGS -z" dnl Turn off optimizer ANSI C aliasing rules
fi tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
# dnl Generate warnings for missing function prototypes
if test "$compiler_id" = "IBMC"; then tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
dnl Ensure that compiler optimizations are always thread-safe. dnl Change some warnings into fatal errors
CFLAGS="$CFLAGS -qthreaded" tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
dnl Disable type based strict aliasing optimizations, using worst ;;
dnl case aliasing assumptions when compiling. Type based aliasing #
dnl would restrict the lvalues that could be safely used to access GNUC)
dnl a data object. #
CFLAGS="$CFLAGS -qnoansialias" dnl Placeholder
dnl Force compiler to stop after the compilation phase, without tmp_CFLAGS="$tmp_CFLAGS"
dnl generating an object code file when compilation has errors. ;;
CFLAGS="$CFLAGS -qhalt=e" #
fi HPUXC)
# #
if test "$compiler_id" = "ICC_unix"; then dnl Placeholder
dnl On unix this compiler uses gcc's header files, so tmp_CFLAGS="$tmp_CFLAGS"
dnl we select ANSI C89 dialect plus GNU extensions. ;;
CPPFLAGS="$CPPFLAGS -std=gnu89" #
dnl Change some warnings into errors IBMC)
dnl #140: too many arguments in function call #
dnl #147: declaration is incompatible with 'previous one' dnl Ensure that compiler optimizations are always thread-safe.
dnl #165: too few arguments in function call tmp_CFLAGS="$tmp_CFLAGS -qthreaded"
dnl #266: function declared implicitly dnl Disable type based strict aliasing optimizations, using worst
CPPFLAGS="$CPPFLAGS -we 140,147,165,266" dnl case aliasing assumptions when compiling. Type based aliasing
dnl Disable some remarks dnl would restrict the lvalues that could be safely used to access
dnl #279: controlling expression is constant dnl a data object.
dnl #981: operands are evaluated in unspecified order tmp_CFLAGS="$tmp_CFLAGS -qnoansialias"
dnl #1469: "cc" clobber ignored dnl Force compiler to stop after the compilation phase, without
if test "$compiler_num" -lt "910"; then dnl generating an object code file when compilation has errors.
CPPFLAGS="$CPPFLAGS -wd 279" tmp_CFLAGS="$tmp_CFLAGS -qhalt=e"
;;
#
ICC_unix)
#
dnl On unix this compiler uses gcc's header files, so
dnl we select ANSI C89 dialect plus GNU extensions.
tmp_CPPFLAGS="$tmp_CPPFLAGS -std=gnu89"
dnl Change some warnings into errors
dnl #140: too many arguments in function call
dnl #147: declaration is incompatible with 'previous one'
dnl #165: too few arguments in function call
dnl #266: function declared implicitly
tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
dnl Disable some remarks
dnl #279: controlling expression is constant
dnl #981: operands are evaluated in unspecified order
dnl #1469: "cc" clobber ignored
tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
dnl Disable use of ANSI C aliasing rules in optimizations
tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
dnl Disable floating point optimizations
tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
;;
#
ICC_windows)
#
dnl Placeholder
tmp_CFLAGS="$tmp_CFLAGS"
;;
#
SUNC)
#
dnl Placeholder
tmp_CFLAGS="$tmp_CFLAGS"
;;
#
esac
#
tmp_CPPFLAGS=`eval echo $tmp_CPPFLAGS`
tmp_CFLAGS=`eval echo $tmp_CFLAGS`
#
if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
AC_MSG_CHECKING([if compiler accepts some basic options])
CPPFLAGS=`eval echo $tmp_save_CPPFLAGS $tmp_CPPFLAGS`
CFLAGS=`eval echo $tmp_save_CFLAGS $tmp_CFLAGS`
CARES_COMPILER_WORKS_IFELSE([
AC_MSG_RESULT([yes])
AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
],[
AC_MSG_RESULT([no])
AC_MSG_NOTICE([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
dnl restore initial settings
CPPFLAGS="$tmp_save_CPPFLAGS"
CFLAGS="$tmp_save_CFLAGS"
])
fi fi
CPPFLAGS="$CPPFLAGS -wd 981,1469" #
dnl Disable use of ANSI C aliasing rules in optimizations
CFLAGS="$CFLAGS -no-ansi-alias"
dnl Disable floating point optimizations
CFLAGS="$CFLAGS -fp-model precise"
fi fi
]) ])
@ -324,13 +433,7 @@ AC_DEFUN([CARES_SET_COMPILER_DEBUG_OPTS], [
CFLAGS="$CFLAGS $flags_dbg_off" CFLAGS="$CFLAGS $flags_dbg_off"
AC_MSG_CHECKING([if compiler accepts debug disabling flags $flags_dbg_off]) AC_MSG_CHECKING([if compiler accepts debug disabling flags $flags_dbg_off])
fi fi
AC_COMPILE_IFELSE([ CARES_COMPILER_WORKS_IFELSE([
AC_LANG_PROGRAM([[
]],[[
int i = 1;
return i;
]])
],[
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
],[ ],[
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
@ -398,13 +501,7 @@ AC_DEFUN([CARES_SET_COMPILER_OPTIMIZE_OPTS], [
CFLAGS="$CFLAGS $flags_opt_off" CFLAGS="$CFLAGS $flags_opt_off"
AC_MSG_CHECKING([if compiler accepts optimizer disabling flags $flags_opt_off]) AC_MSG_CHECKING([if compiler accepts optimizer disabling flags $flags_opt_off])
fi fi
AC_COMPILE_IFELSE([ CARES_COMPILER_WORKS_IFELSE([
AC_LANG_PROGRAM([[
]],[[
int i = 1;
return i;
]])
],[
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
],[ ],[
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
@ -492,7 +589,7 @@ AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [
fi fi
fi fi
# #
if test "$compiler_id" = "HPC"; then if test "$compiler_id" = "HPUXC"; then
if test "$want_warnings" = "yes"; then if test "$want_warnings" = "yes"; then
dnl Issue all warnings dnl Issue all warnings
CFLAGS="$CFLAGS +w1" CFLAGS="$CFLAGS +w1"
@ -597,7 +694,7 @@ AC_DEFUN([CARES_VAR_MATCH_IFELSE], [
if test "$ac_var_match_word" = "yes"; then if test "$ac_var_match_word" = "yes"; then
ifelse($3,,:,[$3]) ifelse($3,,:,[$3])
ifelse($4,,,[else ifelse($4,,,[else
[$4]]) $4])
fi fi
]) ])

Loading…
Cancel
Save