1557
1615
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
1558
1616
]) # XORG_COMPILER_BRAND
1618
# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
1620
# Minimum version: 1.16.0
1622
# Test if the compiler works when passed the given flag as a command line argument.
1623
# If it succeeds, the flag is appeneded to the given variable. If not, it tries the
1624
# next flag in the list until there are no more options.
1626
# Note that this does not guarantee that the compiler supports the flag as some
1627
# compilers will simply ignore arguments that they do not understand, but we do
1628
# attempt to weed out false positives by using -Werror=unknown-warning-option and
1629
# -Werror=unused-command-line-argument
1631
AC_DEFUN([XORG_TESTSET_CFLAG], [
1632
AC_REQUIRE([AC_PROG_CC_C99])
1633
m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
1634
m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
1636
xorg_testset_save_CFLAGS="$CFLAGS"
1638
if test "x$xorg_testset_unknown_warning_option" = "x" ; then
1639
CFLAGS="$CFLAGS -Werror=unknown-warning-option"
1640
AC_MSG_CHECKING([if $CC supports -Werror=unknown-warning-option])
1641
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
1642
[xorg_testset_unknown_warning_option=yes],
1643
[xorg_testset_unknown_warning_option=no])
1644
AC_MSG_RESULT([$xorg_testset_unknown_warning_option])
1645
CFLAGS="$xorg_testset_save_CFLAGS"
1648
if test "x$xorg_testset_unused_command_line_argument" = "x" ; then
1649
if test "x$xorg_testset_unknown_warning_option" = "xyes" ; then
1650
CFLAGS="$CFLAGS -Werror=unknown-warning-option"
1652
CFLAGS="$CFLAGS -Werror=unused-command-line-argument"
1653
AC_MSG_CHECKING([if $CC supports -Werror=unused-command-line-argument])
1654
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
1655
[xorg_testset_unused_command_line_argument=yes],
1656
[xorg_testset_unused_command_line_argument=no])
1657
AC_MSG_RESULT([$xorg_testset_unused_command_line_argument])
1658
CFLAGS="$xorg_testset_save_CFLAGS"
1662
m4_foreach([flag], m4_cdr($@), [
1663
if test $found = "no" ; then
1664
if test "x$xorg_testset_unknown_warning_option" = "xyes" ; then
1665
CFLAGS="$CFLAGS -Werror=unknown-warning-option"
1668
if test "x$xorg_testset_unused_command_line_argument" = "xyes" ; then
1669
CFLAGS="$CFLAGS -Werror=unused-command-line-argument"
1672
CFLAGS="$CFLAGS ]flag["
1674
AC_MSG_CHECKING([if $CC supports ]flag[])
1675
AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
1676
[supported=yes], [supported=no])
1677
AC_MSG_RESULT([$supported])
1678
CFLAGS="$xorg_testset_save_CFLAGS"
1680
if test "$supported" = "yes" ; then
1686
]) # XORG_TESTSET_CFLAG
1688
# XORG_COMPILER_FLAGS
1690
# Minimum version: 1.16.0
1692
# Defines BASE_CFLAGS to contain a set of command line arguments supported
1693
# by the selected compiler which do NOT alter the generated code. These
1694
# arguments will cause the compiler to print various warnings during
1695
# compilation AND turn a conservative set of warnings into errors.
1697
# The set of flags supported by BASE_CFLAGS will grow in future
1698
# versions of util-macros as options are added to new compilers.
1700
AC_DEFUN([XORG_COMPILER_FLAGS], [
1701
AC_REQUIRE([XORG_COMPILER_BRAND])
1703
AC_ARG_ENABLE(selective-werror,
1704
AS_HELP_STRING([--disable-selective-werror],
1705
[Turn off selective compiler errors. (default: enabled)]),
1706
[SELECTIVE_WERROR=$enableval],
1707
[SELECTIVE_WERROR=yes])
1709
# -v is too short to test reliably with XORG_TESTSET_CFLAG
1710
if test "x$SUNCC" = "xyes"; then
1716
# This chunk of warnings were those that existed in the legacy CWARNFLAGS
1717
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wall])
1718
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wpointer-arith])
1719
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wstrict-prototypes])
1720
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wmissing-prototypes])
1721
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wmissing-declarations])
1722
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wnested-externs])
1723
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wbad-function-cast])
1724
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wformat=2], [-Wformat])
1725
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wold-style-definition])
1726
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wdeclaration-after-statement])
1728
# This chunk adds additional warnings that could catch undesired effects.
1729
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wunused])
1730
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wuninitialized])
1731
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wshadow])
1732
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wcast-qual])
1733
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wmissing-noreturn])
1734
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wmissing-format-attribute])
1735
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wredundant-decls])
1737
# These are currently disabled because they are noisy. They will be enabled
1738
# in the future once the codebase is sufficiently modernized to silence
1739
# them. For now, I don't want them to drown out the other warnings.
1740
# XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wlogical-op])
1741
# XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wparentheses])
1742
# XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wcast-align])
1744
# Turn some warnings into errors, so we don't accidently get successful builds
1745
# when there are problems that should be fixed.
1747
if test "x$SELECTIVE_WERROR" = "xyes" ; then
1748
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
1749
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=nonnull])
1750
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=init-self])
1751
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=main])
1752
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=missing-braces])
1753
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=sequence-point])
1754
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
1755
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=trigraphs])
1756
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=array-bounds])
1757
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=write-strings])
1758
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=address])
1759
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
1760
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
1762
AC_MSG_WARN([You have chosen not to turn some select compiler warnings into errors. This should not be necessary. Please report why you needed to do so in a bug report at $PACKAGE_BUGREPORT])
1763
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wimplicit])
1764
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wnonnull])
1765
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Winit-self])
1766
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wmain])
1767
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wmissing-braces])
1768
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wsequence-point])
1769
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wreturn-type])
1770
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wtrigraphs])
1771
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Warray-bounds])
1772
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wwrite-strings])
1773
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Waddress])
1774
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wint-to-pointer-cast])
1775
XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wpointer-to-int-cast])
1778
AC_SUBST([BASE_CFLAGS])
1779
]) # XORG_COMPILER_FLAGS
1560
1781
# XORG_CWARNFLAGS
1561
1782
# ---------------
1562
1783
# Minimum version: 1.2.0
1784
# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
1564
1786
# Defines CWARNFLAGS to enable C compiler warnings.
1788
# This function is deprecated because it defines -fno-strict-aliasing
1789
# which alters the code generated by the compiler. If -fno-strict-aliasing
1790
# is needed, then it should be added explicitly in the module when
1791
# it is updated to use BASE_CFLAGS.
1566
1793
AC_DEFUN([XORG_CWARNFLAGS], [
1567
AC_REQUIRE([AC_PROG_CC_C99])
1794
AC_REQUIRE([XORG_COMPILER_FLAGS])
1568
1795
AC_REQUIRE([XORG_COMPILER_BRAND])
1796
CWARNFLAGS="$BASE_CFLAGS"
1569
1797
if test "x$GCC" = xyes ; then
1570
CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
1571
-Wmissing-declarations -Wnested-externs -fno-strict-aliasing \
1572
-Wbad-function-cast -Wformat=2"
1573
case `$CC -dumpversion` in
1575
CWARNFLAGS="$CWARNFLAGS -Wold-style-definition -Wdeclaration-after-statement"
1579
if test "x$SUNCC" = "xyes"; then
1798
CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
1583
1800
AC_SUBST(CWARNFLAGS)
1584
1801
]) # XORG_CWARNFLAGS
1590
1807
# Add configure option to enable strict compilation flags, such as treating
1591
1808
# warnings as fatal errors.
1592
1809
# If --enable-strict-compilation is passed to configure, adds strict flags to
1810
# $BASE_CFLAGS and the deprecated $CWARNFLAGS.
1595
1812
# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
1596
1813
# when strict compilation is unconditionally desired.
1597
1814
AC_DEFUN([XORG_STRICT_OPTION], [
1598
# If the module's configure.ac calls AC_PROG_CC later on, CC gets set to C89
1599
AC_REQUIRE([AC_PROG_CC_C99])
1600
AC_REQUIRE([XORG_COMPILER_BRAND])
1601
1815
AC_REQUIRE([XORG_CWARNFLAGS])
1816
AC_REQUIRE([XORG_COMPILER_FLAGS])
1603
1818
AC_ARG_ENABLE(strict-compilation,
1604
1819
AS_HELP_STRING([--enable-strict-compilation],
1605
1820
[Enable all warnings from compiler and make them errors (default: disabled)]),
1606
1821
[STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
1607
if test "x$GCC" = xyes ; then
1608
STRICT_CFLAGS="-pedantic -Werror"
1609
# Add -Werror=attributes if supported (gcc 4.2 & later)
1610
AC_MSG_CHECKING([if $CC supports -Werror=attributes])
1611
save_CFLAGS="$CFLAGS"
1612
CFLAGS="$CFLAGS $STRICT_CFLAGS -Werror=attributes"
1613
AC_COMPILE_IFELSE([AC_LANG_SOURCE([return 0;])],
1614
[STRICT_CFLAGS="$STRICT_CFLAGS -Werror=attributes"
1615
AC_MSG_RESULT([yes])],
1616
[AC_MSG_RESULT([no])])
1617
CFLAGS="$save_CFLAGS"
1618
elif test "x$SUNCC" = "xyes"; then
1619
STRICT_CFLAGS="-errwarn"
1620
elif test "x$INTELCC" = "xyes"; then
1621
STRICT_CFLAGS="-Werror"
1824
XORG_TESTSET_CFLAG([STRICT_CFLAGS], [-pedantic])
1825
XORG_TESTSET_CFLAG([STRICT_CFLAGS], [-Werror], [-errwarn])
1827
# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
1828
# activate it with -Werror, so we add it here explicitly.
1829
XORG_TESTSET_CFLAG([STRICT_CFLAGS], [-Werror=attributes])
1623
1831
if test "x$STRICT_COMPILE" = "xyes"; then
1832
BASE_CFLAGS="$BASE_CFLAGS $STRICT_CFLAGS"
1624
1833
CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
1626
1835
AC_SUBST([STRICT_CFLAGS])
1836
AC_SUBST([BASE_CFLAGS])
1627
1837
AC_SUBST([CWARNFLAGS])
1628
1838
]) # XORG_STRICT_OPTION
2574
2801
no) AM_DEFAULT_VERBOSITY=1;;
2575
2802
*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
2805
dnl A few `make' implementations (e.g., NonStop OS and NextStep)
2806
dnl do not support nested variable expansions.
2807
dnl See automake bug#9928 and bug#10237.
2808
am_make=${MAKE-make}
2809
AC_CACHE_CHECK([whether $am_make supports nested variables],
2810
[am_cv_make_support_nested_variables],
2811
[if AS_ECHO([['TRUE=$(BAR$(V))
2817
.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
2818
am_cv_make_support_nested_variables=yes
2820
am_cv_make_support_nested_variables=no
2822
if test $am_cv_make_support_nested_variables = yes; then
2823
dnl Using `$V' instead of `$(V)' breaks IRIX make.
2825
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
2827
AM_V=$AM_DEFAULT_VERBOSITY
2828
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
2831
AM_SUBST_NOTMAKE([AM_V])dnl
2832
AC_SUBST([AM_DEFAULT_V])dnl
2833
AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
2577
2834
AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
2578
2835
AM_BACKSLASH='\'
2579
2836
AC_SUBST([AM_BACKSLASH])dnl
2580
2837
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
2583
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
2840
# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
2585
2842
# This file is free software; the Free Software Foundation
2586
2843
# gives unlimited permission to copy and/or distribute it,
2587
2844
# with or without modifications, as long as this notice is preserved.
2589
2848
# AM_PROG_INSTALL_STRIP
2590
2849
# ---------------------
2591
2850
# One issue with vendor `install' (even GNU) is that you can't