|
|
385871 |
## Copyright (c) 2004-2007 Daniel Elstner <daniel.kitta@gmail.com></daniel.kitta@gmail.com>
|
|
|
385871 |
##
|
|
|
385871 |
## This file is part of danielk's Autostuff.
|
|
|
385871 |
##
|
|
|
385871 |
## danielk's Autostuff is free software; you can redistribute it and/or
|
|
|
385871 |
## modify it under the terms of the GNU General Public License as published
|
|
|
385871 |
## by the Free Software Foundation; either version 2 of the License, or (at
|
|
|
385871 |
## your option) any later version.
|
|
|
385871 |
##
|
|
|
385871 |
## danielk's Autostuff is distributed in the hope that it will be useful, but
|
|
|
385871 |
## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
385871 |
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
385871 |
## for more details.
|
|
|
385871 |
##
|
|
|
385871 |
## You should have received a copy of the GNU General Public License along
|
|
|
385871 |
## with danielk's Autostuff; if not, write to the Free Software Foundation,
|
|
|
385871 |
## Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
385871 |
|
|
|
385871 |
#serial 20070116
|
|
|
385871 |
|
|
|
385871 |
## DK_ARG_ENABLE_WARNINGS(variable, min-flags, max-flags, [deprecation-prefixes])
|
|
|
385871 |
##
|
|
|
385871 |
## Provide the --enable-warnings configure argument, set to "min" by default.
|
|
|
385871 |
## <min-flags> and <max-flags> should be space-separated lists of compiler</max-flags></min-flags>
|
|
|
385871 |
## warning flags to use with --enable-warnings=min or --enable-warnings=max,
|
|
|
385871 |
## respectively. Warning level "fatal" is the same as "max" but in addition
|
|
|
385871 |
## enables -Werror mode.
|
|
|
385871 |
##
|
|
|
385871 |
## If not empty, <deprecation-prefixes> should be a list of module prefixes</deprecation-prefixes>
|
|
|
385871 |
## which is expanded to -D<module>_DISABLE_DEPRECATED flags if fatal warnings</module>
|
|
|
385871 |
## are enabled, too.
|
|
|
385871 |
##
|
|
|
385871 |
AC_DEFUN([DK_ARG_ENABLE_WARNINGS],
|
|
|
385871 |
[dnl
|
|
|
385871 |
m4_if([$3],, [AC_FATAL([3 arguments expected])])[]dnl
|
|
|
385871 |
dnl
|
|
|
385871 |
AC_ARG_ENABLE([warnings], [AS_HELP_STRING(
|
|
|
385871 |
[--enable-warnings=@<:@min|max|fatal|no@:>@],
|
|
|
385871 |
[control compiler pickyness @<:@min@:>@])],
|
|
|
385871 |
[dk_enable_warnings=$enableval],
|
|
|
385871 |
[dk_enable_warnings=min])[]dnl
|
|
|
385871 |
|
|
|
385871 |
dk_lang=
|
|
|
385871 |
case $ac_compile in
|
|
|
385871 |
*'$CXXFLAGS '*)
|
|
|
385871 |
dk_lang='C++'
|
|
|
385871 |
dk_cc=$CXX
|
|
|
385871 |
dk_conftest=conftest.${ac_ext-cc}
|
|
|
385871 |
;;
|
|
|
385871 |
*'$CFLAGS '*)
|
|
|
385871 |
dk_lang=C
|
|
|
385871 |
dk_cc=$CC
|
|
|
385871 |
dk_conftest=conftest.${ac_ext-c}
|
|
|
385871 |
;;
|
|
|
385871 |
esac
|
|
|
385871 |
|
|
|
385871 |
AS_IF([test "x$dk_lang" != x],
|
|
|
385871 |
[
|
|
|
385871 |
AC_MSG_CHECKING([which $dk_lang compiler warning flags to use])
|
|
|
385871 |
|
|
|
385871 |
case $dk_enable_warnings in
|
|
|
385871 |
no) dk_warning_flags=;;
|
|
|
385871 |
max) dk_warning_flags="$3";;
|
|
|
385871 |
fatal) dk_warning_flags="$3 -Werror";;
|
|
|
385871 |
*) dk_warning_flags="$2";;
|
|
|
385871 |
esac
|
|
|
385871 |
|
|
|
385871 |
dk_deprecation_flags=
|
|
|
385871 |
m4_if([$4],,, [
|
|
|
385871 |
AS_IF([test "x$dk_enable_warnings" = xfatal],
|
|
|
385871 |
[
|
|
|
385871 |
dk_deprecation_prefixes="$4"
|
|
|
385871 |
for dk_prefix in $dk_deprecation_prefixes
|
|
|
385871 |
do
|
|
|
385871 |
dk_deprecation_flags="${dk_deprecation_flags}-D${dk_prefix}_DISABLE_DEPRECATED "
|
|
|
385871 |
done
|
|
|
385871 |
])
|
|
|
385871 |
])[]dnl
|
|
|
385871 |
dk_tested_flags=
|
|
|
385871 |
|
|
|
385871 |
AS_IF([test "x$dk_warning_flags" != x],
|
|
|
385871 |
[
|
|
|
385871 |
# Keep in mind that the dummy source must be devoid of any
|
|
|
385871 |
# problems that might cause diagnostics.
|
|
|
385871 |
AC_LANG_CONFTEST([AC_LANG_SOURCE(
|
|
|
385871 |
[[int main(int argc, char** argv) { return (argv != 0) ? argc : 0; }]])])
|
|
|
385871 |
|
|
|
385871 |
for dk_flag in $dk_warning_flags
|
|
|
385871 |
do
|
|
|
385871 |
# Test whether the compiler accepts the flag. GCC doesn't bail
|
|
|
385871 |
# out when given an unsupported flag but prints a warning, so
|
|
|
385871 |
# check the compiler output instead.
|
|
|
385871 |
dk_cc_out=`$dk_cc $dk_tested_flags $dk_flag -c "$dk_conftest" 2>&1 || echo failed`
|
|
|
385871 |
rm -f "conftest.${OBJEXT-o}"
|
|
|
385871 |
|
|
|
385871 |
AS_IF([test "x$dk_cc_out" = x],
|
|
|
385871 |
[
|
|
|
385871 |
AS_IF([test "x$dk_tested_flags" = x],
|
|
|
385871 |
[dk_tested_flags=$dk_flag],
|
|
|
385871 |
[dk_tested_flags="$dk_tested_flags $dk_flag"])
|
|
|
385871 |
], [
|
|
|
385871 |
echo "$dk_cc_out" >&AS_MESSAGE_LOG_FD
|
|
|
385871 |
])
|
|
|
385871 |
done
|
|
|
385871 |
|
|
|
385871 |
rm -f "$dk_conftest"
|
|
|
385871 |
])
|
|
|
385871 |
dk_all_flags=$dk_deprecation_flags$dk_tested_flags
|
|
|
385871 |
AC_SUBST([$1], [$dk_all_flags])
|
|
|
385871 |
|
|
|
385871 |
test "x$dk_all_flags" != x || dk_all_flags=none
|
|
|
385871 |
AC_MSG_RESULT([$dk_all_flags])
|
|
|
385871 |
])
|
|
|
385871 |
])
|