988
988
AC_SUBST([am__untar])
989
989
]) # _AM_PROG_TAR
991
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
993
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
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.
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.
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.
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.
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])
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])
1034
])# PKG_PROG_PKG_CONFIG
1036
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
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.
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
1056
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
1057
# ---------------------------------------------
1058
m4_define([_PKG_CONFIG],
1059
[if test -n "$$1"; then
1061
elif test -n "$PKG_CONFIG"; then
1062
PKG_CHECK_EXISTS([$3],
1063
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
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
1077
_pkg_short_errors_supported=no
1079
])# _PKG_SHORT_ERRORS_SUPPORTED
1082
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1083
# [ACTION-IF-NOT-FOUND])
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
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
1098
AC_MSG_CHECKING([for $1])
1100
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
1101
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
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.])
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`
1112
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
1114
# Put the nasty error message in config.log where it belongs
1115
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
1117
ifelse([$4], , [AC_MSG_ERROR(dnl
1118
[Package requirements ($2) were not met:
1122
Consider adjusting the PKG_CONFIG_PATH environment variable if you
1123
installed software in a non-standard prefix.
1127
[AC_MSG_RESULT([no])
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
1137
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
1140
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
1141
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
1142
AC_MSG_RESULT([yes])
1143
ifelse([$3], , :, [$3])
1145
])# PKG_CHECK_MODULES
991
1147
dnl xorg-macros.m4. Generated from xorg-macros.m4.in xorgversion.m4 by configure.
993
1149
dnl Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
1422
1578
AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
1423
1579
]) # XORG_WITH_XMLTO
1581
# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
1582
# --------------------------------------------
1583
# Minimum version: 1.12.0
1584
# Minimum version for optional DEFAULT argument: 1.12.0
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'.
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
1602
# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
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])
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])
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])
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])
1635
AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
1638
AM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
1639
]) # XORG_WITH_XSLTPROC
1641
# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
1642
# ----------------------------------------
1643
# Minimum version: 1.15.0
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.
1649
# When DEFAULT is not specified, --with-perl assumes 'auto'.
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
1659
# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
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]))
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])
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])
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])
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])
1692
AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
1695
AM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
1425
1698
# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
1426
1699
# ----------------
1427
1700
# Minimum version: 1.5.0
1878
2168
AC_MSG_RESULT([$build_specs])
1879
2169
]) # XORG_ENABLE_SPECS
2171
# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
2172
# ----------------------------------------------
2173
# Minimum version: 1.13.0
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
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.
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.
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
2205
# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
2206
# ----------------------------------------
2207
# Minimum version: 1.13.0
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.
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.
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
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])
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
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])]
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])
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])
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])
2263
AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
2266
# XORG_LD_WRAP([required|optional])
2267
# ---------------------------------
2268
# Minimum version: 1.13.0
2270
# Check if linker supports -wrap, passed via compiler flags
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.
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.
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; }],
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])
2291
AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
2295
# XORG_CHECK_LINKER_FLAGS
2296
# -----------------------
2299
# XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
2303
# Check whether the given linker FLAGS work with the current language's
2304
# linker, or whether they give an error.
2306
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
2309
# PROGRAM-SOURCE is the program source to link with, if needed
2311
# NOTE: Based on AX_CHECK_COMPILER_FLAGS.
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
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.
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.
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/>.
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.
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:
2348
[AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
2349
ax_save_FLAGS=$LDFLAGS
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
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
2368
]) # XORG_CHECK_LINKER_FLAGS
2370
# XORG_MEMORY_CHECK_FLAGS
2371
# -----------------------
2372
# Minimum version: 1.16.0
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.
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
2382
# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
2384
AC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
2386
AC_REQUIRE([AC_CANONICAL_HOST])
2387
AC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
2388
[Environment variables to enable memory checking in tests])
2390
# Check for different types of support on different platforms
2393
AC_CHECK_LIB([umem], [umem_alloc],
2394
[malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
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'
2401
malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
2404
malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
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"
2413
AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
1881
2416
# XORG_CHECK_MALLOC_ZERO
1882
2417
# ----------------------
1883
2418
# Minimum version: 1.0.0
2032
2565
]) # XORG_LINT_LIBRARY
2567
# XORG_COMPILER_BRAND
2568
# -------------------
2569
# Minimum version: 1.14.0
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"
2578
AC_DEFUN([XORG_COMPILER_BRAND], [
2581
AC_REQUIRE([AC_PROG_CC_C99])
2584
AC_REQUIRE([AC_PROG_CXX])
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
2592
# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
2594
# Minimum version: 1.16.0
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.
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
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])])
2609
AC_LANG_COMPILER_REQUIRE
2613
AC_REQUIRE([AC_PROG_CC_C99])
2614
define([PREFIX], [C])
2617
define([PREFIX], [CXX])
2621
[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
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]"
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"
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]"
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"
2655
if test "x$xorg_testset_unused_command_line_argument" = "xyes" ; then
2656
PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
2659
PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
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])])
2669
PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
2671
eval supported=$AS_TR_SH($cacheid)
2672
AC_MSG_RESULT([$supported])
2673
if test "$supported" = "yes" ; then
2679
]) # XORG_TESTSET_CFLAG
2681
# XORG_COMPILER_FLAGS
2683
# Minimum version: 1.16.0
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.
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.
2693
AC_DEFUN([XORG_COMPILER_FLAGS], [
2694
AC_REQUIRE([XORG_COMPILER_BRAND])
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])
2704
define([PREFIX], [C])
2707
define([PREFIX], [CXX])
2710
# -v is too short to test reliably with XORG_TESTSET_CFLAG
2711
if test "x$SUNCC" = "xyes"; then
2712
[BASE_]PREFIX[FLAGS]="-v"
2714
[BASE_]PREFIX[FLAGS]=""
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])
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])
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])
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])
2750
# Turn some warnings into errors, so we don't accidently get successful builds
2751
# when there are problems that should be fixed.
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
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])
2784
AC_SUBST([BASE_]PREFIX[FLAGS])
2785
]) # XORG_COMPILER_FLAGS
2034
2787
# XORG_CWARNFLAGS
2035
2788
# ---------------
2036
2789
# Minimum version: 1.2.0
2790
# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
2038
2792
# Defines CWARNFLAGS to enable C compiler warnings.
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.
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
2048
CWARNFLAGS="$CWARNFLAGS -Wold-style-definition -Wdeclaration-after-statement"
2052
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
2053
if test "x$SUNCC" = "xyes"; then
2057
AC_SUBST(CWARNFLAGS)
2800
AC_REQUIRE([XORG_COMPILER_FLAGS])
2801
AC_REQUIRE([XORG_COMPILER_BRAND])
2804
CWARNFLAGS="$BASE_CFLAGS"
2805
if test "x$GCC" = xyes ; then
2806
CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
2808
AC_SUBST(CWARNFLAGS)
2058
2811
]) # XORG_CWARNFLAGS
2060
2813
# XORG_STRICT_OPTION
2061
2814
# -----------------------
2062
2815
# Minimum version: 1.3.0
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.
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])
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])
2835
define([PREFIX], [C])
2838
define([PREFIX], [CXX])
2842
[STRICT_]PREFIX[FLAGS]=""
2843
XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
2844
XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
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])
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"
2851
[BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
2852
AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
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
2089
2859
# XORG_DEFAULT_OPTIONS
2185
2956
AC_SUBST([CHANGELOG_CMD])
2186
2957
]) # XORG_CHANGELOG
2188
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
2190
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
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.
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.
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.
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.
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])
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])
2231
])# PKG_PROG_PKG_CONFIG
2233
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
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.
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
2253
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
2254
# ---------------------------------------------
2255
m4_define([_PKG_CONFIG],
2256
[if test -n "$$1"; then
2258
elif test -n "$PKG_CONFIG"; then
2259
PKG_CHECK_EXISTS([$3],
2260
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
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
2274
_pkg_short_errors_supported=no
2276
])# _PKG_SHORT_ERRORS_SUPPORTED
2279
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
2280
# [ACTION-IF-NOT-FOUND])
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
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
2295
AC_MSG_CHECKING([for $1])
2297
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
2298
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
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.])
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`
2309
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
2311
# Put the nasty error message in config.log where it belongs
2312
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
2314
ifelse([$4], , [AC_MSG_ERROR(dnl
2315
[Package requirements ($2) were not met:
2319
Consider adjusting the PKG_CONFIG_PATH environment variable if you
2320
installed software in a non-standard prefix.
2324
[AC_MSG_RESULT([no])
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
2334
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
2337
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
2338
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
2339
AC_MSG_RESULT([yes])
2340
ifelse([$3], , :, [$3])
2342
])# PKG_CHECK_MODULES