aclocal.m4 revision c05e7a3e
16a45684fSmrg# generated automatically by aclocal 1.15 -*- Autoconf -*-
26a45684fSmrg
36a45684fSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
4e6232409Smrg
5e6232409Smrg# This file is free software; the Free Software Foundation
6e6232409Smrg# gives unlimited permission to copy and/or distribute it,
7e6232409Smrg# with or without modifications, as long as this notice is preserved.
8e6232409Smrg
9e6232409Smrg# This program is distributed in the hope that it will be useful,
10e6232409Smrg# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11e6232409Smrg# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12e6232409Smrg# PARTICULAR PURPOSE.
13e6232409Smrg
146a45684fSmrgm4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
158fff3f40Smrgm4_ifndef([AC_AUTOCONF_VERSION],
168fff3f40Smrg  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
176a45684fSmrgm4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
186a45684fSmrg[m4_warning([this file was generated for autoconf 2.69.
198fff3f40SmrgYou have another version of autoconf.  It may work, but is not guaranteed to.
208fff3f40SmrgIf you have problems, you may need to regenerate the build system entirely.
216a45684fSmrgTo do so, use the procedure documented by the package, typically 'autoreconf'.])])
22e6232409Smrg
23c05e7a3eSmrgdnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
24c05e7a3eSmrgdnl serial 11 (pkg-config-0.29)
25c05e7a3eSmrgdnl
26c05e7a3eSmrgdnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
27c05e7a3eSmrgdnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
28c05e7a3eSmrgdnl
29c05e7a3eSmrgdnl This program is free software; you can redistribute it and/or modify
30c05e7a3eSmrgdnl it under the terms of the GNU General Public License as published by
31c05e7a3eSmrgdnl the Free Software Foundation; either version 2 of the License, or
32c05e7a3eSmrgdnl (at your option) any later version.
33c05e7a3eSmrgdnl
34c05e7a3eSmrgdnl This program is distributed in the hope that it will be useful, but
35c05e7a3eSmrgdnl WITHOUT ANY WARRANTY; without even the implied warranty of
36c05e7a3eSmrgdnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37c05e7a3eSmrgdnl General Public License for more details.
38c05e7a3eSmrgdnl
39c05e7a3eSmrgdnl You should have received a copy of the GNU General Public License
40c05e7a3eSmrgdnl along with this program; if not, write to the Free Software
41c05e7a3eSmrgdnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
42c05e7a3eSmrgdnl 02111-1307, USA.
43c05e7a3eSmrgdnl
44c05e7a3eSmrgdnl As a special exception to the GNU General Public License, if you
45c05e7a3eSmrgdnl distribute this file as part of a program that contains a
46c05e7a3eSmrgdnl configuration script generated by Autoconf, you may include it under
47c05e7a3eSmrgdnl the same distribution terms that you use for the rest of that
48c05e7a3eSmrgdnl program.
49c05e7a3eSmrg
50c05e7a3eSmrgdnl PKG_PREREQ(MIN-VERSION)
51c05e7a3eSmrgdnl -----------------------
52c05e7a3eSmrgdnl Since: 0.29
53c05e7a3eSmrgdnl
54c05e7a3eSmrgdnl Verify that the version of the pkg-config macros are at least
55c05e7a3eSmrgdnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
56c05e7a3eSmrgdnl installed version of pkg-config, this checks the developer's version
57c05e7a3eSmrgdnl of pkg.m4 when generating configure.
58c05e7a3eSmrgdnl
59c05e7a3eSmrgdnl To ensure that this macro is defined, also add:
60c05e7a3eSmrgdnl m4_ifndef([PKG_PREREQ],
61c05e7a3eSmrgdnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
62c05e7a3eSmrgdnl
63c05e7a3eSmrgdnl See the "Since" comment for each macro you use to see what version
64c05e7a3eSmrgdnl of the macros you require.
65c05e7a3eSmrgm4_defun([PKG_PREREQ],
66c05e7a3eSmrg[m4_define([PKG_MACROS_VERSION], [0.29])
67c05e7a3eSmrgm4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
68c05e7a3eSmrg    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
69c05e7a3eSmrg])dnl PKG_PREREQ
70c05e7a3eSmrg
71c05e7a3eSmrgdnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
72c05e7a3eSmrgdnl ----------------------------------
73c05e7a3eSmrgdnl Since: 0.16
74c05e7a3eSmrgdnl
75c05e7a3eSmrgdnl Search for the pkg-config tool and set the PKG_CONFIG variable to
76c05e7a3eSmrgdnl first found in the path. Checks that the version of pkg-config found
77c05e7a3eSmrgdnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
78c05e7a3eSmrgdnl used since that's the first version where most current features of
79c05e7a3eSmrgdnl pkg-config existed.
80c05e7a3eSmrgAC_DEFUN([PKG_PROG_PKG_CONFIG],
81c05e7a3eSmrg[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
82c05e7a3eSmrgm4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
83c05e7a3eSmrgm4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
84c05e7a3eSmrgAC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
85c05e7a3eSmrgAC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
86c05e7a3eSmrgAC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
87e6232409Smrg
88c05e7a3eSmrgif test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
89c05e7a3eSmrg	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
90c05e7a3eSmrgfi
91c05e7a3eSmrgif test -n "$PKG_CONFIG"; then
92c05e7a3eSmrg	_pkg_min_version=m4_default([$1], [0.9.0])
93c05e7a3eSmrg	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
94c05e7a3eSmrg	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
95c05e7a3eSmrg		AC_MSG_RESULT([yes])
96c05e7a3eSmrg	else
97c05e7a3eSmrg		AC_MSG_RESULT([no])
98c05e7a3eSmrg		PKG_CONFIG=""
99c05e7a3eSmrg	fi
100c05e7a3eSmrgfi[]dnl
101c05e7a3eSmrg])dnl PKG_PROG_PKG_CONFIG
102e6232409Smrg
103c05e7a3eSmrgdnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
104c05e7a3eSmrgdnl -------------------------------------------------------------------
105c05e7a3eSmrgdnl Since: 0.18
106c05e7a3eSmrgdnl
107c05e7a3eSmrgdnl Check to see whether a particular set of modules exists. Similar to
108c05e7a3eSmrgdnl PKG_CHECK_MODULES(), but does not set variables or print errors.
109c05e7a3eSmrgdnl
110c05e7a3eSmrgdnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
111c05e7a3eSmrgdnl only at the first occurence in configure.ac, so if the first place
112c05e7a3eSmrgdnl it's called might be skipped (such as if it is within an "if", you
113c05e7a3eSmrgdnl have to call PKG_CHECK_EXISTS manually
114c05e7a3eSmrgAC_DEFUN([PKG_CHECK_EXISTS],
115c05e7a3eSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
116c05e7a3eSmrgif test -n "$PKG_CONFIG" && \
117c05e7a3eSmrg    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
118c05e7a3eSmrg  m4_default([$2], [:])
119c05e7a3eSmrgm4_ifvaln([$3], [else
120c05e7a3eSmrg  $3])dnl
121c05e7a3eSmrgfi])
1228fff3f40Smrg
123c05e7a3eSmrgdnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
124c05e7a3eSmrgdnl ---------------------------------------------
125c05e7a3eSmrgdnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
126c05e7a3eSmrgdnl pkg_failed based on the result.
127c05e7a3eSmrgm4_define([_PKG_CONFIG],
128c05e7a3eSmrg[if test -n "$$1"; then
129c05e7a3eSmrg    pkg_cv_[]$1="$$1"
130c05e7a3eSmrg elif test -n "$PKG_CONFIG"; then
131c05e7a3eSmrg    PKG_CHECK_EXISTS([$3],
132c05e7a3eSmrg                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
133c05e7a3eSmrg		      test "x$?" != "x0" && pkg_failed=yes ],
134c05e7a3eSmrg		     [pkg_failed=yes])
135c05e7a3eSmrg else
136c05e7a3eSmrg    pkg_failed=untried
137c05e7a3eSmrgfi[]dnl
138c05e7a3eSmrg])dnl _PKG_CONFIG
1398fff3f40Smrg
140c05e7a3eSmrgdnl _PKG_SHORT_ERRORS_SUPPORTED
141c05e7a3eSmrgdnl ---------------------------
142c05e7a3eSmrgdnl Internal check to see if pkg-config supports short errors.
143c05e7a3eSmrgAC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
144c05e7a3eSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
145c05e7a3eSmrgif $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
146c05e7a3eSmrg        _pkg_short_errors_supported=yes
147c05e7a3eSmrgelse
148c05e7a3eSmrg        _pkg_short_errors_supported=no
149c05e7a3eSmrgfi[]dnl
150c05e7a3eSmrg])dnl _PKG_SHORT_ERRORS_SUPPORTED
1518fff3f40Smrg
1528fff3f40Smrg
153c05e7a3eSmrgdnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
154c05e7a3eSmrgdnl   [ACTION-IF-NOT-FOUND])
155c05e7a3eSmrgdnl --------------------------------------------------------------
156c05e7a3eSmrgdnl Since: 0.4.0
157c05e7a3eSmrgdnl
158c05e7a3eSmrgdnl Note that if there is a possibility the first call to
159c05e7a3eSmrgdnl PKG_CHECK_MODULES might not happen, you should be sure to include an
160c05e7a3eSmrgdnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
161c05e7a3eSmrgAC_DEFUN([PKG_CHECK_MODULES],
162c05e7a3eSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
163c05e7a3eSmrgAC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
164c05e7a3eSmrgAC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
165e6232409Smrg
166c05e7a3eSmrgpkg_failed=no
167c05e7a3eSmrgAC_MSG_CHECKING([for $1])
168e6232409Smrg
169c05e7a3eSmrg_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
170c05e7a3eSmrg_PKG_CONFIG([$1][_LIBS], [libs], [$2])
171e6232409Smrg
172c05e7a3eSmrgm4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
173c05e7a3eSmrgand $1[]_LIBS to avoid the need to call pkg-config.
174c05e7a3eSmrgSee the pkg-config man page for more details.])
175e6232409Smrg
176c05e7a3eSmrgif test $pkg_failed = yes; then
177c05e7a3eSmrg   	AC_MSG_RESULT([no])
178c05e7a3eSmrg        _PKG_SHORT_ERRORS_SUPPORTED
179c05e7a3eSmrg        if test $_pkg_short_errors_supported = yes; then
180c05e7a3eSmrg	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
181c05e7a3eSmrg        else 
182c05e7a3eSmrg	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
183c05e7a3eSmrg        fi
184c05e7a3eSmrg	# Put the nasty error message in config.log where it belongs
185c05e7a3eSmrg	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
186e6232409Smrg
187c05e7a3eSmrg	m4_default([$4], [AC_MSG_ERROR(
188c05e7a3eSmrg[Package requirements ($2) were not met:
189e6232409Smrg
190c05e7a3eSmrg$$1_PKG_ERRORS
191e6232409Smrg
192c05e7a3eSmrgConsider adjusting the PKG_CONFIG_PATH environment variable if you
193c05e7a3eSmrginstalled software in a non-standard prefix.
194e6232409Smrg
195c05e7a3eSmrg_PKG_TEXT])[]dnl
196c05e7a3eSmrg        ])
197c05e7a3eSmrgelif test $pkg_failed = untried; then
198c05e7a3eSmrg     	AC_MSG_RESULT([no])
199c05e7a3eSmrg	m4_default([$4], [AC_MSG_FAILURE(
200c05e7a3eSmrg[The pkg-config script could not be found or is too old.  Make sure it
201c05e7a3eSmrgis in your PATH or set the PKG_CONFIG environment variable to the full
202c05e7a3eSmrgpath to pkg-config.
203e6232409Smrg
204c05e7a3eSmrg_PKG_TEXT
205e6232409Smrg
206c05e7a3eSmrgTo get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
207c05e7a3eSmrg        ])
208c05e7a3eSmrgelse
209c05e7a3eSmrg	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
210c05e7a3eSmrg	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
211c05e7a3eSmrg        AC_MSG_RESULT([yes])
212c05e7a3eSmrg	$3
213c05e7a3eSmrgfi[]dnl
214c05e7a3eSmrg])dnl PKG_CHECK_MODULES
215e6232409Smrg
216e6232409Smrg
217c05e7a3eSmrgdnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
218c05e7a3eSmrgdnl   [ACTION-IF-NOT-FOUND])
219c05e7a3eSmrgdnl ---------------------------------------------------------------------
220c05e7a3eSmrgdnl Since: 0.29
221c05e7a3eSmrgdnl
222c05e7a3eSmrgdnl Checks for existence of MODULES and gathers its build flags with
223c05e7a3eSmrgdnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
224c05e7a3eSmrgdnl and VARIABLE-PREFIX_LIBS from --libs.
225c05e7a3eSmrgdnl
226c05e7a3eSmrgdnl Note that if there is a possibility the first call to
227c05e7a3eSmrgdnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
228c05e7a3eSmrgdnl include an explicit call to PKG_PROG_PKG_CONFIG in your
229c05e7a3eSmrgdnl configure.ac.
230c05e7a3eSmrgAC_DEFUN([PKG_CHECK_MODULES_STATIC],
231c05e7a3eSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
232c05e7a3eSmrg_save_PKG_CONFIG=$PKG_CONFIG
233c05e7a3eSmrgPKG_CONFIG="$PKG_CONFIG --static"
234c05e7a3eSmrgPKG_CHECK_MODULES($@)
235c05e7a3eSmrgPKG_CONFIG=$_save_PKG_CONFIG[]dnl
236c05e7a3eSmrg])dnl PKG_CHECK_MODULES_STATIC
237e6232409Smrg
238e6232409Smrg
239c05e7a3eSmrgdnl PKG_INSTALLDIR([DIRECTORY])
240c05e7a3eSmrgdnl -------------------------
241c05e7a3eSmrgdnl Since: 0.27
242c05e7a3eSmrgdnl
243c05e7a3eSmrgdnl Substitutes the variable pkgconfigdir as the location where a module
244c05e7a3eSmrgdnl should install pkg-config .pc files. By default the directory is
245c05e7a3eSmrgdnl $libdir/pkgconfig, but the default can be changed by passing
246c05e7a3eSmrgdnl DIRECTORY. The user can override through the --with-pkgconfigdir
247c05e7a3eSmrgdnl parameter.
248c05e7a3eSmrgAC_DEFUN([PKG_INSTALLDIR],
249c05e7a3eSmrg[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
250c05e7a3eSmrgm4_pushdef([pkg_description],
251c05e7a3eSmrg    [pkg-config installation directory @<:@]pkg_default[@:>@])
252c05e7a3eSmrgAC_ARG_WITH([pkgconfigdir],
253c05e7a3eSmrg    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
254c05e7a3eSmrg    [with_pkgconfigdir=]pkg_default)
255c05e7a3eSmrgAC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
256c05e7a3eSmrgm4_popdef([pkg_default])
257c05e7a3eSmrgm4_popdef([pkg_description])
258c05e7a3eSmrg])dnl PKG_INSTALLDIR
259c05e7a3eSmrg
260c05e7a3eSmrg
261c05e7a3eSmrgdnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
262c05e7a3eSmrgdnl --------------------------------
263c05e7a3eSmrgdnl Since: 0.27
264c05e7a3eSmrgdnl
265c05e7a3eSmrgdnl Substitutes the variable noarch_pkgconfigdir as the location where a
266c05e7a3eSmrgdnl module should install arch-independent pkg-config .pc files. By
267c05e7a3eSmrgdnl default the directory is $datadir/pkgconfig, but the default can be
268c05e7a3eSmrgdnl changed by passing DIRECTORY. The user can override through the
269c05e7a3eSmrgdnl --with-noarch-pkgconfigdir parameter.
270c05e7a3eSmrgAC_DEFUN([PKG_NOARCH_INSTALLDIR],
271c05e7a3eSmrg[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
272c05e7a3eSmrgm4_pushdef([pkg_description],
273c05e7a3eSmrg    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
274c05e7a3eSmrgAC_ARG_WITH([noarch-pkgconfigdir],
275c05e7a3eSmrg    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
276c05e7a3eSmrg    [with_noarch_pkgconfigdir=]pkg_default)
277c05e7a3eSmrgAC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
278c05e7a3eSmrgm4_popdef([pkg_default])
279c05e7a3eSmrgm4_popdef([pkg_description])
280c05e7a3eSmrg])dnl PKG_NOARCH_INSTALLDIR
281c05e7a3eSmrg
282c05e7a3eSmrg
283c05e7a3eSmrgdnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
284c05e7a3eSmrgdnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
285c05e7a3eSmrgdnl -------------------------------------------
286c05e7a3eSmrgdnl Since: 0.28
287c05e7a3eSmrgdnl
288c05e7a3eSmrgdnl Retrieves the value of the pkg-config variable for the given module.
289c05e7a3eSmrgAC_DEFUN([PKG_CHECK_VAR],
290c05e7a3eSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
291c05e7a3eSmrgAC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
29294a251fdSmrg
293c05e7a3eSmrg_PKG_CONFIG([$1], [variable="][$3]["], [$2])
294c05e7a3eSmrgAS_VAR_COPY([$1], [pkg_cv_][$1])
295c05e7a3eSmrg
296c05e7a3eSmrgAS_VAR_IF([$1], [""], [$5], [$4])dnl
297c05e7a3eSmrg])dnl PKG_CHECK_VAR
298c05e7a3eSmrg
299c05e7a3eSmrgdnl xorg-macros.m4.  Generated from xorg-macros.m4.in xorgversion.m4 by configure.
300c05e7a3eSmrgdnl
301c05e7a3eSmrgdnl Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
302c05e7a3eSmrgdnl
303c05e7a3eSmrgdnl Permission is hereby granted, free of charge, to any person obtaining a
304c05e7a3eSmrgdnl copy of this software and associated documentation files (the "Software"),
305c05e7a3eSmrgdnl to deal in the Software without restriction, including without limitation
306c05e7a3eSmrgdnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
307c05e7a3eSmrgdnl and/or sell copies of the Software, and to permit persons to whom the
308c05e7a3eSmrgdnl Software is furnished to do so, subject to the following conditions:
309c05e7a3eSmrgdnl
310c05e7a3eSmrgdnl The above copyright notice and this permission notice (including the next
311c05e7a3eSmrgdnl paragraph) shall be included in all copies or substantial portions of the
312c05e7a3eSmrgdnl Software.
313c05e7a3eSmrgdnl
314c05e7a3eSmrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
315c05e7a3eSmrgdnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
316c05e7a3eSmrgdnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
317c05e7a3eSmrgdnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
318c05e7a3eSmrgdnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
319c05e7a3eSmrgdnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
320c05e7a3eSmrgdnl DEALINGS IN THE SOFTWARE.
321c05e7a3eSmrg
322c05e7a3eSmrg# XORG_MACROS_VERSION(required-version)
323c05e7a3eSmrg# -------------------------------------
324c05e7a3eSmrg# Minimum version: 1.1.0
325c05e7a3eSmrg#
326c05e7a3eSmrg# If you're using a macro added in Version 1.1 or newer, include this in
327c05e7a3eSmrg# your configure.ac with the minimum required version, such as:
328c05e7a3eSmrg# XORG_MACROS_VERSION(1.1)
329c05e7a3eSmrg#
330c05e7a3eSmrg# To ensure that this macro is defined, also add:
331c05e7a3eSmrg# m4_ifndef([XORG_MACROS_VERSION],
332c05e7a3eSmrg#     [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
333c05e7a3eSmrg#
334c05e7a3eSmrg#
335c05e7a3eSmrg# See the "minimum version" comment for each macro you use to see what
336c05e7a3eSmrg# version you require.
337c05e7a3eSmrgm4_defun([XORG_MACROS_VERSION],[
338c05e7a3eSmrgm4_define([vers_have], [1.19.0])
339c05e7a3eSmrgm4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
340c05e7a3eSmrgm4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
341c05e7a3eSmrgm4_if(m4_cmp(maj_have, maj_needed), 0,,
342c05e7a3eSmrg    [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
343c05e7a3eSmrgm4_if(m4_version_compare(vers_have, [$1]), -1,
344c05e7a3eSmrg    [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
345c05e7a3eSmrgm4_undefine([vers_have])
346c05e7a3eSmrgm4_undefine([maj_have])
347c05e7a3eSmrgm4_undefine([maj_needed])
348c05e7a3eSmrg]) # XORG_MACROS_VERSION
349c05e7a3eSmrg
350c05e7a3eSmrg# XORG_PROG_RAWCPP()
351c05e7a3eSmrg# ------------------
352c05e7a3eSmrg# Minimum version: 1.0.0
353c05e7a3eSmrg#
354c05e7a3eSmrg# Find cpp program and necessary flags for use in pre-processing text files
355c05e7a3eSmrg# such as man pages and config files
356c05e7a3eSmrgAC_DEFUN([XORG_PROG_RAWCPP],[
357c05e7a3eSmrgAC_REQUIRE([AC_PROG_CPP])
358c05e7a3eSmrgAC_PATH_PROGS(RAWCPP, [cpp], [${CPP}],
359c05e7a3eSmrg   [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
360c05e7a3eSmrg
361c05e7a3eSmrg# Check for flag to avoid builtin definitions - assumes unix is predefined,
362c05e7a3eSmrg# which is not the best choice for supporting other OS'es, but covers most
363c05e7a3eSmrg# of the ones we need for now.
364c05e7a3eSmrgAC_MSG_CHECKING([if $RAWCPP requires -undef])
365c05e7a3eSmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
366c05e7a3eSmrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
367c05e7a3eSmrg	AC_MSG_RESULT([no])
368e6232409Smrgelse
369c05e7a3eSmrg	if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
370c05e7a3eSmrg		RAWCPPFLAGS=-undef
371c05e7a3eSmrg		AC_MSG_RESULT([yes])
372c05e7a3eSmrg	# under Cygwin unix is still defined even with -undef
373c05e7a3eSmrg	elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
374c05e7a3eSmrg		RAWCPPFLAGS="-undef -ansi"
375c05e7a3eSmrg		AC_MSG_RESULT([yes, with -ansi])
376c05e7a3eSmrg	else
377c05e7a3eSmrg		AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef.  I don't know what to do.])
378c05e7a3eSmrg	fi
379e6232409Smrgfi
380c05e7a3eSmrgrm -f conftest.$ac_ext
381e6232409Smrg
382c05e7a3eSmrgAC_MSG_CHECKING([if $RAWCPP requires -traditional])
383c05e7a3eSmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
384c05e7a3eSmrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
385c05e7a3eSmrg	AC_MSG_RESULT([no])
386c05e7a3eSmrgelse
387c05e7a3eSmrg	if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
388c05e7a3eSmrg		TRADITIONALCPPFLAGS="-traditional"
389c05e7a3eSmrg		RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
390c05e7a3eSmrg		AC_MSG_RESULT([yes])
391c05e7a3eSmrg	else
392c05e7a3eSmrg		AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
393c05e7a3eSmrg	fi
394c05e7a3eSmrgfi
395c05e7a3eSmrgrm -f conftest.$ac_ext
396c05e7a3eSmrgAC_SUBST(RAWCPPFLAGS)
397c05e7a3eSmrgAC_SUBST(TRADITIONALCPPFLAGS)
398c05e7a3eSmrg]) # XORG_PROG_RAWCPP
399e6232409Smrg
400c05e7a3eSmrg# XORG_MANPAGE_SECTIONS()
401c05e7a3eSmrg# -----------------------
402c05e7a3eSmrg# Minimum version: 1.0.0
403c05e7a3eSmrg#
404c05e7a3eSmrg# Determine which sections man pages go in for the different man page types
405c05e7a3eSmrg# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
406c05e7a3eSmrg# Not sure if there's any better way than just hardcoding by OS name.
407c05e7a3eSmrg# Override default settings by setting environment variables
408c05e7a3eSmrg# Added MAN_SUBSTS in version 1.8
409c05e7a3eSmrg# Added AC_PROG_SED in version 1.8
410e6232409Smrg
411c05e7a3eSmrgAC_DEFUN([XORG_MANPAGE_SECTIONS],[
412c05e7a3eSmrgAC_REQUIRE([AC_CANONICAL_HOST])
413c05e7a3eSmrgAC_REQUIRE([AC_PROG_SED])
414e6232409Smrg
415c05e7a3eSmrgif test x$APP_MAN_SUFFIX = x    ; then
416c05e7a3eSmrg    APP_MAN_SUFFIX=1
417c05e7a3eSmrgfi
418c05e7a3eSmrgif test x$APP_MAN_DIR = x    ; then
419c05e7a3eSmrg    APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
420e6232409Smrgfi
421e6232409Smrg
422c05e7a3eSmrgif test x$LIB_MAN_SUFFIX = x    ; then
423c05e7a3eSmrg    LIB_MAN_SUFFIX=3
424c05e7a3eSmrgfi
425c05e7a3eSmrgif test x$LIB_MAN_DIR = x    ; then
426c05e7a3eSmrg    LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
427c05e7a3eSmrgfi
428e6232409Smrg
429c05e7a3eSmrgif test x$FILE_MAN_SUFFIX = x    ; then
430c05e7a3eSmrg    case $host_os in
431c05e7a3eSmrg	# Solaris 2.0 - 11 use SysV man page sections
432c05e7a3eSmrg	solaris2.?|solaris2.1[[01]])	FILE_MAN_SUFFIX=4  ;;
433c05e7a3eSmrg	*)				FILE_MAN_SUFFIX=5  ;;
434c05e7a3eSmrg    esac
435c05e7a3eSmrgfi
436c05e7a3eSmrgif test x$FILE_MAN_DIR = x    ; then
437c05e7a3eSmrg    FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
438c05e7a3eSmrgfi
439e6232409Smrg
440c05e7a3eSmrgif test x$MISC_MAN_SUFFIX = x    ; then
441c05e7a3eSmrg    case $host_os in
442c05e7a3eSmrg	# Solaris 2.0 - 11 use SysV man page sections
443c05e7a3eSmrg	solaris2.?|solaris2.1[[01]])	MISC_MAN_SUFFIX=5  ;;
444c05e7a3eSmrg	*)				MISC_MAN_SUFFIX=7  ;;
445c05e7a3eSmrg    esac
446c05e7a3eSmrgfi
447c05e7a3eSmrgif test x$MISC_MAN_DIR = x    ; then
448c05e7a3eSmrg    MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
449c05e7a3eSmrgfi
450e6232409Smrg
451c05e7a3eSmrgif test x$DRIVER_MAN_SUFFIX = x    ; then
452c05e7a3eSmrg    case $host_os in
453c05e7a3eSmrg	# Solaris 2.0 - 11 use SysV man page sections
454c05e7a3eSmrg	solaris2.?|solaris2.1[[01]])	DRIVER_MAN_SUFFIX=7  ;;
455c05e7a3eSmrg	*)				DRIVER_MAN_SUFFIX=4  ;;
456c05e7a3eSmrg    esac
457c05e7a3eSmrgfi
458c05e7a3eSmrgif test x$DRIVER_MAN_DIR = x    ; then
459c05e7a3eSmrg    DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
460c05e7a3eSmrgfi
461c05e7a3eSmrg
462c05e7a3eSmrgif test x$ADMIN_MAN_SUFFIX = x    ; then
463c05e7a3eSmrg    case $host_os in
464c05e7a3eSmrg	# Solaris 2.0 - 11 use SysV man page sections
465c05e7a3eSmrg	solaris2.?|solaris2.1[[01]])	ADMIN_MAN_SUFFIX=1m ;;
466c05e7a3eSmrg	*)				ADMIN_MAN_SUFFIX=8  ;;
467c05e7a3eSmrg    esac
468c05e7a3eSmrgfi
469c05e7a3eSmrgif test x$ADMIN_MAN_DIR = x    ; then
470c05e7a3eSmrg    ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
471c05e7a3eSmrgfi
472e6232409Smrg
473e6232409Smrg
474c05e7a3eSmrgAC_SUBST([APP_MAN_SUFFIX])
475c05e7a3eSmrgAC_SUBST([LIB_MAN_SUFFIX])
476c05e7a3eSmrgAC_SUBST([FILE_MAN_SUFFIX])
477c05e7a3eSmrgAC_SUBST([MISC_MAN_SUFFIX])
478c05e7a3eSmrgAC_SUBST([DRIVER_MAN_SUFFIX])
479c05e7a3eSmrgAC_SUBST([ADMIN_MAN_SUFFIX])
480c05e7a3eSmrgAC_SUBST([APP_MAN_DIR])
481c05e7a3eSmrgAC_SUBST([LIB_MAN_DIR])
482c05e7a3eSmrgAC_SUBST([FILE_MAN_DIR])
483c05e7a3eSmrgAC_SUBST([MISC_MAN_DIR])
484c05e7a3eSmrgAC_SUBST([DRIVER_MAN_DIR])
485c05e7a3eSmrgAC_SUBST([ADMIN_MAN_DIR])
486c05e7a3eSmrg
487c05e7a3eSmrgXORG_MAN_PAGE="X Version 11"
488c05e7a3eSmrgAC_SUBST([XORG_MAN_PAGE])
489c05e7a3eSmrgMAN_SUBSTS="\
490c05e7a3eSmrg	-e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
491c05e7a3eSmrg	-e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
492c05e7a3eSmrg	-e 's|__xservername__|Xorg|g' \
493c05e7a3eSmrg	-e 's|__xconfigfile__|xorg.conf|g' \
494c05e7a3eSmrg	-e 's|__projectroot__|\$(prefix)|g' \
495c05e7a3eSmrg	-e 's|__apploaddir__|\$(appdefaultdir)|g' \
496c05e7a3eSmrg	-e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
497c05e7a3eSmrg	-e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
498c05e7a3eSmrg	-e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
499c05e7a3eSmrg	-e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
500c05e7a3eSmrg	-e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
501c05e7a3eSmrg	-e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
502c05e7a3eSmrgAC_SUBST([MAN_SUBSTS])
503c05e7a3eSmrg
504c05e7a3eSmrg]) # XORG_MANPAGE_SECTIONS
505c05e7a3eSmrg
506c05e7a3eSmrg# XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
507c05e7a3eSmrg# ------------------------
508c05e7a3eSmrg# Minimum version: 1.7.0
509e6232409Smrg#
510c05e7a3eSmrg# Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
511c05e7a3eSmrg# provided by xorg-sgml-doctools, if installed.
512c05e7a3eSmrgAC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
513c05e7a3eSmrgAC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
514c05e7a3eSmrgXORG_SGML_PATH=
515c05e7a3eSmrgPKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
516c05e7a3eSmrg    [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
517c05e7a3eSmrg    [m4_ifval([$1],[:],
518c05e7a3eSmrg        [if test x"$cross_compiling" != x"yes" ; then
519c05e7a3eSmrg            AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
520c05e7a3eSmrg                          [XORG_SGML_PATH=$prefix/share/sgml])
521c05e7a3eSmrg         fi])
522c05e7a3eSmrg    ])
523e6232409Smrg
524c05e7a3eSmrg# Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
525c05e7a3eSmrg# the path and the name of the doc stylesheet
526c05e7a3eSmrgif test "x$XORG_SGML_PATH" != "x" ; then
527c05e7a3eSmrg   AC_MSG_RESULT([$XORG_SGML_PATH])
528c05e7a3eSmrg   STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
529c05e7a3eSmrg   XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
530c05e7a3eSmrgelse
531c05e7a3eSmrg   AC_MSG_RESULT([no])
532c05e7a3eSmrgfi
533e6232409Smrg
534c05e7a3eSmrgAC_SUBST(XORG_SGML_PATH)
535c05e7a3eSmrgAC_SUBST(STYLESHEET_SRCDIR)
536c05e7a3eSmrgAC_SUBST(XSL_STYLESHEET)
537c05e7a3eSmrgAM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
538c05e7a3eSmrg]) # XORG_CHECK_SGML_DOCTOOLS
539c05e7a3eSmrg
540c05e7a3eSmrg# XORG_CHECK_LINUXDOC
541c05e7a3eSmrg# -------------------
542c05e7a3eSmrg# Minimum version: 1.0.0
543e6232409Smrg#
544c05e7a3eSmrg# Defines the variable MAKE_TEXT if the necessary tools and
545c05e7a3eSmrg# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
546c05e7a3eSmrg# Whether or not the necessary tools and files are found can be checked
547c05e7a3eSmrg# with the AM_CONDITIONAL "BUILD_LINUXDOC"
548c05e7a3eSmrgAC_DEFUN([XORG_CHECK_LINUXDOC],[
549c05e7a3eSmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
550c05e7a3eSmrgAC_REQUIRE([XORG_WITH_PS2PDF])
551e6232409Smrg
552c05e7a3eSmrgAC_PATH_PROG(LINUXDOC, linuxdoc)
553e6232409Smrg
554c05e7a3eSmrgAC_MSG_CHECKING([whether to build documentation])
5556a45684fSmrg
556c05e7a3eSmrgif test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
557c05e7a3eSmrg   BUILDDOC=yes
558c05e7a3eSmrgelse
559c05e7a3eSmrg   BUILDDOC=no
560e6232409Smrgfi
561e6232409Smrg
562c05e7a3eSmrgAM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
563c05e7a3eSmrg
564c05e7a3eSmrgAC_MSG_RESULT([$BUILDDOC])
565c05e7a3eSmrg
566c05e7a3eSmrgAC_MSG_CHECKING([whether to build pdf documentation])
567c05e7a3eSmrg
568c05e7a3eSmrgif test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
569c05e7a3eSmrg   BUILDPDFDOC=yes
570c05e7a3eSmrgelse
571c05e7a3eSmrg   BUILDPDFDOC=no
57294a251fdSmrgfi
573e6232409Smrg
574c05e7a3eSmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
575e6232409Smrg
576c05e7a3eSmrgAC_MSG_RESULT([$BUILDPDFDOC])
577e6232409Smrg
578c05e7a3eSmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
579c05e7a3eSmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
580c05e7a3eSmrgMAKE_PDF="$PS2PDF"
581c05e7a3eSmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
5826a45684fSmrg
583c05e7a3eSmrgAC_SUBST(MAKE_TEXT)
584c05e7a3eSmrgAC_SUBST(MAKE_PS)
585c05e7a3eSmrgAC_SUBST(MAKE_PDF)
586c05e7a3eSmrgAC_SUBST(MAKE_HTML)
587c05e7a3eSmrg]) # XORG_CHECK_LINUXDOC
5886a45684fSmrg
589c05e7a3eSmrg# XORG_CHECK_DOCBOOK
590c05e7a3eSmrg# -------------------
591c05e7a3eSmrg# Minimum version: 1.0.0
592c05e7a3eSmrg#
593c05e7a3eSmrg# Checks for the ability to build output formats from SGML DocBook source.
594c05e7a3eSmrg# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
595c05e7a3eSmrg# indicates whether the necessary tools and files are found and, if set,
596c05e7a3eSmrg# $(MAKE_XXX) blah.sgml will produce blah.xxx.
597c05e7a3eSmrgAC_DEFUN([XORG_CHECK_DOCBOOK],[
598c05e7a3eSmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
5996a45684fSmrg
600c05e7a3eSmrgBUILDTXTDOC=no
601c05e7a3eSmrgBUILDPDFDOC=no
602c05e7a3eSmrgBUILDPSDOC=no
603c05e7a3eSmrgBUILDHTMLDOC=no
6046a45684fSmrg
605c05e7a3eSmrgAC_PATH_PROG(DOCBOOKPS, docbook2ps)
606c05e7a3eSmrgAC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
607c05e7a3eSmrgAC_PATH_PROG(DOCBOOKHTML, docbook2html)
608c05e7a3eSmrgAC_PATH_PROG(DOCBOOKTXT, docbook2txt)
6096a45684fSmrg
610c05e7a3eSmrgAC_MSG_CHECKING([whether to build text documentation])
611c05e7a3eSmrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
612c05e7a3eSmrg   test x$BUILD_TXTDOC != xno; then
613c05e7a3eSmrg	BUILDTXTDOC=yes
614c05e7a3eSmrgfi
615c05e7a3eSmrgAM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
616c05e7a3eSmrgAC_MSG_RESULT([$BUILDTXTDOC])
6176a45684fSmrg
618c05e7a3eSmrgAC_MSG_CHECKING([whether to build PDF documentation])
619c05e7a3eSmrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
620c05e7a3eSmrg   test x$BUILD_PDFDOC != xno; then
621c05e7a3eSmrg	BUILDPDFDOC=yes
622c05e7a3eSmrgfi
623c05e7a3eSmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
624c05e7a3eSmrgAC_MSG_RESULT([$BUILDPDFDOC])
6256a45684fSmrg
626c05e7a3eSmrgAC_MSG_CHECKING([whether to build PostScript documentation])
627c05e7a3eSmrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
628c05e7a3eSmrg   test x$BUILD_PSDOC != xno; then
629c05e7a3eSmrg	BUILDPSDOC=yes
6306a45684fSmrgfi
631c05e7a3eSmrgAM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
632c05e7a3eSmrgAC_MSG_RESULT([$BUILDPSDOC])
633e6232409Smrg
634c05e7a3eSmrgAC_MSG_CHECKING([whether to build HTML documentation])
635c05e7a3eSmrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
636c05e7a3eSmrg   test x$BUILD_HTMLDOC != xno; then
637c05e7a3eSmrg	BUILDHTMLDOC=yes
638c05e7a3eSmrgfi
639c05e7a3eSmrgAM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
640c05e7a3eSmrgAC_MSG_RESULT([$BUILDHTMLDOC])
641e6232409Smrg
642c05e7a3eSmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
643c05e7a3eSmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
644c05e7a3eSmrgMAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
645c05e7a3eSmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
646e6232409Smrg
647c05e7a3eSmrgAC_SUBST(MAKE_TEXT)
648c05e7a3eSmrgAC_SUBST(MAKE_PS)
649c05e7a3eSmrgAC_SUBST(MAKE_PDF)
650c05e7a3eSmrgAC_SUBST(MAKE_HTML)
651c05e7a3eSmrg]) # XORG_CHECK_DOCBOOK
652e6232409Smrg
653c05e7a3eSmrg# XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
654c05e7a3eSmrg# ----------------
655c05e7a3eSmrg# Minimum version: 1.5.0
656c05e7a3eSmrg# Minimum version for optional DEFAULT argument: 1.11.0
657e6232409Smrg#
658c05e7a3eSmrg# Documentation tools are not always available on all platforms and sometimes
659c05e7a3eSmrg# not at the appropriate level. This macro enables a module to test for the
660c05e7a3eSmrg# presence of the tool and obtain it's path in separate variables. Coupled with
661c05e7a3eSmrg# the --with-xmlto option, it allows maximum flexibilty in making decisions
662c05e7a3eSmrg# as whether or not to use the xmlto package. When DEFAULT is not specified,
663c05e7a3eSmrg# --with-xmlto assumes 'auto'.
66494a251fdSmrg#
665c05e7a3eSmrg# Interface to module:
666c05e7a3eSmrg# HAVE_XMLTO: 	used in makefiles to conditionally generate documentation
667c05e7a3eSmrg# XMLTO:	returns the path of the xmlto program found
668c05e7a3eSmrg#		returns the path set by the user in the environment
669c05e7a3eSmrg# --with-xmlto:	'yes' user instructs the module to use xmlto
670c05e7a3eSmrg#		'no' user instructs the module not to use xmlto
671c05e7a3eSmrg#
672c05e7a3eSmrg# Added in version 1.10.0
673c05e7a3eSmrg# HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
674c05e7a3eSmrg#                  xmlto for text output requires either lynx, links, or w3m browsers
675c05e7a3eSmrg#
676c05e7a3eSmrg# If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
677c05e7a3eSmrg#
678c05e7a3eSmrgAC_DEFUN([XORG_WITH_XMLTO],[
679c05e7a3eSmrgAC_ARG_VAR([XMLTO], [Path to xmlto command])
680c05e7a3eSmrgm4_define([_defopt], m4_default([$2], [auto]))
681c05e7a3eSmrgAC_ARG_WITH(xmlto,
682c05e7a3eSmrg	AS_HELP_STRING([--with-xmlto],
683c05e7a3eSmrg	   [Use xmlto to regenerate documentation (default: ]_defopt[)]),
684c05e7a3eSmrg	   [use_xmlto=$withval], [use_xmlto=]_defopt)
685c05e7a3eSmrgm4_undefine([_defopt])
686e6232409Smrg
687c05e7a3eSmrgif test "x$use_xmlto" = x"auto"; then
688c05e7a3eSmrg   AC_PATH_PROG([XMLTO], [xmlto])
689c05e7a3eSmrg   if test "x$XMLTO" = "x"; then
690c05e7a3eSmrg        AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
691c05e7a3eSmrg	have_xmlto=no
692c05e7a3eSmrg   else
693c05e7a3eSmrg        have_xmlto=yes
694c05e7a3eSmrg   fi
695c05e7a3eSmrgelif test "x$use_xmlto" = x"yes" ; then
696c05e7a3eSmrg   AC_PATH_PROG([XMLTO], [xmlto])
697c05e7a3eSmrg   if test "x$XMLTO" = "x"; then
698c05e7a3eSmrg        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
699c05e7a3eSmrg   fi
700c05e7a3eSmrg   have_xmlto=yes
701c05e7a3eSmrgelif test "x$use_xmlto" = x"no" ; then
702c05e7a3eSmrg   if test "x$XMLTO" != "x"; then
703c05e7a3eSmrg      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
704c05e7a3eSmrg   fi
705c05e7a3eSmrg   have_xmlto=no
70694a251fdSmrgelse
707c05e7a3eSmrg   AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
7088fff3f40Smrgfi
709e6232409Smrg
710c05e7a3eSmrg# Test for a minimum version of xmlto, if provided.
711c05e7a3eSmrgm4_ifval([$1],
712c05e7a3eSmrg[if test "$have_xmlto" = yes; then
713c05e7a3eSmrg    # scrape the xmlto version
714c05e7a3eSmrg    AC_MSG_CHECKING([the xmlto version])
715c05e7a3eSmrg    xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
716c05e7a3eSmrg    AC_MSG_RESULT([$xmlto_version])
717c05e7a3eSmrg    AS_VERSION_COMPARE([$xmlto_version], [$1],
718c05e7a3eSmrg        [if test "x$use_xmlto" = xauto; then
719c05e7a3eSmrg            AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
720c05e7a3eSmrg            have_xmlto=no
721c05e7a3eSmrg        else
722c05e7a3eSmrg            AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
723c05e7a3eSmrg        fi])
724c05e7a3eSmrgfi])
72594a251fdSmrg
726c05e7a3eSmrg# Test for the ability of xmlto to generate a text target
7278fff3f40Smrg#
728c05e7a3eSmrg# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
729c05e7a3eSmrg# following test for empty XML docbook files.
730c05e7a3eSmrg# For compatibility reasons use the following empty XML docbook file and if
731c05e7a3eSmrg# it fails try it again with a non-empty XML file.
732c05e7a3eSmrghave_xmlto_text=no
733c05e7a3eSmrgcat > conftest.xml << "EOF"
734c05e7a3eSmrgEOF
735c05e7a3eSmrgAS_IF([test "$have_xmlto" = yes],
736c05e7a3eSmrg      [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
737c05e7a3eSmrg             [have_xmlto_text=yes],
738c05e7a3eSmrg             [# Try it again with a non-empty XML file.
739c05e7a3eSmrg              cat > conftest.xml << "EOF"
740c05e7a3eSmrg<x></x>
741c05e7a3eSmrgEOF
742c05e7a3eSmrg              AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
743c05e7a3eSmrg                    [have_xmlto_text=yes],
744c05e7a3eSmrg                    [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])])
745c05e7a3eSmrgrm -f conftest.xml
746c05e7a3eSmrgAM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
747c05e7a3eSmrgAM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
748c05e7a3eSmrg]) # XORG_WITH_XMLTO
74994a251fdSmrg
750c05e7a3eSmrg# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
751c05e7a3eSmrg# --------------------------------------------
752c05e7a3eSmrg# Minimum version: 1.12.0
753c05e7a3eSmrg# Minimum version for optional DEFAULT argument: 1.12.0
754e6232409Smrg#
755c05e7a3eSmrg# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
756c05e7a3eSmrg# XML-based language used for the transformation of XML documents.
757c05e7a3eSmrg# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
758c05e7a3eSmrg# It is used under the cover by xmlto to generate html files from DocBook/XML.
759c05e7a3eSmrg# The XSLT processor is often used as a standalone tool for transformations.
760c05e7a3eSmrg# It should not be assumed that this tool is used only to work with documnetation.
761c05e7a3eSmrg# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
762c05e7a3eSmrg#
763c05e7a3eSmrg# Interface to module:
764c05e7a3eSmrg# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
765c05e7a3eSmrg# XSLTPROC:	 returns the path of the xsltproc program found
766c05e7a3eSmrg#		 returns the path set by the user in the environment
767c05e7a3eSmrg# --with-xsltproc: 'yes' user instructs the module to use xsltproc
768c05e7a3eSmrg#		  'no' user instructs the module not to use xsltproc
769c05e7a3eSmrg# have_xsltproc: returns yes if xsltproc found in PATH or no
770c05e7a3eSmrg#
771c05e7a3eSmrg# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
772c05e7a3eSmrg#
773c05e7a3eSmrgAC_DEFUN([XORG_WITH_XSLTPROC],[
774c05e7a3eSmrgAC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
775c05e7a3eSmrg# Preserves the interface, should it be implemented later
776c05e7a3eSmrgm4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
777c05e7a3eSmrgm4_define([_defopt], m4_default([$2], [auto]))
778c05e7a3eSmrgAC_ARG_WITH(xsltproc,
779c05e7a3eSmrg	AS_HELP_STRING([--with-xsltproc],
780c05e7a3eSmrg	   [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
781c05e7a3eSmrg	   [use_xsltproc=$withval], [use_xsltproc=]_defopt)
782c05e7a3eSmrgm4_undefine([_defopt])
78394a251fdSmrg
784c05e7a3eSmrgif test "x$use_xsltproc" = x"auto"; then
785c05e7a3eSmrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
786c05e7a3eSmrg   if test "x$XSLTPROC" = "x"; then
787c05e7a3eSmrg        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
788c05e7a3eSmrg	have_xsltproc=no
789c05e7a3eSmrg   else
790c05e7a3eSmrg        have_xsltproc=yes
791c05e7a3eSmrg   fi
792c05e7a3eSmrgelif test "x$use_xsltproc" = x"yes" ; then
793c05e7a3eSmrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
794c05e7a3eSmrg   if test "x$XSLTPROC" = "x"; then
795c05e7a3eSmrg        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
796c05e7a3eSmrg   fi
797c05e7a3eSmrg   have_xsltproc=yes
798c05e7a3eSmrgelif test "x$use_xsltproc" = x"no" ; then
799c05e7a3eSmrg   if test "x$XSLTPROC" != "x"; then
800c05e7a3eSmrg      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
801c05e7a3eSmrg   fi
802c05e7a3eSmrg   have_xsltproc=no
803e6232409Smrgelse
804c05e7a3eSmrg   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
805e6232409Smrgfi
806e6232409Smrg
807c05e7a3eSmrgAM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
808c05e7a3eSmrg]) # XORG_WITH_XSLTPROC
80994a251fdSmrg
810c05e7a3eSmrg# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
811c05e7a3eSmrg# ----------------------------------------
812c05e7a3eSmrg# Minimum version: 1.15.0
8138fff3f40Smrg#
814c05e7a3eSmrg# PERL (Practical Extraction and Report Language) is a language optimized for
815c05e7a3eSmrg# scanning arbitrary text files, extracting information from those text files,
816c05e7a3eSmrg# and printing reports based on that information.
817c05e7a3eSmrg#
818c05e7a3eSmrg# When DEFAULT is not specified, --with-perl assumes 'auto'.
819c05e7a3eSmrg#
820c05e7a3eSmrg# Interface to module:
821c05e7a3eSmrg# HAVE_PERL: used in makefiles to conditionally scan text files
822c05e7a3eSmrg# PERL:	     returns the path of the perl program found
823c05e7a3eSmrg#	     returns the path set by the user in the environment
824c05e7a3eSmrg# --with-perl: 'yes' user instructs the module to use perl
825c05e7a3eSmrg#	       'no' user instructs the module not to use perl
826c05e7a3eSmrg# have_perl: returns yes if perl found in PATH or no
827c05e7a3eSmrg#
828c05e7a3eSmrg# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
829c05e7a3eSmrg#
830c05e7a3eSmrgAC_DEFUN([XORG_WITH_PERL],[
831c05e7a3eSmrgAC_ARG_VAR([PERL], [Path to perl command])
832c05e7a3eSmrg# Preserves the interface, should it be implemented later
833c05e7a3eSmrgm4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
834c05e7a3eSmrgm4_define([_defopt], m4_default([$2], [auto]))
835c05e7a3eSmrgAC_ARG_WITH(perl,
836c05e7a3eSmrg	AS_HELP_STRING([--with-perl],
837c05e7a3eSmrg	   [Use perl for extracting information from files (default: ]_defopt[)]),
838c05e7a3eSmrg	   [use_perl=$withval], [use_perl=]_defopt)
839c05e7a3eSmrgm4_undefine([_defopt])
84094a251fdSmrg
841c05e7a3eSmrgif test "x$use_perl" = x"auto"; then
842c05e7a3eSmrg   AC_PATH_PROG([PERL], [perl])
843c05e7a3eSmrg   if test "x$PERL" = "x"; then
844c05e7a3eSmrg        AC_MSG_WARN([perl not found - cannot extract information and report])
845c05e7a3eSmrg	have_perl=no
846c05e7a3eSmrg   else
847c05e7a3eSmrg        have_perl=yes
848c05e7a3eSmrg   fi
849c05e7a3eSmrgelif test "x$use_perl" = x"yes" ; then
850c05e7a3eSmrg   AC_PATH_PROG([PERL], [perl])
851c05e7a3eSmrg   if test "x$PERL" = "x"; then
852c05e7a3eSmrg        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
853c05e7a3eSmrg   fi
854c05e7a3eSmrg   have_perl=yes
855c05e7a3eSmrgelif test "x$use_perl" = x"no" ; then
856c05e7a3eSmrg   if test "x$PERL" != "x"; then
857c05e7a3eSmrg      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
858c05e7a3eSmrg   fi
859c05e7a3eSmrg   have_perl=no
860c05e7a3eSmrgelse
861c05e7a3eSmrg   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
862c05e7a3eSmrgfi
86394a251fdSmrg
864c05e7a3eSmrgAM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
865c05e7a3eSmrg]) # XORG_WITH_PERL
86694a251fdSmrg
867c05e7a3eSmrg# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
868c05e7a3eSmrg# ----------------
869c05e7a3eSmrg# Minimum version: 1.5.0
870c05e7a3eSmrg# Minimum version for optional DEFAULT argument: 1.11.0
8716a45684fSmrg#
872c05e7a3eSmrg# Documentation tools are not always available on all platforms and sometimes
873c05e7a3eSmrg# not at the appropriate level. This macro enables a module to test for the
874c05e7a3eSmrg# presence of the tool and obtain it's path in separate variables. Coupled with
875c05e7a3eSmrg# the --with-asciidoc option, it allows maximum flexibilty in making decisions
876c05e7a3eSmrg# as whether or not to use the asciidoc package. When DEFAULT is not specified,
877c05e7a3eSmrg# --with-asciidoc assumes 'auto'.
878c05e7a3eSmrg#
879c05e7a3eSmrg# Interface to module:
880c05e7a3eSmrg# HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
881c05e7a3eSmrg# ASCIIDOC:	 returns the path of the asciidoc program found
882c05e7a3eSmrg#		 returns the path set by the user in the environment
883c05e7a3eSmrg# --with-asciidoc: 'yes' user instructs the module to use asciidoc
884c05e7a3eSmrg#		  'no' user instructs the module not to use asciidoc
885c05e7a3eSmrg#
886c05e7a3eSmrg# If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
887c05e7a3eSmrg#
888c05e7a3eSmrgAC_DEFUN([XORG_WITH_ASCIIDOC],[
889c05e7a3eSmrgAC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
890c05e7a3eSmrgm4_define([_defopt], m4_default([$2], [auto]))
891c05e7a3eSmrgAC_ARG_WITH(asciidoc,
892c05e7a3eSmrg	AS_HELP_STRING([--with-asciidoc],
893c05e7a3eSmrg	   [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
894c05e7a3eSmrg	   [use_asciidoc=$withval], [use_asciidoc=]_defopt)
895c05e7a3eSmrgm4_undefine([_defopt])
89694a251fdSmrg
897c05e7a3eSmrgif test "x$use_asciidoc" = x"auto"; then
898c05e7a3eSmrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
899c05e7a3eSmrg   if test "x$ASCIIDOC" = "x"; then
900c05e7a3eSmrg        AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
901c05e7a3eSmrg	have_asciidoc=no
902c05e7a3eSmrg   else
903c05e7a3eSmrg        have_asciidoc=yes
904c05e7a3eSmrg   fi
905c05e7a3eSmrgelif test "x$use_asciidoc" = x"yes" ; then
906c05e7a3eSmrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
907c05e7a3eSmrg   if test "x$ASCIIDOC" = "x"; then
908c05e7a3eSmrg        AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
909c05e7a3eSmrg   fi
910c05e7a3eSmrg   have_asciidoc=yes
911c05e7a3eSmrgelif test "x$use_asciidoc" = x"no" ; then
912c05e7a3eSmrg   if test "x$ASCIIDOC" != "x"; then
913c05e7a3eSmrg      AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
914c05e7a3eSmrg   fi
915c05e7a3eSmrg   have_asciidoc=no
916c05e7a3eSmrgelse
917c05e7a3eSmrg   AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
9186a45684fSmrgfi
919c05e7a3eSmrgm4_ifval([$1],
920c05e7a3eSmrg[if test "$have_asciidoc" = yes; then
921c05e7a3eSmrg    # scrape the asciidoc version
922c05e7a3eSmrg    AC_MSG_CHECKING([the asciidoc version])
923c05e7a3eSmrg    asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
924c05e7a3eSmrg    AC_MSG_RESULT([$asciidoc_version])
925c05e7a3eSmrg    AS_VERSION_COMPARE([$asciidoc_version], [$1],
926c05e7a3eSmrg        [if test "x$use_asciidoc" = xauto; then
927c05e7a3eSmrg            AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
928c05e7a3eSmrg            have_asciidoc=no
929c05e7a3eSmrg        else
930c05e7a3eSmrg            AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
931c05e7a3eSmrg        fi])
932c05e7a3eSmrgfi])
933c05e7a3eSmrgAM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
934c05e7a3eSmrg]) # XORG_WITH_ASCIIDOC
9356a45684fSmrg
936c05e7a3eSmrg# XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
937c05e7a3eSmrg# -------------------------------------------
938c05e7a3eSmrg# Minimum version: 1.5.0
939c05e7a3eSmrg# Minimum version for optional DEFAULT argument: 1.11.0
940c05e7a3eSmrg# Minimum version for optional DOT checking: 1.18.0
9418fff3f40Smrg#
942c05e7a3eSmrg# Documentation tools are not always available on all platforms and sometimes
943c05e7a3eSmrg# not at the appropriate level. This macro enables a module to test for the
944c05e7a3eSmrg# presence of the tool and obtain it's path in separate variables. Coupled with
945c05e7a3eSmrg# the --with-doxygen option, it allows maximum flexibilty in making decisions
946c05e7a3eSmrg# as whether or not to use the doxygen package. When DEFAULT is not specified,
947c05e7a3eSmrg# --with-doxygen assumes 'auto'.
9486a45684fSmrg#
949c05e7a3eSmrg# Interface to module:
950c05e7a3eSmrg# HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
951c05e7a3eSmrg# DOXYGEN:	 returns the path of the doxygen program found
952c05e7a3eSmrg#		 returns the path set by the user in the environment
953c05e7a3eSmrg# --with-doxygen: 'yes' user instructs the module to use doxygen
954c05e7a3eSmrg#		  'no' user instructs the module not to use doxygen
955c05e7a3eSmrg#
956c05e7a3eSmrg# If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
957c05e7a3eSmrg#
958c05e7a3eSmrgAC_DEFUN([XORG_WITH_DOXYGEN],[
959c05e7a3eSmrgAC_ARG_VAR([DOXYGEN], [Path to doxygen command])
960c05e7a3eSmrgAC_ARG_VAR([DOT], [Path to the dot graphics utility])
961c05e7a3eSmrgm4_define([_defopt], m4_default([$2], [auto]))
962c05e7a3eSmrgAC_ARG_WITH(doxygen,
963c05e7a3eSmrg	AS_HELP_STRING([--with-doxygen],
964c05e7a3eSmrg	   [Use doxygen to regenerate documentation (default: ]_defopt[)]),
965c05e7a3eSmrg	   [use_doxygen=$withval], [use_doxygen=]_defopt)
966c05e7a3eSmrgm4_undefine([_defopt])
9676a45684fSmrg
968c05e7a3eSmrgif test "x$use_doxygen" = x"auto"; then
969c05e7a3eSmrg   AC_PATH_PROG([DOXYGEN], [doxygen])
970c05e7a3eSmrg   if test "x$DOXYGEN" = "x"; then
971c05e7a3eSmrg        AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
972c05e7a3eSmrg	have_doxygen=no
973c05e7a3eSmrg   else
974c05e7a3eSmrg        have_doxygen=yes
975c05e7a3eSmrg   fi
976c05e7a3eSmrgelif test "x$use_doxygen" = x"yes" ; then
977c05e7a3eSmrg   AC_PATH_PROG([DOXYGEN], [doxygen])
978c05e7a3eSmrg   if test "x$DOXYGEN" = "x"; then
979c05e7a3eSmrg        AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
980c05e7a3eSmrg   fi
981c05e7a3eSmrg   have_doxygen=yes
982c05e7a3eSmrgelif test "x$use_doxygen" = x"no" ; then
983c05e7a3eSmrg   if test "x$DOXYGEN" != "x"; then
984c05e7a3eSmrg      AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
985c05e7a3eSmrg   fi
986c05e7a3eSmrg   have_doxygen=no
987e6232409Smrgelse
988c05e7a3eSmrg   AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
989e6232409Smrgfi
990c05e7a3eSmrgm4_ifval([$1],
991c05e7a3eSmrg[if test "$have_doxygen" = yes; then
992c05e7a3eSmrg    # scrape the doxygen version
993c05e7a3eSmrg    AC_MSG_CHECKING([the doxygen version])
994c05e7a3eSmrg    doxygen_version=`$DOXYGEN --version 2>/dev/null`
995c05e7a3eSmrg    AC_MSG_RESULT([$doxygen_version])
996c05e7a3eSmrg    AS_VERSION_COMPARE([$doxygen_version], [$1],
997c05e7a3eSmrg        [if test "x$use_doxygen" = xauto; then
998c05e7a3eSmrg            AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
999c05e7a3eSmrg            have_doxygen=no
1000c05e7a3eSmrg        else
1001c05e7a3eSmrg            AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
1002c05e7a3eSmrg        fi])
1003c05e7a3eSmrgfi])
1004c05e7a3eSmrg
1005c05e7a3eSmrgdnl Check for DOT if we have doxygen. The caller decides if it is mandatory
1006c05e7a3eSmrgdnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
1007c05e7a3eSmrgdnl 	HAVE_DOT = @HAVE_DOT@
1008c05e7a3eSmrgHAVE_DOT=no
1009c05e7a3eSmrgif test "x$have_doxygen" = "xyes"; then
1010c05e7a3eSmrg  AC_PATH_PROG([DOT], [dot])
1011c05e7a3eSmrg    if test "x$DOT" != "x"; then
1012c05e7a3eSmrg      HAVE_DOT=yes
1013c05e7a3eSmrg    fi
10146a45684fSmrgfi
1015e6232409Smrg
1016c05e7a3eSmrgAC_SUBST([HAVE_DOT])
1017c05e7a3eSmrgAM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
1018c05e7a3eSmrgAM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
1019c05e7a3eSmrg]) # XORG_WITH_DOXYGEN
10208fff3f40Smrg
1021c05e7a3eSmrg# XORG_WITH_GROFF([DEFAULT])
1022c05e7a3eSmrg# ----------------
1023c05e7a3eSmrg# Minimum version: 1.6.0
1024c05e7a3eSmrg# Minimum version for optional DEFAULT argument: 1.11.0
10258fff3f40Smrg#
1026c05e7a3eSmrg# Documentation tools are not always available on all platforms and sometimes
1027c05e7a3eSmrg# not at the appropriate level. This macro enables a module to test for the
1028c05e7a3eSmrg# presence of the tool and obtain it's path in separate variables. Coupled with
1029c05e7a3eSmrg# the --with-groff option, it allows maximum flexibilty in making decisions
1030c05e7a3eSmrg# as whether or not to use the groff package. When DEFAULT is not specified,
1031c05e7a3eSmrg# --with-groff assumes 'auto'.
1032c05e7a3eSmrg#
1033c05e7a3eSmrg# Interface to module:
1034c05e7a3eSmrg# HAVE_GROFF:	 used in makefiles to conditionally generate documentation
1035c05e7a3eSmrg# HAVE_GROFF_MM: the memorandum macros (-mm) package
1036c05e7a3eSmrg# HAVE_GROFF_MS: the -ms macros package
1037c05e7a3eSmrg# GROFF:	 returns the path of the groff program found
1038c05e7a3eSmrg#		 returns the path set by the user in the environment
1039c05e7a3eSmrg# --with-groff:	 'yes' user instructs the module to use groff
1040c05e7a3eSmrg#		 'no' user instructs the module not to use groff
1041c05e7a3eSmrg#
1042c05e7a3eSmrg# Added in version 1.9.0:
1043c05e7a3eSmrg# HAVE_GROFF_HTML: groff has dependencies to output HTML format:
1044c05e7a3eSmrg#		   pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
1045c05e7a3eSmrg#		   psselect from the psutils package.
1046c05e7a3eSmrg#		   the ghostcript package. Refer to the grohtml man pages
1047c05e7a3eSmrg#
1048c05e7a3eSmrg# If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
1049c05e7a3eSmrg#
1050c05e7a3eSmrg# OS and distros often splits groff in a basic and full package, the former
1051c05e7a3eSmrg# having the groff program and the later having devices, fonts and macros
1052c05e7a3eSmrg# Checking for the groff executable is not enough.
1053c05e7a3eSmrg#
1054c05e7a3eSmrg# If macros are missing, we cannot assume that groff is useless, so we don't
1055c05e7a3eSmrg# unset HAVE_GROFF or GROFF env variables.
1056c05e7a3eSmrg# HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
1057c05e7a3eSmrg#
1058c05e7a3eSmrgAC_DEFUN([XORG_WITH_GROFF],[
1059c05e7a3eSmrgAC_ARG_VAR([GROFF], [Path to groff command])
1060c05e7a3eSmrgm4_define([_defopt], m4_default([$1], [auto]))
1061c05e7a3eSmrgAC_ARG_WITH(groff,
1062c05e7a3eSmrg	AS_HELP_STRING([--with-groff],
1063c05e7a3eSmrg	   [Use groff to regenerate documentation (default: ]_defopt[)]),
1064c05e7a3eSmrg	   [use_groff=$withval], [use_groff=]_defopt)
1065c05e7a3eSmrgm4_undefine([_defopt])
10668fff3f40Smrg
1067c05e7a3eSmrgif test "x$use_groff" = x"auto"; then
1068c05e7a3eSmrg   AC_PATH_PROG([GROFF], [groff])
1069c05e7a3eSmrg   if test "x$GROFF" = "x"; then
1070c05e7a3eSmrg        AC_MSG_WARN([groff not found - documentation targets will be skipped])
1071c05e7a3eSmrg	have_groff=no
1072c05e7a3eSmrg   else
1073c05e7a3eSmrg        have_groff=yes
1074c05e7a3eSmrg   fi
1075c05e7a3eSmrgelif test "x$use_groff" = x"yes" ; then
1076c05e7a3eSmrg   AC_PATH_PROG([GROFF], [groff])
1077c05e7a3eSmrg   if test "x$GROFF" = "x"; then
1078c05e7a3eSmrg        AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
1079c05e7a3eSmrg   fi
1080c05e7a3eSmrg   have_groff=yes
1081c05e7a3eSmrgelif test "x$use_groff" = x"no" ; then
1082c05e7a3eSmrg   if test "x$GROFF" != "x"; then
1083c05e7a3eSmrg      AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
1084c05e7a3eSmrg   fi
1085c05e7a3eSmrg   have_groff=no
1086c05e7a3eSmrgelse
1087c05e7a3eSmrg   AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
10888fff3f40Smrgfi
1089e6232409Smrg
1090c05e7a3eSmrg# We have groff, test for the presence of the macro packages
1091c05e7a3eSmrgif test "x$have_groff" = x"yes"; then
1092c05e7a3eSmrg    AC_MSG_CHECKING([for ${GROFF} -ms macros])
1093c05e7a3eSmrg    if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
1094c05e7a3eSmrg        groff_ms_works=yes
1095c05e7a3eSmrg    else
1096c05e7a3eSmrg        groff_ms_works=no
1097c05e7a3eSmrg    fi
1098c05e7a3eSmrg    AC_MSG_RESULT([$groff_ms_works])
1099c05e7a3eSmrg    AC_MSG_CHECKING([for ${GROFF} -mm macros])
1100c05e7a3eSmrg    if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
1101c05e7a3eSmrg        groff_mm_works=yes
1102c05e7a3eSmrg    else
1103c05e7a3eSmrg        groff_mm_works=no
1104c05e7a3eSmrg    fi
1105c05e7a3eSmrg    AC_MSG_RESULT([$groff_mm_works])
1106c05e7a3eSmrgfi
110794a251fdSmrg
1108c05e7a3eSmrg# We have groff, test for HTML dependencies, one command per package
1109c05e7a3eSmrgif test "x$have_groff" = x"yes"; then
1110c05e7a3eSmrg   AC_PATH_PROGS(GS_PATH, [gs gswin32c])
1111c05e7a3eSmrg   AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
1112c05e7a3eSmrg   AC_PATH_PROG(PSSELECT_PATH, [psselect])
1113c05e7a3eSmrg   if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
1114c05e7a3eSmrg      have_groff_html=yes
1115c05e7a3eSmrg   else
1116c05e7a3eSmrg      have_groff_html=no
1117c05e7a3eSmrg      AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
1118c05e7a3eSmrg   fi
1119c05e7a3eSmrgfi
112094a251fdSmrg
1121c05e7a3eSmrg# Set Automake conditionals for Makefiles
1122c05e7a3eSmrgAM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
1123c05e7a3eSmrgAM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
1124c05e7a3eSmrgAM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
1125c05e7a3eSmrgAM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
1126c05e7a3eSmrg]) # XORG_WITH_GROFF
112794a251fdSmrg
1128c05e7a3eSmrg# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
1129c05e7a3eSmrg# ---------------------------------------
1130c05e7a3eSmrg# Minimum version: 1.6.0
1131c05e7a3eSmrg# Minimum version for optional DEFAULT argument: 1.11.0
1132c05e7a3eSmrg# Minimum version for optional MIN-VERSION argument: 1.15.0
11338fff3f40Smrg#
1134c05e7a3eSmrg# Documentation tools are not always available on all platforms and sometimes
1135c05e7a3eSmrg# not at the appropriate level. This macro enables a module to test for the
1136c05e7a3eSmrg# presence of the tool and obtain it's path in separate variables. Coupled with
1137c05e7a3eSmrg# the --with-fop option, it allows maximum flexibilty in making decisions
1138c05e7a3eSmrg# as whether or not to use the fop package. When DEFAULT is not specified,
1139c05e7a3eSmrg# --with-fop assumes 'auto'.
11408fff3f40Smrg#
1141c05e7a3eSmrg# Interface to module:
1142c05e7a3eSmrg# HAVE_FOP: 	used in makefiles to conditionally generate documentation
1143c05e7a3eSmrg# FOP:	 	returns the path of the fop program found
1144c05e7a3eSmrg#		returns the path set by the user in the environment
1145c05e7a3eSmrg# --with-fop: 	'yes' user instructs the module to use fop
1146c05e7a3eSmrg#		'no' user instructs the module not to use fop
11478fff3f40Smrg#
1148c05e7a3eSmrg# If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
11496a45684fSmrg#
1150c05e7a3eSmrgAC_DEFUN([XORG_WITH_FOP],[
1151c05e7a3eSmrgAC_ARG_VAR([FOP], [Path to fop command])
1152c05e7a3eSmrgm4_define([_defopt], m4_default([$2], [auto]))
1153c05e7a3eSmrgAC_ARG_WITH(fop,
1154c05e7a3eSmrg	AS_HELP_STRING([--with-fop],
1155c05e7a3eSmrg	   [Use fop to regenerate documentation (default: ]_defopt[)]),
1156c05e7a3eSmrg	   [use_fop=$withval], [use_fop=]_defopt)
1157c05e7a3eSmrgm4_undefine([_defopt])
11586a45684fSmrg
1159c05e7a3eSmrgif test "x$use_fop" = x"auto"; then
1160c05e7a3eSmrg   AC_PATH_PROG([FOP], [fop])
1161c05e7a3eSmrg   if test "x$FOP" = "x"; then
1162c05e7a3eSmrg        AC_MSG_WARN([fop not found - documentation targets will be skipped])
1163c05e7a3eSmrg	have_fop=no
1164c05e7a3eSmrg   else
1165c05e7a3eSmrg        have_fop=yes
1166c05e7a3eSmrg   fi
1167c05e7a3eSmrgelif test "x$use_fop" = x"yes" ; then
1168c05e7a3eSmrg   AC_PATH_PROG([FOP], [fop])
1169c05e7a3eSmrg   if test "x$FOP" = "x"; then
1170c05e7a3eSmrg        AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
1171c05e7a3eSmrg   fi
1172c05e7a3eSmrg   have_fop=yes
1173c05e7a3eSmrgelif test "x$use_fop" = x"no" ; then
1174c05e7a3eSmrg   if test "x$FOP" != "x"; then
1175c05e7a3eSmrg      AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
1176c05e7a3eSmrg   fi
1177c05e7a3eSmrg   have_fop=no
1178c05e7a3eSmrgelse
1179c05e7a3eSmrg   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
1180c05e7a3eSmrgfi
11816a45684fSmrg
1182c05e7a3eSmrg# Test for a minimum version of fop, if provided.
1183c05e7a3eSmrgm4_ifval([$1],
1184c05e7a3eSmrg[if test "$have_fop" = yes; then
1185c05e7a3eSmrg    # scrape the fop version
1186c05e7a3eSmrg    AC_MSG_CHECKING([for fop minimum version])
1187c05e7a3eSmrg    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
1188c05e7a3eSmrg    AC_MSG_RESULT([$fop_version])
1189c05e7a3eSmrg    AS_VERSION_COMPARE([$fop_version], [$1],
1190c05e7a3eSmrg        [if test "x$use_fop" = xauto; then
1191c05e7a3eSmrg            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
1192c05e7a3eSmrg            have_fop=no
1193c05e7a3eSmrg        else
1194c05e7a3eSmrg            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
1195c05e7a3eSmrg        fi])
1196c05e7a3eSmrgfi])
1197c05e7a3eSmrgAM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
1198c05e7a3eSmrg]) # XORG_WITH_FOP
119994a251fdSmrg
1200c05e7a3eSmrg# XORG_WITH_M4([MIN-VERSION])
1201c05e7a3eSmrg# ---------------------------
1202c05e7a3eSmrg# Minimum version: 1.19.0
12038fff3f40Smrg#
1204c05e7a3eSmrg# This macro attempts to locate an m4 macro processor which supports
1205c05e7a3eSmrg# -I option and is only useful for modules relying on M4 in order to
1206c05e7a3eSmrg# expand macros in source code files.
12078fff3f40Smrg#
1208c05e7a3eSmrg# Interface to module:
1209c05e7a3eSmrg# M4:	 	returns the path of the m4 program found
1210c05e7a3eSmrg#		returns the path set by the user in the environment
121194a251fdSmrg#
1212c05e7a3eSmrgAC_DEFUN([XORG_WITH_M4], [
1213c05e7a3eSmrgAC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
1214c05e7a3eSmrg   [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
1215c05e7a3eSmrg       [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
1216c05e7a3eSmrg         ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
1217c05e7a3eSmrg   [AC_MSG_ERROR([could not find m4 that supports -I option])],
1218c05e7a3eSmrg   [$PATH:/usr/gnu/bin])])
121994a251fdSmrg
1220c05e7a3eSmrgAC_SUBST([M4], [$ac_cv_path_M4])
1221c05e7a3eSmrg]) # XORG_WITH_M4
12228fff3f40Smrg
1223c05e7a3eSmrg# XORG_WITH_PS2PDF([DEFAULT])
1224c05e7a3eSmrg# ----------------
1225c05e7a3eSmrg# Minimum version: 1.6.0
1226c05e7a3eSmrg# Minimum version for optional DEFAULT argument: 1.11.0
1227c05e7a3eSmrg#
1228c05e7a3eSmrg# Documentation tools are not always available on all platforms and sometimes
1229c05e7a3eSmrg# not at the appropriate level. This macro enables a module to test for the
1230c05e7a3eSmrg# presence of the tool and obtain it's path in separate variables. Coupled with
1231c05e7a3eSmrg# the --with-ps2pdf option, it allows maximum flexibilty in making decisions
1232c05e7a3eSmrg# as whether or not to use the ps2pdf package. When DEFAULT is not specified,
1233c05e7a3eSmrg# --with-ps2pdf assumes 'auto'.
12348fff3f40Smrg#
1235c05e7a3eSmrg# Interface to module:
1236c05e7a3eSmrg# HAVE_PS2PDF: 	used in makefiles to conditionally generate documentation
1237c05e7a3eSmrg# PS2PDF:	returns the path of the ps2pdf program found
1238c05e7a3eSmrg#		returns the path set by the user in the environment
1239c05e7a3eSmrg# --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
1240c05e7a3eSmrg#		 'no' user instructs the module not to use ps2pdf
12418fff3f40Smrg#
1242c05e7a3eSmrg# If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
1243e6232409Smrg#
1244c05e7a3eSmrgAC_DEFUN([XORG_WITH_PS2PDF],[
1245c05e7a3eSmrgAC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
1246c05e7a3eSmrgm4_define([_defopt], m4_default([$1], [auto]))
1247c05e7a3eSmrgAC_ARG_WITH(ps2pdf,
1248c05e7a3eSmrg	AS_HELP_STRING([--with-ps2pdf],
1249c05e7a3eSmrg	   [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
1250c05e7a3eSmrg	   [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
1251c05e7a3eSmrgm4_undefine([_defopt])
125294a251fdSmrg
1253c05e7a3eSmrgif test "x$use_ps2pdf" = x"auto"; then
1254c05e7a3eSmrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
1255c05e7a3eSmrg   if test "x$PS2PDF" = "x"; then
1256c05e7a3eSmrg        AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
1257c05e7a3eSmrg	have_ps2pdf=no
1258c05e7a3eSmrg   else
1259c05e7a3eSmrg        have_ps2pdf=yes
1260c05e7a3eSmrg   fi
1261c05e7a3eSmrgelif test "x$use_ps2pdf" = x"yes" ; then
1262c05e7a3eSmrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
1263c05e7a3eSmrg   if test "x$PS2PDF" = "x"; then
1264c05e7a3eSmrg        AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
1265c05e7a3eSmrg   fi
1266c05e7a3eSmrg   have_ps2pdf=yes
1267c05e7a3eSmrgelif test "x$use_ps2pdf" = x"no" ; then
1268c05e7a3eSmrg   if test "x$PS2PDF" != "x"; then
1269c05e7a3eSmrg      AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
1270c05e7a3eSmrg   fi
1271c05e7a3eSmrg   have_ps2pdf=no
12728fff3f40Smrgelse
1273c05e7a3eSmrg   AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
1274c05e7a3eSmrgfi
1275c05e7a3eSmrgAM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
1276c05e7a3eSmrg]) # XORG_WITH_PS2PDF
1277e6232409Smrg
1278c05e7a3eSmrg# XORG_ENABLE_DOCS (enable_docs=yes)
1279c05e7a3eSmrg# ----------------
1280c05e7a3eSmrg# Minimum version: 1.6.0
12818fff3f40Smrg#
1282c05e7a3eSmrg# Documentation tools are not always available on all platforms and sometimes
1283c05e7a3eSmrg# not at the appropriate level. This macro enables a builder to skip all
1284c05e7a3eSmrg# documentation targets except traditional man pages.
1285c05e7a3eSmrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
1286c05e7a3eSmrg# maximum flexibilty in controlling documentation building.
1287c05e7a3eSmrg# Refer to:
1288c05e7a3eSmrg# XORG_WITH_XMLTO         --with-xmlto
1289c05e7a3eSmrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1290c05e7a3eSmrg# XORG_WITH_DOXYGEN       --with-doxygen
1291c05e7a3eSmrg# XORG_WITH_FOP           --with-fop
1292c05e7a3eSmrg# XORG_WITH_GROFF         --with-groff
1293c05e7a3eSmrg# XORG_WITH_PS2PDF        --with-ps2pdf
129494a251fdSmrg#
1295c05e7a3eSmrg# Interface to module:
1296c05e7a3eSmrg# ENABLE_DOCS: 	  used in makefiles to conditionally generate documentation
1297c05e7a3eSmrg# --enable-docs: 'yes' user instructs the module to generate docs
1298c05e7a3eSmrg#		 'no' user instructs the module not to generate docs
1299c05e7a3eSmrg# parm1:	specify the default value, yes or no.
130094a251fdSmrg#
1301c05e7a3eSmrgAC_DEFUN([XORG_ENABLE_DOCS],[
1302c05e7a3eSmrgm4_define([docs_default], m4_default([$1], [yes]))
1303c05e7a3eSmrgAC_ARG_ENABLE(docs,
1304c05e7a3eSmrg	AS_HELP_STRING([--enable-docs],
1305c05e7a3eSmrg	   [Enable building the documentation (default: ]docs_default[)]),
1306c05e7a3eSmrg	   [build_docs=$enableval], [build_docs=]docs_default)
1307c05e7a3eSmrgm4_undefine([docs_default])
1308c05e7a3eSmrgAM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
1309c05e7a3eSmrgAC_MSG_CHECKING([whether to build documentation])
1310c05e7a3eSmrgAC_MSG_RESULT([$build_docs])
1311c05e7a3eSmrg]) # XORG_ENABLE_DOCS
1312e6232409Smrg
1313c05e7a3eSmrg# XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
1314c05e7a3eSmrg# ----------------
1315c05e7a3eSmrg# Minimum version: 1.6.0
1316c05e7a3eSmrg#
1317c05e7a3eSmrg# This macro enables a builder to skip all developer documentation.
1318c05e7a3eSmrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
1319c05e7a3eSmrg# maximum flexibilty in controlling documentation building.
1320c05e7a3eSmrg# Refer to:
1321c05e7a3eSmrg# XORG_WITH_XMLTO         --with-xmlto
1322c05e7a3eSmrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1323c05e7a3eSmrg# XORG_WITH_DOXYGEN       --with-doxygen
1324c05e7a3eSmrg# XORG_WITH_FOP           --with-fop
1325c05e7a3eSmrg# XORG_WITH_GROFF         --with-groff
1326c05e7a3eSmrg# XORG_WITH_PS2PDF        --with-ps2pdf
1327c05e7a3eSmrg#
1328c05e7a3eSmrg# Interface to module:
1329c05e7a3eSmrg# ENABLE_DEVEL_DOCS:	used in makefiles to conditionally generate developer docs
1330c05e7a3eSmrg# --enable-devel-docs:	'yes' user instructs the module to generate developer docs
1331c05e7a3eSmrg#			'no' user instructs the module not to generate developer docs
1332c05e7a3eSmrg# parm1:		specify the default value, yes or no.
1333c05e7a3eSmrg#
1334c05e7a3eSmrgAC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
1335c05e7a3eSmrgm4_define([devel_default], m4_default([$1], [yes]))
1336c05e7a3eSmrgAC_ARG_ENABLE(devel-docs,
1337c05e7a3eSmrg	AS_HELP_STRING([--enable-devel-docs],
1338c05e7a3eSmrg	   [Enable building the developer documentation (default: ]devel_default[)]),
1339c05e7a3eSmrg	   [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
1340c05e7a3eSmrgm4_undefine([devel_default])
1341c05e7a3eSmrgAM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
1342c05e7a3eSmrgAC_MSG_CHECKING([whether to build developer documentation])
1343c05e7a3eSmrgAC_MSG_RESULT([$build_devel_docs])
1344c05e7a3eSmrg]) # XORG_ENABLE_DEVEL_DOCS
13458fff3f40Smrg
1346c05e7a3eSmrg# XORG_ENABLE_SPECS (enable_specs=yes)
1347c05e7a3eSmrg# ----------------
1348c05e7a3eSmrg# Minimum version: 1.6.0
1349c05e7a3eSmrg#
1350c05e7a3eSmrg# This macro enables a builder to skip all functional specification targets.
1351c05e7a3eSmrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
1352c05e7a3eSmrg# maximum flexibilty in controlling documentation building.
1353c05e7a3eSmrg# Refer to:
1354c05e7a3eSmrg# XORG_WITH_XMLTO         --with-xmlto
1355c05e7a3eSmrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1356c05e7a3eSmrg# XORG_WITH_DOXYGEN       --with-doxygen
1357c05e7a3eSmrg# XORG_WITH_FOP           --with-fop
1358c05e7a3eSmrg# XORG_WITH_GROFF         --with-groff
1359c05e7a3eSmrg# XORG_WITH_PS2PDF        --with-ps2pdf
1360c05e7a3eSmrg#
1361c05e7a3eSmrg# Interface to module:
1362c05e7a3eSmrg# ENABLE_SPECS:		used in makefiles to conditionally generate specs
1363c05e7a3eSmrg# --enable-specs:	'yes' user instructs the module to generate specs
1364c05e7a3eSmrg#			'no' user instructs the module not to generate specs
1365c05e7a3eSmrg# parm1:		specify the default value, yes or no.
1366c05e7a3eSmrg#
1367c05e7a3eSmrgAC_DEFUN([XORG_ENABLE_SPECS],[
1368c05e7a3eSmrgm4_define([spec_default], m4_default([$1], [yes]))
1369c05e7a3eSmrgAC_ARG_ENABLE(specs,
1370c05e7a3eSmrg	AS_HELP_STRING([--enable-specs],
1371c05e7a3eSmrg	   [Enable building the specs (default: ]spec_default[)]),
1372c05e7a3eSmrg	   [build_specs=$enableval], [build_specs=]spec_default)
1373c05e7a3eSmrgm4_undefine([spec_default])
1374c05e7a3eSmrgAM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
1375c05e7a3eSmrgAC_MSG_CHECKING([whether to build functional specifications])
1376c05e7a3eSmrgAC_MSG_RESULT([$build_specs])
1377c05e7a3eSmrg]) # XORG_ENABLE_SPECS
13788fff3f40Smrg
1379c05e7a3eSmrg# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
1380c05e7a3eSmrg# ----------------------------------------------
1381c05e7a3eSmrg# Minimum version: 1.13.0
1382c05e7a3eSmrg#
1383c05e7a3eSmrg# This macro enables a builder to enable/disable unit testing
1384c05e7a3eSmrg# It makes no assumption about the test cases implementation
1385c05e7a3eSmrg# Test cases may or may not use Automake "Support for test suites"
1386c05e7a3eSmrg# They may or may not use the software utility library GLib
1387c05e7a3eSmrg#
1388c05e7a3eSmrg# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
1389c05e7a3eSmrg# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
1390c05e7a3eSmrg# The variable enable_unit_tests is used by other macros in this file.
1391c05e7a3eSmrg#
1392c05e7a3eSmrg# Interface to module:
1393c05e7a3eSmrg# ENABLE_UNIT_TESTS:	used in makefiles to conditionally build tests
1394c05e7a3eSmrg# enable_unit_tests:    used in configure.ac for additional configuration
1395c05e7a3eSmrg# --enable-unit-tests:	'yes' user instructs the module to build tests
1396c05e7a3eSmrg#			'no' user instructs the module not to build tests
1397c05e7a3eSmrg# parm1:		specify the default value, yes or no.
1398c05e7a3eSmrg#
1399c05e7a3eSmrgAC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
1400c05e7a3eSmrgAC_BEFORE([$0], [XORG_WITH_GLIB])
1401c05e7a3eSmrgAC_BEFORE([$0], [XORG_LD_WRAP])
1402c05e7a3eSmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
1403c05e7a3eSmrgm4_define([_defopt], m4_default([$1], [auto]))
1404c05e7a3eSmrgAC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
1405c05e7a3eSmrg	[Enable building unit test cases (default: ]_defopt[)]),
1406c05e7a3eSmrg	[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
1407c05e7a3eSmrgm4_undefine([_defopt])
1408c05e7a3eSmrgAM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
1409c05e7a3eSmrgAC_MSG_CHECKING([whether to build unit test cases])
1410c05e7a3eSmrgAC_MSG_RESULT([$enable_unit_tests])
1411c05e7a3eSmrg]) # XORG_ENABLE_UNIT_TESTS
1412e6232409Smrg
1413c05e7a3eSmrg# XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
1414c05e7a3eSmrg# ------------------------------------------------------
1415c05e7a3eSmrg# Minimum version: 1.17.0
1416c05e7a3eSmrg#
1417c05e7a3eSmrg# This macro enables a builder to enable/disable integration testing
1418c05e7a3eSmrg# It makes no assumption about the test cases' implementation
1419c05e7a3eSmrg# Test cases may or may not use Automake "Support for test suites"
1420c05e7a3eSmrg#
1421c05e7a3eSmrg# Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
1422c05e7a3eSmrg# usually requires less dependencies and may be built and run under less
1423c05e7a3eSmrg# stringent environments than integration tests.
1424c05e7a3eSmrg#
1425c05e7a3eSmrg# Interface to module:
1426c05e7a3eSmrg# ENABLE_INTEGRATION_TESTS:   used in makefiles to conditionally build tests
1427c05e7a3eSmrg# enable_integration_tests:   used in configure.ac for additional configuration
1428c05e7a3eSmrg# --enable-integration-tests: 'yes' user instructs the module to build tests
1429c05e7a3eSmrg#                             'no' user instructs the module not to build tests
1430c05e7a3eSmrg# parm1:                      specify the default value, yes or no.
1431c05e7a3eSmrg#
1432c05e7a3eSmrgAC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
1433c05e7a3eSmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
1434c05e7a3eSmrgm4_define([_defopt], m4_default([$1], [auto]))
1435c05e7a3eSmrgAC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
1436c05e7a3eSmrg	[Enable building integration test cases (default: ]_defopt[)]),
1437c05e7a3eSmrg	[enable_integration_tests=$enableval],
1438c05e7a3eSmrg	[enable_integration_tests=]_defopt)
1439c05e7a3eSmrgm4_undefine([_defopt])
1440c05e7a3eSmrgAM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
1441c05e7a3eSmrg	[test "x$enable_integration_tests" != xno])
1442c05e7a3eSmrgAC_MSG_CHECKING([whether to build unit test cases])
1443c05e7a3eSmrgAC_MSG_RESULT([$enable_integration_tests])
1444c05e7a3eSmrg]) # XORG_ENABLE_INTEGRATION_TESTS
1445e6232409Smrg
1446c05e7a3eSmrg# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
1447c05e7a3eSmrg# ----------------------------------------
1448c05e7a3eSmrg# Minimum version: 1.13.0
1449c05e7a3eSmrg#
1450c05e7a3eSmrg# GLib is a library which provides advanced data structures and functions.
1451c05e7a3eSmrg# This macro enables a module to test for the presence of Glib.
1452c05e7a3eSmrg#
1453c05e7a3eSmrg# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
1454c05e7a3eSmrg# Otherwise the value of $enable_unit_tests is blank.
1455c05e7a3eSmrg#
1456c05e7a3eSmrg# Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
1457c05e7a3eSmrg# test support usually requires less dependencies and may be built and run under
1458c05e7a3eSmrg# less stringent environments than integration tests.
1459c05e7a3eSmrg#
1460c05e7a3eSmrg# Interface to module:
1461c05e7a3eSmrg# HAVE_GLIB: used in makefiles to conditionally build targets
1462c05e7a3eSmrg# with_glib: used in configure.ac to know if GLib has been found
1463c05e7a3eSmrg# --with-glib:	'yes' user instructs the module to use glib
1464c05e7a3eSmrg#		'no' user instructs the module not to use glib
1465c05e7a3eSmrg#
1466c05e7a3eSmrgAC_DEFUN([XORG_WITH_GLIB],[
1467c05e7a3eSmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
1468c05e7a3eSmrgm4_define([_defopt], m4_default([$2], [auto]))
1469c05e7a3eSmrgAC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
1470c05e7a3eSmrg	[Use GLib library for unit testing (default: ]_defopt[)]),
1471c05e7a3eSmrg	[with_glib=$withval], [with_glib=]_defopt)
1472c05e7a3eSmrgm4_undefine([_defopt])
1473e6232409Smrg
1474c05e7a3eSmrghave_glib=no
1475c05e7a3eSmrg# Do not probe GLib if user explicitly disabled unit testing
1476c05e7a3eSmrgif test "x$enable_unit_tests" != x"no"; then
1477c05e7a3eSmrg  # Do not probe GLib if user explicitly disabled it
1478c05e7a3eSmrg  if test "x$with_glib" != x"no"; then
1479c05e7a3eSmrg    m4_ifval(
1480c05e7a3eSmrg      [$1],
1481c05e7a3eSmrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
1482c05e7a3eSmrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
1483c05e7a3eSmrg    )
1484c05e7a3eSmrg  fi
1485c05e7a3eSmrgfi
1486e6232409Smrg
1487c05e7a3eSmrg# Not having GLib when unit testing has been explicitly requested is an error
1488c05e7a3eSmrgif test "x$enable_unit_tests" = x"yes"; then
1489c05e7a3eSmrg  if test "x$have_glib" = x"no"; then
1490c05e7a3eSmrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
1491c05e7a3eSmrg  fi
1492c05e7a3eSmrgfi
14938fff3f40Smrg
1494c05e7a3eSmrg# Having unit testing disabled when GLib has been explicitly requested is an error
1495c05e7a3eSmrgif test "x$enable_unit_tests" = x"no"; then
1496c05e7a3eSmrg  if test "x$with_glib" = x"yes"; then
1497c05e7a3eSmrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
1498c05e7a3eSmrg  fi
1499c05e7a3eSmrgfi
1500e6232409Smrg
1501c05e7a3eSmrg# Not having GLib when it has been explicitly requested is an error
1502c05e7a3eSmrgif test "x$with_glib" = x"yes"; then
1503c05e7a3eSmrg  if test "x$have_glib" = x"no"; then
1504c05e7a3eSmrg    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
1505c05e7a3eSmrg  fi
1506c05e7a3eSmrgfi
15078fff3f40Smrg
1508c05e7a3eSmrgAM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
1509c05e7a3eSmrg]) # XORG_WITH_GLIB
1510e6232409Smrg
1511c05e7a3eSmrg# XORG_LD_WRAP([required|optional])
1512c05e7a3eSmrg# ---------------------------------
1513c05e7a3eSmrg# Minimum version: 1.13.0
151494a251fdSmrg#
1515c05e7a3eSmrg# Check if linker supports -wrap, passed via compiler flags
151694a251fdSmrg#
1517c05e7a3eSmrg# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
1518c05e7a3eSmrg# Otherwise the value of $enable_unit_tests is blank.
151994a251fdSmrg#
1520c05e7a3eSmrg# Argument added in 1.16.0 - default is "required", to match existing behavior
1521c05e7a3eSmrg# of returning an error if enable_unit_tests is yes, and ld -wrap is not
1522c05e7a3eSmrg# available, an argument of "optional" allows use when some unit tests require
1523c05e7a3eSmrg# ld -wrap and others do not.
152494a251fdSmrg#
1525c05e7a3eSmrgAC_DEFUN([XORG_LD_WRAP],[
1526c05e7a3eSmrgXORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
1527c05e7a3eSmrg    [AC_LANG_PROGRAM([#include <stdlib.h>
1528c05e7a3eSmrg                      void __wrap_exit(int status) { return; }],
1529c05e7a3eSmrg                     [exit(0);])])
1530c05e7a3eSmrg# Not having ld wrap when unit testing has been explicitly requested is an error
1531c05e7a3eSmrgif test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
1532c05e7a3eSmrg  if test "x$have_ld_wrap" = x"no"; then
1533c05e7a3eSmrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
1534c05e7a3eSmrg  fi
153594a251fdSmrgfi
1536c05e7a3eSmrgAM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
1537c05e7a3eSmrg#
1538c05e7a3eSmrg]) # XORG_LD_WRAP
153994a251fdSmrg
1540c05e7a3eSmrg# XORG_CHECK_LINKER_FLAGS
1541c05e7a3eSmrg# -----------------------
1542c05e7a3eSmrg# SYNOPSIS
1543c05e7a3eSmrg#
1544c05e7a3eSmrg#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
1545c05e7a3eSmrg#
1546c05e7a3eSmrg# DESCRIPTION
1547c05e7a3eSmrg#
1548c05e7a3eSmrg#   Check whether the given linker FLAGS work with the current language's
1549c05e7a3eSmrg#   linker, or whether they give an error.
1550c05e7a3eSmrg#
1551c05e7a3eSmrg#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
1552c05e7a3eSmrg#   success/failure.
1553c05e7a3eSmrg#
1554c05e7a3eSmrg#   PROGRAM-SOURCE is the program source to link with, if needed
1555c05e7a3eSmrg#
1556c05e7a3eSmrg#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
1557c05e7a3eSmrg#
1558c05e7a3eSmrg# LICENSE
1559c05e7a3eSmrg#
1560c05e7a3eSmrg#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
1561c05e7a3eSmrg#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
1562c05e7a3eSmrg#   Copyright (c) 2009 Matteo Frigo
1563c05e7a3eSmrg#
1564c05e7a3eSmrg#   This program is free software: you can redistribute it and/or modify it
1565c05e7a3eSmrg#   under the terms of the GNU General Public License as published by the
1566c05e7a3eSmrg#   Free Software Foundation, either version 3 of the License, or (at your
1567c05e7a3eSmrg#   option) any later version.
1568c05e7a3eSmrg#
1569c05e7a3eSmrg#   This program is distributed in the hope that it will be useful, but
1570c05e7a3eSmrg#   WITHOUT ANY WARRANTY; without even the implied warranty of
1571c05e7a3eSmrg#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
1572c05e7a3eSmrg#   Public License for more details.
1573c05e7a3eSmrg#
1574c05e7a3eSmrg#   You should have received a copy of the GNU General Public License along
1575c05e7a3eSmrg#   with this program. If not, see <http://www.gnu.org/licenses/>.
1576c05e7a3eSmrg#
1577c05e7a3eSmrg#   As a special exception, the respective Autoconf Macro's copyright owner
1578c05e7a3eSmrg#   gives unlimited permission to copy, distribute and modify the configure
1579c05e7a3eSmrg#   scripts that are the output of Autoconf when processing the Macro. You
1580c05e7a3eSmrg#   need not follow the terms of the GNU General Public License when using
1581c05e7a3eSmrg#   or distributing such scripts, even though portions of the text of the
1582c05e7a3eSmrg#   Macro appear in them. The GNU General Public License (GPL) does govern
1583c05e7a3eSmrg#   all other use of the material that constitutes the Autoconf Macro.
1584c05e7a3eSmrg#
1585c05e7a3eSmrg#   This special exception to the GPL applies to versions of the Autoconf
1586c05e7a3eSmrg#   Macro released by the Autoconf Archive. When you make and distribute a
1587c05e7a3eSmrg#   modified version of the Autoconf Macro, you may extend this special
1588c05e7a3eSmrg#   exception to the GPL to apply to your modified version as well.#
1589c05e7a3eSmrgAC_DEFUN([XORG_CHECK_LINKER_FLAGS],
1590c05e7a3eSmrg[AC_MSG_CHECKING([whether the linker accepts $1])
1591c05e7a3eSmrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
1592c05e7a3eSmrgAS_LITERAL_IF([$1],
1593c05e7a3eSmrg  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
1594c05e7a3eSmrg      ax_save_FLAGS=$LDFLAGS
1595c05e7a3eSmrg      LDFLAGS="$1"
1596c05e7a3eSmrg      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
1597c05e7a3eSmrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
1598c05e7a3eSmrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
1599c05e7a3eSmrg      LDFLAGS=$ax_save_FLAGS])],
1600c05e7a3eSmrg  [ax_save_FLAGS=$LDFLAGS
1601c05e7a3eSmrg   LDFLAGS="$1"
1602c05e7a3eSmrg   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
1603c05e7a3eSmrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
1604c05e7a3eSmrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
1605c05e7a3eSmrg   LDFLAGS=$ax_save_FLAGS])
1606c05e7a3eSmrgeval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
1607c05e7a3eSmrgAC_MSG_RESULT($xorg_check_linker_flags)
1608c05e7a3eSmrgif test "x$xorg_check_linker_flags" = xyes; then
1609c05e7a3eSmrg	m4_default([$2], :)
161094a251fdSmrgelse
1611c05e7a3eSmrg	m4_default([$3], :)
161294a251fdSmrgfi
1613c05e7a3eSmrg]) # XORG_CHECK_LINKER_FLAGS
1614e6232409Smrg
1615c05e7a3eSmrg# XORG_MEMORY_CHECK_FLAGS
161694a251fdSmrg# -----------------------
1617c05e7a3eSmrg# Minimum version: 1.16.0
16188fff3f40Smrg#
1619c05e7a3eSmrg# This macro attempts to find appropriate memory checking functionality
1620c05e7a3eSmrg# for various platforms which unit testing code may use to catch various
1621c05e7a3eSmrg# forms of memory allocation and access errors in testing.
1622c05e7a3eSmrg#
1623c05e7a3eSmrg# Interface to module:
1624c05e7a3eSmrg# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
1625c05e7a3eSmrg#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
1626c05e7a3eSmrg#
1627c05e7a3eSmrg# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
1628c05e7a3eSmrg#
1629c05e7a3eSmrgAC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
16308fff3f40Smrg
163194a251fdSmrgAC_REQUIRE([AC_CANONICAL_HOST])
1632c05e7a3eSmrgAC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
1633c05e7a3eSmrg           [Environment variables to enable memory checking in tests])
1634e6232409Smrg
1635c05e7a3eSmrg# Check for different types of support on different platforms
1636c05e7a3eSmrgcase $host_os in
1637c05e7a3eSmrg    solaris*)
1638c05e7a3eSmrg        AC_CHECK_LIB([umem], [umem_alloc],
1639c05e7a3eSmrg            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
1640c05e7a3eSmrg        ;;
1641c05e7a3eSmrg    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
1642c05e7a3eSmrg        # both directly and inverted, so should not be 0 or 255.
1643c05e7a3eSmrg        malloc_debug_env='MALLOC_PERTURB_=15'
1644c05e7a3eSmrg        ;;
1645c05e7a3eSmrg    darwin*)
1646c05e7a3eSmrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
1647c05e7a3eSmrg        ;;
1648c05e7a3eSmrg    *bsd*)
1649c05e7a3eSmrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
1650c05e7a3eSmrg        ;;
1651c05e7a3eSmrgesac
1652e6232409Smrg
1653c05e7a3eSmrg# User supplied flags override default flags
1654c05e7a3eSmrgif test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
1655c05e7a3eSmrg    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
165694a251fdSmrgfi
1657e6232409Smrg
1658c05e7a3eSmrgAC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
1659c05e7a3eSmrg]) # XORG_WITH_LINT
1660e6232409Smrg
1661c05e7a3eSmrg# XORG_CHECK_MALLOC_ZERO
1662c05e7a3eSmrg# ----------------------
1663c05e7a3eSmrg# Minimum version: 1.0.0
1664c05e7a3eSmrg#
1665c05e7a3eSmrg# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
1666c05e7a3eSmrg# malloc(0) returns NULL.  Packages should add one of these cflags to
1667c05e7a3eSmrg# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
1668c05e7a3eSmrgAC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
1669c05e7a3eSmrgAC_ARG_ENABLE(malloc0returnsnull,
1670c05e7a3eSmrg	AS_HELP_STRING([--enable-malloc0returnsnull],
1671c05e7a3eSmrg		       [malloc(0) returns NULL (default: auto)]),
1672c05e7a3eSmrg	[MALLOC_ZERO_RETURNS_NULL=$enableval],
1673c05e7a3eSmrg	[MALLOC_ZERO_RETURNS_NULL=auto])
1674e6232409Smrg
1675c05e7a3eSmrgAC_MSG_CHECKING([whether malloc(0) returns NULL])
1676c05e7a3eSmrgif test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
1677c05e7a3eSmrgAC_CACHE_VAL([xorg_cv_malloc0_returns_null],
1678c05e7a3eSmrg	[AC_RUN_IFELSE([AC_LANG_PROGRAM([
1679c05e7a3eSmrg#include <stdlib.h>
1680c05e7a3eSmrg],[
1681c05e7a3eSmrg    char *m0, *r0, *c0, *p;
1682c05e7a3eSmrg    m0 = malloc(0);
1683c05e7a3eSmrg    p = malloc(10);
1684c05e7a3eSmrg    r0 = realloc(p,0);
1685c05e7a3eSmrg    c0 = calloc(0,10);
1686c05e7a3eSmrg    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
1687c05e7a3eSmrg])],
1688c05e7a3eSmrg		[xorg_cv_malloc0_returns_null=yes],
1689c05e7a3eSmrg		[xorg_cv_malloc0_returns_null=no])])
1690c05e7a3eSmrgMALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null
169194a251fdSmrgfi
1692c05e7a3eSmrgAC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
169394a251fdSmrg
1694c05e7a3eSmrgif test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
1695c05e7a3eSmrg	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
1696c05e7a3eSmrg	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
1697c05e7a3eSmrg	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
169894a251fdSmrgelse
1699c05e7a3eSmrg	MALLOC_ZERO_CFLAGS=""
1700c05e7a3eSmrg	XMALLOC_ZERO_CFLAGS=""
1701c05e7a3eSmrg	XTMALLOC_ZERO_CFLAGS=""
170294a251fdSmrgfi
170394a251fdSmrg
1704c05e7a3eSmrgAC_SUBST([MALLOC_ZERO_CFLAGS])
1705c05e7a3eSmrgAC_SUBST([XMALLOC_ZERO_CFLAGS])
1706c05e7a3eSmrgAC_SUBST([XTMALLOC_ZERO_CFLAGS])
1707c05e7a3eSmrg]) # XORG_CHECK_MALLOC_ZERO
170894a251fdSmrg
1709c05e7a3eSmrg# XORG_WITH_LINT()
1710c05e7a3eSmrg# ----------------
1711c05e7a3eSmrg# Minimum version: 1.1.0
17128fff3f40Smrg#
1713c05e7a3eSmrg# This macro enables the use of a tool that flags some suspicious and
1714c05e7a3eSmrg# non-portable constructs (likely to be bugs) in C language source code.
1715c05e7a3eSmrg# It will attempt to locate the tool and use appropriate options.
1716c05e7a3eSmrg# There are various lint type tools on different platforms.
1717c05e7a3eSmrg#
1718c05e7a3eSmrg# Interface to module:
1719c05e7a3eSmrg# LINT:		returns the path to the tool found on the platform
1720c05e7a3eSmrg#		or the value set to LINT on the configure cmd line
1721c05e7a3eSmrg#		also an Automake conditional
1722c05e7a3eSmrg# LINT_FLAGS:	an Automake variable with appropriate flags
1723c05e7a3eSmrg#
1724c05e7a3eSmrg# --with-lint:	'yes' user instructs the module to use lint
1725c05e7a3eSmrg#		'no' user instructs the module not to use lint (default)
1726c05e7a3eSmrg#
1727c05e7a3eSmrg# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
1728c05e7a3eSmrg# If the user sets the value of LINT_FLAGS, they are used verbatim.
1729c05e7a3eSmrg#
1730c05e7a3eSmrgAC_DEFUN([XORG_WITH_LINT],[
1731e6232409Smrg
1732c05e7a3eSmrgAC_ARG_VAR([LINT], [Path to a lint-style command])
1733c05e7a3eSmrgAC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
1734c05e7a3eSmrgAC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
1735c05e7a3eSmrg		[Use a lint-style source code checker (default: disabled)])],
1736c05e7a3eSmrg		[use_lint=$withval], [use_lint=no])
1737e6232409Smrg
1738c05e7a3eSmrg# Obtain platform specific info like program name and options
1739c05e7a3eSmrg# The lint program on FreeBSD and NetBSD is different from the one on Solaris
1740c05e7a3eSmrgcase $host_os in
1741c05e7a3eSmrg  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
1742c05e7a3eSmrg	lint_name=splint
1743c05e7a3eSmrg	lint_options="-badflag"
1744c05e7a3eSmrg	;;
1745c05e7a3eSmrg  *freebsd* | *netbsd*)
1746c05e7a3eSmrg	lint_name=lint
1747c05e7a3eSmrg	lint_options="-u -b"
1748c05e7a3eSmrg	;;
1749c05e7a3eSmrg  *solaris*)
1750c05e7a3eSmrg	lint_name=lint
1751c05e7a3eSmrg	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
1752c05e7a3eSmrg	;;
1753c05e7a3eSmrgesac
1754e6232409Smrg
1755c05e7a3eSmrg# Test for the presence of the program (either guessed by the code or spelled out by the user)
1756c05e7a3eSmrgif test "x$use_lint" = x"yes" ; then
1757c05e7a3eSmrg   AC_PATH_PROG([LINT], [$lint_name])
1758c05e7a3eSmrg   if test "x$LINT" = "x"; then
1759c05e7a3eSmrg        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
1760c05e7a3eSmrg   fi
1761c05e7a3eSmrgelif test "x$use_lint" = x"no" ; then
1762c05e7a3eSmrg   if test "x$LINT" != "x"; then
1763c05e7a3eSmrg      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
1764c05e7a3eSmrg   fi
176594a251fdSmrgelse
1766c05e7a3eSmrg   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
176794a251fdSmrgfi
1768e6232409Smrg
1769c05e7a3eSmrg# User supplied flags override default flags
1770c05e7a3eSmrgif test "x$LINT_FLAGS" != "x"; then
1771c05e7a3eSmrg   lint_options=$LINT_FLAGS
1772e6232409Smrgfi
1773e6232409Smrg
1774c05e7a3eSmrgAC_SUBST([LINT_FLAGS],[$lint_options])
1775c05e7a3eSmrgAM_CONDITIONAL(LINT, [test "x$LINT" != x])
1776e6232409Smrg
1777c05e7a3eSmrg]) # XORG_WITH_LINT
1778e6232409Smrg
1779c05e7a3eSmrg# XORG_LINT_LIBRARY(LIBNAME)
1780c05e7a3eSmrg# --------------------------
1781c05e7a3eSmrg# Minimum version: 1.1.0
17828fff3f40Smrg#
1783c05e7a3eSmrg# Sets up flags for building lint libraries for checking programs that call
1784c05e7a3eSmrg# functions in the library.
1785c05e7a3eSmrg#
1786c05e7a3eSmrg# Interface to module:
1787c05e7a3eSmrg# LINTLIB		- Automake variable with the name of lint library file to make
1788c05e7a3eSmrg# MAKE_LINT_LIB		- Automake conditional
1789c05e7a3eSmrg#
1790c05e7a3eSmrg# --enable-lint-library:  - 'yes' user instructs the module to created a lint library
1791c05e7a3eSmrg#			  - 'no' user instructs the module not to create a lint library (default)
1792e6232409Smrg
1793c05e7a3eSmrgAC_DEFUN([XORG_LINT_LIBRARY],[
1794c05e7a3eSmrgAC_REQUIRE([XORG_WITH_LINT])
1795c05e7a3eSmrgAC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
1796c05e7a3eSmrg	[Create lint library (default: disabled)])],
1797c05e7a3eSmrg	[make_lint_lib=$enableval], [make_lint_lib=no])
1798e6232409Smrg
1799c05e7a3eSmrgif test "x$make_lint_lib" = x"yes" ; then
1800c05e7a3eSmrg   LINTLIB=llib-l$1.ln
1801c05e7a3eSmrg   if test "x$LINT" = "x"; then
1802c05e7a3eSmrg        AC_MSG_ERROR([Cannot make lint library without --with-lint])
1803c05e7a3eSmrg   fi
1804c05e7a3eSmrgelif test "x$make_lint_lib" != x"no" ; then
1805c05e7a3eSmrg   AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
180694a251fdSmrgfi
1807e6232409Smrg
1808c05e7a3eSmrgAC_SUBST(LINTLIB)
1809c05e7a3eSmrgAM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
1810e6232409Smrg
1811c05e7a3eSmrg]) # XORG_LINT_LIBRARY
181294a251fdSmrg
1813c05e7a3eSmrg# XORG_COMPILER_BRAND
1814c05e7a3eSmrg# -------------------
1815c05e7a3eSmrg# Minimum version: 1.14.0
181694a251fdSmrg#
1817c05e7a3eSmrg# Checks for various brands of compilers and sets flags as appropriate:
1818c05e7a3eSmrg#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
1819c05e7a3eSmrg#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
1820c05e7a3eSmrg#   clang compiler - sets CLANGCC to "yes"
1821c05e7a3eSmrg#   Intel compiler - sets INTELCC to "yes"
1822c05e7a3eSmrg#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
182394a251fdSmrg#
1824c05e7a3eSmrgAC_DEFUN([XORG_COMPILER_BRAND], [
1825c05e7a3eSmrgAC_LANG_CASE(
1826c05e7a3eSmrg	[C], [
1827c05e7a3eSmrg		AC_REQUIRE([AC_PROG_CC_C99])
1828c05e7a3eSmrg	],
1829c05e7a3eSmrg	[C++], [
1830c05e7a3eSmrg		AC_REQUIRE([AC_PROG_CXX])
1831c05e7a3eSmrg	]
1832c05e7a3eSmrg)
1833c05e7a3eSmrgAC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
1834c05e7a3eSmrgAC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
1835c05e7a3eSmrgAC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
1836c05e7a3eSmrg]) # XORG_COMPILER_BRAND
1837c05e7a3eSmrg
1838c05e7a3eSmrg# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
1839c05e7a3eSmrg# ---------------
1840c05e7a3eSmrg# Minimum version: 1.16.0
184194a251fdSmrg#
1842c05e7a3eSmrg# Test if the compiler works when passed the given flag as a command line argument.
1843c05e7a3eSmrg# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
1844c05e7a3eSmrg# next flag in the list until there are no more options.
184594a251fdSmrg#
1846c05e7a3eSmrg# Note that this does not guarantee that the compiler supports the flag as some
1847c05e7a3eSmrg# compilers will simply ignore arguments that they do not understand, but we do
1848c05e7a3eSmrg# attempt to weed out false positives by using -Werror=unknown-warning-option and
1849c05e7a3eSmrg# -Werror=unused-command-line-argument
185094a251fdSmrg#
1851c05e7a3eSmrgAC_DEFUN([XORG_TESTSET_CFLAG], [
1852c05e7a3eSmrgm4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
1853c05e7a3eSmrgm4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
185494a251fdSmrg
1855c05e7a3eSmrgAC_LANG_COMPILER_REQUIRE
1856c05e7a3eSmrg
1857c05e7a3eSmrgAC_LANG_CASE(
1858c05e7a3eSmrg	[C], [
1859c05e7a3eSmrg		AC_REQUIRE([AC_PROG_CC_C99])
1860c05e7a3eSmrg		define([PREFIX], [C])
1861c05e7a3eSmrg		define([CACHE_PREFIX], [cc])
1862c05e7a3eSmrg		define([COMPILER], [$CC])
1863c05e7a3eSmrg	],
1864c05e7a3eSmrg	[C++], [
1865c05e7a3eSmrg		define([PREFIX], [CXX])
1866c05e7a3eSmrg		define([CACHE_PREFIX], [cxx])
1867c05e7a3eSmrg		define([COMPILER], [$CXX])
1868c05e7a3eSmrg	]
1869c05e7a3eSmrg)
1870c05e7a3eSmrg
1871c05e7a3eSmrg[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
1872c05e7a3eSmrg
1873c05e7a3eSmrgif test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
1874c05e7a3eSmrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
1875c05e7a3eSmrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
1876c05e7a3eSmrg			[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
1877c05e7a3eSmrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
1878c05e7a3eSmrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
1879c05e7a3eSmrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
1880c05e7a3eSmrg	[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
1881c05e7a3eSmrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
188294a251fdSmrgfi
188394a251fdSmrg
1884c05e7a3eSmrgif test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
1885c05e7a3eSmrg	if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
1886c05e7a3eSmrg		PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
1887c05e7a3eSmrg	fi
1888c05e7a3eSmrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
1889c05e7a3eSmrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
1890c05e7a3eSmrg			[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
1891c05e7a3eSmrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
1892c05e7a3eSmrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
1893c05e7a3eSmrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
1894c05e7a3eSmrg	[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
1895c05e7a3eSmrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
1896c05e7a3eSmrgfi
1897e6232409Smrg
1898c05e7a3eSmrgfound="no"
1899c05e7a3eSmrgm4_foreach([flag], m4_cdr($@), [
1900c05e7a3eSmrg	if test $found = "no" ; then
1901c05e7a3eSmrg		if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
1902c05e7a3eSmrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
1903c05e7a3eSmrg		fi
190494a251fdSmrg
1905c05e7a3eSmrg		if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
1906c05e7a3eSmrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
1907c05e7a3eSmrg		fi
1908c05e7a3eSmrg
1909c05e7a3eSmrg		PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
1910c05e7a3eSmrg
1911c05e7a3eSmrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
1912c05e7a3eSmrg		AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
1913c05e7a3eSmrg		cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
1914c05e7a3eSmrg		AC_CACHE_VAL($cacheid,
1915c05e7a3eSmrg			     [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
1916c05e7a3eSmrg					     [eval $cacheid=yes],
1917c05e7a3eSmrg					     [eval $cacheid=no])])
1918c05e7a3eSmrg
1919c05e7a3eSmrg		PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
1920c05e7a3eSmrg
1921c05e7a3eSmrg		eval supported=\$$cacheid
1922c05e7a3eSmrg		AC_MSG_RESULT([$supported])
1923c05e7a3eSmrg		if test "$supported" = "yes" ; then
1924c05e7a3eSmrg			$1="$$1 ]flag["
1925c05e7a3eSmrg			found="yes"
1926c05e7a3eSmrg		fi
1927c05e7a3eSmrg	fi
1928c05e7a3eSmrg])
1929c05e7a3eSmrg]) # XORG_TESTSET_CFLAG
1930c05e7a3eSmrg
1931c05e7a3eSmrg# XORG_COMPILER_FLAGS
1932c05e7a3eSmrg# ---------------
1933c05e7a3eSmrg# Minimum version: 1.16.0
193494a251fdSmrg#
1935c05e7a3eSmrg# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
1936c05e7a3eSmrg# arguments supported by the selected compiler which do NOT alter the generated
1937c05e7a3eSmrg# code.  These arguments will cause the compiler to print various warnings
1938c05e7a3eSmrg# during compilation AND turn a conservative set of warnings into errors.
193994a251fdSmrg#
1940c05e7a3eSmrg# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
1941c05e7a3eSmrg# future versions of util-macros as options are added to new compilers.
194294a251fdSmrg#
1943c05e7a3eSmrgAC_DEFUN([XORG_COMPILER_FLAGS], [
1944c05e7a3eSmrgAC_REQUIRE([XORG_COMPILER_BRAND])
194594a251fdSmrg
1946c05e7a3eSmrgAC_ARG_ENABLE(selective-werror,
1947c05e7a3eSmrg              AS_HELP_STRING([--disable-selective-werror],
1948c05e7a3eSmrg                             [Turn off selective compiler errors. (default: enabled)]),
1949c05e7a3eSmrg              [SELECTIVE_WERROR=$enableval],
1950c05e7a3eSmrg              [SELECTIVE_WERROR=yes])
1951c05e7a3eSmrg
1952c05e7a3eSmrgAC_LANG_CASE(
1953c05e7a3eSmrg        [C], [
1954c05e7a3eSmrg                define([PREFIX], [C])
1955c05e7a3eSmrg        ],
1956c05e7a3eSmrg        [C++], [
1957c05e7a3eSmrg                define([PREFIX], [CXX])
1958c05e7a3eSmrg        ]
1959c05e7a3eSmrg)
1960c05e7a3eSmrg# -v is too short to test reliably with XORG_TESTSET_CFLAG
1961c05e7a3eSmrgif test "x$SUNCC" = "xyes"; then
1962c05e7a3eSmrg    [BASE_]PREFIX[FLAGS]="-v"
19638fff3f40Smrgelse
1964c05e7a3eSmrg    [BASE_]PREFIX[FLAGS]=""
1965e6232409Smrgfi
1966e6232409Smrg
1967c05e7a3eSmrg# This chunk of warnings were those that existed in the legacy CWARNFLAGS
1968c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
1969c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
1970c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
1971c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
1972e6232409Smrg
1973c05e7a3eSmrgAC_LANG_CASE(
1974c05e7a3eSmrg	[C], [
1975c05e7a3eSmrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
1976c05e7a3eSmrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
1977c05e7a3eSmrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
1978c05e7a3eSmrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
1979c05e7a3eSmrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
1980c05e7a3eSmrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
1981c05e7a3eSmrg	]
1982c05e7a3eSmrg)
1983c05e7a3eSmrg
1984c05e7a3eSmrg# This chunk adds additional warnings that could catch undesired effects.
1985c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
1986c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
1987c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
1988c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
1989c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
1990c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
1991c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
1992c05e7a3eSmrg
1993c05e7a3eSmrg# These are currently disabled because they are noisy.  They will be enabled
1994c05e7a3eSmrg# in the future once the codebase is sufficiently modernized to silence
1995c05e7a3eSmrg# them.  For now, I don't want them to drown out the other warnings.
1996c05e7a3eSmrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
1997c05e7a3eSmrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
1998c05e7a3eSmrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
1999c05e7a3eSmrg
2000c05e7a3eSmrg# Turn some warnings into errors, so we don't accidently get successful builds
2001c05e7a3eSmrg# when there are problems that should be fixed.
2002c05e7a3eSmrg
2003c05e7a3eSmrgif test "x$SELECTIVE_WERROR" = "xyes" ; then
2004c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
2005c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
2006c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
2007c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
2008c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
2009c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
2010c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
2011c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
2012c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
2013c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
2014c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
2015c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
2016c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
2017c05e7a3eSmrgelse
2018c05e7a3eSmrgAC_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])
2019c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
2020c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
2021c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
2022c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
2023c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
2024c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
2025c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
2026c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
2027c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
2028c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
2029c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
2030c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
2031c05e7a3eSmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
2032c05e7a3eSmrgfi
2033c05e7a3eSmrg
2034c05e7a3eSmrgAC_SUBST([BASE_]PREFIX[FLAGS])
2035c05e7a3eSmrg]) # XORG_COMPILER_FLAGS
2036c05e7a3eSmrg
2037c05e7a3eSmrg# XORG_CWARNFLAGS
2038c05e7a3eSmrg# ---------------
2039c05e7a3eSmrg# Minimum version: 1.2.0
2040c05e7a3eSmrg# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
204194a251fdSmrg#
2042c05e7a3eSmrg# Defines CWARNFLAGS to enable C compiler warnings.
204394a251fdSmrg#
2044c05e7a3eSmrg# This function is deprecated because it defines -fno-strict-aliasing
2045c05e7a3eSmrg# which alters the code generated by the compiler.  If -fno-strict-aliasing
2046c05e7a3eSmrg# is needed, then it should be added explicitly in the module when
2047c05e7a3eSmrg# it is updated to use BASE_CFLAGS.
204894a251fdSmrg#
2049c05e7a3eSmrgAC_DEFUN([XORG_CWARNFLAGS], [
2050c05e7a3eSmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
2051c05e7a3eSmrgAC_REQUIRE([XORG_COMPILER_BRAND])
2052c05e7a3eSmrgAC_LANG_CASE(
2053c05e7a3eSmrg	[C], [
2054c05e7a3eSmrg		CWARNFLAGS="$BASE_CFLAGS"
2055c05e7a3eSmrg		if  test "x$GCC" = xyes ; then
2056c05e7a3eSmrg		    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
2057c05e7a3eSmrg		fi
2058c05e7a3eSmrg		AC_SUBST(CWARNFLAGS)
2059c05e7a3eSmrg	]
2060c05e7a3eSmrg)
2061c05e7a3eSmrg]) # XORG_CWARNFLAGS
2062c05e7a3eSmrg
2063c05e7a3eSmrg# XORG_STRICT_OPTION
2064c05e7a3eSmrg# -----------------------
2065c05e7a3eSmrg# Minimum version: 1.3.0
206694a251fdSmrg#
2067c05e7a3eSmrg# Add configure option to enable strict compilation flags, such as treating
2068c05e7a3eSmrg# warnings as fatal errors.
2069c05e7a3eSmrg# If --enable-strict-compilation is passed to configure, adds strict flags to
2070c05e7a3eSmrg# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
207194a251fdSmrg#
2072c05e7a3eSmrg# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
2073c05e7a3eSmrg# when strict compilation is unconditionally desired.
2074c05e7a3eSmrgAC_DEFUN([XORG_STRICT_OPTION], [
2075c05e7a3eSmrgAC_REQUIRE([XORG_CWARNFLAGS])
2076c05e7a3eSmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
207794a251fdSmrg
2078c05e7a3eSmrgAC_ARG_ENABLE(strict-compilation,
2079c05e7a3eSmrg			  AS_HELP_STRING([--enable-strict-compilation],
2080c05e7a3eSmrg			  [Enable all warnings from compiler and make them errors (default: disabled)]),
2081c05e7a3eSmrg			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
2082e6232409Smrg
2083c05e7a3eSmrgAC_LANG_CASE(
2084c05e7a3eSmrg        [C], [
2085c05e7a3eSmrg                define([PREFIX], [C])
2086c05e7a3eSmrg        ],
2087c05e7a3eSmrg        [C++], [
2088c05e7a3eSmrg                define([PREFIX], [CXX])
2089c05e7a3eSmrg        ]
2090c05e7a3eSmrg)
2091e6232409Smrg
2092c05e7a3eSmrg[STRICT_]PREFIX[FLAGS]=""
2093c05e7a3eSmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
2094c05e7a3eSmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
2095c05e7a3eSmrg
2096c05e7a3eSmrg# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
2097c05e7a3eSmrg# activate it with -Werror, so we add it here explicitly.
2098c05e7a3eSmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
2099c05e7a3eSmrg
2100c05e7a3eSmrgif test "x$STRICT_COMPILE" = "xyes"; then
2101c05e7a3eSmrg    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
2102c05e7a3eSmrg    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
2103c05e7a3eSmrgfi
2104c05e7a3eSmrgAC_SUBST([STRICT_]PREFIX[FLAGS])
2105c05e7a3eSmrgAC_SUBST([BASE_]PREFIX[FLAGS])
2106c05e7a3eSmrgAC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
2107c05e7a3eSmrg]) # XORG_STRICT_OPTION
2108c05e7a3eSmrg
2109c05e7a3eSmrg# XORG_DEFAULT_OPTIONS
2110c05e7a3eSmrg# --------------------
2111c05e7a3eSmrg# Minimum version: 1.3.0
2112e6232409Smrg#
2113c05e7a3eSmrg# Defines default options for X.Org modules.
211494a251fdSmrg#
2115c05e7a3eSmrgAC_DEFUN([XORG_DEFAULT_OPTIONS], [
2116c05e7a3eSmrgAC_REQUIRE([AC_PROG_INSTALL])
2117c05e7a3eSmrgXORG_COMPILER_FLAGS
2118c05e7a3eSmrgXORG_CWARNFLAGS
2119c05e7a3eSmrgXORG_STRICT_OPTION
2120c05e7a3eSmrgXORG_RELEASE_VERSION
2121c05e7a3eSmrgXORG_CHANGELOG
2122c05e7a3eSmrgXORG_INSTALL
2123c05e7a3eSmrgXORG_MANPAGE_SECTIONS
2124c05e7a3eSmrgm4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
2125c05e7a3eSmrg    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
2126c05e7a3eSmrg]) # XORG_DEFAULT_OPTIONS
2127c05e7a3eSmrg
2128c05e7a3eSmrg# XORG_INSTALL()
2129c05e7a3eSmrg# ----------------
2130c05e7a3eSmrg# Minimum version: 1.4.0
213194a251fdSmrg#
2132c05e7a3eSmrg# Defines the variable INSTALL_CMD as the command to copy
2133c05e7a3eSmrg# INSTALL from $prefix/share/util-macros.
213494a251fdSmrg#
2135c05e7a3eSmrgAC_DEFUN([XORG_INSTALL], [
2136c05e7a3eSmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
2137c05e7a3eSmrgmacros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
2138c05e7a3eSmrgINSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
2139c05e7a3eSmrgmv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
2140c05e7a3eSmrg|| (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \
2141c05e7a3eSmrgecho 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
2142c05e7a3eSmrgAC_SUBST([INSTALL_CMD])
2143c05e7a3eSmrg]) # XORG_INSTALL
2144c05e7a3eSmrgdnl Copyright 2005 Red Hat, Inc
2145c05e7a3eSmrgdnl
2146c05e7a3eSmrgdnl Permission to use, copy, modify, distribute, and sell this software and its
2147c05e7a3eSmrgdnl documentation for any purpose is hereby granted without fee, provided that
2148c05e7a3eSmrgdnl the above copyright notice appear in all copies and that both that
2149c05e7a3eSmrgdnl copyright notice and this permission notice appear in supporting
2150c05e7a3eSmrgdnl documentation.
2151c05e7a3eSmrgdnl
2152c05e7a3eSmrgdnl The above copyright notice and this permission notice shall be included
2153c05e7a3eSmrgdnl in all copies or substantial portions of the Software.
2154c05e7a3eSmrgdnl
2155c05e7a3eSmrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2156c05e7a3eSmrgdnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2157c05e7a3eSmrgdnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2158c05e7a3eSmrgdnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
2159c05e7a3eSmrgdnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2160c05e7a3eSmrgdnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2161c05e7a3eSmrgdnl OTHER DEALINGS IN THE SOFTWARE.
2162c05e7a3eSmrgdnl
2163c05e7a3eSmrgdnl Except as contained in this notice, the name of the copyright holders shall
2164c05e7a3eSmrgdnl not be used in advertising or otherwise to promote the sale, use or
2165c05e7a3eSmrgdnl other dealings in this Software without prior written authorization
2166c05e7a3eSmrgdnl from the copyright holders.
2167c05e7a3eSmrgdnl
2168e6232409Smrg
2169c05e7a3eSmrg# XORG_RELEASE_VERSION
2170c05e7a3eSmrg# --------------------
2171c05e7a3eSmrg# Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use.
2172c05e7a3eSmrg
2173c05e7a3eSmrgAC_DEFUN([XORG_RELEASE_VERSION],[
2174c05e7a3eSmrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
2175c05e7a3eSmrg		[`echo $PACKAGE_VERSION | cut -d . -f 1`],
2176c05e7a3eSmrg		[Major version of this package])
2177c05e7a3eSmrg	PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1`
2178c05e7a3eSmrg	if test "x$PVM" = "x"; then
2179c05e7a3eSmrg		PVM="0"
2180c05e7a3eSmrg	fi
2181c05e7a3eSmrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
2182c05e7a3eSmrg		[$PVM],
2183c05e7a3eSmrg		[Minor version of this package])
2184c05e7a3eSmrg	PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1`
2185c05e7a3eSmrg	if test "x$PVP" = "x"; then
2186c05e7a3eSmrg		PVP="0"
2187c05e7a3eSmrg	fi
2188c05e7a3eSmrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
2189c05e7a3eSmrg		[$PVP],
2190c05e7a3eSmrg		[Patch version of this package])
2191c05e7a3eSmrg])
2192c05e7a3eSmrg
2193c05e7a3eSmrg# XORG_CHANGELOG()
2194c05e7a3eSmrg# ----------------
2195c05e7a3eSmrg# Minimum version: 1.2.0
219694a251fdSmrg#
2197c05e7a3eSmrg# Defines the variable CHANGELOG_CMD as the command to generate
2198c05e7a3eSmrg# ChangeLog from git.
219994a251fdSmrg#
220094a251fdSmrg#
2201c05e7a3eSmrgAC_DEFUN([XORG_CHANGELOG], [
2202c05e7a3eSmrgCHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp && \
2203c05e7a3eSmrgmv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
2204c05e7a3eSmrg|| (rm -f \$(top_srcdir)/.changelog.tmp; touch \$(top_srcdir)/ChangeLog; \
2205c05e7a3eSmrgecho 'git directory not found: installing possibly empty changelog.' >&2)"
2206c05e7a3eSmrgAC_SUBST([CHANGELOG_CMD])
2207c05e7a3eSmrg]) # XORG_CHANGELOG
2208c05e7a3eSmrg
2209c05e7a3eSmrg# Copyright (C) 2002-2014 Free Software Foundation, Inc.
221094a251fdSmrg#
2211c05e7a3eSmrg# This file is free software; the Free Software Foundation
2212c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2213c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
2214e6232409Smrg
2215c05e7a3eSmrg# AM_AUTOMAKE_VERSION(VERSION)
2216c05e7a3eSmrg# ----------------------------
2217c05e7a3eSmrg# Automake X.Y traces this macro to ensure aclocal.m4 has been
2218c05e7a3eSmrg# generated from the m4 files accompanying Automake X.Y.
2219c05e7a3eSmrg# (This private macro should not be called outside this file.)
2220c05e7a3eSmrgAC_DEFUN([AM_AUTOMAKE_VERSION],
2221c05e7a3eSmrg[am__api_version='1.15'
2222c05e7a3eSmrgdnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
2223c05e7a3eSmrgdnl require some minimum version.  Point them to the right macro.
2224c05e7a3eSmrgm4_if([$1], [1.15], [],
2225c05e7a3eSmrg      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
2226c05e7a3eSmrg])
22276a45684fSmrg
2228c05e7a3eSmrg# _AM_AUTOCONF_VERSION(VERSION)
2229c05e7a3eSmrg# -----------------------------
2230c05e7a3eSmrg# aclocal traces this macro to find the Autoconf version.
2231c05e7a3eSmrg# This is a private macro too.  Using m4_define simplifies
2232c05e7a3eSmrg# the logic in aclocal, which can simply ignore this definition.
2233c05e7a3eSmrgm4_define([_AM_AUTOCONF_VERSION], [])
22346a45684fSmrg
2235c05e7a3eSmrg# AM_SET_CURRENT_AUTOMAKE_VERSION
2236c05e7a3eSmrg# -------------------------------
2237c05e7a3eSmrg# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
2238c05e7a3eSmrg# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
2239c05e7a3eSmrgAC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
2240c05e7a3eSmrg[AM_AUTOMAKE_VERSION([1.15])dnl
2241c05e7a3eSmrgm4_ifndef([AC_AUTOCONF_VERSION],
2242c05e7a3eSmrg  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
2243c05e7a3eSmrg_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
2244e6232409Smrg
2245c05e7a3eSmrg# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
2246c05e7a3eSmrg
2247c05e7a3eSmrg# Copyright (C) 2001-2014 Free Software Foundation, Inc.
224894a251fdSmrg#
2249c05e7a3eSmrg# This file is free software; the Free Software Foundation
2250c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2251c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
2252c05e7a3eSmrg
2253c05e7a3eSmrg# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
2254c05e7a3eSmrg# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
2255c05e7a3eSmrg# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
2256e6232409Smrg#
2257c05e7a3eSmrg# Of course, Automake must honor this variable whenever it calls a
2258c05e7a3eSmrg# tool from the auxiliary directory.  The problem is that $srcdir (and
2259c05e7a3eSmrg# therefore $ac_aux_dir as well) can be either absolute or relative,
2260c05e7a3eSmrg# depending on how configure is run.  This is pretty annoying, since
2261c05e7a3eSmrg# it makes $ac_aux_dir quite unusable in subdirectories: in the top
2262c05e7a3eSmrg# source directory, any form will work fine, but in subdirectories a
2263c05e7a3eSmrg# relative path needs to be adjusted first.
2264e6232409Smrg#
2265c05e7a3eSmrg# $ac_aux_dir/missing
2266c05e7a3eSmrg#    fails when called from a subdirectory if $ac_aux_dir is relative
2267c05e7a3eSmrg# $top_srcdir/$ac_aux_dir/missing
2268c05e7a3eSmrg#    fails if $ac_aux_dir is absolute,
2269c05e7a3eSmrg#    fails when called from a subdirectory in a VPATH build with
2270c05e7a3eSmrg#          a relative $ac_aux_dir
2271e6232409Smrg#
2272c05e7a3eSmrg# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
2273c05e7a3eSmrg# are both prefixed by $srcdir.  In an in-source build this is usually
2274c05e7a3eSmrg# harmless because $srcdir is '.', but things will broke when you
2275c05e7a3eSmrg# start a VPATH build or use an absolute $srcdir.
227694a251fdSmrg#
2277c05e7a3eSmrg# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
2278c05e7a3eSmrg# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
2279c05e7a3eSmrg#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
2280c05e7a3eSmrg# and then we would define $MISSING as
2281c05e7a3eSmrg#   MISSING="\${SHELL} $am_aux_dir/missing"
2282c05e7a3eSmrg# This will work as long as MISSING is not called from configure, because
2283c05e7a3eSmrg# unfortunately $(top_srcdir) has no meaning in configure.
2284c05e7a3eSmrg# However there are other variables, like CC, which are often used in
2285c05e7a3eSmrg# configure, and could therefore not use this "fixed" $ac_aux_dir.
228694a251fdSmrg#
2287c05e7a3eSmrg# Another solution, used here, is to always expand $ac_aux_dir to an
2288c05e7a3eSmrg# absolute PATH.  The drawback is that using absolute paths prevent a
2289c05e7a3eSmrg# configured tree to be moved without reconfiguration.
22908fff3f40Smrg
2291c05e7a3eSmrgAC_DEFUN([AM_AUX_DIR_EXPAND],
2292c05e7a3eSmrg[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
2293c05e7a3eSmrg# Expand $ac_aux_dir to an absolute path.
2294c05e7a3eSmrgam_aux_dir=`cd "$ac_aux_dir" && pwd`
2295c05e7a3eSmrg])
2296c05e7a3eSmrg
2297c05e7a3eSmrg# AM_CONDITIONAL                                            -*- Autoconf -*-
2298c05e7a3eSmrg
2299c05e7a3eSmrg# Copyright (C) 1997-2014 Free Software Foundation, Inc.
2300c05e7a3eSmrg#
2301c05e7a3eSmrg# This file is free software; the Free Software Foundation
2302c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2303c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
2304c05e7a3eSmrg
2305c05e7a3eSmrg# AM_CONDITIONAL(NAME, SHELL-CONDITION)
2306c05e7a3eSmrg# -------------------------------------
2307c05e7a3eSmrg# Define a conditional.
2308c05e7a3eSmrgAC_DEFUN([AM_CONDITIONAL],
2309c05e7a3eSmrg[AC_PREREQ([2.52])dnl
2310c05e7a3eSmrg m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
2311c05e7a3eSmrg       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
2312c05e7a3eSmrgAC_SUBST([$1_TRUE])dnl
2313c05e7a3eSmrgAC_SUBST([$1_FALSE])dnl
2314c05e7a3eSmrg_AM_SUBST_NOTMAKE([$1_TRUE])dnl
2315c05e7a3eSmrg_AM_SUBST_NOTMAKE([$1_FALSE])dnl
2316c05e7a3eSmrgm4_define([_AM_COND_VALUE_$1], [$2])dnl
2317c05e7a3eSmrgif $2; then
2318c05e7a3eSmrg  $1_TRUE=
2319c05e7a3eSmrg  $1_FALSE='#'
232094a251fdSmrgelse
2321c05e7a3eSmrg  $1_TRUE='#'
2322c05e7a3eSmrg  $1_FALSE=
2323e6232409Smrgfi
2324c05e7a3eSmrgAC_CONFIG_COMMANDS_PRE(
2325c05e7a3eSmrg[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
2326c05e7a3eSmrg  AC_MSG_ERROR([[conditional "$1" was never defined.
2327c05e7a3eSmrgUsually this means the macro was only invoked conditionally.]])
2328c05e7a3eSmrgfi])])
2329e6232409Smrg
2330c05e7a3eSmrg# Copyright (C) 1999-2014 Free Software Foundation, Inc.
2331c05e7a3eSmrg#
2332c05e7a3eSmrg# This file is free software; the Free Software Foundation
2333c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2334c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
23358fff3f40Smrg
23368fff3f40Smrg
2337c05e7a3eSmrg# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
2338c05e7a3eSmrg# written in clear, in which case automake, when reading aclocal.m4,
2339c05e7a3eSmrg# will think it sees a *use*, and therefore will trigger all it's
2340c05e7a3eSmrg# C support machinery.  Also note that it means that autoscan, seeing
2341c05e7a3eSmrg# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
23428fff3f40Smrg
2343c05e7a3eSmrg
2344c05e7a3eSmrg# _AM_DEPENDENCIES(NAME)
2345c05e7a3eSmrg# ----------------------
2346c05e7a3eSmrg# See how the compiler implements dependency checking.
2347c05e7a3eSmrg# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
2348c05e7a3eSmrg# We try a few techniques and use that to set a single cache variable.
234994a251fdSmrg#
2350c05e7a3eSmrg# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
2351c05e7a3eSmrg# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
2352c05e7a3eSmrg# dependency, and given that the user is not expected to run this macro,
2353c05e7a3eSmrg# just rely on AC_PROG_CC.
2354c05e7a3eSmrgAC_DEFUN([_AM_DEPENDENCIES],
2355c05e7a3eSmrg[AC_REQUIRE([AM_SET_DEPDIR])dnl
2356c05e7a3eSmrgAC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
2357c05e7a3eSmrgAC_REQUIRE([AM_MAKE_INCLUDE])dnl
2358c05e7a3eSmrgAC_REQUIRE([AM_DEP_TRACK])dnl
23598fff3f40Smrg
2360c05e7a3eSmrgm4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
2361c05e7a3eSmrg      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
2362c05e7a3eSmrg      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
2363c05e7a3eSmrg      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
2364c05e7a3eSmrg      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
2365c05e7a3eSmrg      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
2366c05e7a3eSmrg                    [depcc="$$1"   am_compiler_list=])
23678fff3f40Smrg
2368c05e7a3eSmrgAC_CACHE_CHECK([dependency style of $depcc],
2369c05e7a3eSmrg               [am_cv_$1_dependencies_compiler_type],
2370c05e7a3eSmrg[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
2371c05e7a3eSmrg  # We make a subdir and do the tests there.  Otherwise we can end up
2372c05e7a3eSmrg  # making bogus files that we don't know about and never remove.  For
2373c05e7a3eSmrg  # instance it was reported that on HP-UX the gcc test will end up
2374c05e7a3eSmrg  # making a dummy file named 'D' -- because '-MD' means "put the output
2375c05e7a3eSmrg  # in D".
2376c05e7a3eSmrg  rm -rf conftest.dir
2377c05e7a3eSmrg  mkdir conftest.dir
2378c05e7a3eSmrg  # Copy depcomp to subdir because otherwise we won't find it if we're
2379c05e7a3eSmrg  # using a relative directory.
2380c05e7a3eSmrg  cp "$am_depcomp" conftest.dir
2381c05e7a3eSmrg  cd conftest.dir
2382c05e7a3eSmrg  # We will build objects and dependencies in a subdirectory because
2383c05e7a3eSmrg  # it helps to detect inapplicable dependency modes.  For instance
2384c05e7a3eSmrg  # both Tru64's cc and ICC support -MD to output dependencies as a
2385c05e7a3eSmrg  # side effect of compilation, but ICC will put the dependencies in
2386c05e7a3eSmrg  # the current directory while Tru64 will put them in the object
2387c05e7a3eSmrg  # directory.
2388c05e7a3eSmrg  mkdir sub
23898fff3f40Smrg
2390c05e7a3eSmrg  am_cv_$1_dependencies_compiler_type=none
2391c05e7a3eSmrg  if test "$am_compiler_list" = ""; then
2392c05e7a3eSmrg     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
2393c05e7a3eSmrg  fi
2394c05e7a3eSmrg  am__universal=false
2395c05e7a3eSmrg  m4_case([$1], [CC],
2396c05e7a3eSmrg    [case " $depcc " in #(
2397c05e7a3eSmrg     *\ -arch\ *\ -arch\ *) am__universal=true ;;
2398c05e7a3eSmrg     esac],
2399c05e7a3eSmrg    [CXX],
2400c05e7a3eSmrg    [case " $depcc " in #(
2401c05e7a3eSmrg     *\ -arch\ *\ -arch\ *) am__universal=true ;;
2402c05e7a3eSmrg     esac])
24036a45684fSmrg
2404c05e7a3eSmrg  for depmode in $am_compiler_list; do
2405c05e7a3eSmrg    # Setup a source with many dependencies, because some compilers
2406c05e7a3eSmrg    # like to wrap large dependency lists on column 80 (with \), and
2407c05e7a3eSmrg    # we should not choose a depcomp mode which is confused by this.
2408c05e7a3eSmrg    #
2409c05e7a3eSmrg    # We need to recreate these files for each test, as the compiler may
2410c05e7a3eSmrg    # overwrite some of them when testing with obscure command lines.
2411c05e7a3eSmrg    # This happens at least with the AIX C compiler.
2412c05e7a3eSmrg    : > sub/conftest.c
2413c05e7a3eSmrg    for i in 1 2 3 4 5 6; do
2414c05e7a3eSmrg      echo '#include "conftst'$i'.h"' >> sub/conftest.c
2415c05e7a3eSmrg      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
2416c05e7a3eSmrg      # Solaris 10 /bin/sh.
2417c05e7a3eSmrg      echo '/* dummy */' > sub/conftst$i.h
2418c05e7a3eSmrg    done
2419c05e7a3eSmrg    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
24206a45684fSmrg
2421c05e7a3eSmrg    # We check with '-c' and '-o' for the sake of the "dashmstdout"
2422c05e7a3eSmrg    # mode.  It turns out that the SunPro C++ compiler does not properly
2423c05e7a3eSmrg    # handle '-M -o', and we need to detect this.  Also, some Intel
2424c05e7a3eSmrg    # versions had trouble with output in subdirs.
2425c05e7a3eSmrg    am__obj=sub/conftest.${OBJEXT-o}
2426c05e7a3eSmrg    am__minus_obj="-o $am__obj"
2427c05e7a3eSmrg    case $depmode in
2428c05e7a3eSmrg    gcc)
2429c05e7a3eSmrg      # This depmode causes a compiler race in universal mode.
2430c05e7a3eSmrg      test "$am__universal" = false || continue
2431c05e7a3eSmrg      ;;
2432c05e7a3eSmrg    nosideeffect)
2433c05e7a3eSmrg      # After this tag, mechanisms are not by side-effect, so they'll
2434c05e7a3eSmrg      # only be used when explicitly requested.
2435c05e7a3eSmrg      if test "x$enable_dependency_tracking" = xyes; then
2436c05e7a3eSmrg	continue
2437c05e7a3eSmrg      else
2438c05e7a3eSmrg	break
2439c05e7a3eSmrg      fi
2440c05e7a3eSmrg      ;;
2441c05e7a3eSmrg    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
2442c05e7a3eSmrg      # This compiler won't grok '-c -o', but also, the minuso test has
2443c05e7a3eSmrg      # not run yet.  These depmodes are late enough in the game, and
2444c05e7a3eSmrg      # so weak that their functioning should not be impacted.
2445c05e7a3eSmrg      am__obj=conftest.${OBJEXT-o}
2446c05e7a3eSmrg      am__minus_obj=
2447c05e7a3eSmrg      ;;
2448c05e7a3eSmrg    none) break ;;
2449c05e7a3eSmrg    esac
2450c05e7a3eSmrg    if depmode=$depmode \
2451c05e7a3eSmrg       source=sub/conftest.c object=$am__obj \
2452c05e7a3eSmrg       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
2453c05e7a3eSmrg       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
2454c05e7a3eSmrg         >/dev/null 2>conftest.err &&
2455c05e7a3eSmrg       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
2456c05e7a3eSmrg       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
2457c05e7a3eSmrg       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
2458c05e7a3eSmrg       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
2459c05e7a3eSmrg      # icc doesn't choke on unknown options, it will just issue warnings
2460c05e7a3eSmrg      # or remarks (even with -Werror).  So we grep stderr for any message
2461c05e7a3eSmrg      # that says an option was ignored or not supported.
2462c05e7a3eSmrg      # When given -MP, icc 7.0 and 7.1 complain thusly:
2463c05e7a3eSmrg      #   icc: Command line warning: ignoring option '-M'; no argument required
2464c05e7a3eSmrg      # The diagnosis changed in icc 8.0:
2465c05e7a3eSmrg      #   icc: Command line remark: option '-MP' not supported
2466c05e7a3eSmrg      if (grep 'ignoring option' conftest.err ||
2467c05e7a3eSmrg          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
2468c05e7a3eSmrg        am_cv_$1_dependencies_compiler_type=$depmode
2469c05e7a3eSmrg        break
2470c05e7a3eSmrg      fi
2471c05e7a3eSmrg    fi
2472c05e7a3eSmrg  done
24738fff3f40Smrg
2474c05e7a3eSmrg  cd ..
2475c05e7a3eSmrg  rm -rf conftest.dir
24768fff3f40Smrgelse
2477c05e7a3eSmrg  am_cv_$1_dependencies_compiler_type=none
24788fff3f40Smrgfi
2479c05e7a3eSmrg])
2480c05e7a3eSmrgAC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
2481c05e7a3eSmrgAM_CONDITIONAL([am__fastdep$1], [
2482c05e7a3eSmrg  test "x$enable_dependency_tracking" != xno \
2483c05e7a3eSmrg  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
2484c05e7a3eSmrg])
24858fff3f40Smrg
24868fff3f40Smrg
2487c05e7a3eSmrg# AM_SET_DEPDIR
2488c05e7a3eSmrg# -------------
2489c05e7a3eSmrg# Choose a directory name for dependency files.
2490c05e7a3eSmrg# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
2491c05e7a3eSmrgAC_DEFUN([AM_SET_DEPDIR],
2492c05e7a3eSmrg[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
2493c05e7a3eSmrgAC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
2494c05e7a3eSmrg])
2495c05e7a3eSmrg
2496c05e7a3eSmrg
2497c05e7a3eSmrg# AM_DEP_TRACK
2498c05e7a3eSmrg# ------------
2499c05e7a3eSmrgAC_DEFUN([AM_DEP_TRACK],
2500c05e7a3eSmrg[AC_ARG_ENABLE([dependency-tracking], [dnl
2501c05e7a3eSmrgAS_HELP_STRING(
2502c05e7a3eSmrg  [--enable-dependency-tracking],
2503c05e7a3eSmrg  [do not reject slow dependency extractors])
2504c05e7a3eSmrgAS_HELP_STRING(
2505c05e7a3eSmrg  [--disable-dependency-tracking],
2506c05e7a3eSmrg  [speeds up one-time build])])
2507c05e7a3eSmrgif test "x$enable_dependency_tracking" != xno; then
2508c05e7a3eSmrg  am_depcomp="$ac_aux_dir/depcomp"
2509c05e7a3eSmrg  AMDEPBACKSLASH='\'
2510c05e7a3eSmrg  am__nodep='_no'
2511c05e7a3eSmrgfi
2512c05e7a3eSmrgAM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
2513c05e7a3eSmrgAC_SUBST([AMDEPBACKSLASH])dnl
2514c05e7a3eSmrg_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
2515c05e7a3eSmrgAC_SUBST([am__nodep])dnl
2516c05e7a3eSmrg_AM_SUBST_NOTMAKE([am__nodep])dnl
2517c05e7a3eSmrg])
2518e6232409Smrg
2519c05e7a3eSmrg# Generate code to set up dependency tracking.              -*- Autoconf -*-
25208fff3f40Smrg
2521c05e7a3eSmrg# Copyright (C) 1999-2014 Free Software Foundation, Inc.
252294a251fdSmrg#
2523c05e7a3eSmrg# This file is free software; the Free Software Foundation
2524c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2525c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
252694a251fdSmrg
252794a251fdSmrg
2528c05e7a3eSmrg# _AM_OUTPUT_DEPENDENCY_COMMANDS
2529c05e7a3eSmrg# ------------------------------
2530c05e7a3eSmrgAC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
2531c05e7a3eSmrg[{
2532c05e7a3eSmrg  # Older Autoconf quotes --file arguments for eval, but not when files
2533c05e7a3eSmrg  # are listed without --file.  Let's play safe and only enable the eval
2534c05e7a3eSmrg  # if we detect the quoting.
2535c05e7a3eSmrg  case $CONFIG_FILES in
2536c05e7a3eSmrg  *\'*) eval set x "$CONFIG_FILES" ;;
2537c05e7a3eSmrg  *)   set x $CONFIG_FILES ;;
2538c05e7a3eSmrg  esac
2539c05e7a3eSmrg  shift
2540c05e7a3eSmrg  for mf
2541c05e7a3eSmrg  do
2542c05e7a3eSmrg    # Strip MF so we end up with the name of the file.
2543c05e7a3eSmrg    mf=`echo "$mf" | sed -e 's/:.*$//'`
2544c05e7a3eSmrg    # Check whether this is an Automake generated Makefile or not.
2545c05e7a3eSmrg    # We used to match only the files named 'Makefile.in', but
2546c05e7a3eSmrg    # some people rename them; so instead we look at the file content.
2547c05e7a3eSmrg    # Grep'ing the first line is not enough: some people post-process
2548c05e7a3eSmrg    # each Makefile.in and add a new line on top of each file to say so.
2549c05e7a3eSmrg    # Grep'ing the whole file is not good either: AIX grep has a line
2550c05e7a3eSmrg    # limit of 2048, but all sed's we know have understand at least 4000.
2551c05e7a3eSmrg    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
2552c05e7a3eSmrg      dirpart=`AS_DIRNAME("$mf")`
2553c05e7a3eSmrg    else
2554c05e7a3eSmrg      continue
2555c05e7a3eSmrg    fi
2556c05e7a3eSmrg    # Extract the definition of DEPDIR, am__include, and am__quote
2557c05e7a3eSmrg    # from the Makefile without running 'make'.
2558c05e7a3eSmrg    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
2559c05e7a3eSmrg    test -z "$DEPDIR" && continue
2560c05e7a3eSmrg    am__include=`sed -n 's/^am__include = //p' < "$mf"`
2561c05e7a3eSmrg    test -z "$am__include" && continue
2562c05e7a3eSmrg    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
2563c05e7a3eSmrg    # Find all dependency output files, they are included files with
2564c05e7a3eSmrg    # $(DEPDIR) in their names.  We invoke sed twice because it is the
2565c05e7a3eSmrg    # simplest approach to changing $(DEPDIR) to its actual value in the
2566c05e7a3eSmrg    # expansion.
2567c05e7a3eSmrg    for file in `sed -n "
2568c05e7a3eSmrg      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
2569c05e7a3eSmrg	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
2570c05e7a3eSmrg      # Make sure the directory exists.
2571c05e7a3eSmrg      test -f "$dirpart/$file" && continue
2572c05e7a3eSmrg      fdir=`AS_DIRNAME(["$file"])`
2573c05e7a3eSmrg      AS_MKDIR_P([$dirpart/$fdir])
2574c05e7a3eSmrg      # echo "creating $dirpart/$file"
2575c05e7a3eSmrg      echo '# dummy' > "$dirpart/$file"
2576c05e7a3eSmrg    done
2577c05e7a3eSmrg  done
2578c05e7a3eSmrg}
2579c05e7a3eSmrg])# _AM_OUTPUT_DEPENDENCY_COMMANDS
2580c05e7a3eSmrg
2581c05e7a3eSmrg
2582c05e7a3eSmrg# AM_OUTPUT_DEPENDENCY_COMMANDS
2583c05e7a3eSmrg# -----------------------------
2584c05e7a3eSmrg# This macro should only be invoked once -- use via AC_REQUIRE.
258594a251fdSmrg#
2586c05e7a3eSmrg# This code is only required when automatic dependency tracking
2587c05e7a3eSmrg# is enabled.  FIXME.  This creates each '.P' file that we will
2588c05e7a3eSmrg# need in order to bootstrap the dependency handling code.
2589c05e7a3eSmrgAC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
2590c05e7a3eSmrg[AC_CONFIG_COMMANDS([depfiles],
2591c05e7a3eSmrg     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
2592c05e7a3eSmrg     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
2593c05e7a3eSmrg])
2594c05e7a3eSmrg
2595c05e7a3eSmrg# Do all the work for Automake.                             -*- Autoconf -*-
2596c05e7a3eSmrg
2597c05e7a3eSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
259894a251fdSmrg#
2599c05e7a3eSmrg# This file is free software; the Free Software Foundation
2600c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2601c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
260294a251fdSmrg
2603c05e7a3eSmrg# This macro actually does too much.  Some checks are only needed if
2604c05e7a3eSmrg# your package does certain things.  But this isn't really a big deal.
26058fff3f40Smrg
2606c05e7a3eSmrgdnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
2607c05e7a3eSmrgm4_define([AC_PROG_CC],
2608c05e7a3eSmrgm4_defn([AC_PROG_CC])
2609c05e7a3eSmrg[_AM_PROG_CC_C_O
2610c05e7a3eSmrg])
26118fff3f40Smrg
2612c05e7a3eSmrg# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
2613c05e7a3eSmrg# AM_INIT_AUTOMAKE([OPTIONS])
2614c05e7a3eSmrg# -----------------------------------------------
2615c05e7a3eSmrg# The call with PACKAGE and VERSION arguments is the old style
2616c05e7a3eSmrg# call (pre autoconf-2.50), which is being phased out.  PACKAGE
2617c05e7a3eSmrg# and VERSION should now be passed to AC_INIT and removed from
2618c05e7a3eSmrg# the call to AM_INIT_AUTOMAKE.
2619c05e7a3eSmrg# We support both call styles for the transition.  After
2620c05e7a3eSmrg# the next Automake release, Autoconf can make the AC_INIT
2621c05e7a3eSmrg# arguments mandatory, and then we can depend on a new Autoconf
2622c05e7a3eSmrg# release and drop the old call support.
2623c05e7a3eSmrgAC_DEFUN([AM_INIT_AUTOMAKE],
2624c05e7a3eSmrg[AC_PREREQ([2.65])dnl
2625c05e7a3eSmrgdnl Autoconf wants to disallow AM_ names.  We explicitly allow
2626c05e7a3eSmrgdnl the ones we care about.
2627c05e7a3eSmrgm4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
2628c05e7a3eSmrgAC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
2629c05e7a3eSmrgAC_REQUIRE([AC_PROG_INSTALL])dnl
2630c05e7a3eSmrgif test "`cd $srcdir && pwd`" != "`pwd`"; then
2631c05e7a3eSmrg  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
2632c05e7a3eSmrg  # is not polluted with repeated "-I."
2633c05e7a3eSmrg  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
2634c05e7a3eSmrg  # test to see if srcdir already configured
2635c05e7a3eSmrg  if test -f $srcdir/config.status; then
2636c05e7a3eSmrg    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
263794a251fdSmrg  fi
263894a251fdSmrgfi
263994a251fdSmrg
2640c05e7a3eSmrg# test whether we have cygpath
2641c05e7a3eSmrgif test -z "$CYGPATH_W"; then
2642c05e7a3eSmrg  if (cygpath --version) >/dev/null 2>/dev/null; then
2643c05e7a3eSmrg    CYGPATH_W='cygpath -w'
2644c05e7a3eSmrg  else
2645c05e7a3eSmrg    CYGPATH_W=echo
264694a251fdSmrg  fi
264794a251fdSmrgfi
2648c05e7a3eSmrgAC_SUBST([CYGPATH_W])
26498fff3f40Smrg
2650c05e7a3eSmrg# Define the identity of the package.
2651c05e7a3eSmrgdnl Distinguish between old-style and new-style calls.
2652c05e7a3eSmrgm4_ifval([$2],
2653c05e7a3eSmrg[AC_DIAGNOSE([obsolete],
2654c05e7a3eSmrg             [$0: two- and three-arguments forms are deprecated.])
2655c05e7a3eSmrgm4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
2656c05e7a3eSmrg AC_SUBST([PACKAGE], [$1])dnl
2657c05e7a3eSmrg AC_SUBST([VERSION], [$2])],
2658c05e7a3eSmrg[_AM_SET_OPTIONS([$1])dnl
2659c05e7a3eSmrgdnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
2660c05e7a3eSmrgm4_if(
2661c05e7a3eSmrg  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
2662c05e7a3eSmrg  [ok:ok],,
2663c05e7a3eSmrg  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
2664c05e7a3eSmrg AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
2665c05e7a3eSmrg AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
26668fff3f40Smrg
2667c05e7a3eSmrg_AM_IF_OPTION([no-define],,
2668c05e7a3eSmrg[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
2669c05e7a3eSmrg AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
267094a251fdSmrg
2671c05e7a3eSmrg# Some tools Automake needs.
2672c05e7a3eSmrgAC_REQUIRE([AM_SANITY_CHECK])dnl
2673c05e7a3eSmrgAC_REQUIRE([AC_ARG_PROGRAM])dnl
2674c05e7a3eSmrgAM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
2675c05e7a3eSmrgAM_MISSING_PROG([AUTOCONF], [autoconf])
2676c05e7a3eSmrgAM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
2677c05e7a3eSmrgAM_MISSING_PROG([AUTOHEADER], [autoheader])
2678c05e7a3eSmrgAM_MISSING_PROG([MAKEINFO], [makeinfo])
2679c05e7a3eSmrgAC_REQUIRE([AM_PROG_INSTALL_SH])dnl
2680c05e7a3eSmrgAC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
2681c05e7a3eSmrgAC_REQUIRE([AC_PROG_MKDIR_P])dnl
2682c05e7a3eSmrg# For better backward compatibility.  To be removed once Automake 1.9.x
2683c05e7a3eSmrg# dies out for good.  For more background, see:
2684c05e7a3eSmrg# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
2685c05e7a3eSmrg# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
2686c05e7a3eSmrgAC_SUBST([mkdir_p], ['$(MKDIR_P)'])
2687c05e7a3eSmrg# We need awk for the "check" target (and possibly the TAP driver).  The
2688c05e7a3eSmrg# system "awk" is bad on some platforms.
2689c05e7a3eSmrgAC_REQUIRE([AC_PROG_AWK])dnl
2690c05e7a3eSmrgAC_REQUIRE([AC_PROG_MAKE_SET])dnl
2691c05e7a3eSmrgAC_REQUIRE([AM_SET_LEADING_DOT])dnl
2692c05e7a3eSmrg_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
2693c05e7a3eSmrg	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
2694c05e7a3eSmrg			     [_AM_PROG_TAR([v7])])])
2695c05e7a3eSmrg_AM_IF_OPTION([no-dependencies],,
2696c05e7a3eSmrg[AC_PROVIDE_IFELSE([AC_PROG_CC],
2697c05e7a3eSmrg		  [_AM_DEPENDENCIES([CC])],
2698c05e7a3eSmrg		  [m4_define([AC_PROG_CC],
2699c05e7a3eSmrg			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
2700c05e7a3eSmrgAC_PROVIDE_IFELSE([AC_PROG_CXX],
2701c05e7a3eSmrg		  [_AM_DEPENDENCIES([CXX])],
2702c05e7a3eSmrg		  [m4_define([AC_PROG_CXX],
2703c05e7a3eSmrg			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
2704c05e7a3eSmrgAC_PROVIDE_IFELSE([AC_PROG_OBJC],
2705c05e7a3eSmrg		  [_AM_DEPENDENCIES([OBJC])],
2706c05e7a3eSmrg		  [m4_define([AC_PROG_OBJC],
2707c05e7a3eSmrg			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
2708c05e7a3eSmrgAC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
2709c05e7a3eSmrg		  [_AM_DEPENDENCIES([OBJCXX])],
2710c05e7a3eSmrg		  [m4_define([AC_PROG_OBJCXX],
2711c05e7a3eSmrg			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
2712c05e7a3eSmrg])
2713c05e7a3eSmrgAC_REQUIRE([AM_SILENT_RULES])dnl
2714c05e7a3eSmrgdnl The testsuite driver may need to know about EXEEXT, so add the
2715c05e7a3eSmrgdnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
2716c05e7a3eSmrgdnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
2717c05e7a3eSmrgAC_CONFIG_COMMANDS_PRE(dnl
2718c05e7a3eSmrg[m4_provide_if([_AM_COMPILER_EXEEXT],
2719c05e7a3eSmrg  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
27208fff3f40Smrg
2721c05e7a3eSmrg# POSIX will say in a future version that running "rm -f" with no argument
2722c05e7a3eSmrg# is OK; and we want to be able to make that assumption in our Makefile
2723c05e7a3eSmrg# recipes.  So use an aggressive probe to check that the usage we want is
2724c05e7a3eSmrg# actually supported "in the wild" to an acceptable degree.
2725c05e7a3eSmrg# See automake bug#10828.
2726c05e7a3eSmrg# To make any issue more visible, cause the running configure to be aborted
2727c05e7a3eSmrg# by default if the 'rm' program in use doesn't match our expectations; the
2728c05e7a3eSmrg# user can still override this though.
2729c05e7a3eSmrgif rm -f && rm -fr && rm -rf; then : OK; else
2730c05e7a3eSmrg  cat >&2 <<'END'
2731c05e7a3eSmrgOops!
27328fff3f40Smrg
2733c05e7a3eSmrgYour 'rm' program seems unable to run without file operands specified
2734c05e7a3eSmrgon the command line, even when the '-f' option is present.  This is contrary
2735c05e7a3eSmrgto the behaviour of most rm programs out there, and not conforming with
2736c05e7a3eSmrgthe upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
273794a251fdSmrg
2738c05e7a3eSmrgPlease tell bug-automake@gnu.org about your system, including the value
2739c05e7a3eSmrgof your $PATH and any error possibly output before this message.  This
2740c05e7a3eSmrgcan help us improve future automake versions.
27418fff3f40Smrg
2742c05e7a3eSmrgEND
2743c05e7a3eSmrg  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
2744c05e7a3eSmrg    echo 'Configuration will proceed anyway, since you have set the' >&2
2745c05e7a3eSmrg    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
2746c05e7a3eSmrg    echo >&2
2747c05e7a3eSmrg  else
2748c05e7a3eSmrg    cat >&2 <<'END'
2749c05e7a3eSmrgAborting the configuration process, to ensure you take notice of the issue.
2750e6232409Smrg
2751c05e7a3eSmrgYou can download and install GNU coreutils to get an 'rm' implementation
2752c05e7a3eSmrgthat behaves properly: <http://www.gnu.org/software/coreutils/>.
2753e6232409Smrg
2754c05e7a3eSmrgIf you want to complete the configuration process using your problematic
2755c05e7a3eSmrg'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
2756c05e7a3eSmrgto "yes", and re-run configure.
27578fff3f40Smrg
2758c05e7a3eSmrgEND
2759c05e7a3eSmrg    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
2760c05e7a3eSmrg  fi
276194a251fdSmrgfi
2762c05e7a3eSmrgdnl The trailing newline in this macro's definition is deliberate, for
2763c05e7a3eSmrgdnl backward compatibility and to allow trailing 'dnl'-style comments
2764c05e7a3eSmrgdnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
2765c05e7a3eSmrg])
27668fff3f40Smrg
2767c05e7a3eSmrgdnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
2768c05e7a3eSmrgdnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
2769c05e7a3eSmrgdnl mangled by Autoconf and run in a shell conditional statement.
2770c05e7a3eSmrgm4_define([_AC_COMPILER_EXEEXT],
2771c05e7a3eSmrgm4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
27728fff3f40Smrg
2773c05e7a3eSmrg# When config.status generates a header, we must update the stamp-h file.
2774c05e7a3eSmrg# This file resides in the same directory as the config header
2775c05e7a3eSmrg# that is generated.  The stamp files are numbered to have different names.
27768fff3f40Smrg
2777c05e7a3eSmrg# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
2778c05e7a3eSmrg# loop where config.status creates the headers, so we can generate
2779c05e7a3eSmrg# our stamp files there.
2780c05e7a3eSmrgAC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
2781c05e7a3eSmrg[# Compute $1's index in $config_headers.
2782c05e7a3eSmrg_am_arg=$1
2783c05e7a3eSmrg_am_stamp_count=1
2784c05e7a3eSmrgfor _am_header in $config_headers :; do
2785c05e7a3eSmrg  case $_am_header in
2786c05e7a3eSmrg    $_am_arg | $_am_arg:* )
2787c05e7a3eSmrg      break ;;
2788c05e7a3eSmrg    * )
2789c05e7a3eSmrg      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
2790c05e7a3eSmrg  esac
2791c05e7a3eSmrgdone
2792c05e7a3eSmrgecho "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
2793c05e7a3eSmrg
2794c05e7a3eSmrg# Copyright (C) 2001-2014 Free Software Foundation, Inc.
279594a251fdSmrg#
2796c05e7a3eSmrg# This file is free software; the Free Software Foundation
2797c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2798c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
27998fff3f40Smrg
2800c05e7a3eSmrg# AM_PROG_INSTALL_SH
2801c05e7a3eSmrg# ------------------
2802c05e7a3eSmrg# Define $install_sh.
2803c05e7a3eSmrgAC_DEFUN([AM_PROG_INSTALL_SH],
2804c05e7a3eSmrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2805c05e7a3eSmrgif test x"${install_sh+set}" != xset; then
2806c05e7a3eSmrg  case $am_aux_dir in
2807c05e7a3eSmrg  *\ * | *\	*)
2808c05e7a3eSmrg    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
2809c05e7a3eSmrg  *)
2810c05e7a3eSmrg    install_sh="\${SHELL} $am_aux_dir/install-sh"
2811c05e7a3eSmrg  esac
2812c05e7a3eSmrgfi
2813c05e7a3eSmrgAC_SUBST([install_sh])])
28148fff3f40Smrg
2815c05e7a3eSmrg# Copyright (C) 2003-2014 Free Software Foundation, Inc.
2816c05e7a3eSmrg#
2817c05e7a3eSmrg# This file is free software; the Free Software Foundation
2818c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2819c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
28208fff3f40Smrg
2821c05e7a3eSmrg# Check whether the underlying file-system supports filenames
2822c05e7a3eSmrg# with a leading dot.  For instance MS-DOS doesn't.
2823c05e7a3eSmrgAC_DEFUN([AM_SET_LEADING_DOT],
2824c05e7a3eSmrg[rm -rf .tst 2>/dev/null
2825c05e7a3eSmrgmkdir .tst 2>/dev/null
2826c05e7a3eSmrgif test -d .tst; then
2827c05e7a3eSmrg  am__leading_dot=.
28288fff3f40Smrgelse
2829c05e7a3eSmrg  am__leading_dot=_
283094a251fdSmrgfi
2831c05e7a3eSmrgrmdir .tst 2>/dev/null
2832c05e7a3eSmrgAC_SUBST([am__leading_dot])])
28338fff3f40Smrg
2834c05e7a3eSmrg# Check to see how 'make' treats includes.	            -*- Autoconf -*-
283594a251fdSmrg
2836c05e7a3eSmrg# Copyright (C) 2001-2014 Free Software Foundation, Inc.
283794a251fdSmrg#
2838c05e7a3eSmrg# This file is free software; the Free Software Foundation
2839c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2840c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
284194a251fdSmrg
2842c05e7a3eSmrg# AM_MAKE_INCLUDE()
2843c05e7a3eSmrg# -----------------
2844c05e7a3eSmrg# Check to see how make treats includes.
2845c05e7a3eSmrgAC_DEFUN([AM_MAKE_INCLUDE],
2846c05e7a3eSmrg[am_make=${MAKE-make}
2847c05e7a3eSmrgcat > confinc << 'END'
2848c05e7a3eSmrgam__doit:
2849c05e7a3eSmrg	@echo this is the am__doit target
2850c05e7a3eSmrg.PHONY: am__doit
2851c05e7a3eSmrgEND
2852c05e7a3eSmrg# If we don't find an include directive, just comment out the code.
2853c05e7a3eSmrgAC_MSG_CHECKING([for style of include used by $am_make])
2854c05e7a3eSmrgam__include="#"
2855c05e7a3eSmrgam__quote=
2856c05e7a3eSmrg_am_result=none
2857c05e7a3eSmrg# First try GNU make style include.
2858c05e7a3eSmrgecho "include confinc" > confmf
2859c05e7a3eSmrg# Ignore all kinds of additional output from 'make'.
2860c05e7a3eSmrgcase `$am_make -s -f confmf 2> /dev/null` in #(
2861c05e7a3eSmrg*the\ am__doit\ target*)
2862c05e7a3eSmrg  am__include=include
2863c05e7a3eSmrg  am__quote=
2864c05e7a3eSmrg  _am_result=GNU
2865c05e7a3eSmrg  ;;
2866c05e7a3eSmrgesac
2867c05e7a3eSmrg# Now try BSD make style include.
2868c05e7a3eSmrgif test "$am__include" = "#"; then
2869c05e7a3eSmrg   echo '.include "confinc"' > confmf
2870c05e7a3eSmrg   case `$am_make -s -f confmf 2> /dev/null` in #(
2871c05e7a3eSmrg   *the\ am__doit\ target*)
2872c05e7a3eSmrg     am__include=.include
2873c05e7a3eSmrg     am__quote="\""
2874c05e7a3eSmrg     _am_result=BSD
2875c05e7a3eSmrg     ;;
2876c05e7a3eSmrg   esac
287794a251fdSmrgfi
2878c05e7a3eSmrgAC_SUBST([am__include])
2879c05e7a3eSmrgAC_SUBST([am__quote])
2880c05e7a3eSmrgAC_MSG_RESULT([$_am_result])
2881c05e7a3eSmrgrm -f confinc confmf
2882c05e7a3eSmrg])
288394a251fdSmrg
2884c05e7a3eSmrg# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
288594a251fdSmrg
2886c05e7a3eSmrg# Copyright (C) 1997-2014 Free Software Foundation, Inc.
288794a251fdSmrg#
2888c05e7a3eSmrg# This file is free software; the Free Software Foundation
2889c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2890c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
289194a251fdSmrg
2892c05e7a3eSmrg# AM_MISSING_PROG(NAME, PROGRAM)
2893c05e7a3eSmrg# ------------------------------
2894c05e7a3eSmrgAC_DEFUN([AM_MISSING_PROG],
2895c05e7a3eSmrg[AC_REQUIRE([AM_MISSING_HAS_RUN])
2896c05e7a3eSmrg$1=${$1-"${am_missing_run}$2"}
2897c05e7a3eSmrgAC_SUBST($1)])
289894a251fdSmrg
2899c05e7a3eSmrg# AM_MISSING_HAS_RUN
2900c05e7a3eSmrg# ------------------
2901c05e7a3eSmrg# Define MISSING if not defined so far and test if it is modern enough.
2902c05e7a3eSmrg# If it is, set am_missing_run to use it, otherwise, to nothing.
2903c05e7a3eSmrgAC_DEFUN([AM_MISSING_HAS_RUN],
2904c05e7a3eSmrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2905c05e7a3eSmrgAC_REQUIRE_AUX_FILE([missing])dnl
2906c05e7a3eSmrgif test x"${MISSING+set}" != xset; then
2907c05e7a3eSmrg  case $am_aux_dir in
2908c05e7a3eSmrg  *\ * | *\	*)
2909c05e7a3eSmrg    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
2910c05e7a3eSmrg  *)
2911c05e7a3eSmrg    MISSING="\${SHELL} $am_aux_dir/missing" ;;
2912c05e7a3eSmrg  esac
291394a251fdSmrgfi
2914c05e7a3eSmrg# Use eval to expand $SHELL
2915c05e7a3eSmrgif eval "$MISSING --is-lightweight"; then
2916c05e7a3eSmrg  am_missing_run="$MISSING "
2917c05e7a3eSmrgelse
2918c05e7a3eSmrg  am_missing_run=
2919c05e7a3eSmrg  AC_MSG_WARN(['missing' script is too old or missing])
292094a251fdSmrgfi
2921c05e7a3eSmrg])
292294a251fdSmrg
2923c05e7a3eSmrg# Helper functions for option handling.                     -*- Autoconf -*-
292494a251fdSmrg
2925c05e7a3eSmrg# Copyright (C) 2001-2014 Free Software Foundation, Inc.
2926c05e7a3eSmrg#
2927c05e7a3eSmrg# This file is free software; the Free Software Foundation
2928c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2929c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
293094a251fdSmrg
2931c05e7a3eSmrg# _AM_MANGLE_OPTION(NAME)
2932c05e7a3eSmrg# -----------------------
2933c05e7a3eSmrgAC_DEFUN([_AM_MANGLE_OPTION],
2934c05e7a3eSmrg[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
293594a251fdSmrg
2936c05e7a3eSmrg# _AM_SET_OPTION(NAME)
2937c05e7a3eSmrg# --------------------
2938c05e7a3eSmrg# Set option NAME.  Presently that only means defining a flag for this option.
2939c05e7a3eSmrgAC_DEFUN([_AM_SET_OPTION],
2940c05e7a3eSmrg[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
294194a251fdSmrg
2942c05e7a3eSmrg# _AM_SET_OPTIONS(OPTIONS)
2943c05e7a3eSmrg# ------------------------
2944c05e7a3eSmrg# OPTIONS is a space-separated list of Automake options.
2945c05e7a3eSmrgAC_DEFUN([_AM_SET_OPTIONS],
2946c05e7a3eSmrg[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
294794a251fdSmrg
2948c05e7a3eSmrg# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
2949c05e7a3eSmrg# -------------------------------------------
2950c05e7a3eSmrg# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
2951c05e7a3eSmrgAC_DEFUN([_AM_IF_OPTION],
2952c05e7a3eSmrg[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
29538fff3f40Smrg
2954c05e7a3eSmrg# Copyright (C) 1999-2014 Free Software Foundation, Inc.
295594a251fdSmrg#
2956c05e7a3eSmrg# This file is free software; the Free Software Foundation
2957c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
2958c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
295994a251fdSmrg
2960c05e7a3eSmrg# _AM_PROG_CC_C_O
2961c05e7a3eSmrg# ---------------
2962c05e7a3eSmrg# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
2963c05e7a3eSmrg# to automatically call this.
2964c05e7a3eSmrgAC_DEFUN([_AM_PROG_CC_C_O],
2965c05e7a3eSmrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2966c05e7a3eSmrgAC_REQUIRE_AUX_FILE([compile])dnl
2967c05e7a3eSmrgAC_LANG_PUSH([C])dnl
2968c05e7a3eSmrgAC_CACHE_CHECK(
2969c05e7a3eSmrg  [whether $CC understands -c and -o together],
2970c05e7a3eSmrg  [am_cv_prog_cc_c_o],
2971c05e7a3eSmrg  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
2972c05e7a3eSmrg  # Make sure it works both with $CC and with simple cc.
2973c05e7a3eSmrg  # Following AC_PROG_CC_C_O, we do the test twice because some
2974c05e7a3eSmrg  # compilers refuse to overwrite an existing .o file with -o,
2975c05e7a3eSmrg  # though they will create one.
2976c05e7a3eSmrg  am_cv_prog_cc_c_o=yes
2977c05e7a3eSmrg  for am_i in 1 2; do
2978c05e7a3eSmrg    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
2979c05e7a3eSmrg         && test -f conftest2.$ac_objext; then
2980c05e7a3eSmrg      : OK
2981c05e7a3eSmrg    else
2982c05e7a3eSmrg      am_cv_prog_cc_c_o=no
2983c05e7a3eSmrg      break
2984c05e7a3eSmrg    fi
2985c05e7a3eSmrg  done
2986c05e7a3eSmrg  rm -f core conftest*
2987c05e7a3eSmrg  unset am_i])
2988c05e7a3eSmrgif test "$am_cv_prog_cc_c_o" != yes; then
2989c05e7a3eSmrg   # Losing compiler, so override with the script.
2990c05e7a3eSmrg   # FIXME: It is wrong to rewrite CC.
2991c05e7a3eSmrg   # But if we don't then we get into trouble of one sort or another.
2992c05e7a3eSmrg   # A longer-term fix would be to have automake use am__CC in this case,
2993c05e7a3eSmrg   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
2994c05e7a3eSmrg   CC="$am_aux_dir/compile $CC"
299594a251fdSmrgfi
2996c05e7a3eSmrgAC_LANG_POP([C])])
29978fff3f40Smrg
2998c05e7a3eSmrg# For backward compatibility.
2999c05e7a3eSmrgAC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
3000c05e7a3eSmrg
3001c05e7a3eSmrg# Copyright (C) 2001-2014 Free Software Foundation, Inc.
3002c05e7a3eSmrg#
3003c05e7a3eSmrg# This file is free software; the Free Software Foundation
3004c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
3005c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
3006c05e7a3eSmrg
3007c05e7a3eSmrg# AM_RUN_LOG(COMMAND)
3008c05e7a3eSmrg# -------------------
3009c05e7a3eSmrg# Run COMMAND, save the exit status in ac_status, and log it.
3010c05e7a3eSmrg# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
3011c05e7a3eSmrgAC_DEFUN([AM_RUN_LOG],
3012c05e7a3eSmrg[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
3013c05e7a3eSmrg   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
3014c05e7a3eSmrg   ac_status=$?
3015c05e7a3eSmrg   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
3016c05e7a3eSmrg   (exit $ac_status); }])
301794a251fdSmrg
3018c05e7a3eSmrg# Check to make sure that the build environment is sane.    -*- Autoconf -*-
301994a251fdSmrg
3020c05e7a3eSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
3021c05e7a3eSmrg#
3022c05e7a3eSmrg# This file is free software; the Free Software Foundation
3023c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
3024c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
302594a251fdSmrg
3026c05e7a3eSmrg# AM_SANITY_CHECK
3027c05e7a3eSmrg# ---------------
3028c05e7a3eSmrgAC_DEFUN([AM_SANITY_CHECK],
3029c05e7a3eSmrg[AC_MSG_CHECKING([whether build environment is sane])
3030c05e7a3eSmrg# Reject unsafe characters in $srcdir or the absolute working directory
3031c05e7a3eSmrg# name.  Accept space and tab only in the latter.
3032c05e7a3eSmrgam_lf='
3033c05e7a3eSmrg'
3034c05e7a3eSmrgcase `pwd` in
3035c05e7a3eSmrg  *[[\\\"\#\$\&\'\`$am_lf]]*)
3036c05e7a3eSmrg    AC_MSG_ERROR([unsafe absolute working directory name]);;
3037c05e7a3eSmrgesac
3038c05e7a3eSmrgcase $srcdir in
3039c05e7a3eSmrg  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
3040c05e7a3eSmrg    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
3041c05e7a3eSmrgesac
304294a251fdSmrg
3043c05e7a3eSmrg# Do 'set' in a subshell so we don't clobber the current shell's
3044c05e7a3eSmrg# arguments.  Must try -L first in case configure is actually a
3045c05e7a3eSmrg# symlink; some systems play weird games with the mod time of symlinks
3046c05e7a3eSmrg# (eg FreeBSD returns the mod time of the symlink's containing
3047c05e7a3eSmrg# directory).
3048c05e7a3eSmrgif (
3049c05e7a3eSmrg   am_has_slept=no
3050c05e7a3eSmrg   for am_try in 1 2; do
3051c05e7a3eSmrg     echo "timestamp, slept: $am_has_slept" > conftest.file
3052c05e7a3eSmrg     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
3053c05e7a3eSmrg     if test "$[*]" = "X"; then
3054c05e7a3eSmrg	# -L didn't work.
3055c05e7a3eSmrg	set X `ls -t "$srcdir/configure" conftest.file`
3056c05e7a3eSmrg     fi
3057c05e7a3eSmrg     if test "$[*]" != "X $srcdir/configure conftest.file" \
3058c05e7a3eSmrg	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
305994a251fdSmrg
3060c05e7a3eSmrg	# If neither matched, then we have a broken ls.  This can happen
3061c05e7a3eSmrg	# if, for instance, CONFIG_SHELL is bash and it inherits a
3062c05e7a3eSmrg	# broken ls alias from the environment.  This has actually
3063c05e7a3eSmrg	# happened.  Such a system could not be considered "sane".
3064c05e7a3eSmrg	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
3065c05e7a3eSmrg  alias in your environment])
3066c05e7a3eSmrg     fi
3067c05e7a3eSmrg     if test "$[2]" = conftest.file || test $am_try -eq 2; then
3068c05e7a3eSmrg       break
3069c05e7a3eSmrg     fi
3070c05e7a3eSmrg     # Just in case.
3071c05e7a3eSmrg     sleep 1
3072c05e7a3eSmrg     am_has_slept=yes
3073c05e7a3eSmrg   done
3074c05e7a3eSmrg   test "$[2]" = conftest.file
3075c05e7a3eSmrg   )
3076c05e7a3eSmrgthen
3077c05e7a3eSmrg   # Ok.
3078c05e7a3eSmrg   :
307994a251fdSmrgelse
3080c05e7a3eSmrg   AC_MSG_ERROR([newly created file is older than distributed files!
3081c05e7a3eSmrgCheck your system clock])
30828fff3f40Smrgfi
3083c05e7a3eSmrgAC_MSG_RESULT([yes])
3084c05e7a3eSmrg# If we didn't sleep, we still need to ensure time stamps of config.status and
3085c05e7a3eSmrg# generated files are strictly newer.
3086c05e7a3eSmrgam_sleep_pid=
3087c05e7a3eSmrgif grep 'slept: no' conftest.file >/dev/null 2>&1; then
3088c05e7a3eSmrg  ( sleep 1 ) &
3089c05e7a3eSmrg  am_sleep_pid=$!
3090c05e7a3eSmrgfi
3091c05e7a3eSmrgAC_CONFIG_COMMANDS_PRE(
3092c05e7a3eSmrg  [AC_MSG_CHECKING([that generated files are newer than configure])
3093c05e7a3eSmrg   if test -n "$am_sleep_pid"; then
3094c05e7a3eSmrg     # Hide warnings about reused PIDs.
3095c05e7a3eSmrg     wait $am_sleep_pid 2>/dev/null
3096c05e7a3eSmrg   fi
3097c05e7a3eSmrg   AC_MSG_RESULT([done])])
3098c05e7a3eSmrgrm -f conftest.file
3099c05e7a3eSmrg])
31008fff3f40Smrg
3101c05e7a3eSmrg# Copyright (C) 2009-2014 Free Software Foundation, Inc.
310294a251fdSmrg#
3103c05e7a3eSmrg# This file is free software; the Free Software Foundation
3104c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
3105c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
3106e6232409Smrg
3107c05e7a3eSmrg# AM_SILENT_RULES([DEFAULT])
3108c05e7a3eSmrg# --------------------------
3109c05e7a3eSmrg# Enable less verbose build rules; with the default set to DEFAULT
3110c05e7a3eSmrg# ("yes" being less verbose, "no" or empty being verbose).
3111c05e7a3eSmrgAC_DEFUN([AM_SILENT_RULES],
3112c05e7a3eSmrg[AC_ARG_ENABLE([silent-rules], [dnl
3113c05e7a3eSmrgAS_HELP_STRING(
3114c05e7a3eSmrg  [--enable-silent-rules],
3115c05e7a3eSmrg  [less verbose build output (undo: "make V=1")])
3116c05e7a3eSmrgAS_HELP_STRING(
3117c05e7a3eSmrg  [--disable-silent-rules],
3118c05e7a3eSmrg  [verbose build output (undo: "make V=0")])dnl
3119c05e7a3eSmrg])
3120c05e7a3eSmrgcase $enable_silent_rules in @%:@ (((
3121c05e7a3eSmrg  yes) AM_DEFAULT_VERBOSITY=0;;
3122c05e7a3eSmrg   no) AM_DEFAULT_VERBOSITY=1;;
3123c05e7a3eSmrg    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
3124c05e7a3eSmrgesac
3125c05e7a3eSmrgdnl
3126c05e7a3eSmrgdnl A few 'make' implementations (e.g., NonStop OS and NextStep)
3127c05e7a3eSmrgdnl do not support nested variable expansions.
3128c05e7a3eSmrgdnl See automake bug#9928 and bug#10237.
3129c05e7a3eSmrgam_make=${MAKE-make}
3130c05e7a3eSmrgAC_CACHE_CHECK([whether $am_make supports nested variables],
3131c05e7a3eSmrg   [am_cv_make_support_nested_variables],
3132c05e7a3eSmrg   [if AS_ECHO([['TRUE=$(BAR$(V))
3133c05e7a3eSmrgBAR0=false
3134c05e7a3eSmrgBAR1=true
3135c05e7a3eSmrgV=1
3136c05e7a3eSmrgam__doit:
3137c05e7a3eSmrg	@$(TRUE)
3138c05e7a3eSmrg.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
3139c05e7a3eSmrg  am_cv_make_support_nested_variables=yes
3140c05e7a3eSmrgelse
3141c05e7a3eSmrg  am_cv_make_support_nested_variables=no
3142c05e7a3eSmrgfi])
3143c05e7a3eSmrgif test $am_cv_make_support_nested_variables = yes; then
3144c05e7a3eSmrg  dnl Using '$V' instead of '$(V)' breaks IRIX make.
3145c05e7a3eSmrg  AM_V='$(V)'
3146c05e7a3eSmrg  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
3147c05e7a3eSmrgelse
3148c05e7a3eSmrg  AM_V=$AM_DEFAULT_VERBOSITY
3149c05e7a3eSmrg  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
3150c05e7a3eSmrgfi
3151c05e7a3eSmrgAC_SUBST([AM_V])dnl
3152c05e7a3eSmrgAM_SUBST_NOTMAKE([AM_V])dnl
3153c05e7a3eSmrgAC_SUBST([AM_DEFAULT_V])dnl
3154c05e7a3eSmrgAM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
3155c05e7a3eSmrgAC_SUBST([AM_DEFAULT_VERBOSITY])dnl
3156c05e7a3eSmrgAM_BACKSLASH='\'
3157c05e7a3eSmrgAC_SUBST([AM_BACKSLASH])dnl
3158c05e7a3eSmrg_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
3159c05e7a3eSmrg])
3160c05e7a3eSmrg
3161c05e7a3eSmrg# Copyright (C) 2001-2014 Free Software Foundation, Inc.
316294a251fdSmrg#
3163c05e7a3eSmrg# This file is free software; the Free Software Foundation
3164c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
3165c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
3166c05e7a3eSmrg
3167c05e7a3eSmrg# AM_PROG_INSTALL_STRIP
3168c05e7a3eSmrg# ---------------------
3169c05e7a3eSmrg# One issue with vendor 'install' (even GNU) is that you can't
3170c05e7a3eSmrg# specify the program used to strip binaries.  This is especially
3171c05e7a3eSmrg# annoying in cross-compiling environments, where the build's strip
3172c05e7a3eSmrg# is unlikely to handle the host's binaries.
3173c05e7a3eSmrg# Fortunately install-sh will honor a STRIPPROG variable, so we
3174c05e7a3eSmrg# always use install-sh in "make install-strip", and initialize
3175c05e7a3eSmrg# STRIPPROG with the value of the STRIP variable (set by the user).
3176c05e7a3eSmrgAC_DEFUN([AM_PROG_INSTALL_STRIP],
3177c05e7a3eSmrg[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
3178c05e7a3eSmrg# Installed binaries are usually stripped using 'strip' when the user
3179c05e7a3eSmrg# run "make install-strip".  However 'strip' might not be the right
3180c05e7a3eSmrg# tool to use in cross-compilation environments, therefore Automake
3181c05e7a3eSmrg# will honor the 'STRIP' environment variable to overrule this program.
3182c05e7a3eSmrgdnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
3183c05e7a3eSmrgif test "$cross_compiling" != no; then
3184c05e7a3eSmrg  AC_CHECK_TOOL([STRIP], [strip], :)
3185c05e7a3eSmrgfi
3186c05e7a3eSmrgINSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
3187c05e7a3eSmrgAC_SUBST([INSTALL_STRIP_PROGRAM])])
3188e6232409Smrg
3189c05e7a3eSmrg# Copyright (C) 2006-2014 Free Software Foundation, Inc.
3190c05e7a3eSmrg#
3191c05e7a3eSmrg# This file is free software; the Free Software Foundation
3192c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
3193c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
3194e6232409Smrg
3195c05e7a3eSmrg# _AM_SUBST_NOTMAKE(VARIABLE)
3196c05e7a3eSmrg# ---------------------------
3197c05e7a3eSmrg# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
3198c05e7a3eSmrg# This macro is traced by Automake.
3199c05e7a3eSmrgAC_DEFUN([_AM_SUBST_NOTMAKE])
3200e6232409Smrg
3201c05e7a3eSmrg# AM_SUBST_NOTMAKE(VARIABLE)
3202c05e7a3eSmrg# --------------------------
3203c05e7a3eSmrg# Public sister of _AM_SUBST_NOTMAKE.
3204c05e7a3eSmrgAC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
3205e6232409Smrg
3206c05e7a3eSmrg# Check how to create a tarball.                            -*- Autoconf -*-
3207e6232409Smrg
3208c05e7a3eSmrg# Copyright (C) 2004-2014 Free Software Foundation, Inc.
3209c05e7a3eSmrg#
3210c05e7a3eSmrg# This file is free software; the Free Software Foundation
3211c05e7a3eSmrg# gives unlimited permission to copy and/or distribute it,
3212c05e7a3eSmrg# with or without modifications, as long as this notice is preserved.
3213e6232409Smrg
3214c05e7a3eSmrg# _AM_PROG_TAR(FORMAT)
32158fff3f40Smrg# --------------------
3216c05e7a3eSmrg# Check how to create a tarball in format FORMAT.
3217c05e7a3eSmrg# FORMAT should be one of 'v7', 'ustar', or 'pax'.
32188fff3f40Smrg#
3219c05e7a3eSmrg# Substitute a variable $(am__tar) that is a command
3220c05e7a3eSmrg# writing to stdout a FORMAT-tarball containing the directory
3221c05e7a3eSmrg# $tardir.
3222c05e7a3eSmrg#     tardir=directory && $(am__tar) > result.tar
322394a251fdSmrg#
3224c05e7a3eSmrg# Substitute a variable $(am__untar) that extract such
3225c05e7a3eSmrg# a tarball read from stdin.
3226c05e7a3eSmrg#     $(am__untar) < result.tar
322794a251fdSmrg#
3228c05e7a3eSmrgAC_DEFUN([_AM_PROG_TAR],
3229c05e7a3eSmrg[# Always define AMTAR for backward compatibility.  Yes, it's still used
3230c05e7a3eSmrg# in the wild :-(  We should find a proper way to deprecate it ...
3231c05e7a3eSmrgAC_SUBST([AMTAR], ['$${TAR-tar}'])
32328fff3f40Smrg
3233c05e7a3eSmrg# We'll loop over all known methods to create a tar archive until one works.
3234c05e7a3eSmrg_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
32356a45684fSmrg
3236c05e7a3eSmrgm4_if([$1], [v7],
3237c05e7a3eSmrg  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
32388fff3f40Smrg
3239c05e7a3eSmrg  [m4_case([$1],
3240c05e7a3eSmrg    [ustar],
3241c05e7a3eSmrg     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
3242c05e7a3eSmrg      # There is notably a 21 bits limit for the UID and the GID.  In fact,
3243c05e7a3eSmrg      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
3244c05e7a3eSmrg      # and bug#13588).
3245c05e7a3eSmrg      am_max_uid=2097151 # 2^21 - 1
3246c05e7a3eSmrg      am_max_gid=$am_max_uid
3247c05e7a3eSmrg      # The $UID and $GID variables are not portable, so we need to resort
3248c05e7a3eSmrg      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
3249c05e7a3eSmrg      # below are definitely unexpected, so allow the users to see them
3250c05e7a3eSmrg      # (that is, avoid stderr redirection).
3251c05e7a3eSmrg      am_uid=`id -u || echo unknown`
3252c05e7a3eSmrg      am_gid=`id -g || echo unknown`
3253c05e7a3eSmrg      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
3254c05e7a3eSmrg      if test $am_uid -le $am_max_uid; then
3255c05e7a3eSmrg         AC_MSG_RESULT([yes])
3256c05e7a3eSmrg      else
3257c05e7a3eSmrg         AC_MSG_RESULT([no])
3258c05e7a3eSmrg         _am_tools=none
3259c05e7a3eSmrg      fi
3260c05e7a3eSmrg      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
3261c05e7a3eSmrg      if test $am_gid -le $am_max_gid; then
3262c05e7a3eSmrg         AC_MSG_RESULT([yes])
3263c05e7a3eSmrg      else
3264c05e7a3eSmrg        AC_MSG_RESULT([no])
3265c05e7a3eSmrg        _am_tools=none
3266c05e7a3eSmrg      fi],
3267c05e7a3eSmrg
3268c05e7a3eSmrg  [pax],
3269c05e7a3eSmrg    [],
3270c05e7a3eSmrg
3271c05e7a3eSmrg  [m4_fatal([Unknown tar format])])
3272c05e7a3eSmrg
3273c05e7a3eSmrg  AC_MSG_CHECKING([how to create a $1 tar archive])
3274c05e7a3eSmrg
3275c05e7a3eSmrg  # Go ahead even if we have the value already cached.  We do so because we
3276c05e7a3eSmrg  # need to set the values for the 'am__tar' and 'am__untar' variables.
3277c05e7a3eSmrg  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
3278c05e7a3eSmrg
3279c05e7a3eSmrg  for _am_tool in $_am_tools; do
3280c05e7a3eSmrg    case $_am_tool in
3281c05e7a3eSmrg    gnutar)
3282c05e7a3eSmrg      for _am_tar in tar gnutar gtar; do
3283c05e7a3eSmrg        AM_RUN_LOG([$_am_tar --version]) && break
3284c05e7a3eSmrg      done
3285c05e7a3eSmrg      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
3286c05e7a3eSmrg      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
3287c05e7a3eSmrg      am__untar="$_am_tar -xf -"
3288c05e7a3eSmrg      ;;
3289c05e7a3eSmrg    plaintar)
3290c05e7a3eSmrg      # Must skip GNU tar: if it does not support --format= it doesn't create
3291c05e7a3eSmrg      # ustar tarball either.
3292c05e7a3eSmrg      (tar --version) >/dev/null 2>&1 && continue
3293c05e7a3eSmrg      am__tar='tar chf - "$$tardir"'
3294c05e7a3eSmrg      am__tar_='tar chf - "$tardir"'
3295c05e7a3eSmrg      am__untar='tar xf -'
3296c05e7a3eSmrg      ;;
3297c05e7a3eSmrg    pax)
3298c05e7a3eSmrg      am__tar='pax -L -x $1 -w "$$tardir"'
3299c05e7a3eSmrg      am__tar_='pax -L -x $1 -w "$tardir"'
3300c05e7a3eSmrg      am__untar='pax -r'
3301c05e7a3eSmrg      ;;
3302c05e7a3eSmrg    cpio)
3303c05e7a3eSmrg      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
3304c05e7a3eSmrg      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
3305c05e7a3eSmrg      am__untar='cpio -i -H $1 -d'
3306c05e7a3eSmrg      ;;
3307c05e7a3eSmrg    none)
3308c05e7a3eSmrg      am__tar=false
3309c05e7a3eSmrg      am__tar_=false
3310c05e7a3eSmrg      am__untar=false
3311c05e7a3eSmrg      ;;
3312c05e7a3eSmrg    esac
3313c05e7a3eSmrg
3314c05e7a3eSmrg    # If the value was cached, stop now.  We just wanted to have am__tar
3315c05e7a3eSmrg    # and am__untar set.
3316c05e7a3eSmrg    test -n "${am_cv_prog_tar_$1}" && break
3317c05e7a3eSmrg
3318c05e7a3eSmrg    # tar/untar a dummy directory, and stop if the command works.
3319c05e7a3eSmrg    rm -rf conftest.dir
3320c05e7a3eSmrg    mkdir conftest.dir
3321c05e7a3eSmrg    echo GrepMe > conftest.dir/file
3322c05e7a3eSmrg    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
3323c05e7a3eSmrg    rm -rf conftest.dir
3324c05e7a3eSmrg    if test -s conftest.tar; then
3325c05e7a3eSmrg      AM_RUN_LOG([$am__untar <conftest.tar])
3326c05e7a3eSmrg      AM_RUN_LOG([cat conftest.dir/file])
3327c05e7a3eSmrg      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
3328c05e7a3eSmrg    fi
3329c05e7a3eSmrg  done
3330c05e7a3eSmrg  rm -rf conftest.dir
3331c05e7a3eSmrg
3332c05e7a3eSmrg  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
3333c05e7a3eSmrg  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
3334c05e7a3eSmrg
3335c05e7a3eSmrgAC_SUBST([am__tar])
3336c05e7a3eSmrgAC_SUBST([am__untar])
3337c05e7a3eSmrg]) # _AM_PROG_TAR
3338e6232409Smrg
3339