~ubuntu-branches/ubuntu/precise/xutils-dev/precise

« back to all changes in this revision

Viewing changes to makedepend/aclocal.m4

  • Committer: Package Import Robot
  • Author(s): Julien Cristau, Robert Hooker, Julien Cristau
  • Date: 2012-03-14 20:07:57 UTC
  • Revision ID: package-import@ubuntu.com-20120314200757-pjffob485msoqrwm
Tags: 1:7.7~1
[ Robert Hooker ]
* imake 1.0.5
* makedepend 1.0.4
* lndir 1.0.3
* Bump x11proto-core-dev build dep version, required by the lndir
  update.
* util-macros 1.17.0

[ Julien Cristau ]
* Don't require (fake)root for debian/rules clean.
* Build-Depend on autoconf to work around lack of AM_MAINTAINER_MODE in
  makedepend's configure.ac.
* Bump version number as we're nearing X.Org X11R7.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
988
988
AC_SUBST([am__untar])
989
989
]) # _AM_PROG_TAR
990
990
 
 
991
# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
 
992
 
993
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
 
994
#
 
995
# This program is free software; you can redistribute it and/or modify
 
996
# it under the terms of the GNU General Public License as published by
 
997
# the Free Software Foundation; either version 2 of the License, or
 
998
# (at your option) any later version.
 
999
#
 
1000
# This program is distributed in the hope that it will be useful, but
 
1001
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
1002
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
1003
# General Public License for more details.
 
1004
#
 
1005
# You should have received a copy of the GNU General Public License
 
1006
# along with this program; if not, write to the Free Software
 
1007
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
1008
#
 
1009
# As a special exception to the GNU General Public License, if you
 
1010
# distribute this file as part of a program that contains a
 
1011
# configuration script generated by Autoconf, you may include it under
 
1012
# the same distribution terms that you use for the rest of that program.
 
1013
 
 
1014
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
 
1015
# ----------------------------------
 
1016
AC_DEFUN([PKG_PROG_PKG_CONFIG],
 
1017
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
 
1018
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
 
1019
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
 
1020
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
 
1021
        AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
 
1022
fi
 
1023
if test -n "$PKG_CONFIG"; then
 
1024
        _pkg_min_version=m4_default([$1], [0.9.0])
 
1025
        AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
 
1026
        if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
 
1027
                AC_MSG_RESULT([yes])
 
1028
        else
 
1029
                AC_MSG_RESULT([no])
 
1030
                PKG_CONFIG=""
 
1031
        fi
 
1032
                
 
1033
fi[]dnl
 
1034
])# PKG_PROG_PKG_CONFIG
 
1035
 
 
1036
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 
1037
#
 
1038
# Check to see whether a particular set of modules exists.  Similar
 
1039
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
 
1040
#
 
1041
#
 
1042
# Similar to PKG_CHECK_MODULES, make sure that the first instance of
 
1043
# this or PKG_CHECK_MODULES is called, or make sure to call
 
1044
# PKG_CHECK_EXISTS manually
 
1045
# --------------------------------------------------------------
 
1046
AC_DEFUN([PKG_CHECK_EXISTS],
 
1047
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 
1048
if test -n "$PKG_CONFIG" && \
 
1049
    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
 
1050
  m4_ifval([$2], [$2], [:])
 
1051
m4_ifvaln([$3], [else
 
1052
  $3])dnl
 
1053
fi])
 
1054
 
 
1055
 
 
1056
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
 
1057
# ---------------------------------------------
 
1058
m4_define([_PKG_CONFIG],
 
1059
[if test -n "$$1"; then
 
1060
    pkg_cv_[]$1="$$1"
 
1061
 elif test -n "$PKG_CONFIG"; then
 
1062
    PKG_CHECK_EXISTS([$3],
 
1063
                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
 
1064
                     [pkg_failed=yes])
 
1065
 else
 
1066
    pkg_failed=untried
 
1067
fi[]dnl
 
1068
])# _PKG_CONFIG
 
1069
 
 
1070
# _PKG_SHORT_ERRORS_SUPPORTED
 
1071
# -----------------------------
 
1072
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
 
1073
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
 
1074
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
 
1075
        _pkg_short_errors_supported=yes
 
1076
else
 
1077
        _pkg_short_errors_supported=no
 
1078
fi[]dnl
 
1079
])# _PKG_SHORT_ERRORS_SUPPORTED
 
1080
 
 
1081
 
 
1082
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
 
1083
# [ACTION-IF-NOT-FOUND])
 
1084
#
 
1085
#
 
1086
# Note that if there is a possibility the first call to
 
1087
# PKG_CHECK_MODULES might not happen, you should be sure to include an
 
1088
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
 
1089
#
 
1090
#
 
1091
# --------------------------------------------------------------
 
1092
AC_DEFUN([PKG_CHECK_MODULES],
 
1093
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 
1094
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
 
1095
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
 
1096
 
 
1097
pkg_failed=no
 
1098
AC_MSG_CHECKING([for $1])
 
1099
 
 
1100
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
 
1101
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
 
1102
 
 
1103
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
 
1104
and $1[]_LIBS to avoid the need to call pkg-config.
 
1105
See the pkg-config man page for more details.])
 
1106
 
 
1107
if test $pkg_failed = yes; then
 
1108
        _PKG_SHORT_ERRORS_SUPPORTED
 
1109
        if test $_pkg_short_errors_supported = yes; then
 
1110
                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
 
1111
        else 
 
1112
                $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
 
1113
        fi
 
1114
        # Put the nasty error message in config.log where it belongs
 
1115
        echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
 
1116
 
 
1117
        ifelse([$4], , [AC_MSG_ERROR(dnl
 
1118
[Package requirements ($2) were not met:
 
1119
 
 
1120
$$1_PKG_ERRORS
 
1121
 
 
1122
Consider adjusting the PKG_CONFIG_PATH environment variable if you
 
1123
installed software in a non-standard prefix.
 
1124
 
 
1125
_PKG_TEXT
 
1126
])],
 
1127
                [AC_MSG_RESULT([no])
 
1128
                $4])
 
1129
elif test $pkg_failed = untried; then
 
1130
        ifelse([$4], , [AC_MSG_FAILURE(dnl
 
1131
[The pkg-config script could not be found or is too old.  Make sure it
 
1132
is in your PATH or set the PKG_CONFIG environment variable to the full
 
1133
path to pkg-config.
 
1134
 
 
1135
_PKG_TEXT
 
1136
 
 
1137
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
 
1138
                [$4])
 
1139
else
 
1140
        $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
 
1141
        $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
 
1142
        AC_MSG_RESULT([yes])
 
1143
        ifelse([$3], , :, [$3])
 
1144
fi[]dnl
 
1145
])# PKG_CHECK_MODULES
 
1146
 
991
1147
dnl xorg-macros.m4.  Generated from xorg-macros.m4.in xorgversion.m4 by configure.
992
1148
dnl
993
1149
dnl Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
1027
1183
# See the "minimum version" comment for each macro you use to see what 
1028
1184
# version you require.
1029
1185
m4_defun([XORG_MACROS_VERSION],[
1030
 
m4_define([vers_have], [1.11.0])
 
1186
m4_define([vers_have], [1.16.2])
1031
1187
m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
1032
1188
m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
1033
1189
m4_if(m4_cmp(maj_have, maj_needed), 0,,
1054
1210
# which is not the best choice for supporting other OS'es, but covers most
1055
1211
# of the ones we need for now.
1056
1212
AC_MSG_CHECKING([if $RAWCPP requires -undef])
1057
 
AC_LANG_CONFTEST([Does cpp redefine unix ?])
 
1213
AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
1058
1214
if test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
1059
1215
        AC_MSG_RESULT([no])
1060
1216
else
1072
1228
rm -f conftest.$ac_ext
1073
1229
 
1074
1230
AC_MSG_CHECKING([if $RAWCPP requires -traditional])
1075
 
AC_LANG_CONFTEST([Does cpp preserve   "whitespace"?])
 
1231
AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
1076
1232
if test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
1077
1233
        AC_MSG_RESULT([no])
1078
1234
else
1422
1578
AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
1423
1579
]) # XORG_WITH_XMLTO
1424
1580
 
 
1581
# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
 
1582
# --------------------------------------------
 
1583
# Minimum version: 1.12.0
 
1584
# Minimum version for optional DEFAULT argument: 1.12.0
 
1585
#
 
1586
# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
 
1587
# XML-based language used for the transformation of XML documents.
 
1588
# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
 
1589
# It is used under the cover by xmlto to generate html files from DocBook/XML.
 
1590
# The XSLT processor is often used as a standalone tool for transformations.
 
1591
# It should not be assumed that this tool is used only to work with documnetation.
 
1592
# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
 
1593
#
 
1594
# Interface to module:
 
1595
# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
 
1596
# XSLTPROC:      returns the path of the xsltproc program found
 
1597
#                returns the path set by the user in the environment
 
1598
# --with-xsltproc: 'yes' user instructs the module to use xsltproc
 
1599
#                 'no' user instructs the module not to use xsltproc
 
1600
# have_xsltproc: returns yes if xsltproc found in PATH or no
 
1601
#
 
1602
# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
 
1603
#
 
1604
AC_DEFUN([XORG_WITH_XSLTPROC],[
 
1605
AC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
 
1606
# Preserves the interface, should it be implemented later
 
1607
m4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
 
1608
m4_define([_defopt], m4_default([$2], [auto]))
 
1609
AC_ARG_WITH(xsltproc,
 
1610
        AS_HELP_STRING([--with-xsltproc],
 
1611
           [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
 
1612
           [use_xsltproc=$withval], [use_xsltproc=]_defopt)
 
1613
m4_undefine([_defopt])
 
1614
 
 
1615
if test "x$use_xsltproc" = x"auto"; then
 
1616
   AC_PATH_PROG([XSLTPROC], [xsltproc])
 
1617
   if test "x$XSLTPROC" = "x"; then
 
1618
        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
 
1619
        have_xsltproc=no
 
1620
   else
 
1621
        have_xsltproc=yes
 
1622
   fi
 
1623
elif test "x$use_xsltproc" = x"yes" ; then
 
1624
   AC_PATH_PROG([XSLTPROC], [xsltproc])
 
1625
   if test "x$XSLTPROC" = "x"; then
 
1626
        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
 
1627
   fi
 
1628
   have_xsltproc=yes
 
1629
elif test "x$use_xsltproc" = x"no" ; then
 
1630
   if test "x$XSLTPROC" != "x"; then
 
1631
      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
 
1632
   fi
 
1633
   have_xsltproc=no
 
1634
else
 
1635
   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
 
1636
fi
 
1637
 
 
1638
AM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
 
1639
]) # XORG_WITH_XSLTPROC
 
1640
 
 
1641
# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
 
1642
# ----------------------------------------
 
1643
# Minimum version: 1.15.0
 
1644
#
 
1645
# PERL (Practical Extraction and Report Language) is a language optimized for
 
1646
# scanning arbitrary text files, extracting information from those text files,
 
1647
# and printing reports based on that information.
 
1648
#
 
1649
# When DEFAULT is not specified, --with-perl assumes 'auto'.
 
1650
#
 
1651
# Interface to module:
 
1652
# HAVE_PERL: used in makefiles to conditionally scan text files
 
1653
# PERL:      returns the path of the perl program found
 
1654
#            returns the path set by the user in the environment
 
1655
# --with-perl: 'yes' user instructs the module to use perl
 
1656
#              'no' user instructs the module not to use perl
 
1657
# have_perl: returns yes if perl found in PATH or no
 
1658
#
 
1659
# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
 
1660
#
 
1661
AC_DEFUN([XORG_WITH_PERL],[
 
1662
AC_ARG_VAR([PERL], [Path to perl command])
 
1663
# Preserves the interface, should it be implemented later
 
1664
m4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
 
1665
m4_define([_defopt], m4_default([$2], [auto]))
 
1666
AC_ARG_WITH(perl,
 
1667
        AS_HELP_STRING([--with-perl],
 
1668
           [Use perl for extracting information from files (default: ]_defopt[)]),
 
1669
           [use_perl=$withval], [use_perl=]_defopt)
 
1670
m4_undefine([_defopt])
 
1671
 
 
1672
if test "x$use_perl" = x"auto"; then
 
1673
   AC_PATH_PROG([PERL], [perl])
 
1674
   if test "x$PERL" = "x"; then
 
1675
        AC_MSG_WARN([perl not found - cannot extract information and report])
 
1676
        have_perl=no
 
1677
   else
 
1678
        have_perl=yes
 
1679
   fi
 
1680
elif test "x$use_perl" = x"yes" ; then
 
1681
   AC_PATH_PROG([PERL], [perl])
 
1682
   if test "x$PERL" = "x"; then
 
1683
        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
 
1684
   fi
 
1685
   have_perl=yes
 
1686
elif test "x$use_perl" = x"no" ; then
 
1687
   if test "x$PERL" != "x"; then
 
1688
      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
 
1689
   fi
 
1690
   have_perl=no
 
1691
else
 
1692
   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
 
1693
fi
 
1694
 
 
1695
AM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
 
1696
]) # XORG_WITH_PERL
 
1697
 
1425
1698
# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
1426
1699
# ----------------
1427
1700
# Minimum version: 1.5.0
1667
1940
AM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
1668
1941
]) # XORG_WITH_GROFF
1669
1942
 
1670
 
# XORG_WITH_FOP([DEFAULT])
1671
 
# ----------------
 
1943
# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
 
1944
# ---------------------------------------
1672
1945
# Minimum version: 1.6.0
1673
1946
# Minimum version for optional DEFAULT argument: 1.11.0
 
1947
# Minimum version for optional MIN-VERSION argument: 1.15.0
1674
1948
#
1675
1949
# Documentation tools are not always available on all platforms and sometimes
1676
1950
# not at the appropriate level. This macro enables a module to test for the
1690
1964
#
1691
1965
AC_DEFUN([XORG_WITH_FOP],[
1692
1966
AC_ARG_VAR([FOP], [Path to fop command])
1693
 
m4_define([_defopt], m4_default([$1], [auto]))
 
1967
m4_define([_defopt], m4_default([$2], [auto]))
1694
1968
AC_ARG_WITH(fop,
1695
1969
        AS_HELP_STRING([--with-fop],
1696
1970
           [Use fop to regenerate documentation (default: ]_defopt[)]),
1719
1993
else
1720
1994
   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
1721
1995
fi
 
1996
 
 
1997
# Test for a minimum version of fop, if provided.
 
1998
m4_ifval([$1],
 
1999
[if test "$have_fop" = yes; then
 
2000
    # scrape the fop version
 
2001
    AC_MSG_CHECKING([for fop minimum version])
 
2002
    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
 
2003
    AC_MSG_RESULT([$fop_version])
 
2004
    AS_VERSION_COMPARE([$fop_version], [$1],
 
2005
        [if test "x$use_fop" = xauto; then
 
2006
            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
 
2007
            have_fop=no
 
2008
        else
 
2009
            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
 
2010
        fi])
 
2011
fi])
1722
2012
AM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
1723
2013
]) # XORG_WITH_FOP
1724
2014
 
1801
2091
# parm1:        specify the default value, yes or no.
1802
2092
#
1803
2093
AC_DEFUN([XORG_ENABLE_DOCS],[
1804
 
m4_define([default], m4_default([$1], [yes]))
 
2094
m4_define([docs_default], m4_default([$1], [yes]))
1805
2095
AC_ARG_ENABLE(docs,
1806
2096
        AS_HELP_STRING([--enable-docs],
1807
 
           [Enable building the documentation (default: ]default[)]),
1808
 
           [build_docs=$enableval], [build_docs=]default)
1809
 
m4_undefine([default])
 
2097
           [Enable building the documentation (default: ]docs_default[)]),
 
2098
           [build_docs=$enableval], [build_docs=]docs_default)
 
2099
m4_undefine([docs_default])
1810
2100
AM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
1811
2101
AC_MSG_CHECKING([whether to build documentation])
1812
2102
AC_MSG_RESULT([$build_docs])
1878
2168
AC_MSG_RESULT([$build_specs])
1879
2169
]) # XORG_ENABLE_SPECS
1880
2170
 
 
2171
# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
 
2172
# ----------------------------------------------
 
2173
# Minimum version: 1.13.0
 
2174
#
 
2175
# This macro enables a builder to enable/disable unit testing
 
2176
# It makes no assumption about the test cases implementation
 
2177
# Test cases may or may not use Automake "Support for test suites"
 
2178
# They may or may not use the software utility library GLib
 
2179
#
 
2180
# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
 
2181
# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
 
2182
# The variable enable_unit_tests is used by other macros in this file.
 
2183
#
 
2184
# Interface to module:
 
2185
# ENABLE_UNIT_TESTS:    used in makefiles to conditionally build tests
 
2186
# enable_unit_tests:    used in configure.ac for additional configuration
 
2187
# --enable-unit-tests:  'yes' user instructs the module to build tests
 
2188
#                       'no' user instructs the module not to build tests
 
2189
# parm1:                specify the default value, yes or no.
 
2190
#
 
2191
AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
 
2192
AC_BEFORE([$0], [XORG_WITH_GLIB])
 
2193
AC_BEFORE([$0], [XORG_LD_WRAP])
 
2194
AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
 
2195
m4_define([_defopt], m4_default([$1], [auto]))
 
2196
AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
 
2197
        [Enable building unit test cases (default: ]_defopt[)]),
 
2198
        [enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
 
2199
m4_undefine([_defopt])
 
2200
AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
 
2201
AC_MSG_CHECKING([whether to build unit test cases])
 
2202
AC_MSG_RESULT([$enable_unit_tests])
 
2203
]) # XORG_ENABLE_UNIT_TESTS
 
2204
 
 
2205
# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
 
2206
# ----------------------------------------
 
2207
# Minimum version: 1.13.0
 
2208
#
 
2209
# GLib is a library which provides advanced data structures and functions.
 
2210
# This macro enables a module to test for the presence of Glib.
 
2211
#
 
2212
# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
 
2213
# Otherwise the value of $enable_unit_tests is blank.
 
2214
#
 
2215
# Interface to module:
 
2216
# HAVE_GLIB: used in makefiles to conditionally build targets
 
2217
# with_glib: used in configure.ac to know if GLib has been found
 
2218
# --with-glib:  'yes' user instructs the module to use glib
 
2219
#               'no' user instructs the module not to use glib
 
2220
#
 
2221
AC_DEFUN([XORG_WITH_GLIB],[
 
2222
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
 
2223
m4_define([_defopt], m4_default([$2], [auto]))
 
2224
AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
 
2225
        [Use GLib library for unit testing (default: ]_defopt[)]),
 
2226
        [with_glib=$withval], [with_glib=]_defopt)
 
2227
m4_undefine([_defopt])
 
2228
 
 
2229
have_glib=no
 
2230
# Do not probe GLib if user explicitly disabled unit testing
 
2231
if test "x$enable_unit_tests" != x"no"; then
 
2232
  # Do not probe GLib if user explicitly disabled it
 
2233
  if test "x$with_glib" != x"no"; then
 
2234
    m4_ifval(
 
2235
      [$1],
 
2236
      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
 
2237
      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
 
2238
    )
 
2239
  fi
 
2240
fi
 
2241
 
 
2242
# Not having GLib when unit testing has been explicitly requested is an error
 
2243
if test "x$enable_unit_tests" = x"yes"; then
 
2244
  if test "x$have_glib" = x"no"; then
 
2245
    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
 
2246
  fi
 
2247
fi
 
2248
 
 
2249
# Having unit testing disabled when GLib has been explicitly requested is an error
 
2250
if test "x$enable_unit_tests" = x"no"; then
 
2251
  if test "x$with_glib" = x"yes"; then
 
2252
    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
 
2253
  fi
 
2254
fi
 
2255
 
 
2256
# Not having GLib when it has been explicitly requested is an error
 
2257
if test "x$with_glib" = x"yes"; then
 
2258
  if test "x$have_glib" = x"no"; then
 
2259
    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
 
2260
  fi
 
2261
fi
 
2262
 
 
2263
AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
 
2264
]) # XORG_WITH_GLIB
 
2265
 
 
2266
# XORG_LD_WRAP([required|optional])
 
2267
# ---------------------------------
 
2268
# Minimum version: 1.13.0
 
2269
#
 
2270
# Check if linker supports -wrap, passed via compiler flags
 
2271
#
 
2272
# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
 
2273
# Otherwise the value of $enable_unit_tests is blank.
 
2274
#
 
2275
# Argument added in 1.16.0 - default is "required", to match existing behavior
 
2276
# of returning an error if enable_unit_tests is yes, and ld -wrap is not
 
2277
# available, an argument of "optional" allows use when some unit tests require
 
2278
# ld -wrap and others do not.
 
2279
#
 
2280
AC_DEFUN([XORG_LD_WRAP],[
 
2281
XORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
 
2282
    [AC_LANG_PROGRAM([#include <stdlib.h>
 
2283
                      void __wrap_exit(int status) { return; }],
 
2284
                     [exit(0);])])
 
2285
# Not having ld wrap when unit testing has been explicitly requested is an error
 
2286
if test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
 
2287
  if test "x$have_ld_wrap" = x"no"; then
 
2288
    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
 
2289
  fi
 
2290
fi
 
2291
AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
 
2292
#
 
2293
]) # XORG_LD_WRAP
 
2294
 
 
2295
# XORG_CHECK_LINKER_FLAGS
 
2296
# -----------------------
 
2297
# SYNOPSIS
 
2298
#
 
2299
#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
 
2300
#
 
2301
# DESCRIPTION
 
2302
#
 
2303
#   Check whether the given linker FLAGS work with the current language's
 
2304
#   linker, or whether they give an error.
 
2305
#
 
2306
#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
 
2307
#   success/failure.
 
2308
#
 
2309
#   PROGRAM-SOURCE is the program source to link with, if needed
 
2310
#
 
2311
#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
 
2312
#
 
2313
# LICENSE
 
2314
#
 
2315
#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
 
2316
#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
 
2317
#   Copyright (c) 2009 Matteo Frigo
 
2318
#
 
2319
#   This program is free software: you can redistribute it and/or modify it
 
2320
#   under the terms of the GNU General Public License as published by the
 
2321
#   Free Software Foundation, either version 3 of the License, or (at your
 
2322
#   option) any later version.
 
2323
#
 
2324
#   This program is distributed in the hope that it will be useful, but
 
2325
#   WITHOUT ANY WARRANTY; without even the implied warranty of
 
2326
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 
2327
#   Public License for more details.
 
2328
#
 
2329
#   You should have received a copy of the GNU General Public License along
 
2330
#   with this program. If not, see <http://www.gnu.org/licenses/>.
 
2331
#
 
2332
#   As a special exception, the respective Autoconf Macro's copyright owner
 
2333
#   gives unlimited permission to copy, distribute and modify the configure
 
2334
#   scripts that are the output of Autoconf when processing the Macro. You
 
2335
#   need not follow the terms of the GNU General Public License when using
 
2336
#   or distributing such scripts, even though portions of the text of the
 
2337
#   Macro appear in them. The GNU General Public License (GPL) does govern
 
2338
#   all other use of the material that constitutes the Autoconf Macro.
 
2339
#
 
2340
#   This special exception to the GPL applies to versions of the Autoconf
 
2341
#   Macro released by the Autoconf Archive. When you make and distribute a
 
2342
#   modified version of the Autoconf Macro, you may extend this special
 
2343
#   exception to the GPL to apply to your modified version as well.#
 
2344
AC_DEFUN([XORG_CHECK_LINKER_FLAGS],
 
2345
[AC_MSG_CHECKING([whether the linker accepts $1])
 
2346
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
 
2347
AS_LITERAL_IF([$1],
 
2348
  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
 
2349
      ax_save_FLAGS=$LDFLAGS
 
2350
      LDFLAGS="$1"
 
2351
      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
 
2352
        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
 
2353
        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
 
2354
      LDFLAGS=$ax_save_FLAGS])],
 
2355
  [ax_save_FLAGS=$LDFLAGS
 
2356
   LDFLAGS="$1"
 
2357
   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
 
2358
     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
 
2359
     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
 
2360
   LDFLAGS=$ax_save_FLAGS])
 
2361
eval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
 
2362
AC_MSG_RESULT($xorg_check_linker_flags)
 
2363
if test "x$xorg_check_linker_flags" = xyes; then
 
2364
        m4_default([$2], :)
 
2365
else
 
2366
        m4_default([$3], :)
 
2367
fi
 
2368
]) # XORG_CHECK_LINKER_FLAGS
 
2369
 
 
2370
# XORG_MEMORY_CHECK_FLAGS
 
2371
# -----------------------
 
2372
# Minimum version: 1.16.0
 
2373
#
 
2374
# This macro attempts to find appropriate memory checking functionality
 
2375
# for various platforms which unit testing code may use to catch various
 
2376
# forms of memory allocation and access errors in testing.
 
2377
#
 
2378
# Interface to module:
 
2379
# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
 
2380
#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
 
2381
#
 
2382
# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
 
2383
#
 
2384
AC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
 
2385
 
 
2386
AC_REQUIRE([AC_CANONICAL_HOST])
 
2387
AC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
 
2388
           [Environment variables to enable memory checking in tests])
 
2389
 
 
2390
# Check for different types of support on different platforms
 
2391
case $host_os in
 
2392
    solaris*)
 
2393
        AC_CHECK_LIB([umem], [umem_alloc],
 
2394
            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
 
2395
        ;;
 
2396
    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
 
2397
        # both directly and inverted, so should not be 0 or 255.
 
2398
        malloc_debug_env='MALLOC_PERTURB_=15'
 
2399
        ;;
 
2400
    darwin*)
 
2401
        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
 
2402
        ;;
 
2403
    *bsd*)
 
2404
        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
 
2405
        ;;
 
2406
esac
 
2407
 
 
2408
# User supplied flags override default flags
 
2409
if test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
 
2410
    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
 
2411
fi
 
2412
 
 
2413
AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
 
2414
]) # XORG_WITH_LINT
 
2415
 
1881
2416
# XORG_CHECK_MALLOC_ZERO
1882
2417
# ----------------------
1883
2418
# Minimum version: 1.0.0
1894
2429
 
1895
2430
AC_MSG_CHECKING([whether malloc(0) returns NULL])
1896
2431
if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
1897
 
        AC_RUN_IFELSE([
1898
 
char *malloc();
1899
 
char *realloc();
1900
 
char *calloc();
1901
 
main() {
 
2432
        AC_RUN_IFELSE([AC_LANG_PROGRAM([
 
2433
#include <stdlib.h>
 
2434
],[
1902
2435
    char *m0, *r0, *c0, *p;
1903
2436
    m0 = malloc(0);
1904
2437
    p = malloc(10);
1905
2438
    r0 = realloc(p,0);
1906
 
    c0 = calloc(0);
1907
 
    exit(m0 == 0 || r0 == 0 || c0 == 0 ? 0 : 1);
1908
 
}],
 
2439
    c0 = calloc(0,10);
 
2440
    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
 
2441
])],
1909
2442
                [MALLOC_ZERO_RETURNS_NULL=yes],
1910
2443
                [MALLOC_ZERO_RETURNS_NULL=no],
1911
2444
                [MALLOC_ZERO_RETURNS_NULL=yes])
2031
2564
 
2032
2565
]) # XORG_LINT_LIBRARY
2033
2566
 
 
2567
# XORG_COMPILER_BRAND
 
2568
# -------------------
 
2569
# Minimum version: 1.14.0
 
2570
#
 
2571
# Checks for various brands of compilers and sets flags as appropriate:
 
2572
#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
 
2573
#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
 
2574
#   clang compiler - sets CLANGCC to "yes"
 
2575
#   Intel compiler - sets INTELCC to "yes"
 
2576
#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
 
2577
#
 
2578
AC_DEFUN([XORG_COMPILER_BRAND], [
 
2579
AC_LANG_CASE(
 
2580
        [C], [
 
2581
                AC_REQUIRE([AC_PROG_CC_C99])
 
2582
        ],
 
2583
        [C++], [
 
2584
                AC_REQUIRE([AC_PROG_CXX])
 
2585
        ]
 
2586
)
 
2587
AC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
 
2588
AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
 
2589
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
 
2590
]) # XORG_COMPILER_BRAND
 
2591
 
 
2592
# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
 
2593
# ---------------
 
2594
# Minimum version: 1.16.0
 
2595
#
 
2596
# Test if the compiler works when passed the given flag as a command line argument.
 
2597
# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
 
2598
# next flag in the list until there are no more options.
 
2599
#
 
2600
# Note that this does not guarantee that the compiler supports the flag as some
 
2601
# compilers will simply ignore arguments that they do not understand, but we do
 
2602
# attempt to weed out false positives by using -Werror=unknown-warning-option and
 
2603
# -Werror=unused-command-line-argument
 
2604
#
 
2605
AC_DEFUN([XORG_TESTSET_CFLAG], [
 
2606
m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
 
2607
m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
 
2608
 
 
2609
AC_LANG_COMPILER_REQUIRE
 
2610
 
 
2611
AC_LANG_CASE(
 
2612
        [C], [
 
2613
                AC_REQUIRE([AC_PROG_CC_C99])
 
2614
                define([PREFIX], [C])
 
2615
        ],
 
2616
        [C++], [
 
2617
                define([PREFIX], [CXX])
 
2618
        ]
 
2619
)
 
2620
 
 
2621
[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
 
2622
 
 
2623
if test "x$xorg_testset_unknown_warning_option" = "x" ; then
 
2624
        PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
 
2625
        AC_CACHE_CHECK([if compiler supports -Werror=unknown-warning-option],
 
2626
                        xorg_cv_compiler_flag_unknown_warning_option,
 
2627
                        AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
 
2628
                                          [xorg_cv_compiler_flag_unknown_warning_option=yes],
 
2629
                                          [xorg_cv_compiler_flag_unknown_warning_option=no]))
 
2630
        xorg_testset_unknown_warning_option=$xorg_cv_compiler_flag_unknown_warning_option
 
2631
        PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
 
2632
fi
 
2633
 
 
2634
if test "x$xorg_testset_unused_command_line_argument" = "x" ; then
 
2635
        if test "x$xorg_testset_unknown_warning_option" = "xyes" ; then
 
2636
                PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
 
2637
        fi
 
2638
        PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
 
2639
        AC_CACHE_CHECK([if compiler supports -Werror=unused-command-line-argument],
 
2640
                        xorg_cv_compiler_flag_unused_command_line_argument,
 
2641
                        AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
 
2642
                                          [xorg_cv_compiler_flag_unused_command_line_argument=yes],
 
2643
                                          [xorg_cv_compiler_flag_unused_command_line_argument=no]))
 
2644
        xorg_testset_unused_command_line_argument=$xorg_cv_compiler_flag_unused_command_line_argument
 
2645
        PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
 
2646
fi
 
2647
 
 
2648
found="no"
 
2649
m4_foreach([flag], m4_cdr($@), [
 
2650
        if test $found = "no" ; then
 
2651
                if test "x$xorg_testset_unknown_warning_option" = "xyes" ; then
 
2652
                        PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
 
2653
                fi
 
2654
 
 
2655
                if test "x$xorg_testset_unused_command_line_argument" = "xyes" ; then
 
2656
                        PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
 
2657
                fi
 
2658
 
 
2659
                PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
 
2660
 
 
2661
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
 
2662
                AC_MSG_CHECKING([if $CC supports ]flag[])
 
2663
                cacheid=`AS_ECHO([xorg_cv_cc_flag_]flag[])`
 
2664
                AC_CACHE_VAL(AS_TR_SH($cacheid),
 
2665
                             [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
 
2666
                                             [eval AS_TR_SH($cacheid)=yes],
 
2667
                                             [eval AS_TR_SH($cacheid)=no])])
 
2668
 
 
2669
                PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
 
2670
 
 
2671
                eval supported=$AS_TR_SH($cacheid)
 
2672
                AC_MSG_RESULT([$supported])
 
2673
                if test "$supported" = "yes" ; then
 
2674
                        $1="$$1 ]flag["
 
2675
                        found="yes"
 
2676
                fi
 
2677
        fi
 
2678
])
 
2679
]) # XORG_TESTSET_CFLAG
 
2680
 
 
2681
# XORG_COMPILER_FLAGS
 
2682
# ---------------
 
2683
# Minimum version: 1.16.0
 
2684
#
 
2685
# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
 
2686
# arguments supported by the selected compiler which do NOT alter the generated
 
2687
# code.  These arguments will cause the compiler to print various warnings
 
2688
# during compilation AND turn a conservative set of warnings into errors.
 
2689
#
 
2690
# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
 
2691
# future versions of util-macros as options are added to new compilers.
 
2692
#
 
2693
AC_DEFUN([XORG_COMPILER_FLAGS], [
 
2694
AC_REQUIRE([XORG_COMPILER_BRAND])
 
2695
 
 
2696
AC_ARG_ENABLE(selective-werror,
 
2697
              AS_HELP_STRING([--disable-selective-werror],
 
2698
                             [Turn off selective compiler errors. (default: enabled)]),
 
2699
              [SELECTIVE_WERROR=$enableval],
 
2700
              [SELECTIVE_WERROR=yes])
 
2701
 
 
2702
AC_LANG_CASE(
 
2703
        [C], [
 
2704
                define([PREFIX], [C])
 
2705
        ],
 
2706
        [C++], [
 
2707
                define([PREFIX], [CXX])
 
2708
        ]
 
2709
)
 
2710
# -v is too short to test reliably with XORG_TESTSET_CFLAG
 
2711
if test "x$SUNCC" = "xyes"; then
 
2712
    [BASE_]PREFIX[FLAGS]="-v"
 
2713
else
 
2714
    [BASE_]PREFIX[FLAGS]=""
 
2715
fi
 
2716
 
 
2717
# This chunk of warnings were those that existed in the legacy CWARNFLAGS
 
2718
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
 
2719
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
 
2720
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
 
2721
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
 
2722
 
 
2723
AC_LANG_CASE(
 
2724
        [C], [
 
2725
                XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
 
2726
                XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
 
2727
                XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
 
2728
                XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
 
2729
                XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition])
 
2730
                XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
 
2731
        ]
 
2732
)
 
2733
 
 
2734
# This chunk adds additional warnings that could catch undesired effects.
 
2735
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
 
2736
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
 
2737
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
 
2738
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
 
2739
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
 
2740
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
 
2741
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
 
2742
 
 
2743
# These are currently disabled because they are noisy.  They will be enabled
 
2744
# in the future once the codebase is sufficiently modernized to silence
 
2745
# them.  For now, I don't want them to drown out the other warnings.
 
2746
# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
 
2747
# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
 
2748
# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
 
2749
 
 
2750
# Turn some warnings into errors, so we don't accidently get successful builds
 
2751
# when there are problems that should be fixed.
 
2752
 
 
2753
if test "x$SELECTIVE_WERROR" = "xyes" ; then
 
2754
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
 
2755
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
 
2756
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
 
2757
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
 
2758
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
 
2759
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
 
2760
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
 
2761
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
 
2762
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
 
2763
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
 
2764
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
 
2765
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
 
2766
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
 
2767
else
 
2768
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])
 
2769
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
 
2770
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
 
2771
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
 
2772
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
 
2773
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
 
2774
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
 
2775
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
 
2776
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
 
2777
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
 
2778
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
 
2779
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
 
2780
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
 
2781
XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
 
2782
fi
 
2783
 
 
2784
AC_SUBST([BASE_]PREFIX[FLAGS])
 
2785
]) # XORG_COMPILER_FLAGS
 
2786
 
2034
2787
# XORG_CWARNFLAGS
2035
2788
# ---------------
2036
2789
# Minimum version: 1.2.0
 
2790
# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
2037
2791
#
2038
2792
# Defines CWARNFLAGS to enable C compiler warnings.
2039
2793
#
 
2794
# This function is deprecated because it defines -fno-strict-aliasing
 
2795
# which alters the code generated by the compiler.  If -fno-strict-aliasing
 
2796
# is needed, then it should be added explicitly in the module when
 
2797
# it is updated to use BASE_CFLAGS.
 
2798
#
2040
2799
AC_DEFUN([XORG_CWARNFLAGS], [
2041
 
AC_REQUIRE([AC_PROG_CC_C99])
2042
 
if  test "x$GCC" = xyes ; then
2043
 
    CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
2044
 
-Wmissing-declarations -Wnested-externs -fno-strict-aliasing \
2045
 
-Wbad-function-cast -Wformat=2"
2046
 
    case `$CC -dumpversion` in
2047
 
    3.4.* | 4.*)
2048
 
        CWARNFLAGS="$CWARNFLAGS -Wold-style-definition -Wdeclaration-after-statement"
2049
 
        ;;
2050
 
    esac
2051
 
else
2052
 
    AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
2053
 
    if test "x$SUNCC" = "xyes"; then
2054
 
        CWARNFLAGS="-v"
2055
 
    fi
2056
 
fi
2057
 
AC_SUBST(CWARNFLAGS)
 
2800
AC_REQUIRE([XORG_COMPILER_FLAGS])
 
2801
AC_REQUIRE([XORG_COMPILER_BRAND])
 
2802
AC_LANG_CASE(
 
2803
        [C], [
 
2804
                CWARNFLAGS="$BASE_CFLAGS"
 
2805
                if  test "x$GCC" = xyes ; then
 
2806
                    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
 
2807
                fi
 
2808
                AC_SUBST(CWARNFLAGS)
 
2809
        ]
 
2810
)
2058
2811
]) # XORG_CWARNFLAGS
2059
2812
 
2060
2813
# XORG_STRICT_OPTION
2061
2814
# -----------------------
2062
2815
# Minimum version: 1.3.0
2063
2816
#
2064
 
# Add configure option to enable strict compilation
 
2817
# Add configure option to enable strict compilation flags, such as treating
 
2818
# warnings as fatal errors.
 
2819
# If --enable-strict-compilation is passed to configure, adds strict flags to
 
2820
# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
 
2821
#
 
2822
# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
 
2823
# when strict compilation is unconditionally desired.
2065
2824
AC_DEFUN([XORG_STRICT_OPTION], [
2066
 
# If the module's configure.ac calls AC_PROG_CC later on, CC gets set to C89
2067
 
AC_REQUIRE([AC_PROG_CC_C99])
2068
2825
AC_REQUIRE([XORG_CWARNFLAGS])
 
2826
AC_REQUIRE([XORG_COMPILER_FLAGS])
2069
2827
 
2070
2828
AC_ARG_ENABLE(strict-compilation,
2071
2829
                          AS_HELP_STRING([--enable-strict-compilation],
2072
2830
                          [Enable all warnings from compiler and make them errors (default: disabled)]),
2073
2831
                          [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
 
2832
 
 
2833
AC_LANG_CASE(
 
2834
        [C], [
 
2835
                define([PREFIX], [C])
 
2836
        ],
 
2837
        [C++], [
 
2838
                define([PREFIX], [CXX])
 
2839
        ]
 
2840
)
 
2841
 
 
2842
[STRICT_]PREFIX[FLAGS]=""
 
2843
XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
 
2844
XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
 
2845
 
 
2846
# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
 
2847
# activate it with -Werror, so we add it here explicitly.
 
2848
XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
 
2849
 
2074
2850
if test "x$STRICT_COMPILE" = "xyes"; then
2075
 
        AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
2076
 
        AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
2077
 
        if test "x$GCC" = xyes ; then
2078
 
                STRICT_CFLAGS="-pedantic -Werror"
2079
 
        elif test "x$SUNCC" = "xyes"; then
2080
 
                STRICT_CFLAGS="-errwarn"
2081
 
    elif test "x$INTELCC" = "xyes"; then
2082
 
                STRICT_CFLAGS="-Werror"
2083
 
        fi
 
2851
    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
 
2852
    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
2084
2853
fi
2085
 
CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
2086
 
AC_SUBST([CWARNFLAGS])
 
2854
AC_SUBST([STRICT_]PREFIX[FLAGS])
 
2855
AC_SUBST([BASE_]PREFIX[FLAGS])
 
2856
AC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
2087
2857
]) # XORG_STRICT_OPTION
2088
2858
 
2089
2859
# XORG_DEFAULT_OPTIONS
2094
2864
#
2095
2865
AC_DEFUN([XORG_DEFAULT_OPTIONS], [
2096
2866
AC_REQUIRE([AC_PROG_INSTALL])
 
2867
XORG_COMPILER_FLAGS
2097
2868
XORG_CWARNFLAGS
2098
2869
XORG_STRICT_OPTION
2099
2870
XORG_RELEASE_VERSION
2185
2956
AC_SUBST([CHANGELOG_CMD])
2186
2957
]) # XORG_CHANGELOG
2187
2958
 
2188
 
# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
2189
 
2190
 
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
2191
 
#
2192
 
# This program is free software; you can redistribute it and/or modify
2193
 
# it under the terms of the GNU General Public License as published by
2194
 
# the Free Software Foundation; either version 2 of the License, or
2195
 
# (at your option) any later version.
2196
 
#
2197
 
# This program is distributed in the hope that it will be useful, but
2198
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
2199
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2200
 
# General Public License for more details.
2201
 
#
2202
 
# You should have received a copy of the GNU General Public License
2203
 
# along with this program; if not, write to the Free Software
2204
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2205
 
#
2206
 
# As a special exception to the GNU General Public License, if you
2207
 
# distribute this file as part of a program that contains a
2208
 
# configuration script generated by Autoconf, you may include it under
2209
 
# the same distribution terms that you use for the rest of that program.
2210
 
 
2211
 
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
2212
 
# ----------------------------------
2213
 
AC_DEFUN([PKG_PROG_PKG_CONFIG],
2214
 
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
2215
 
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
2216
 
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
2217
 
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
2218
 
        AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2219
 
fi
2220
 
if test -n "$PKG_CONFIG"; then
2221
 
        _pkg_min_version=m4_default([$1], [0.9.0])
2222
 
        AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
2223
 
        if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
2224
 
                AC_MSG_RESULT([yes])
2225
 
        else
2226
 
                AC_MSG_RESULT([no])
2227
 
                PKG_CONFIG=""
2228
 
        fi
2229
 
                
2230
 
fi[]dnl
2231
 
])# PKG_PROG_PKG_CONFIG
2232
 
 
2233
 
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2234
 
#
2235
 
# Check to see whether a particular set of modules exists.  Similar
2236
 
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
2237
 
#
2238
 
#
2239
 
# Similar to PKG_CHECK_MODULES, make sure that the first instance of
2240
 
# this or PKG_CHECK_MODULES is called, or make sure to call
2241
 
# PKG_CHECK_EXISTS manually
2242
 
# --------------------------------------------------------------
2243
 
AC_DEFUN([PKG_CHECK_EXISTS],
2244
 
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
2245
 
if test -n "$PKG_CONFIG" && \
2246
 
    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
2247
 
  m4_ifval([$2], [$2], [:])
2248
 
m4_ifvaln([$3], [else
2249
 
  $3])dnl
2250
 
fi])
2251
 
 
2252
 
 
2253
 
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
2254
 
# ---------------------------------------------
2255
 
m4_define([_PKG_CONFIG],
2256
 
[if test -n "$$1"; then
2257
 
    pkg_cv_[]$1="$$1"
2258
 
 elif test -n "$PKG_CONFIG"; then
2259
 
    PKG_CHECK_EXISTS([$3],
2260
 
                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
2261
 
                     [pkg_failed=yes])
2262
 
 else
2263
 
    pkg_failed=untried
2264
 
fi[]dnl
2265
 
])# _PKG_CONFIG
2266
 
 
2267
 
# _PKG_SHORT_ERRORS_SUPPORTED
2268
 
# -----------------------------
2269
 
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
2270
 
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
2271
 
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
2272
 
        _pkg_short_errors_supported=yes
2273
 
else
2274
 
        _pkg_short_errors_supported=no
2275
 
fi[]dnl
2276
 
])# _PKG_SHORT_ERRORS_SUPPORTED
2277
 
 
2278
 
 
2279
 
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
2280
 
# [ACTION-IF-NOT-FOUND])
2281
 
#
2282
 
#
2283
 
# Note that if there is a possibility the first call to
2284
 
# PKG_CHECK_MODULES might not happen, you should be sure to include an
2285
 
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
2286
 
#
2287
 
#
2288
 
# --------------------------------------------------------------
2289
 
AC_DEFUN([PKG_CHECK_MODULES],
2290
 
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
2291
 
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
2292
 
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
2293
 
 
2294
 
pkg_failed=no
2295
 
AC_MSG_CHECKING([for $1])
2296
 
 
2297
 
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
2298
 
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
2299
 
 
2300
 
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
2301
 
and $1[]_LIBS to avoid the need to call pkg-config.
2302
 
See the pkg-config man page for more details.])
2303
 
 
2304
 
if test $pkg_failed = yes; then
2305
 
        _PKG_SHORT_ERRORS_SUPPORTED
2306
 
        if test $_pkg_short_errors_supported = yes; then
2307
 
                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
2308
 
        else 
2309
 
                $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
2310
 
        fi
2311
 
        # Put the nasty error message in config.log where it belongs
2312
 
        echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
2313
 
 
2314
 
        ifelse([$4], , [AC_MSG_ERROR(dnl
2315
 
[Package requirements ($2) were not met:
2316
 
 
2317
 
$$1_PKG_ERRORS
2318
 
 
2319
 
Consider adjusting the PKG_CONFIG_PATH environment variable if you
2320
 
installed software in a non-standard prefix.
2321
 
 
2322
 
_PKG_TEXT
2323
 
])],
2324
 
                [AC_MSG_RESULT([no])
2325
 
                $4])
2326
 
elif test $pkg_failed = untried; then
2327
 
        ifelse([$4], , [AC_MSG_FAILURE(dnl
2328
 
[The pkg-config script could not be found or is too old.  Make sure it
2329
 
is in your PATH or set the PKG_CONFIG environment variable to the full
2330
 
path to pkg-config.
2331
 
 
2332
 
_PKG_TEXT
2333
 
 
2334
 
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
2335
 
                [$4])
2336
 
else
2337
 
        $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
2338
 
        $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
2339
 
        AC_MSG_RESULT([yes])
2340
 
        ifelse([$3], , :, [$3])
2341
 
fi[]dnl
2342
 
])# PKG_CHECK_MODULES
2343