From d930280af5df9de318229b8fa7d4f1f7d27b748d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 7 Oct 2008 13:13:34 +0000 Subject: Initial attempt to support configure's --(dis|en)able-optimize option to specify dis(activation) of compiler optimizations. If option is specified, it will be honored independant of the --(dis|en)able-debug option. --- ares/m4/cares-confopts.m4 | 76 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 10 deletions(-) (limited to 'ares/m4/cares-confopts.m4') diff --git a/ares/m4/cares-confopts.m4 b/ares/m4/cares-confopts.m4 index 2299b6074..17a6875f3 100644 --- a/ares/m4/cares-confopts.m4 +++ b/ares/m4/cares-confopts.m4 @@ -16,7 +16,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 1 +# serial 2 dnl CARES_CHECK_OPTION_DEBUG @@ -27,13 +27,13 @@ dnl variable want_debug value as appropriate. AC_DEFUN([CARES_CHECK_OPTION_DEBUG], [ AC_BEFORE([$0],[CARES_CHECK_OPTION_WARNINGS])dnl - AC_BEFORE([$0],[AC_PROG_CC])dnl + AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl AC_MSG_CHECKING([whether to enable debug build options]) OPT_DEBUG_BUILD="default" AC_ARG_ENABLE(debug, - AC_HELP_STRING([--enable-debug],[Enable debug build options]) - AC_HELP_STRING([--disable-debug],[Disable debug build options]), - OPT_DEBUG_BUILD=$enableval) +AC_HELP_STRING([--enable-debug],[Enable debug build options]) +AC_HELP_STRING([--disable-debug],[Disable debug build options]), + OPT_DEBUG_BUILD=$enableval) case "$OPT_DEBUG_BUILD" in no) dnl --disable-debug option used @@ -52,21 +52,77 @@ AC_DEFUN([CARES_CHECK_OPTION_DEBUG], [ ]) +dnl CARES_CHECK_OPTION_OPTIMIZE +dnl ------------------------------------------------- +dnl Verify if configure has been invoked with option +dnl --enable-optimize or --disable-optimize, and set +dnl shell variable want_optimize value as appropriate. + +AC_DEFUN([CARES_CHECK_OPTION_OPTIMIZE], [ + AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl + AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl + AC_MSG_CHECKING([whether to enable compiler optimizer]) + OPT_COMPILER_OPTIMIZE="default" + AC_ARG_ENABLE(optimize, +AC_HELP_STRING([--enable-optimize(=OPT)],[Enable compiler optimizations (default=-O2)]) +AC_HELP_STRING([--disable-optimize],[Disable compiler optimizations]), + OPT_COMPILER_OPTIMIZE=$enableval) + case "$OPT_COMPILER_OPTIMIZE" in + no) + dnl --disable-optimize option used. We will handle this as + dnl a request to disable compiler optimizations if possible. + dnl If the compiler is known CFLAGS and CPPFLAGS will be + dnl overridden, otherwise this can not be honored. + want_optimize="no" + AC_MSG_RESULT([no]) + ;; + default) + dnl configure's optimize option not specified. Initially we will + dnl handle this as a a request contrary to configure's setting + dnl for --enable-debug. IOW, initially, for debug-enabled builds + dnl this will be handled as a request to disable optimizations if + dnl possible, and for debug-disabled builds this will be handled + dnl initially as a request to enable optimizations if possible. + dnl Finally, if the compiler is known and CFLAGS and CPPFLAGS do + dnl not have any optimizer flag the request will be honored, in + dnl any other case the request can not be honored. + dnl IOW, existing optimizer flags defined in CFLAGS or CPPFLAGS + dnl will always take precedence over any initial assumption. + if test "$want_debug" = "yes"; then + want_optimize="assume_no" + AC_MSG_RESULT([not specified (assuming no)]) + else + want_optimize="assume_yes" + AC_MSG_RESULT([not specified (assuming yes)]) + fi + ;; + *) + dnl --enable-optimize option used. We will handle this as + dnl a request to enable compiler optimizations if possible. + dnl If the compiler is known CFLAGS and CPPFLAGS will be + dnl overridden, otherwise this can not be honored. + want_optimize="yes" + AC_MSG_RESULT([yes]) + ;; + esac +]) + + dnl CARES_CHECK_OPTION_WARNINGS dnl ------------------------------------------------- dnl Verify if configure has been invoked with option dnl --enable-warnings or --disable-warnings, and set -DNL shell variable want_warnings as appropriate. +dnl shell variable want_warnings as appropriate. AC_DEFUN([CARES_CHECK_OPTION_WARNINGS], [ AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl - AC_BEFORE([$0],[AC_PROG_CC])dnl + AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl AC_MSG_CHECKING([whether to enable strict compiler warnings]) OPT_COMPILER_WARNINGS="default" AC_ARG_ENABLE(warnings, - AC_HELP_STRING([--enable-warnings],[Enable strict compiler warnings]) - AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]), - OPT_COMPILER_WARNINGS=$enableval) +AC_HELP_STRING([--enable-warnings],[Enable strict compiler warnings]) +AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]), + OPT_COMPILER_WARNINGS=$enableval) case "$OPT_COMPILER_WARNINGS" in no) dnl --disable-warnings option used -- cgit v1.2.3