aclocal.m4 revision bfe6082c
1bfe6082cSmrg# generated automatically by aclocal 1.16.2 -*- Autoconf -*-
2c82dfdfbSmrg
3bfe6082cSmrg# Copyright (C) 1996-2020 Free Software Foundation, Inc.
4f46a6179Smrg
5f46a6179Smrg# This file is free software; the Free Software Foundation
6f46a6179Smrg# gives unlimited permission to copy and/or distribute it,
7f46a6179Smrg# with or without modifications, as long as this notice is preserved.
8f46a6179Smrg
9f46a6179Smrg# This program is distributed in the hope that it will be useful,
10f46a6179Smrg# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11f46a6179Smrg# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12f46a6179Smrg# PARTICULAR PURPOSE.
13f46a6179Smrg
14c82dfdfbSmrgm4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
15f46a6179Smrgm4_ifndef([AC_AUTOCONF_VERSION],
16f46a6179Smrg  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
17c82dfdfbSmrgm4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
18c82dfdfbSmrg[m4_warning([this file was generated for autoconf 2.69.
19f46a6179SmrgYou have another version of autoconf.  It may work, but is not guaranteed to.
20f46a6179SmrgIf you have problems, you may need to regenerate the build system entirely.
21c82dfdfbSmrgTo do so, use the procedure documented by the package, typically 'autoreconf'.])])
22c82dfdfbSmrg
23f757b1e9Smrg# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
24f757b1e9Smrg# serial 11 (pkg-config-0.29.1)
25f757b1e9Smrg
26f757b1e9Smrgdnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
27f757b1e9Smrgdnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
28f757b1e9Smrgdnl
29f757b1e9Smrgdnl This program is free software; you can redistribute it and/or modify
30f757b1e9Smrgdnl it under the terms of the GNU General Public License as published by
31f757b1e9Smrgdnl the Free Software Foundation; either version 2 of the License, or
32f757b1e9Smrgdnl (at your option) any later version.
33f757b1e9Smrgdnl
34f757b1e9Smrgdnl This program is distributed in the hope that it will be useful, but
35f757b1e9Smrgdnl WITHOUT ANY WARRANTY; without even the implied warranty of
36f757b1e9Smrgdnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37f757b1e9Smrgdnl General Public License for more details.
38f757b1e9Smrgdnl
39f757b1e9Smrgdnl You should have received a copy of the GNU General Public License
40f757b1e9Smrgdnl along with this program; if not, write to the Free Software
41f757b1e9Smrgdnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
42f757b1e9Smrgdnl 02111-1307, USA.
43f757b1e9Smrgdnl
44f757b1e9Smrgdnl As a special exception to the GNU General Public License, if you
45f757b1e9Smrgdnl distribute this file as part of a program that contains a
46f757b1e9Smrgdnl configuration script generated by Autoconf, you may include it under
47f757b1e9Smrgdnl the same distribution terms that you use for the rest of that
48f757b1e9Smrgdnl program.
49f757b1e9Smrg
50f757b1e9Smrgdnl PKG_PREREQ(MIN-VERSION)
51f757b1e9Smrgdnl -----------------------
52f757b1e9Smrgdnl Since: 0.29
53f757b1e9Smrgdnl
54f757b1e9Smrgdnl Verify that the version of the pkg-config macros are at least
55f757b1e9Smrgdnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
56f757b1e9Smrgdnl installed version of pkg-config, this checks the developer's version
57f757b1e9Smrgdnl of pkg.m4 when generating configure.
58f757b1e9Smrgdnl
59f757b1e9Smrgdnl To ensure that this macro is defined, also add:
60f757b1e9Smrgdnl m4_ifndef([PKG_PREREQ],
61f757b1e9Smrgdnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
62f757b1e9Smrgdnl
63f757b1e9Smrgdnl See the "Since" comment for each macro you use to see what version
64f757b1e9Smrgdnl of the macros you require.
65f757b1e9Smrgm4_defun([PKG_PREREQ],
66f757b1e9Smrg[m4_define([PKG_MACROS_VERSION], [0.29.1])
67f757b1e9Smrgm4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
68f757b1e9Smrg    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
69f757b1e9Smrg])dnl PKG_PREREQ
70f757b1e9Smrg
71f757b1e9Smrgdnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
72f757b1e9Smrgdnl ----------------------------------
73f757b1e9Smrgdnl Since: 0.16
74f757b1e9Smrgdnl
75f757b1e9Smrgdnl Search for the pkg-config tool and set the PKG_CONFIG variable to
76f757b1e9Smrgdnl first found in the path. Checks that the version of pkg-config found
77f757b1e9Smrgdnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
78f757b1e9Smrgdnl used since that's the first version where most current features of
79f757b1e9Smrgdnl pkg-config existed.
80c82dfdfbSmrgAC_DEFUN([PKG_PROG_PKG_CONFIG],
81c82dfdfbSmrg[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
82c82dfdfbSmrgm4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
83c82dfdfbSmrgm4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
84c82dfdfbSmrgAC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
85c82dfdfbSmrgAC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
86c82dfdfbSmrgAC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
87c82dfdfbSmrg
88c82dfdfbSmrgif test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
89c82dfdfbSmrg	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
90c82dfdfbSmrgfi
91c82dfdfbSmrgif test -n "$PKG_CONFIG"; then
92c82dfdfbSmrg	_pkg_min_version=m4_default([$1], [0.9.0])
93c82dfdfbSmrg	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
94c82dfdfbSmrg	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
95c82dfdfbSmrg		AC_MSG_RESULT([yes])
96c82dfdfbSmrg	else
97c82dfdfbSmrg		AC_MSG_RESULT([no])
98c82dfdfbSmrg		PKG_CONFIG=""
99c82dfdfbSmrg	fi
100c82dfdfbSmrgfi[]dnl
101f757b1e9Smrg])dnl PKG_PROG_PKG_CONFIG
102c82dfdfbSmrg
103f757b1e9Smrgdnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
104f757b1e9Smrgdnl -------------------------------------------------------------------
105f757b1e9Smrgdnl Since: 0.18
106f757b1e9Smrgdnl
107f757b1e9Smrgdnl Check to see whether a particular set of modules exists. Similar to
108f757b1e9Smrgdnl PKG_CHECK_MODULES(), but does not set variables or print errors.
109f757b1e9Smrgdnl
110f757b1e9Smrgdnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
111f757b1e9Smrgdnl only at the first occurence in configure.ac, so if the first place
112f757b1e9Smrgdnl it's called might be skipped (such as if it is within an "if", you
113f757b1e9Smrgdnl have to call PKG_CHECK_EXISTS manually
114c82dfdfbSmrgAC_DEFUN([PKG_CHECK_EXISTS],
115c82dfdfbSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
116c82dfdfbSmrgif test -n "$PKG_CONFIG" && \
117c82dfdfbSmrg    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
118c82dfdfbSmrg  m4_default([$2], [:])
119c82dfdfbSmrgm4_ifvaln([$3], [else
120c82dfdfbSmrg  $3])dnl
121c82dfdfbSmrgfi])
122c82dfdfbSmrg
123f757b1e9Smrgdnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
124f757b1e9Smrgdnl ---------------------------------------------
125f757b1e9Smrgdnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
126f757b1e9Smrgdnl pkg_failed based on the result.
127c82dfdfbSmrgm4_define([_PKG_CONFIG],
128c82dfdfbSmrg[if test -n "$$1"; then
129c82dfdfbSmrg    pkg_cv_[]$1="$$1"
130c82dfdfbSmrg elif test -n "$PKG_CONFIG"; then
131c82dfdfbSmrg    PKG_CHECK_EXISTS([$3],
132c82dfdfbSmrg                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
133c82dfdfbSmrg		      test "x$?" != "x0" && pkg_failed=yes ],
134c82dfdfbSmrg		     [pkg_failed=yes])
135c82dfdfbSmrg else
136c82dfdfbSmrg    pkg_failed=untried
137c82dfdfbSmrgfi[]dnl
138f757b1e9Smrg])dnl _PKG_CONFIG
139c82dfdfbSmrg
140f757b1e9Smrgdnl _PKG_SHORT_ERRORS_SUPPORTED
141f757b1e9Smrgdnl ---------------------------
142f757b1e9Smrgdnl Internal check to see if pkg-config supports short errors.
143c82dfdfbSmrgAC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
144c82dfdfbSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
145c82dfdfbSmrgif $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
146c82dfdfbSmrg        _pkg_short_errors_supported=yes
147c82dfdfbSmrgelse
148c82dfdfbSmrg        _pkg_short_errors_supported=no
149c82dfdfbSmrgfi[]dnl
150f757b1e9Smrg])dnl _PKG_SHORT_ERRORS_SUPPORTED
151c82dfdfbSmrg
152c82dfdfbSmrg
153f757b1e9Smrgdnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
154f757b1e9Smrgdnl   [ACTION-IF-NOT-FOUND])
155f757b1e9Smrgdnl --------------------------------------------------------------
156f757b1e9Smrgdnl Since: 0.4.0
157f757b1e9Smrgdnl
158f757b1e9Smrgdnl Note that if there is a possibility the first call to
159f757b1e9Smrgdnl PKG_CHECK_MODULES might not happen, you should be sure to include an
160f757b1e9Smrgdnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
161c82dfdfbSmrgAC_DEFUN([PKG_CHECK_MODULES],
162c82dfdfbSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
163c82dfdfbSmrgAC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
164c82dfdfbSmrgAC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
165c82dfdfbSmrg
166c82dfdfbSmrgpkg_failed=no
167c82dfdfbSmrgAC_MSG_CHECKING([for $1])
168c82dfdfbSmrg
169c82dfdfbSmrg_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
170c82dfdfbSmrg_PKG_CONFIG([$1][_LIBS], [libs], [$2])
171c82dfdfbSmrg
172c82dfdfbSmrgm4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
173c82dfdfbSmrgand $1[]_LIBS to avoid the need to call pkg-config.
174c82dfdfbSmrgSee the pkg-config man page for more details.])
175c82dfdfbSmrg
176c82dfdfbSmrgif test $pkg_failed = yes; then
177c82dfdfbSmrg   	AC_MSG_RESULT([no])
178c82dfdfbSmrg        _PKG_SHORT_ERRORS_SUPPORTED
179c82dfdfbSmrg        if test $_pkg_short_errors_supported = yes; then
180c82dfdfbSmrg	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
181c82dfdfbSmrg        else 
182c82dfdfbSmrg	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
183c82dfdfbSmrg        fi
184c82dfdfbSmrg	# Put the nasty error message in config.log where it belongs
185c82dfdfbSmrg	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
186c82dfdfbSmrg
187c82dfdfbSmrg	m4_default([$4], [AC_MSG_ERROR(
188c82dfdfbSmrg[Package requirements ($2) were not met:
189c82dfdfbSmrg
190c82dfdfbSmrg$$1_PKG_ERRORS
191c82dfdfbSmrg
192c82dfdfbSmrgConsider adjusting the PKG_CONFIG_PATH environment variable if you
193c82dfdfbSmrginstalled software in a non-standard prefix.
194c82dfdfbSmrg
195c82dfdfbSmrg_PKG_TEXT])[]dnl
196c82dfdfbSmrg        ])
197c82dfdfbSmrgelif test $pkg_failed = untried; then
198c82dfdfbSmrg     	AC_MSG_RESULT([no])
199c82dfdfbSmrg	m4_default([$4], [AC_MSG_FAILURE(
200c82dfdfbSmrg[The pkg-config script could not be found or is too old.  Make sure it
201c82dfdfbSmrgis in your PATH or set the PKG_CONFIG environment variable to the full
202c82dfdfbSmrgpath to pkg-config.
203f46a6179Smrg
204c82dfdfbSmrg_PKG_TEXT
205c82dfdfbSmrg
206c82dfdfbSmrgTo get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
207c82dfdfbSmrg        ])
208c82dfdfbSmrgelse
209c82dfdfbSmrg	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
210c82dfdfbSmrg	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
211c82dfdfbSmrg        AC_MSG_RESULT([yes])
212c82dfdfbSmrg	$3
213c82dfdfbSmrgfi[]dnl
214f757b1e9Smrg])dnl PKG_CHECK_MODULES
215f757b1e9Smrg
216f757b1e9Smrg
217f757b1e9Smrgdnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
218f757b1e9Smrgdnl   [ACTION-IF-NOT-FOUND])
219f757b1e9Smrgdnl ---------------------------------------------------------------------
220f757b1e9Smrgdnl Since: 0.29
221f757b1e9Smrgdnl
222f757b1e9Smrgdnl Checks for existence of MODULES and gathers its build flags with
223f757b1e9Smrgdnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
224f757b1e9Smrgdnl and VARIABLE-PREFIX_LIBS from --libs.
225f757b1e9Smrgdnl
226f757b1e9Smrgdnl Note that if there is a possibility the first call to
227f757b1e9Smrgdnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
228f757b1e9Smrgdnl include an explicit call to PKG_PROG_PKG_CONFIG in your
229f757b1e9Smrgdnl configure.ac.
230f757b1e9SmrgAC_DEFUN([PKG_CHECK_MODULES_STATIC],
231f757b1e9Smrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
232f757b1e9Smrg_save_PKG_CONFIG=$PKG_CONFIG
233f757b1e9SmrgPKG_CONFIG="$PKG_CONFIG --static"
234f757b1e9SmrgPKG_CHECK_MODULES($@)
235f757b1e9SmrgPKG_CONFIG=$_save_PKG_CONFIG[]dnl
236f757b1e9Smrg])dnl PKG_CHECK_MODULES_STATIC
237c82dfdfbSmrg
238c82dfdfbSmrg
239f757b1e9Smrgdnl PKG_INSTALLDIR([DIRECTORY])
240f757b1e9Smrgdnl -------------------------
241f757b1e9Smrgdnl Since: 0.27
242f757b1e9Smrgdnl
243f757b1e9Smrgdnl Substitutes the variable pkgconfigdir as the location where a module
244f757b1e9Smrgdnl should install pkg-config .pc files. By default the directory is
245f757b1e9Smrgdnl $libdir/pkgconfig, but the default can be changed by passing
246f757b1e9Smrgdnl DIRECTORY. The user can override through the --with-pkgconfigdir
247f757b1e9Smrgdnl parameter.
248c82dfdfbSmrgAC_DEFUN([PKG_INSTALLDIR],
249c82dfdfbSmrg[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
250c82dfdfbSmrgm4_pushdef([pkg_description],
251c82dfdfbSmrg    [pkg-config installation directory @<:@]pkg_default[@:>@])
252c82dfdfbSmrgAC_ARG_WITH([pkgconfigdir],
253c82dfdfbSmrg    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
254c82dfdfbSmrg    [with_pkgconfigdir=]pkg_default)
255c82dfdfbSmrgAC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
256c82dfdfbSmrgm4_popdef([pkg_default])
257c82dfdfbSmrgm4_popdef([pkg_description])
258f757b1e9Smrg])dnl PKG_INSTALLDIR
259c82dfdfbSmrg
260c82dfdfbSmrg
261f757b1e9Smrgdnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
262f757b1e9Smrgdnl --------------------------------
263f757b1e9Smrgdnl Since: 0.27
264f757b1e9Smrgdnl
265f757b1e9Smrgdnl Substitutes the variable noarch_pkgconfigdir as the location where a
266f757b1e9Smrgdnl module should install arch-independent pkg-config .pc files. By
267f757b1e9Smrgdnl default the directory is $datadir/pkgconfig, but the default can be
268f757b1e9Smrgdnl changed by passing DIRECTORY. The user can override through the
269f757b1e9Smrgdnl --with-noarch-pkgconfigdir parameter.
270c82dfdfbSmrgAC_DEFUN([PKG_NOARCH_INSTALLDIR],
271c82dfdfbSmrg[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
272c82dfdfbSmrgm4_pushdef([pkg_description],
273c82dfdfbSmrg    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
274c82dfdfbSmrgAC_ARG_WITH([noarch-pkgconfigdir],
275c82dfdfbSmrg    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
276c82dfdfbSmrg    [with_noarch_pkgconfigdir=]pkg_default)
277c82dfdfbSmrgAC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
278c82dfdfbSmrgm4_popdef([pkg_default])
279c82dfdfbSmrgm4_popdef([pkg_description])
280f757b1e9Smrg])dnl PKG_NOARCH_INSTALLDIR
281c82dfdfbSmrg
282c82dfdfbSmrg
283f757b1e9Smrgdnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
284f757b1e9Smrgdnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
285f757b1e9Smrgdnl -------------------------------------------
286f757b1e9Smrgdnl Since: 0.28
287f757b1e9Smrgdnl
288f757b1e9Smrgdnl Retrieves the value of the pkg-config variable for the given module.
289c82dfdfbSmrgAC_DEFUN([PKG_CHECK_VAR],
290c82dfdfbSmrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
291c82dfdfbSmrgAC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
292c82dfdfbSmrg
293c82dfdfbSmrg_PKG_CONFIG([$1], [variable="][$3]["], [$2])
294c82dfdfbSmrgAS_VAR_COPY([$1], [pkg_cv_][$1])
295c82dfdfbSmrg
296c82dfdfbSmrgAS_VAR_IF([$1], [""], [$5], [$4])dnl
297f757b1e9Smrg])dnl PKG_CHECK_VAR
29807d2e718Smrg
299f757b1e9Smrgdnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
300f757b1e9Smrgdnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
301f757b1e9Smrgdnl   [DESCRIPTION], [DEFAULT])
302f757b1e9Smrgdnl ------------------------------------------
303f757b1e9Smrgdnl
304f757b1e9Smrgdnl Prepare a "--with-" configure option using the lowercase
305f757b1e9Smrgdnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
306f757b1e9Smrgdnl PKG_CHECK_MODULES in a single macro.
307f757b1e9SmrgAC_DEFUN([PKG_WITH_MODULES],
308f757b1e9Smrg[
309f757b1e9Smrgm4_pushdef([with_arg], m4_tolower([$1]))
310f757b1e9Smrg
311f757b1e9Smrgm4_pushdef([description],
312f757b1e9Smrg           [m4_default([$5], [build with ]with_arg[ support])])
313f757b1e9Smrg
314f757b1e9Smrgm4_pushdef([def_arg], [m4_default([$6], [auto])])
315f757b1e9Smrgm4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
316f757b1e9Smrgm4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
317f757b1e9Smrg
318f757b1e9Smrgm4_case(def_arg,
319f757b1e9Smrg            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
320f757b1e9Smrg            [m4_pushdef([with_without],[--with-]with_arg)])
321f757b1e9Smrg
322f757b1e9SmrgAC_ARG_WITH(with_arg,
323f757b1e9Smrg     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
324f757b1e9Smrg    [AS_TR_SH([with_]with_arg)=def_arg])
325f757b1e9Smrg
326f757b1e9SmrgAS_CASE([$AS_TR_SH([with_]with_arg)],
327f757b1e9Smrg            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
328f757b1e9Smrg            [auto],[PKG_CHECK_MODULES([$1],[$2],
329f757b1e9Smrg                                        [m4_n([def_action_if_found]) $3],
330f757b1e9Smrg                                        [m4_n([def_action_if_not_found]) $4])])
331f757b1e9Smrg
332f757b1e9Smrgm4_popdef([with_arg])
333f757b1e9Smrgm4_popdef([description])
334f757b1e9Smrgm4_popdef([def_arg])
335f757b1e9Smrg
336f757b1e9Smrg])dnl PKG_WITH_MODULES
337f757b1e9Smrg
338f757b1e9Smrgdnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
339f757b1e9Smrgdnl   [DESCRIPTION], [DEFAULT])
340f757b1e9Smrgdnl -----------------------------------------------
341f757b1e9Smrgdnl
342f757b1e9Smrgdnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
343f757b1e9Smrgdnl check._[VARIABLE-PREFIX] is exported as make variable.
344f757b1e9SmrgAC_DEFUN([PKG_HAVE_WITH_MODULES],
345f757b1e9Smrg[
346f757b1e9SmrgPKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
347f757b1e9Smrg
348f757b1e9SmrgAM_CONDITIONAL([HAVE_][$1],
349f757b1e9Smrg               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
350f757b1e9Smrg])dnl PKG_HAVE_WITH_MODULES
351f757b1e9Smrg
352f757b1e9Smrgdnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
353f757b1e9Smrgdnl   [DESCRIPTION], [DEFAULT])
354f757b1e9Smrgdnl ------------------------------------------------------
355f757b1e9Smrgdnl
356f757b1e9Smrgdnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
357f757b1e9Smrgdnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
358f757b1e9Smrgdnl and preprocessor variable.
359f757b1e9SmrgAC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
360f757b1e9Smrg[
361f757b1e9SmrgPKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
36207d2e718Smrg
363f757b1e9SmrgAS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
364f757b1e9Smrg        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
365f757b1e9Smrg])dnl PKG_HAVE_DEFINE_WITH_MODULES
36607d2e718Smrg
367f757b1e9Smrgdnl xorg-macros.m4.  Generated from xorg-macros.m4.in xorgversion.m4 by configure.
368f757b1e9Smrgdnl
369bfe6082cSmrgdnl Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
370f757b1e9Smrgdnl
371f757b1e9Smrgdnl Permission is hereby granted, free of charge, to any person obtaining a
372f757b1e9Smrgdnl copy of this software and associated documentation files (the "Software"),
373f757b1e9Smrgdnl to deal in the Software without restriction, including without limitation
374f757b1e9Smrgdnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
375f757b1e9Smrgdnl and/or sell copies of the Software, and to permit persons to whom the
376f757b1e9Smrgdnl Software is furnished to do so, subject to the following conditions:
377f757b1e9Smrgdnl
378f757b1e9Smrgdnl The above copyright notice and this permission notice (including the next
379f757b1e9Smrgdnl paragraph) shall be included in all copies or substantial portions of the
380f757b1e9Smrgdnl Software.
381f757b1e9Smrgdnl
382f757b1e9Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
383f757b1e9Smrgdnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
384f757b1e9Smrgdnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
385f757b1e9Smrgdnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
386f757b1e9Smrgdnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
387f757b1e9Smrgdnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
388f757b1e9Smrgdnl DEALINGS IN THE SOFTWARE.
38907d2e718Smrg
390f757b1e9Smrg# XORG_MACROS_VERSION(required-version)
391f757b1e9Smrg# -------------------------------------
392f757b1e9Smrg# Minimum version: 1.1.0
39307d2e718Smrg#
394f757b1e9Smrg# If you're using a macro added in Version 1.1 or newer, include this in
395f757b1e9Smrg# your configure.ac with the minimum required version, such as:
396f757b1e9Smrg# XORG_MACROS_VERSION(1.1)
39707d2e718Smrg#
398f757b1e9Smrg# To ensure that this macro is defined, also add:
399f757b1e9Smrg# m4_ifndef([XORG_MACROS_VERSION],
400f757b1e9Smrg#     [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
40107d2e718Smrg#
4021d8c7986Smrg#
403f757b1e9Smrg# See the "minimum version" comment for each macro you use to see what
404f757b1e9Smrg# version you require.
405f757b1e9Smrgm4_defun([XORG_MACROS_VERSION],[
406bfe6082cSmrgm4_define([vers_have], [1.19.2])
407f757b1e9Smrgm4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
408f757b1e9Smrgm4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
409f757b1e9Smrgm4_if(m4_cmp(maj_have, maj_needed), 0,,
410f757b1e9Smrg    [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
411f757b1e9Smrgm4_if(m4_version_compare(vers_have, [$1]), -1,
412f757b1e9Smrg    [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
413f757b1e9Smrgm4_undefine([vers_have])
414f757b1e9Smrgm4_undefine([maj_have])
415f757b1e9Smrgm4_undefine([maj_needed])
416f757b1e9Smrg]) # XORG_MACROS_VERSION
41707d2e718Smrg
418f757b1e9Smrg# XORG_PROG_RAWCPP()
419f757b1e9Smrg# ------------------
420f757b1e9Smrg# Minimum version: 1.0.0
4211d8c7986Smrg#
422f757b1e9Smrg# Find cpp program and necessary flags for use in pre-processing text files
423f757b1e9Smrg# such as man pages and config files
424f757b1e9SmrgAC_DEFUN([XORG_PROG_RAWCPP],[
425f757b1e9SmrgAC_REQUIRE([AC_PROG_CPP])
426f757b1e9SmrgAC_PATH_PROGS(RAWCPP, [cpp], [${CPP}],
427f757b1e9Smrg   [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
42807d2e718Smrg
429f757b1e9Smrg# Check for flag to avoid builtin definitions - assumes unix is predefined,
430f757b1e9Smrg# which is not the best choice for supporting other OS'es, but covers most
431f757b1e9Smrg# of the ones we need for now.
432f757b1e9SmrgAC_MSG_CHECKING([if $RAWCPP requires -undef])
433f757b1e9SmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
434f757b1e9Smrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
435f757b1e9Smrg	AC_MSG_RESULT([no])
4361d8c7986Smrgelse
437f757b1e9Smrg	if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
438f757b1e9Smrg		RAWCPPFLAGS=-undef
439f757b1e9Smrg		AC_MSG_RESULT([yes])
440f757b1e9Smrg	# under Cygwin unix is still defined even with -undef
441f757b1e9Smrg	elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
442f757b1e9Smrg		RAWCPPFLAGS="-undef -ansi"
443f757b1e9Smrg		AC_MSG_RESULT([yes, with -ansi])
444f757b1e9Smrg	else
445f757b1e9Smrg		AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef.  I don't know what to do.])
446f757b1e9Smrg	fi
4471d8c7986Smrgfi
448f757b1e9Smrgrm -f conftest.$ac_ext
44907d2e718Smrg
450f757b1e9SmrgAC_MSG_CHECKING([if $RAWCPP requires -traditional])
451f757b1e9SmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
452f757b1e9Smrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
453f757b1e9Smrg	AC_MSG_RESULT([no])
454f757b1e9Smrgelse
455f757b1e9Smrg	if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
456f757b1e9Smrg		TRADITIONALCPPFLAGS="-traditional"
457f757b1e9Smrg		RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
458f757b1e9Smrg		AC_MSG_RESULT([yes])
459f757b1e9Smrg	else
460f757b1e9Smrg		AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
461f757b1e9Smrg	fi
462f757b1e9Smrgfi
463f757b1e9Smrgrm -f conftest.$ac_ext
464f757b1e9SmrgAC_SUBST(RAWCPPFLAGS)
465f757b1e9SmrgAC_SUBST(TRADITIONALCPPFLAGS)
466f757b1e9Smrg]) # XORG_PROG_RAWCPP
467f757b1e9Smrg
468f757b1e9Smrg# XORG_MANPAGE_SECTIONS()
469f757b1e9Smrg# -----------------------
470f757b1e9Smrg# Minimum version: 1.0.0
4711d8c7986Smrg#
472f757b1e9Smrg# Determine which sections man pages go in for the different man page types
473f757b1e9Smrg# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
474f757b1e9Smrg# Not sure if there's any better way than just hardcoding by OS name.
475f757b1e9Smrg# Override default settings by setting environment variables
476f757b1e9Smrg# Added MAN_SUBSTS in version 1.8
477f757b1e9Smrg# Added AC_PROG_SED in version 1.8
47807d2e718Smrg
479f757b1e9SmrgAC_DEFUN([XORG_MANPAGE_SECTIONS],[
480f757b1e9SmrgAC_REQUIRE([AC_CANONICAL_HOST])
481f757b1e9SmrgAC_REQUIRE([AC_PROG_SED])
48207d2e718Smrg
483bfe6082cSmrgcase $host_os in
484bfe6082cSmrg    solaris*)
485bfe6082cSmrg        # Solaris 2.0 - 11.3 use SysV man page section numbers, so we
486bfe6082cSmrg        # check for a man page file found in later versions that use
487bfe6082cSmrg        # traditional section numbers instead
488bfe6082cSmrg        AC_CHECK_FILE([/usr/share/man/man7/attributes.7],
489bfe6082cSmrg                [SYSV_MAN_SECTIONS=false], [SYSV_MAN_SECTIONS=true])
490bfe6082cSmrg        ;;
491bfe6082cSmrg    *) SYSV_MAN_SECTIONS=false ;;
492bfe6082cSmrgesac
493bfe6082cSmrg
494f757b1e9Smrgif test x$APP_MAN_SUFFIX = x    ; then
495f757b1e9Smrg    APP_MAN_SUFFIX=1
496f757b1e9Smrgfi
497f757b1e9Smrgif test x$APP_MAN_DIR = x    ; then
498f757b1e9Smrg    APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
499f757b1e9Smrgfi
50007d2e718Smrg
501f757b1e9Smrgif test x$LIB_MAN_SUFFIX = x    ; then
502f757b1e9Smrg    LIB_MAN_SUFFIX=3
503f757b1e9Smrgfi
504f757b1e9Smrgif test x$LIB_MAN_DIR = x    ; then
505f757b1e9Smrg    LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
506f757b1e9Smrgfi
50707d2e718Smrg
508f757b1e9Smrgif test x$FILE_MAN_SUFFIX = x    ; then
509bfe6082cSmrg    case $SYSV_MAN_SECTIONS in
510bfe6082cSmrg	true)				FILE_MAN_SUFFIX=4  ;;
511bfe6082cSmrg	*)				FILE_MAN_SUFFIX=5  ;;
512f757b1e9Smrg    esac
513f757b1e9Smrgfi
514f757b1e9Smrgif test x$FILE_MAN_DIR = x    ; then
515f757b1e9Smrg    FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
516f757b1e9Smrgfi
517f46a6179Smrg
518f757b1e9Smrgif test x$MISC_MAN_SUFFIX = x    ; then
519bfe6082cSmrg    case $SYSV_MAN_SECTIONS in
520bfe6082cSmrg	true)				MISC_MAN_SUFFIX=5  ;;
521bfe6082cSmrg	*)				MISC_MAN_SUFFIX=7  ;;
5221d8c7986Smrg    esac
523f757b1e9Smrgfi
524f757b1e9Smrgif test x$MISC_MAN_DIR = x    ; then
525f757b1e9Smrg    MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
526f757b1e9Smrgfi
5271d8c7986Smrg
528f757b1e9Smrgif test x$DRIVER_MAN_SUFFIX = x    ; then
529bfe6082cSmrg    case $SYSV_MAN_SECTIONS in
530bfe6082cSmrg	true)				DRIVER_MAN_SUFFIX=7  ;;
531bfe6082cSmrg	*)				DRIVER_MAN_SUFFIX=4  ;;
532f757b1e9Smrg    esac
533f757b1e9Smrgfi
534f757b1e9Smrgif test x$DRIVER_MAN_DIR = x    ; then
535f757b1e9Smrg    DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
536f46a6179Smrgfi
537f46a6179Smrg
538f757b1e9Smrgif test x$ADMIN_MAN_SUFFIX = x    ; then
539bfe6082cSmrg    case $SYSV_MAN_SECTIONS in
540bfe6082cSmrg	true)				ADMIN_MAN_SUFFIX=1m ;;
541bfe6082cSmrg	*)				ADMIN_MAN_SUFFIX=8  ;;
542f757b1e9Smrg    esac
543f757b1e9Smrgfi
544f757b1e9Smrgif test x$ADMIN_MAN_DIR = x    ; then
545f757b1e9Smrg    ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
546f757b1e9Smrgfi
547f46a6179Smrg
548f46a6179Smrg
549f757b1e9SmrgAC_SUBST([APP_MAN_SUFFIX])
550f757b1e9SmrgAC_SUBST([LIB_MAN_SUFFIX])
551f757b1e9SmrgAC_SUBST([FILE_MAN_SUFFIX])
552f757b1e9SmrgAC_SUBST([MISC_MAN_SUFFIX])
553f757b1e9SmrgAC_SUBST([DRIVER_MAN_SUFFIX])
554f757b1e9SmrgAC_SUBST([ADMIN_MAN_SUFFIX])
555f757b1e9SmrgAC_SUBST([APP_MAN_DIR])
556f757b1e9SmrgAC_SUBST([LIB_MAN_DIR])
557f757b1e9SmrgAC_SUBST([FILE_MAN_DIR])
558f757b1e9SmrgAC_SUBST([MISC_MAN_DIR])
559f757b1e9SmrgAC_SUBST([DRIVER_MAN_DIR])
560f757b1e9SmrgAC_SUBST([ADMIN_MAN_DIR])
561f46a6179Smrg
562f757b1e9SmrgXORG_MAN_PAGE="X Version 11"
563f757b1e9SmrgAC_SUBST([XORG_MAN_PAGE])
564f757b1e9SmrgMAN_SUBSTS="\
565f757b1e9Smrg	-e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
566f757b1e9Smrg	-e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
567f757b1e9Smrg	-e 's|__xservername__|Xorg|g' \
568f757b1e9Smrg	-e 's|__xconfigfile__|xorg.conf|g' \
569f757b1e9Smrg	-e 's|__projectroot__|\$(prefix)|g' \
570f757b1e9Smrg	-e 's|__apploaddir__|\$(appdefaultdir)|g' \
571f757b1e9Smrg	-e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
572f757b1e9Smrg	-e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
573f757b1e9Smrg	-e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
574f757b1e9Smrg	-e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
575f757b1e9Smrg	-e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
576f757b1e9Smrg	-e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
577f757b1e9SmrgAC_SUBST([MAN_SUBSTS])
578f46a6179Smrg
579f757b1e9Smrg]) # XORG_MANPAGE_SECTIONS
580f46a6179Smrg
581f757b1e9Smrg# XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
582f757b1e9Smrg# ------------------------
583f757b1e9Smrg# Minimum version: 1.7.0
5841d8c7986Smrg#
585f757b1e9Smrg# Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
586f757b1e9Smrg# provided by xorg-sgml-doctools, if installed.
587f757b1e9SmrgAC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
588f757b1e9SmrgAC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
589f757b1e9SmrgXORG_SGML_PATH=
590f757b1e9SmrgPKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
591f757b1e9Smrg    [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
592f757b1e9Smrg    [m4_ifval([$1],[:],
593f757b1e9Smrg        [if test x"$cross_compiling" != x"yes" ; then
594f757b1e9Smrg            AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
595f757b1e9Smrg                          [XORG_SGML_PATH=$prefix/share/sgml])
596f757b1e9Smrg         fi])
597f757b1e9Smrg    ])
598f46a6179Smrg
599f757b1e9Smrg# Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
600f757b1e9Smrg# the path and the name of the doc stylesheet
601f757b1e9Smrgif test "x$XORG_SGML_PATH" != "x" ; then
602f757b1e9Smrg   AC_MSG_RESULT([$XORG_SGML_PATH])
603f757b1e9Smrg   STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
604f757b1e9Smrg   XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
605f757b1e9Smrgelse
606f757b1e9Smrg   AC_MSG_RESULT([no])
607f757b1e9Smrgfi
608f46a6179Smrg
609f757b1e9SmrgAC_SUBST(XORG_SGML_PATH)
610f757b1e9SmrgAC_SUBST(STYLESHEET_SRCDIR)
611f757b1e9SmrgAC_SUBST(XSL_STYLESHEET)
612f757b1e9SmrgAM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
613f757b1e9Smrg]) # XORG_CHECK_SGML_DOCTOOLS
614690143ccSmrg
615f757b1e9Smrg# XORG_CHECK_LINUXDOC
616f757b1e9Smrg# -------------------
617f757b1e9Smrg# Minimum version: 1.0.0
618690143ccSmrg#
619f757b1e9Smrg# Defines the variable MAKE_TEXT if the necessary tools and
620f757b1e9Smrg# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
621f757b1e9Smrg# Whether or not the necessary tools and files are found can be checked
622f757b1e9Smrg# with the AM_CONDITIONAL "BUILD_LINUXDOC"
623f757b1e9SmrgAC_DEFUN([XORG_CHECK_LINUXDOC],[
624f757b1e9SmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
625f757b1e9SmrgAC_REQUIRE([XORG_WITH_PS2PDF])
626f46a6179Smrg
627f757b1e9SmrgAC_PATH_PROG(LINUXDOC, linuxdoc)
628f46a6179Smrg
629f757b1e9SmrgAC_MSG_CHECKING([whether to build documentation])
630690143ccSmrg
631f757b1e9Smrgif test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
632f757b1e9Smrg   BUILDDOC=yes
633f757b1e9Smrgelse
634f757b1e9Smrg   BUILDDOC=no
635f757b1e9Smrgfi
636f46a6179Smrg
637f757b1e9SmrgAM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
638c82dfdfbSmrg
639f757b1e9SmrgAC_MSG_RESULT([$BUILDDOC])
640f46a6179Smrg
641f757b1e9SmrgAC_MSG_CHECKING([whether to build pdf documentation])
642f757b1e9Smrg
643f757b1e9Smrgif test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
644f757b1e9Smrg   BUILDPDFDOC=yes
645f757b1e9Smrgelse
646f757b1e9Smrg   BUILDPDFDOC=no
647690143ccSmrgfi
648f46a6179Smrg
649f757b1e9SmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
650f46a6179Smrg
651f757b1e9SmrgAC_MSG_RESULT([$BUILDPDFDOC])
652f46a6179Smrg
653f757b1e9SmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
654f757b1e9SmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
655f757b1e9SmrgMAKE_PDF="$PS2PDF"
656f757b1e9SmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
657f46a6179Smrg
658f757b1e9SmrgAC_SUBST(MAKE_TEXT)
659f757b1e9SmrgAC_SUBST(MAKE_PS)
660f757b1e9SmrgAC_SUBST(MAKE_PDF)
661f757b1e9SmrgAC_SUBST(MAKE_HTML)
662f757b1e9Smrg]) # XORG_CHECK_LINUXDOC
663c82dfdfbSmrg
664f757b1e9Smrg# XORG_CHECK_DOCBOOK
665f757b1e9Smrg# -------------------
666f757b1e9Smrg# Minimum version: 1.0.0
667f757b1e9Smrg#
668f757b1e9Smrg# Checks for the ability to build output formats from SGML DocBook source.
669f757b1e9Smrg# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
670f757b1e9Smrg# indicates whether the necessary tools and files are found and, if set,
671f757b1e9Smrg# $(MAKE_XXX) blah.sgml will produce blah.xxx.
672f757b1e9SmrgAC_DEFUN([XORG_CHECK_DOCBOOK],[
673f757b1e9SmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
674c82dfdfbSmrg
675f757b1e9SmrgBUILDTXTDOC=no
676f757b1e9SmrgBUILDPDFDOC=no
677f757b1e9SmrgBUILDPSDOC=no
678f757b1e9SmrgBUILDHTMLDOC=no
679c82dfdfbSmrg
680f757b1e9SmrgAC_PATH_PROG(DOCBOOKPS, docbook2ps)
681f757b1e9SmrgAC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
682f757b1e9SmrgAC_PATH_PROG(DOCBOOKHTML, docbook2html)
683f757b1e9SmrgAC_PATH_PROG(DOCBOOKTXT, docbook2txt)
684c82dfdfbSmrg
685f757b1e9SmrgAC_MSG_CHECKING([whether to build text documentation])
686f757b1e9Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
687f757b1e9Smrg   test x$BUILD_TXTDOC != xno; then
688f757b1e9Smrg	BUILDTXTDOC=yes
689f757b1e9Smrgfi
690f757b1e9SmrgAM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
691f757b1e9SmrgAC_MSG_RESULT([$BUILDTXTDOC])
692c82dfdfbSmrg
693f757b1e9SmrgAC_MSG_CHECKING([whether to build PDF documentation])
694f757b1e9Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
695f757b1e9Smrg   test x$BUILD_PDFDOC != xno; then
696f757b1e9Smrg	BUILDPDFDOC=yes
697f757b1e9Smrgfi
698f757b1e9SmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
699f757b1e9SmrgAC_MSG_RESULT([$BUILDPDFDOC])
700c82dfdfbSmrg
701f757b1e9SmrgAC_MSG_CHECKING([whether to build PostScript documentation])
702f757b1e9Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
703f757b1e9Smrg   test x$BUILD_PSDOC != xno; then
704f757b1e9Smrg	BUILDPSDOC=yes
7053fb1fa07Smrgfi
706f757b1e9SmrgAM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
707f757b1e9SmrgAC_MSG_RESULT([$BUILDPSDOC])
708c82dfdfbSmrg
709f757b1e9SmrgAC_MSG_CHECKING([whether to build HTML documentation])
710f757b1e9Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
711f757b1e9Smrg   test x$BUILD_HTMLDOC != xno; then
712f757b1e9Smrg	BUILDHTMLDOC=yes
713f757b1e9Smrgfi
714f757b1e9SmrgAM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
715f757b1e9SmrgAC_MSG_RESULT([$BUILDHTMLDOC])
716f46a6179Smrg
717f757b1e9SmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
718f757b1e9SmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
719f757b1e9SmrgMAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
720f757b1e9SmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
721f46a6179Smrg
722f757b1e9SmrgAC_SUBST(MAKE_TEXT)
723f757b1e9SmrgAC_SUBST(MAKE_PS)
724f757b1e9SmrgAC_SUBST(MAKE_PDF)
725f757b1e9SmrgAC_SUBST(MAKE_HTML)
726f757b1e9Smrg]) # XORG_CHECK_DOCBOOK
7275fac8b10Smrg
728f757b1e9Smrg# XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
729f757b1e9Smrg# ----------------
730f757b1e9Smrg# Minimum version: 1.5.0
731f757b1e9Smrg# Minimum version for optional DEFAULT argument: 1.11.0
7321d8c7986Smrg#
733f757b1e9Smrg# Documentation tools are not always available on all platforms and sometimes
734f757b1e9Smrg# not at the appropriate level. This macro enables a module to test for the
735f757b1e9Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
736f757b1e9Smrg# the --with-xmlto option, it allows maximum flexibilty in making decisions
737f757b1e9Smrg# as whether or not to use the xmlto package. When DEFAULT is not specified,
738f757b1e9Smrg# --with-xmlto assumes 'auto'.
739690143ccSmrg#
740f757b1e9Smrg# Interface to module:
741f757b1e9Smrg# HAVE_XMLTO: 	used in makefiles to conditionally generate documentation
742f757b1e9Smrg# XMLTO:	returns the path of the xmlto program found
743f757b1e9Smrg#		returns the path set by the user in the environment
744f757b1e9Smrg# --with-xmlto:	'yes' user instructs the module to use xmlto
745f757b1e9Smrg#		'no' user instructs the module not to use xmlto
746f757b1e9Smrg#
747f757b1e9Smrg# Added in version 1.10.0
748f757b1e9Smrg# HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
749f757b1e9Smrg#                  xmlto for text output requires either lynx, links, or w3m browsers
750f757b1e9Smrg#
751f757b1e9Smrg# If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
752f757b1e9Smrg#
753f757b1e9SmrgAC_DEFUN([XORG_WITH_XMLTO],[
754f757b1e9SmrgAC_ARG_VAR([XMLTO], [Path to xmlto command])
755f757b1e9Smrgm4_define([_defopt], m4_default([$2], [auto]))
756f757b1e9SmrgAC_ARG_WITH(xmlto,
757f757b1e9Smrg	AS_HELP_STRING([--with-xmlto],
758f757b1e9Smrg	   [Use xmlto to regenerate documentation (default: ]_defopt[)]),
759f757b1e9Smrg	   [use_xmlto=$withval], [use_xmlto=]_defopt)
760f757b1e9Smrgm4_undefine([_defopt])
761f46a6179Smrg
762f757b1e9Smrgif test "x$use_xmlto" = x"auto"; then
763f757b1e9Smrg   AC_PATH_PROG([XMLTO], [xmlto])
764f757b1e9Smrg   if test "x$XMLTO" = "x"; then
765f757b1e9Smrg        AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
766f757b1e9Smrg	have_xmlto=no
767f757b1e9Smrg   else
768f757b1e9Smrg        have_xmlto=yes
769f757b1e9Smrg   fi
770f757b1e9Smrgelif test "x$use_xmlto" = x"yes" ; then
771f757b1e9Smrg   AC_PATH_PROG([XMLTO], [xmlto])
772f757b1e9Smrg   if test "x$XMLTO" = "x"; then
773f757b1e9Smrg        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
774f757b1e9Smrg   fi
775f757b1e9Smrg   have_xmlto=yes
776f757b1e9Smrgelif test "x$use_xmlto" = x"no" ; then
777f757b1e9Smrg   if test "x$XMLTO" != "x"; then
778f757b1e9Smrg      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
779f757b1e9Smrg   fi
780f757b1e9Smrg   have_xmlto=no
781690143ccSmrgelse
782f757b1e9Smrg   AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
7835fac8b10Smrgfi
784f46a6179Smrg
785f757b1e9Smrg# Test for a minimum version of xmlto, if provided.
786f757b1e9Smrgm4_ifval([$1],
787f757b1e9Smrg[if test "$have_xmlto" = yes; then
788f757b1e9Smrg    # scrape the xmlto version
789f757b1e9Smrg    AC_MSG_CHECKING([the xmlto version])
790f757b1e9Smrg    xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
791f757b1e9Smrg    AC_MSG_RESULT([$xmlto_version])
792f757b1e9Smrg    AS_VERSION_COMPARE([$xmlto_version], [$1],
793f757b1e9Smrg        [if test "x$use_xmlto" = xauto; then
794f757b1e9Smrg            AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
795f757b1e9Smrg            have_xmlto=no
796f757b1e9Smrg        else
797f757b1e9Smrg            AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
798f757b1e9Smrg        fi])
799f757b1e9Smrgfi])
8005fac8b10Smrg
801f757b1e9Smrg# Test for the ability of xmlto to generate a text target
802bfe6082cSmrg#
803bfe6082cSmrg# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
804bfe6082cSmrg# following test for empty XML docbook files.
805bfe6082cSmrg# For compatibility reasons use the following empty XML docbook file and if
806bfe6082cSmrg# it fails try it again with a non-empty XML file.
807f757b1e9Smrghave_xmlto_text=no
808f757b1e9Smrgcat > conftest.xml << "EOF"
809f757b1e9SmrgEOF
810f757b1e9SmrgAS_IF([test "$have_xmlto" = yes],
811f757b1e9Smrg      [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
812f757b1e9Smrg             [have_xmlto_text=yes],
813bfe6082cSmrg             [# Try it again with a non-empty XML file.
814bfe6082cSmrg              cat > conftest.xml << "EOF"
815bfe6082cSmrg<x></x>
816bfe6082cSmrgEOF
817bfe6082cSmrg              AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
818bfe6082cSmrg                    [have_xmlto_text=yes],
819bfe6082cSmrg                    [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])])
820f757b1e9Smrgrm -f conftest.xml
821f757b1e9SmrgAM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
822f757b1e9SmrgAM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
823f757b1e9Smrg]) # XORG_WITH_XMLTO
824f757b1e9Smrg
825f757b1e9Smrg# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
826f757b1e9Smrg# --------------------------------------------
827f757b1e9Smrg# Minimum version: 1.12.0
828f757b1e9Smrg# Minimum version for optional DEFAULT argument: 1.12.0
829690143ccSmrg#
830f757b1e9Smrg# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
831f757b1e9Smrg# XML-based language used for the transformation of XML documents.
832f757b1e9Smrg# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
833f757b1e9Smrg# It is used under the cover by xmlto to generate html files from DocBook/XML.
834f757b1e9Smrg# The XSLT processor is often used as a standalone tool for transformations.
835f757b1e9Smrg# It should not be assumed that this tool is used only to work with documnetation.
836f757b1e9Smrg# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
837f757b1e9Smrg#
838f757b1e9Smrg# Interface to module:
839f757b1e9Smrg# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
840f757b1e9Smrg# XSLTPROC:	 returns the path of the xsltproc program found
841f757b1e9Smrg#		 returns the path set by the user in the environment
842f757b1e9Smrg# --with-xsltproc: 'yes' user instructs the module to use xsltproc
843f757b1e9Smrg#		  'no' user instructs the module not to use xsltproc
844f757b1e9Smrg# have_xsltproc: returns yes if xsltproc found in PATH or no
845f757b1e9Smrg#
846f757b1e9Smrg# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
847f757b1e9Smrg#
848f757b1e9SmrgAC_DEFUN([XORG_WITH_XSLTPROC],[
849f757b1e9SmrgAC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
850f757b1e9Smrg# Preserves the interface, should it be implemented later
851f757b1e9Smrgm4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
852f757b1e9Smrgm4_define([_defopt], m4_default([$2], [auto]))
853f757b1e9SmrgAC_ARG_WITH(xsltproc,
854f757b1e9Smrg	AS_HELP_STRING([--with-xsltproc],
855f757b1e9Smrg	   [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
856f757b1e9Smrg	   [use_xsltproc=$withval], [use_xsltproc=]_defopt)
857f757b1e9Smrgm4_undefine([_defopt])
8581d8c7986Smrg
859f757b1e9Smrgif test "x$use_xsltproc" = x"auto"; then
860f757b1e9Smrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
861f757b1e9Smrg   if test "x$XSLTPROC" = "x"; then
862f757b1e9Smrg        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
863f757b1e9Smrg	have_xsltproc=no
864f757b1e9Smrg   else
865f757b1e9Smrg        have_xsltproc=yes
866f757b1e9Smrg   fi
867f757b1e9Smrgelif test "x$use_xsltproc" = x"yes" ; then
868f757b1e9Smrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
869f757b1e9Smrg   if test "x$XSLTPROC" = "x"; then
870f757b1e9Smrg        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
871f757b1e9Smrg   fi
872f757b1e9Smrg   have_xsltproc=yes
873f757b1e9Smrgelif test "x$use_xsltproc" = x"no" ; then
874f757b1e9Smrg   if test "x$XSLTPROC" != "x"; then
875f757b1e9Smrg      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
876f757b1e9Smrg   fi
877f757b1e9Smrg   have_xsltproc=no
878f757b1e9Smrgelse
879f757b1e9Smrg   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
8801d8c7986Smrgfi
8811d8c7986Smrg
882f757b1e9SmrgAM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
883f757b1e9Smrg]) # XORG_WITH_XSLTPROC
8841d8c7986Smrg
885f757b1e9Smrg# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
886f757b1e9Smrg# ----------------------------------------
887f757b1e9Smrg# Minimum version: 1.15.0
888690143ccSmrg#
889f757b1e9Smrg# PERL (Practical Extraction and Report Language) is a language optimized for
890f757b1e9Smrg# scanning arbitrary text files, extracting information from those text files,
891f757b1e9Smrg# and printing reports based on that information.
892f757b1e9Smrg#
893f757b1e9Smrg# When DEFAULT is not specified, --with-perl assumes 'auto'.
894f757b1e9Smrg#
895f757b1e9Smrg# Interface to module:
896f757b1e9Smrg# HAVE_PERL: used in makefiles to conditionally scan text files
897f757b1e9Smrg# PERL:	     returns the path of the perl program found
898f757b1e9Smrg#	     returns the path set by the user in the environment
899f757b1e9Smrg# --with-perl: 'yes' user instructs the module to use perl
900f757b1e9Smrg#	       'no' user instructs the module not to use perl
901f757b1e9Smrg# have_perl: returns yes if perl found in PATH or no
902f757b1e9Smrg#
903f757b1e9Smrg# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
904f757b1e9Smrg#
905f757b1e9SmrgAC_DEFUN([XORG_WITH_PERL],[
906f757b1e9SmrgAC_ARG_VAR([PERL], [Path to perl command])
907f757b1e9Smrg# Preserves the interface, should it be implemented later
908f757b1e9Smrgm4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
909f757b1e9Smrgm4_define([_defopt], m4_default([$2], [auto]))
910f757b1e9SmrgAC_ARG_WITH(perl,
911f757b1e9Smrg	AS_HELP_STRING([--with-perl],
912f757b1e9Smrg	   [Use perl for extracting information from files (default: ]_defopt[)]),
913f757b1e9Smrg	   [use_perl=$withval], [use_perl=]_defopt)
914f757b1e9Smrgm4_undefine([_defopt])
9151d8c7986Smrg
916f757b1e9Smrgif test "x$use_perl" = x"auto"; then
917f757b1e9Smrg   AC_PATH_PROG([PERL], [perl])
918f757b1e9Smrg   if test "x$PERL" = "x"; then
919f757b1e9Smrg        AC_MSG_WARN([perl not found - cannot extract information and report])
920f757b1e9Smrg	have_perl=no
921f757b1e9Smrg   else
922f757b1e9Smrg        have_perl=yes
923f757b1e9Smrg   fi
924f757b1e9Smrgelif test "x$use_perl" = x"yes" ; then
925f757b1e9Smrg   AC_PATH_PROG([PERL], [perl])
926f757b1e9Smrg   if test "x$PERL" = "x"; then
927f757b1e9Smrg        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
928f757b1e9Smrg   fi
929f757b1e9Smrg   have_perl=yes
930f757b1e9Smrgelif test "x$use_perl" = x"no" ; then
931f757b1e9Smrg   if test "x$PERL" != "x"; then
932f757b1e9Smrg      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
933f757b1e9Smrg   fi
934f757b1e9Smrg   have_perl=no
935690143ccSmrgelse
936f757b1e9Smrg   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
937690143ccSmrgfi
9385fac8b10Smrg
939f757b1e9SmrgAM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
940f757b1e9Smrg]) # XORG_WITH_PERL
9411d8c7986Smrg
942f757b1e9Smrg# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
943f757b1e9Smrg# ----------------
944f757b1e9Smrg# Minimum version: 1.5.0
945f757b1e9Smrg# Minimum version for optional DEFAULT argument: 1.11.0
946690143ccSmrg#
947f757b1e9Smrg# Documentation tools are not always available on all platforms and sometimes
948f757b1e9Smrg# not at the appropriate level. This macro enables a module to test for the
949f757b1e9Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
950f757b1e9Smrg# the --with-asciidoc option, it allows maximum flexibilty in making decisions
951f757b1e9Smrg# as whether or not to use the asciidoc package. When DEFAULT is not specified,
952f757b1e9Smrg# --with-asciidoc assumes 'auto'.
953f757b1e9Smrg#
954f757b1e9Smrg# Interface to module:
955f757b1e9Smrg# HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
956f757b1e9Smrg# ASCIIDOC:	 returns the path of the asciidoc program found
957f757b1e9Smrg#		 returns the path set by the user in the environment
958f757b1e9Smrg# --with-asciidoc: 'yes' user instructs the module to use asciidoc
959f757b1e9Smrg#		  'no' user instructs the module not to use asciidoc
960f757b1e9Smrg#
961f757b1e9Smrg# If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
962f757b1e9Smrg#
963f757b1e9SmrgAC_DEFUN([XORG_WITH_ASCIIDOC],[
964f757b1e9SmrgAC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
965f757b1e9Smrgm4_define([_defopt], m4_default([$2], [auto]))
966f757b1e9SmrgAC_ARG_WITH(asciidoc,
967f757b1e9Smrg	AS_HELP_STRING([--with-asciidoc],
968f757b1e9Smrg	   [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
969f757b1e9Smrg	   [use_asciidoc=$withval], [use_asciidoc=]_defopt)
970f757b1e9Smrgm4_undefine([_defopt])
9711d8c7986Smrg
972f757b1e9Smrgif test "x$use_asciidoc" = x"auto"; then
973f757b1e9Smrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
974f757b1e9Smrg   if test "x$ASCIIDOC" = "x"; then
975f757b1e9Smrg        AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
976f757b1e9Smrg	have_asciidoc=no
977f757b1e9Smrg   else
978f757b1e9Smrg        have_asciidoc=yes
979f757b1e9Smrg   fi
980f757b1e9Smrgelif test "x$use_asciidoc" = x"yes" ; then
981f757b1e9Smrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
982f757b1e9Smrg   if test "x$ASCIIDOC" = "x"; then
983f757b1e9Smrg        AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
984f757b1e9Smrg   fi
985f757b1e9Smrg   have_asciidoc=yes
986f757b1e9Smrgelif test "x$use_asciidoc" = x"no" ; then
987f757b1e9Smrg   if test "x$ASCIIDOC" != "x"; then
988f757b1e9Smrg      AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
989f757b1e9Smrg   fi
990f757b1e9Smrg   have_asciidoc=no
991f757b1e9Smrgelse
992f757b1e9Smrg   AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
993f757b1e9Smrgfi
994f757b1e9Smrgm4_ifval([$1],
995f757b1e9Smrg[if test "$have_asciidoc" = yes; then
996f757b1e9Smrg    # scrape the asciidoc version
997f757b1e9Smrg    AC_MSG_CHECKING([the asciidoc version])
998f757b1e9Smrg    asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
999f757b1e9Smrg    AC_MSG_RESULT([$asciidoc_version])
1000f757b1e9Smrg    AS_VERSION_COMPARE([$asciidoc_version], [$1],
1001f757b1e9Smrg        [if test "x$use_asciidoc" = xauto; then
1002f757b1e9Smrg            AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
1003f757b1e9Smrg            have_asciidoc=no
1004f757b1e9Smrg        else
1005f757b1e9Smrg            AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
1006f757b1e9Smrg        fi])
1007f757b1e9Smrgfi])
1008f757b1e9SmrgAM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
1009f757b1e9Smrg]) # XORG_WITH_ASCIIDOC
10101d8c7986Smrg
1011f757b1e9Smrg# XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
10121d8c7986Smrg# -------------------------------------------
1013f757b1e9Smrg# Minimum version: 1.5.0
1014f757b1e9Smrg# Minimum version for optional DEFAULT argument: 1.11.0
1015f757b1e9Smrg# Minimum version for optional DOT checking: 1.18.0
1016c82dfdfbSmrg#
1017f757b1e9Smrg# Documentation tools are not always available on all platforms and sometimes
1018f757b1e9Smrg# not at the appropriate level. This macro enables a module to test for the
1019f757b1e9Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
1020f757b1e9Smrg# the --with-doxygen option, it allows maximum flexibilty in making decisions
1021f757b1e9Smrg# as whether or not to use the doxygen package. When DEFAULT is not specified,
1022f757b1e9Smrg# --with-doxygen assumes 'auto'.
1023f757b1e9Smrg#
1024f757b1e9Smrg# Interface to module:
1025f757b1e9Smrg# HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
1026f757b1e9Smrg# DOXYGEN:	 returns the path of the doxygen program found
1027f757b1e9Smrg#		 returns the path set by the user in the environment
1028f757b1e9Smrg# --with-doxygen: 'yes' user instructs the module to use doxygen
1029f757b1e9Smrg#		  'no' user instructs the module not to use doxygen
1030f757b1e9Smrg#
1031f757b1e9Smrg# If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
1032f757b1e9Smrg#
1033f757b1e9SmrgAC_DEFUN([XORG_WITH_DOXYGEN],[
1034f757b1e9SmrgAC_ARG_VAR([DOXYGEN], [Path to doxygen command])
1035f757b1e9SmrgAC_ARG_VAR([DOT], [Path to the dot graphics utility])
1036f757b1e9Smrgm4_define([_defopt], m4_default([$2], [auto]))
1037f757b1e9SmrgAC_ARG_WITH(doxygen,
1038f757b1e9Smrg	AS_HELP_STRING([--with-doxygen],
1039f757b1e9Smrg	   [Use doxygen to regenerate documentation (default: ]_defopt[)]),
1040f757b1e9Smrg	   [use_doxygen=$withval], [use_doxygen=]_defopt)
1041f757b1e9Smrgm4_undefine([_defopt])
1042c82dfdfbSmrg
1043f757b1e9Smrgif test "x$use_doxygen" = x"auto"; then
1044f757b1e9Smrg   AC_PATH_PROG([DOXYGEN], [doxygen])
1045f757b1e9Smrg   if test "x$DOXYGEN" = "x"; then
1046f757b1e9Smrg        AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
1047f757b1e9Smrg	have_doxygen=no
1048f757b1e9Smrg   else
1049f757b1e9Smrg        have_doxygen=yes
1050f757b1e9Smrg   fi
1051f757b1e9Smrgelif test "x$use_doxygen" = x"yes" ; then
1052f757b1e9Smrg   AC_PATH_PROG([DOXYGEN], [doxygen])
1053f757b1e9Smrg   if test "x$DOXYGEN" = "x"; then
1054f757b1e9Smrg        AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
1055f757b1e9Smrg   fi
1056f757b1e9Smrg   have_doxygen=yes
1057f757b1e9Smrgelif test "x$use_doxygen" = x"no" ; then
1058f757b1e9Smrg   if test "x$DOXYGEN" != "x"; then
1059f757b1e9Smrg      AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
1060f757b1e9Smrg   fi
1061f757b1e9Smrg   have_doxygen=no
1062f757b1e9Smrgelse
1063f757b1e9Smrg   AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
1064f757b1e9Smrgfi
1065f757b1e9Smrgm4_ifval([$1],
1066f757b1e9Smrg[if test "$have_doxygen" = yes; then
1067f757b1e9Smrg    # scrape the doxygen version
1068f757b1e9Smrg    AC_MSG_CHECKING([the doxygen version])
1069f757b1e9Smrg    doxygen_version=`$DOXYGEN --version 2>/dev/null`
1070f757b1e9Smrg    AC_MSG_RESULT([$doxygen_version])
1071f757b1e9Smrg    AS_VERSION_COMPARE([$doxygen_version], [$1],
1072f757b1e9Smrg        [if test "x$use_doxygen" = xauto; then
1073f757b1e9Smrg            AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
1074f757b1e9Smrg            have_doxygen=no
1075f757b1e9Smrg        else
1076f757b1e9Smrg            AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
1077f757b1e9Smrg        fi])
1078f757b1e9Smrgfi])
1079f757b1e9Smrg
1080f757b1e9Smrgdnl Check for DOT if we have doxygen. The caller decides if it is mandatory
1081f757b1e9Smrgdnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
1082f757b1e9Smrgdnl 	HAVE_DOT = @HAVE_DOT@
1083f757b1e9SmrgHAVE_DOT=no
1084f757b1e9Smrgif test "x$have_doxygen" = "xyes"; then
1085f757b1e9Smrg  AC_PATH_PROG([DOT], [dot])
1086f757b1e9Smrg    if test "x$DOT" != "x"; then
1087f757b1e9Smrg      HAVE_DOT=yes
1088c82dfdfbSmrg    fi
1089c82dfdfbSmrgfi
1090c82dfdfbSmrg
1091f757b1e9SmrgAC_SUBST([HAVE_DOT])
1092f757b1e9SmrgAM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
1093f757b1e9SmrgAM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
1094f757b1e9Smrg]) # XORG_WITH_DOXYGEN
10951d8c7986Smrg
1096f757b1e9Smrg# XORG_WITH_GROFF([DEFAULT])
1097f757b1e9Smrg# ----------------
1098f757b1e9Smrg# Minimum version: 1.6.0
1099f757b1e9Smrg# Minimum version for optional DEFAULT argument: 1.11.0
1100690143ccSmrg#
1101f757b1e9Smrg# Documentation tools are not always available on all platforms and sometimes
1102f757b1e9Smrg# not at the appropriate level. This macro enables a module to test for the
1103f757b1e9Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
1104f757b1e9Smrg# the --with-groff option, it allows maximum flexibilty in making decisions
1105f757b1e9Smrg# as whether or not to use the groff package. When DEFAULT is not specified,
1106f757b1e9Smrg# --with-groff assumes 'auto'.
1107c82dfdfbSmrg#
1108f757b1e9Smrg# Interface to module:
1109f757b1e9Smrg# HAVE_GROFF:	 used in makefiles to conditionally generate documentation
1110f757b1e9Smrg# HAVE_GROFF_MM: the memorandum macros (-mm) package
1111f757b1e9Smrg# HAVE_GROFF_MS: the -ms macros package
1112f757b1e9Smrg# GROFF:	 returns the path of the groff program found
1113f757b1e9Smrg#		 returns the path set by the user in the environment
1114f757b1e9Smrg# --with-groff:	 'yes' user instructs the module to use groff
1115f757b1e9Smrg#		 'no' user instructs the module not to use groff
1116f757b1e9Smrg#
1117f757b1e9Smrg# Added in version 1.9.0:
1118f757b1e9Smrg# HAVE_GROFF_HTML: groff has dependencies to output HTML format:
1119f757b1e9Smrg#		   pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
1120f757b1e9Smrg#		   psselect from the psutils package.
1121f757b1e9Smrg#		   the ghostcript package. Refer to the grohtml man pages
1122f757b1e9Smrg#
1123f757b1e9Smrg# If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
1124f757b1e9Smrg#
1125f757b1e9Smrg# OS and distros often splits groff in a basic and full package, the former
1126f757b1e9Smrg# having the groff program and the later having devices, fonts and macros
1127f757b1e9Smrg# Checking for the groff executable is not enough.
1128f757b1e9Smrg#
1129f757b1e9Smrg# If macros are missing, we cannot assume that groff is useless, so we don't
1130f757b1e9Smrg# unset HAVE_GROFF or GROFF env variables.
1131f757b1e9Smrg# HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
1132f757b1e9Smrg#
1133f757b1e9SmrgAC_DEFUN([XORG_WITH_GROFF],[
1134f757b1e9SmrgAC_ARG_VAR([GROFF], [Path to groff command])
1135f757b1e9Smrgm4_define([_defopt], m4_default([$1], [auto]))
1136f757b1e9SmrgAC_ARG_WITH(groff,
1137f757b1e9Smrg	AS_HELP_STRING([--with-groff],
1138f757b1e9Smrg	   [Use groff to regenerate documentation (default: ]_defopt[)]),
1139f757b1e9Smrg	   [use_groff=$withval], [use_groff=]_defopt)
1140f757b1e9Smrgm4_undefine([_defopt])
1141c82dfdfbSmrg
1142f757b1e9Smrgif test "x$use_groff" = x"auto"; then
1143f757b1e9Smrg   AC_PATH_PROG([GROFF], [groff])
1144f757b1e9Smrg   if test "x$GROFF" = "x"; then
1145f757b1e9Smrg        AC_MSG_WARN([groff not found - documentation targets will be skipped])
1146f757b1e9Smrg	have_groff=no
1147f757b1e9Smrg   else
1148f757b1e9Smrg        have_groff=yes
1149f757b1e9Smrg   fi
1150f757b1e9Smrgelif test "x$use_groff" = x"yes" ; then
1151f757b1e9Smrg   AC_PATH_PROG([GROFF], [groff])
1152f757b1e9Smrg   if test "x$GROFF" = "x"; then
1153f757b1e9Smrg        AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
1154f757b1e9Smrg   fi
1155f757b1e9Smrg   have_groff=yes
1156f757b1e9Smrgelif test "x$use_groff" = x"no" ; then
1157f757b1e9Smrg   if test "x$GROFF" != "x"; then
1158f757b1e9Smrg      AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
1159f757b1e9Smrg   fi
1160f757b1e9Smrg   have_groff=no
11611d8c7986Smrgelse
1162f757b1e9Smrg   AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
1163c82dfdfbSmrgfi
1164f46a6179Smrg
1165f757b1e9Smrg# We have groff, test for the presence of the macro packages
1166f757b1e9Smrgif test "x$have_groff" = x"yes"; then
1167f757b1e9Smrg    AC_MSG_CHECKING([for ${GROFF} -ms macros])
1168f757b1e9Smrg    if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
1169f757b1e9Smrg        groff_ms_works=yes
1170f757b1e9Smrg    else
1171f757b1e9Smrg        groff_ms_works=no
1172f757b1e9Smrg    fi
1173f757b1e9Smrg    AC_MSG_RESULT([$groff_ms_works])
1174f757b1e9Smrg    AC_MSG_CHECKING([for ${GROFF} -mm macros])
1175f757b1e9Smrg    if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
1176f757b1e9Smrg        groff_mm_works=yes
1177f757b1e9Smrg    else
1178f757b1e9Smrg        groff_mm_works=no
1179f757b1e9Smrg    fi
1180f757b1e9Smrg    AC_MSG_RESULT([$groff_mm_works])
1181c82dfdfbSmrgfi
11821d8c7986Smrg
1183f757b1e9Smrg# We have groff, test for HTML dependencies, one command per package
1184f757b1e9Smrgif test "x$have_groff" = x"yes"; then
1185f757b1e9Smrg   AC_PATH_PROGS(GS_PATH, [gs gswin32c])
1186f757b1e9Smrg   AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
1187f757b1e9Smrg   AC_PATH_PROG(PSSELECT_PATH, [psselect])
1188f757b1e9Smrg   if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
1189f757b1e9Smrg      have_groff_html=yes
1190f757b1e9Smrg   else
1191f757b1e9Smrg      have_groff_html=no
1192f757b1e9Smrg      AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
1193f757b1e9Smrg   fi
1194f757b1e9Smrgfi
1195f757b1e9Smrg
1196f757b1e9Smrg# Set Automake conditionals for Makefiles
1197f757b1e9SmrgAM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
1198f757b1e9SmrgAM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
1199f757b1e9SmrgAM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
1200f757b1e9SmrgAM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
1201f757b1e9Smrg]) # XORG_WITH_GROFF
1202f757b1e9Smrg
1203f757b1e9Smrg# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
1204f757b1e9Smrg# ---------------------------------------
1205f757b1e9Smrg# Minimum version: 1.6.0
1206f757b1e9Smrg# Minimum version for optional DEFAULT argument: 1.11.0
1207f757b1e9Smrg# Minimum version for optional MIN-VERSION argument: 1.15.0
1208690143ccSmrg#
1209f757b1e9Smrg# Documentation tools are not always available on all platforms and sometimes
1210f757b1e9Smrg# not at the appropriate level. This macro enables a module to test for the
1211f757b1e9Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
1212f757b1e9Smrg# the --with-fop option, it allows maximum flexibilty in making decisions
1213f757b1e9Smrg# as whether or not to use the fop package. When DEFAULT is not specified,
1214f757b1e9Smrg# --with-fop assumes 'auto'.
1215f757b1e9Smrg#
1216f757b1e9Smrg# Interface to module:
1217f757b1e9Smrg# HAVE_FOP: 	used in makefiles to conditionally generate documentation
1218f757b1e9Smrg# FOP:	 	returns the path of the fop program found
1219f757b1e9Smrg#		returns the path set by the user in the environment
1220f757b1e9Smrg# --with-fop: 	'yes' user instructs the module to use fop
1221f757b1e9Smrg#		'no' user instructs the module not to use fop
1222f757b1e9Smrg#
1223f757b1e9Smrg# If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
1224f757b1e9Smrg#
1225f757b1e9SmrgAC_DEFUN([XORG_WITH_FOP],[
1226f757b1e9SmrgAC_ARG_VAR([FOP], [Path to fop command])
1227f757b1e9Smrgm4_define([_defopt], m4_default([$2], [auto]))
1228f757b1e9SmrgAC_ARG_WITH(fop,
1229f757b1e9Smrg	AS_HELP_STRING([--with-fop],
1230f757b1e9Smrg	   [Use fop to regenerate documentation (default: ]_defopt[)]),
1231f757b1e9Smrg	   [use_fop=$withval], [use_fop=]_defopt)
1232f757b1e9Smrgm4_undefine([_defopt])
1233f46a6179Smrg
1234f757b1e9Smrgif test "x$use_fop" = x"auto"; then
1235f757b1e9Smrg   AC_PATH_PROG([FOP], [fop])
1236f757b1e9Smrg   if test "x$FOP" = "x"; then
1237f757b1e9Smrg        AC_MSG_WARN([fop not found - documentation targets will be skipped])
1238f757b1e9Smrg	have_fop=no
1239f757b1e9Smrg   else
1240f757b1e9Smrg        have_fop=yes
1241f757b1e9Smrg   fi
1242f757b1e9Smrgelif test "x$use_fop" = x"yes" ; then
1243f757b1e9Smrg   AC_PATH_PROG([FOP], [fop])
1244f757b1e9Smrg   if test "x$FOP" = "x"; then
1245f757b1e9Smrg        AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
1246f757b1e9Smrg   fi
1247f757b1e9Smrg   have_fop=yes
1248f757b1e9Smrgelif test "x$use_fop" = x"no" ; then
1249f757b1e9Smrg   if test "x$FOP" != "x"; then
1250f757b1e9Smrg      AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
1251f757b1e9Smrg   fi
1252f757b1e9Smrg   have_fop=no
1253f757b1e9Smrgelse
1254f757b1e9Smrg   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
12555fac8b10Smrgfi
1256f46a6179Smrg
1257f757b1e9Smrg# Test for a minimum version of fop, if provided.
1258f757b1e9Smrgm4_ifval([$1],
1259f757b1e9Smrg[if test "$have_fop" = yes; then
1260f757b1e9Smrg    # scrape the fop version
1261f757b1e9Smrg    AC_MSG_CHECKING([for fop minimum version])
1262f757b1e9Smrg    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
1263f757b1e9Smrg    AC_MSG_RESULT([$fop_version])
1264f757b1e9Smrg    AS_VERSION_COMPARE([$fop_version], [$1],
1265f757b1e9Smrg        [if test "x$use_fop" = xauto; then
1266f757b1e9Smrg            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
1267f757b1e9Smrg            have_fop=no
1268f757b1e9Smrg        else
1269f757b1e9Smrg            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
1270f757b1e9Smrg        fi])
1271f757b1e9Smrgfi])
1272f757b1e9SmrgAM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
1273f757b1e9Smrg]) # XORG_WITH_FOP
1274f46a6179Smrg
1275f757b1e9Smrg# XORG_WITH_M4([MIN-VERSION])
12761d8c7986Smrg# ---------------------------
1277f757b1e9Smrg# Minimum version: 1.19.0
1278f757b1e9Smrg#
1279f757b1e9Smrg# This macro attempts to locate an m4 macro processor which supports
1280f757b1e9Smrg# -I option and is only useful for modules relying on M4 in order to
1281f757b1e9Smrg# expand macros in source code files.
1282f757b1e9Smrg#
1283f757b1e9Smrg# Interface to module:
1284f757b1e9Smrg# M4:	 	returns the path of the m4 program found
1285f757b1e9Smrg#		returns the path set by the user in the environment
1286f757b1e9Smrg#
1287f757b1e9SmrgAC_DEFUN([XORG_WITH_M4], [
1288f757b1e9SmrgAC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
1289f757b1e9Smrg   [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
1290f757b1e9Smrg       [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
1291f757b1e9Smrg         ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
1292f757b1e9Smrg   [AC_MSG_ERROR([could not find m4 that supports -I option])],
1293f757b1e9Smrg   [$PATH:/usr/gnu/bin])])
1294f46a6179Smrg
1295f757b1e9SmrgAC_SUBST([M4], [$ac_cv_path_M4])
1296f757b1e9Smrg]) # XORG_WITH_M4
12971d8c7986Smrg
1298f757b1e9Smrg# XORG_WITH_PS2PDF([DEFAULT])
1299f757b1e9Smrg# ----------------
1300f757b1e9Smrg# Minimum version: 1.6.0
1301f757b1e9Smrg# Minimum version for optional DEFAULT argument: 1.11.0
1302690143ccSmrg#
1303f757b1e9Smrg# Documentation tools are not always available on all platforms and sometimes
1304f757b1e9Smrg# not at the appropriate level. This macro enables a module to test for the
1305f757b1e9Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
1306f757b1e9Smrg# the --with-ps2pdf option, it allows maximum flexibilty in making decisions
1307f757b1e9Smrg# as whether or not to use the ps2pdf package. When DEFAULT is not specified,
1308f757b1e9Smrg# --with-ps2pdf assumes 'auto'.
1309690143ccSmrg#
1310f757b1e9Smrg# Interface to module:
1311f757b1e9Smrg# HAVE_PS2PDF: 	used in makefiles to conditionally generate documentation
1312f757b1e9Smrg# PS2PDF:	returns the path of the ps2pdf program found
1313f757b1e9Smrg#		returns the path set by the user in the environment
1314f757b1e9Smrg# --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
1315f757b1e9Smrg#		 'no' user instructs the module not to use ps2pdf
1316690143ccSmrg#
1317f757b1e9Smrg# If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
1318c82dfdfbSmrg#
1319f757b1e9SmrgAC_DEFUN([XORG_WITH_PS2PDF],[
1320f757b1e9SmrgAC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
1321f757b1e9Smrgm4_define([_defopt], m4_default([$1], [auto]))
1322f757b1e9SmrgAC_ARG_WITH(ps2pdf,
1323f757b1e9Smrg	AS_HELP_STRING([--with-ps2pdf],
1324f757b1e9Smrg	   [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
1325f757b1e9Smrg	   [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
1326f757b1e9Smrgm4_undefine([_defopt])
132734345a63Smrg
1328f757b1e9Smrgif test "x$use_ps2pdf" = x"auto"; then
1329f757b1e9Smrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
1330f757b1e9Smrg   if test "x$PS2PDF" = "x"; then
1331f757b1e9Smrg        AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
1332f757b1e9Smrg	have_ps2pdf=no
1333f757b1e9Smrg   else
1334f757b1e9Smrg        have_ps2pdf=yes
1335f757b1e9Smrg   fi
1336f757b1e9Smrgelif test "x$use_ps2pdf" = x"yes" ; then
1337f757b1e9Smrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
1338f757b1e9Smrg   if test "x$PS2PDF" = "x"; then
1339f757b1e9Smrg        AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
1340f757b1e9Smrg   fi
1341f757b1e9Smrg   have_ps2pdf=yes
1342f757b1e9Smrgelif test "x$use_ps2pdf" = x"no" ; then
1343f757b1e9Smrg   if test "x$PS2PDF" != "x"; then
1344f757b1e9Smrg      AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
1345f757b1e9Smrg   fi
1346f757b1e9Smrg   have_ps2pdf=no
1347f757b1e9Smrgelse
1348f757b1e9Smrg   AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
1349f757b1e9Smrgfi
1350f757b1e9SmrgAM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
1351f757b1e9Smrg]) # XORG_WITH_PS2PDF
1352c82dfdfbSmrg
1353f757b1e9Smrg# XORG_ENABLE_DOCS (enable_docs=yes)
1354f757b1e9Smrg# ----------------
1355f757b1e9Smrg# Minimum version: 1.6.0
1356f757b1e9Smrg#
1357f757b1e9Smrg# Documentation tools are not always available on all platforms and sometimes
1358f757b1e9Smrg# not at the appropriate level. This macro enables a builder to skip all
1359f757b1e9Smrg# documentation targets except traditional man pages.
1360f757b1e9Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
1361f757b1e9Smrg# maximum flexibilty in controlling documentation building.
1362f757b1e9Smrg# Refer to:
1363f757b1e9Smrg# XORG_WITH_XMLTO         --with-xmlto
1364f757b1e9Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1365f757b1e9Smrg# XORG_WITH_DOXYGEN       --with-doxygen
1366f757b1e9Smrg# XORG_WITH_FOP           --with-fop
1367f757b1e9Smrg# XORG_WITH_GROFF         --with-groff
1368f757b1e9Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
1369f757b1e9Smrg#
1370f757b1e9Smrg# Interface to module:
1371f757b1e9Smrg# ENABLE_DOCS: 	  used in makefiles to conditionally generate documentation
1372f757b1e9Smrg# --enable-docs: 'yes' user instructs the module to generate docs
1373f757b1e9Smrg#		 'no' user instructs the module not to generate docs
1374f757b1e9Smrg# parm1:	specify the default value, yes or no.
1375f757b1e9Smrg#
1376f757b1e9SmrgAC_DEFUN([XORG_ENABLE_DOCS],[
1377f757b1e9Smrgm4_define([docs_default], m4_default([$1], [yes]))
1378f757b1e9SmrgAC_ARG_ENABLE(docs,
1379f757b1e9Smrg	AS_HELP_STRING([--enable-docs],
1380f757b1e9Smrg	   [Enable building the documentation (default: ]docs_default[)]),
1381f757b1e9Smrg	   [build_docs=$enableval], [build_docs=]docs_default)
1382f757b1e9Smrgm4_undefine([docs_default])
1383f757b1e9SmrgAM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
1384f757b1e9SmrgAC_MSG_CHECKING([whether to build documentation])
1385f757b1e9SmrgAC_MSG_RESULT([$build_docs])
1386f757b1e9Smrg]) # XORG_ENABLE_DOCS
1387c82dfdfbSmrg
1388f757b1e9Smrg# XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
1389f757b1e9Smrg# ----------------
1390f757b1e9Smrg# Minimum version: 1.6.0
1391f757b1e9Smrg#
1392f757b1e9Smrg# This macro enables a builder to skip all developer documentation.
1393f757b1e9Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
1394f757b1e9Smrg# maximum flexibilty in controlling documentation building.
1395f757b1e9Smrg# Refer to:
1396f757b1e9Smrg# XORG_WITH_XMLTO         --with-xmlto
1397f757b1e9Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1398f757b1e9Smrg# XORG_WITH_DOXYGEN       --with-doxygen
1399f757b1e9Smrg# XORG_WITH_FOP           --with-fop
1400f757b1e9Smrg# XORG_WITH_GROFF         --with-groff
1401f757b1e9Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
1402f757b1e9Smrg#
1403f757b1e9Smrg# Interface to module:
1404f757b1e9Smrg# ENABLE_DEVEL_DOCS:	used in makefiles to conditionally generate developer docs
1405f757b1e9Smrg# --enable-devel-docs:	'yes' user instructs the module to generate developer docs
1406f757b1e9Smrg#			'no' user instructs the module not to generate developer docs
1407f757b1e9Smrg# parm1:		specify the default value, yes or no.
1408f757b1e9Smrg#
1409f757b1e9SmrgAC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
1410f757b1e9Smrgm4_define([devel_default], m4_default([$1], [yes]))
1411f757b1e9SmrgAC_ARG_ENABLE(devel-docs,
1412f757b1e9Smrg	AS_HELP_STRING([--enable-devel-docs],
1413f757b1e9Smrg	   [Enable building the developer documentation (default: ]devel_default[)]),
1414f757b1e9Smrg	   [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
1415f757b1e9Smrgm4_undefine([devel_default])
1416f757b1e9SmrgAM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
1417f757b1e9SmrgAC_MSG_CHECKING([whether to build developer documentation])
1418f757b1e9SmrgAC_MSG_RESULT([$build_devel_docs])
1419f757b1e9Smrg]) # XORG_ENABLE_DEVEL_DOCS
1420c82dfdfbSmrg
1421f757b1e9Smrg# XORG_ENABLE_SPECS (enable_specs=yes)
1422f757b1e9Smrg# ----------------
1423f757b1e9Smrg# Minimum version: 1.6.0
1424f757b1e9Smrg#
1425f757b1e9Smrg# This macro enables a builder to skip all functional specification targets.
1426f757b1e9Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
1427f757b1e9Smrg# maximum flexibilty in controlling documentation building.
1428f757b1e9Smrg# Refer to:
1429f757b1e9Smrg# XORG_WITH_XMLTO         --with-xmlto
1430f757b1e9Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1431f757b1e9Smrg# XORG_WITH_DOXYGEN       --with-doxygen
1432f757b1e9Smrg# XORG_WITH_FOP           --with-fop
1433f757b1e9Smrg# XORG_WITH_GROFF         --with-groff
1434f757b1e9Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
1435f757b1e9Smrg#
1436f757b1e9Smrg# Interface to module:
1437f757b1e9Smrg# ENABLE_SPECS:		used in makefiles to conditionally generate specs
1438f757b1e9Smrg# --enable-specs:	'yes' user instructs the module to generate specs
1439f757b1e9Smrg#			'no' user instructs the module not to generate specs
1440f757b1e9Smrg# parm1:		specify the default value, yes or no.
1441f757b1e9Smrg#
1442f757b1e9SmrgAC_DEFUN([XORG_ENABLE_SPECS],[
1443f757b1e9Smrgm4_define([spec_default], m4_default([$1], [yes]))
1444f757b1e9SmrgAC_ARG_ENABLE(specs,
1445f757b1e9Smrg	AS_HELP_STRING([--enable-specs],
1446f757b1e9Smrg	   [Enable building the specs (default: ]spec_default[)]),
1447f757b1e9Smrg	   [build_specs=$enableval], [build_specs=]spec_default)
1448f757b1e9Smrgm4_undefine([spec_default])
1449f757b1e9SmrgAM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
1450f757b1e9SmrgAC_MSG_CHECKING([whether to build functional specifications])
1451f757b1e9SmrgAC_MSG_RESULT([$build_specs])
1452f757b1e9Smrg]) # XORG_ENABLE_SPECS
1453c82dfdfbSmrg
1454f757b1e9Smrg# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
1455f757b1e9Smrg# ----------------------------------------------
1456f757b1e9Smrg# Minimum version: 1.13.0
1457f757b1e9Smrg#
1458f757b1e9Smrg# This macro enables a builder to enable/disable unit testing
1459f757b1e9Smrg# It makes no assumption about the test cases implementation
1460f757b1e9Smrg# Test cases may or may not use Automake "Support for test suites"
1461f757b1e9Smrg# They may or may not use the software utility library GLib
1462f757b1e9Smrg#
1463f757b1e9Smrg# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
1464f757b1e9Smrg# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
1465f757b1e9Smrg# The variable enable_unit_tests is used by other macros in this file.
1466f757b1e9Smrg#
1467f757b1e9Smrg# Interface to module:
1468f757b1e9Smrg# ENABLE_UNIT_TESTS:	used in makefiles to conditionally build tests
1469f757b1e9Smrg# enable_unit_tests:    used in configure.ac for additional configuration
1470f757b1e9Smrg# --enable-unit-tests:	'yes' user instructs the module to build tests
1471f757b1e9Smrg#			'no' user instructs the module not to build tests
1472f757b1e9Smrg# parm1:		specify the default value, yes or no.
1473f757b1e9Smrg#
1474f757b1e9SmrgAC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
1475f757b1e9SmrgAC_BEFORE([$0], [XORG_WITH_GLIB])
1476f757b1e9SmrgAC_BEFORE([$0], [XORG_LD_WRAP])
1477f757b1e9SmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
1478f757b1e9Smrgm4_define([_defopt], m4_default([$1], [auto]))
1479f757b1e9SmrgAC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
1480f757b1e9Smrg	[Enable building unit test cases (default: ]_defopt[)]),
1481f757b1e9Smrg	[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
1482f757b1e9Smrgm4_undefine([_defopt])
1483f757b1e9SmrgAM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
1484f757b1e9SmrgAC_MSG_CHECKING([whether to build unit test cases])
1485f757b1e9SmrgAC_MSG_RESULT([$enable_unit_tests])
1486f757b1e9Smrg]) # XORG_ENABLE_UNIT_TESTS
14871d8c7986Smrg
1488f757b1e9Smrg# XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
1489f757b1e9Smrg# ------------------------------------------------------
1490f757b1e9Smrg# Minimum version: 1.17.0
1491f757b1e9Smrg#
1492f757b1e9Smrg# This macro enables a builder to enable/disable integration testing
1493f757b1e9Smrg# It makes no assumption about the test cases' implementation
1494f757b1e9Smrg# Test cases may or may not use Automake "Support for test suites"
1495f757b1e9Smrg#
1496f757b1e9Smrg# Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
1497f757b1e9Smrg# usually requires less dependencies and may be built and run under less
1498f757b1e9Smrg# stringent environments than integration tests.
1499f757b1e9Smrg#
1500f757b1e9Smrg# Interface to module:
1501f757b1e9Smrg# ENABLE_INTEGRATION_TESTS:   used in makefiles to conditionally build tests
1502f757b1e9Smrg# enable_integration_tests:   used in configure.ac for additional configuration
1503f757b1e9Smrg# --enable-integration-tests: 'yes' user instructs the module to build tests
1504f757b1e9Smrg#                             'no' user instructs the module not to build tests
1505f757b1e9Smrg# parm1:                      specify the default value, yes or no.
1506f757b1e9Smrg#
1507f757b1e9SmrgAC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
1508f757b1e9SmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
1509f757b1e9Smrgm4_define([_defopt], m4_default([$1], [auto]))
1510f757b1e9SmrgAC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
1511f757b1e9Smrg	[Enable building integration test cases (default: ]_defopt[)]),
1512f757b1e9Smrg	[enable_integration_tests=$enableval],
1513f757b1e9Smrg	[enable_integration_tests=]_defopt)
1514f757b1e9Smrgm4_undefine([_defopt])
1515f757b1e9SmrgAM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
1516f757b1e9Smrg	[test "x$enable_integration_tests" != xno])
1517f757b1e9SmrgAC_MSG_CHECKING([whether to build unit test cases])
1518f757b1e9SmrgAC_MSG_RESULT([$enable_integration_tests])
1519f757b1e9Smrg]) # XORG_ENABLE_INTEGRATION_TESTS
1520c82dfdfbSmrg
1521f757b1e9Smrg# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
1522f757b1e9Smrg# ----------------------------------------
1523f757b1e9Smrg# Minimum version: 1.13.0
1524f757b1e9Smrg#
1525f757b1e9Smrg# GLib is a library which provides advanced data structures and functions.
1526f757b1e9Smrg# This macro enables a module to test for the presence of Glib.
1527f757b1e9Smrg#
1528f757b1e9Smrg# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
1529f757b1e9Smrg# Otherwise the value of $enable_unit_tests is blank.
1530f757b1e9Smrg#
1531f757b1e9Smrg# Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
1532f757b1e9Smrg# test support usually requires less dependencies and may be built and run under
1533f757b1e9Smrg# less stringent environments than integration tests.
1534f757b1e9Smrg#
1535f757b1e9Smrg# Interface to module:
1536f757b1e9Smrg# HAVE_GLIB: used in makefiles to conditionally build targets
1537f757b1e9Smrg# with_glib: used in configure.ac to know if GLib has been found
1538f757b1e9Smrg# --with-glib:	'yes' user instructs the module to use glib
1539f757b1e9Smrg#		'no' user instructs the module not to use glib
1540f757b1e9Smrg#
1541f757b1e9SmrgAC_DEFUN([XORG_WITH_GLIB],[
1542f757b1e9SmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
1543f757b1e9Smrgm4_define([_defopt], m4_default([$2], [auto]))
1544f757b1e9SmrgAC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
1545f757b1e9Smrg	[Use GLib library for unit testing (default: ]_defopt[)]),
1546f757b1e9Smrg	[with_glib=$withval], [with_glib=]_defopt)
1547f757b1e9Smrgm4_undefine([_defopt])
15481d8c7986Smrg
1549f757b1e9Smrghave_glib=no
1550f757b1e9Smrg# Do not probe GLib if user explicitly disabled unit testing
1551f757b1e9Smrgif test "x$enable_unit_tests" != x"no"; then
1552f757b1e9Smrg  # Do not probe GLib if user explicitly disabled it
1553f757b1e9Smrg  if test "x$with_glib" != x"no"; then
1554f757b1e9Smrg    m4_ifval(
1555f757b1e9Smrg      [$1],
1556f757b1e9Smrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
1557f757b1e9Smrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
1558f757b1e9Smrg    )
1559f757b1e9Smrg  fi
1560f757b1e9Smrgfi
1561c82dfdfbSmrg
1562f757b1e9Smrg# Not having GLib when unit testing has been explicitly requested is an error
1563f757b1e9Smrgif test "x$enable_unit_tests" = x"yes"; then
1564f757b1e9Smrg  if test "x$have_glib" = x"no"; then
1565f757b1e9Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
1566f757b1e9Smrg  fi
1567f757b1e9Smrgfi
15681d8c7986Smrg
1569f757b1e9Smrg# Having unit testing disabled when GLib has been explicitly requested is an error
1570f757b1e9Smrgif test "x$enable_unit_tests" = x"no"; then
1571f757b1e9Smrg  if test "x$with_glib" = x"yes"; then
1572f757b1e9Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
1573f757b1e9Smrg  fi
1574f757b1e9Smrgfi
1575f46a6179Smrg
1576f757b1e9Smrg# Not having GLib when it has been explicitly requested is an error
1577f757b1e9Smrgif test "x$with_glib" = x"yes"; then
1578f757b1e9Smrg  if test "x$have_glib" = x"no"; then
1579f757b1e9Smrg    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
1580f757b1e9Smrg  fi
1581f757b1e9Smrgfi
1582f757b1e9Smrg
1583f757b1e9SmrgAM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
1584f757b1e9Smrg]) # XORG_WITH_GLIB
1585f757b1e9Smrg
1586f757b1e9Smrg# XORG_LD_WRAP([required|optional])
1587f757b1e9Smrg# ---------------------------------
1588f757b1e9Smrg# Minimum version: 1.13.0
1589690143ccSmrg#
1590f757b1e9Smrg# Check if linker supports -wrap, passed via compiler flags
1591690143ccSmrg#
1592f757b1e9Smrg# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
1593f757b1e9Smrg# Otherwise the value of $enable_unit_tests is blank.
1594690143ccSmrg#
1595f757b1e9Smrg# Argument added in 1.16.0 - default is "required", to match existing behavior
1596f757b1e9Smrg# of returning an error if enable_unit_tests is yes, and ld -wrap is not
1597f757b1e9Smrg# available, an argument of "optional" allows use when some unit tests require
1598f757b1e9Smrg# ld -wrap and others do not.
1599690143ccSmrg#
1600f757b1e9SmrgAC_DEFUN([XORG_LD_WRAP],[
1601f757b1e9SmrgXORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
1602f757b1e9Smrg    [AC_LANG_PROGRAM([#include <stdlib.h>
1603f757b1e9Smrg                      void __wrap_exit(int status) { return; }],
1604f757b1e9Smrg                     [exit(0);])])
1605f757b1e9Smrg# Not having ld wrap when unit testing has been explicitly requested is an error
1606f757b1e9Smrgif test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
1607f757b1e9Smrg  if test "x$have_ld_wrap" = x"no"; then
1608f757b1e9Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
1609f757b1e9Smrg  fi
161083e5f723Smrgfi
1611f757b1e9SmrgAM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
1612f757b1e9Smrg#
1613f757b1e9Smrg]) # XORG_LD_WRAP
161483e5f723Smrg
1615f757b1e9Smrg# XORG_CHECK_LINKER_FLAGS
1616f757b1e9Smrg# -----------------------
1617f757b1e9Smrg# SYNOPSIS
1618f757b1e9Smrg#
1619f757b1e9Smrg#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
1620f757b1e9Smrg#
1621f757b1e9Smrg# DESCRIPTION
1622f757b1e9Smrg#
1623f757b1e9Smrg#   Check whether the given linker FLAGS work with the current language's
1624f757b1e9Smrg#   linker, or whether they give an error.
1625f757b1e9Smrg#
1626f757b1e9Smrg#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
1627f757b1e9Smrg#   success/failure.
1628f757b1e9Smrg#
1629f757b1e9Smrg#   PROGRAM-SOURCE is the program source to link with, if needed
1630f757b1e9Smrg#
1631f757b1e9Smrg#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
1632f757b1e9Smrg#
1633f757b1e9Smrg# LICENSE
1634f757b1e9Smrg#
1635f757b1e9Smrg#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
1636f757b1e9Smrg#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
1637f757b1e9Smrg#   Copyright (c) 2009 Matteo Frigo
1638f757b1e9Smrg#
1639f757b1e9Smrg#   This program is free software: you can redistribute it and/or modify it
1640f757b1e9Smrg#   under the terms of the GNU General Public License as published by the
1641f757b1e9Smrg#   Free Software Foundation, either version 3 of the License, or (at your
1642f757b1e9Smrg#   option) any later version.
1643f757b1e9Smrg#
1644f757b1e9Smrg#   This program is distributed in the hope that it will be useful, but
1645f757b1e9Smrg#   WITHOUT ANY WARRANTY; without even the implied warranty of
1646f757b1e9Smrg#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
1647f757b1e9Smrg#   Public License for more details.
1648f757b1e9Smrg#
1649f757b1e9Smrg#   You should have received a copy of the GNU General Public License along
1650f757b1e9Smrg#   with this program. If not, see <http://www.gnu.org/licenses/>.
1651f757b1e9Smrg#
1652f757b1e9Smrg#   As a special exception, the respective Autoconf Macro's copyright owner
1653f757b1e9Smrg#   gives unlimited permission to copy, distribute and modify the configure
1654f757b1e9Smrg#   scripts that are the output of Autoconf when processing the Macro. You
1655f757b1e9Smrg#   need not follow the terms of the GNU General Public License when using
1656f757b1e9Smrg#   or distributing such scripts, even though portions of the text of the
1657f757b1e9Smrg#   Macro appear in them. The GNU General Public License (GPL) does govern
1658f757b1e9Smrg#   all other use of the material that constitutes the Autoconf Macro.
1659f757b1e9Smrg#
1660f757b1e9Smrg#   This special exception to the GPL applies to versions of the Autoconf
1661f757b1e9Smrg#   Macro released by the Autoconf Archive. When you make and distribute a
1662f757b1e9Smrg#   modified version of the Autoconf Macro, you may extend this special
1663f757b1e9Smrg#   exception to the GPL to apply to your modified version as well.#
1664f757b1e9SmrgAC_DEFUN([XORG_CHECK_LINKER_FLAGS],
1665f757b1e9Smrg[AC_MSG_CHECKING([whether the linker accepts $1])
1666f757b1e9Smrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
1667f757b1e9SmrgAS_LITERAL_IF([$1],
1668f757b1e9Smrg  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
1669f757b1e9Smrg      ax_save_FLAGS=$LDFLAGS
1670f757b1e9Smrg      LDFLAGS="$1"
1671f757b1e9Smrg      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
1672f757b1e9Smrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
1673f757b1e9Smrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
1674f757b1e9Smrg      LDFLAGS=$ax_save_FLAGS])],
1675f757b1e9Smrg  [ax_save_FLAGS=$LDFLAGS
1676f757b1e9Smrg   LDFLAGS="$1"
1677f757b1e9Smrg   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
1678f757b1e9Smrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
1679f757b1e9Smrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
1680f757b1e9Smrg   LDFLAGS=$ax_save_FLAGS])
1681f757b1e9Smrgeval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
1682f757b1e9SmrgAC_MSG_RESULT($xorg_check_linker_flags)
1683f757b1e9Smrgif test "x$xorg_check_linker_flags" = xyes; then
1684f757b1e9Smrg	m4_default([$2], :)
16851d8c7986Smrgelse
1686f757b1e9Smrg	m4_default([$3], :)
16871d8c7986Smrgfi
1688f757b1e9Smrg]) # XORG_CHECK_LINKER_FLAGS
16891d8c7986Smrg
1690f757b1e9Smrg# XORG_MEMORY_CHECK_FLAGS
1691690143ccSmrg# -----------------------
1692f757b1e9Smrg# Minimum version: 1.16.0
1693690143ccSmrg#
1694f757b1e9Smrg# This macro attempts to find appropriate memory checking functionality
1695f757b1e9Smrg# for various platforms which unit testing code may use to catch various
1696f757b1e9Smrg# forms of memory allocation and access errors in testing.
1697f757b1e9Smrg#
1698f757b1e9Smrg# Interface to module:
1699f757b1e9Smrg# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
1700f757b1e9Smrg#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
1701f757b1e9Smrg#
1702f757b1e9Smrg# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
1703f757b1e9Smrg#
1704f757b1e9SmrgAC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
1705f46a6179Smrg
17061d8c7986SmrgAC_REQUIRE([AC_CANONICAL_HOST])
1707f757b1e9SmrgAC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
1708f757b1e9Smrg           [Environment variables to enable memory checking in tests])
17091d8c7986Smrg
1710f757b1e9Smrg# Check for different types of support on different platforms
1711f757b1e9Smrgcase $host_os in
1712f757b1e9Smrg    solaris*)
1713f757b1e9Smrg        AC_CHECK_LIB([umem], [umem_alloc],
1714f757b1e9Smrg            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
1715f757b1e9Smrg        ;;
1716f757b1e9Smrg    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
1717f757b1e9Smrg        # both directly and inverted, so should not be 0 or 255.
1718f757b1e9Smrg        malloc_debug_env='MALLOC_PERTURB_=15'
1719f757b1e9Smrg        ;;
1720f757b1e9Smrg    darwin*)
1721f757b1e9Smrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
1722f757b1e9Smrg        ;;
1723f757b1e9Smrg    *bsd*)
1724f757b1e9Smrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
1725f757b1e9Smrg        ;;
1726f757b1e9Smrgesac
1727f757b1e9Smrg
1728f757b1e9Smrg# User supplied flags override default flags
1729f757b1e9Smrgif test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
1730f757b1e9Smrg    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
17315fac8b10Smrgfi
1732f757b1e9Smrg
1733f757b1e9SmrgAC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
1734f757b1e9Smrg]) # XORG_WITH_LINT
1735f757b1e9Smrg
1736f757b1e9Smrg# XORG_CHECK_MALLOC_ZERO
1737f757b1e9Smrg# ----------------------
1738f757b1e9Smrg# Minimum version: 1.0.0
1739f757b1e9Smrg#
1740f757b1e9Smrg# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
1741f757b1e9Smrg# malloc(0) returns NULL.  Packages should add one of these cflags to
1742f757b1e9Smrg# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
1743f757b1e9SmrgAC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
1744f757b1e9SmrgAC_ARG_ENABLE(malloc0returnsnull,
1745f757b1e9Smrg	AS_HELP_STRING([--enable-malloc0returnsnull],
1746f757b1e9Smrg		       [malloc(0) returns NULL (default: auto)]),
1747f757b1e9Smrg	[MALLOC_ZERO_RETURNS_NULL=$enableval],
1748f757b1e9Smrg	[MALLOC_ZERO_RETURNS_NULL=auto])
1749f757b1e9Smrg
1750f757b1e9SmrgAC_MSG_CHECKING([whether malloc(0) returns NULL])
1751f757b1e9Smrgif test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
1752f757b1e9SmrgAC_CACHE_VAL([xorg_cv_malloc0_returns_null],
1753f757b1e9Smrg	[AC_RUN_IFELSE([AC_LANG_PROGRAM([
1754f757b1e9Smrg#include <stdlib.h>
1755f757b1e9Smrg],[
1756f757b1e9Smrg    char *m0, *r0, *c0, *p;
1757f757b1e9Smrg    m0 = malloc(0);
1758f757b1e9Smrg    p = malloc(10);
1759f757b1e9Smrg    r0 = realloc(p,0);
1760f757b1e9Smrg    c0 = calloc(0,10);
1761f757b1e9Smrg    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
1762f757b1e9Smrg])],
1763f757b1e9Smrg		[xorg_cv_malloc0_returns_null=yes],
1764f757b1e9Smrg		[xorg_cv_malloc0_returns_null=no])])
1765f757b1e9SmrgMALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null
1766690143ccSmrgfi
1767f757b1e9SmrgAC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
1768f46a6179Smrg
1769f757b1e9Smrgif test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
1770f757b1e9Smrg	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
1771f757b1e9Smrg	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
1772f757b1e9Smrg	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
1773f757b1e9Smrgelse
1774f757b1e9Smrg	MALLOC_ZERO_CFLAGS=""
1775f757b1e9Smrg	XMALLOC_ZERO_CFLAGS=""
1776f757b1e9Smrg	XTMALLOC_ZERO_CFLAGS=""
17771d8c7986Smrgfi
177883e5f723Smrg
1779f757b1e9SmrgAC_SUBST([MALLOC_ZERO_CFLAGS])
1780f757b1e9SmrgAC_SUBST([XMALLOC_ZERO_CFLAGS])
1781f757b1e9SmrgAC_SUBST([XTMALLOC_ZERO_CFLAGS])
1782f757b1e9Smrg]) # XORG_CHECK_MALLOC_ZERO
1783f46a6179Smrg
1784f757b1e9Smrg# XORG_WITH_LINT()
1785f757b1e9Smrg# ----------------
1786f757b1e9Smrg# Minimum version: 1.1.0
1787f757b1e9Smrg#
1788f757b1e9Smrg# This macro enables the use of a tool that flags some suspicious and
1789f757b1e9Smrg# non-portable constructs (likely to be bugs) in C language source code.
1790f757b1e9Smrg# It will attempt to locate the tool and use appropriate options.
1791f757b1e9Smrg# There are various lint type tools on different platforms.
1792f757b1e9Smrg#
1793f757b1e9Smrg# Interface to module:
1794f757b1e9Smrg# LINT:		returns the path to the tool found on the platform
1795f757b1e9Smrg#		or the value set to LINT on the configure cmd line
1796f757b1e9Smrg#		also an Automake conditional
1797f757b1e9Smrg# LINT_FLAGS:	an Automake variable with appropriate flags
1798f757b1e9Smrg#
1799f757b1e9Smrg# --with-lint:	'yes' user instructs the module to use lint
1800f757b1e9Smrg#		'no' user instructs the module not to use lint (default)
1801f757b1e9Smrg#
1802f757b1e9Smrg# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
1803f757b1e9Smrg# If the user sets the value of LINT_FLAGS, they are used verbatim.
1804f757b1e9Smrg#
1805f757b1e9SmrgAC_DEFUN([XORG_WITH_LINT],[
1806f46a6179Smrg
1807f757b1e9SmrgAC_ARG_VAR([LINT], [Path to a lint-style command])
1808f757b1e9SmrgAC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
1809f757b1e9SmrgAC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
1810f757b1e9Smrg		[Use a lint-style source code checker (default: disabled)])],
1811f757b1e9Smrg		[use_lint=$withval], [use_lint=no])
1812f46a6179Smrg
1813f757b1e9Smrg# Obtain platform specific info like program name and options
1814f757b1e9Smrg# The lint program on FreeBSD and NetBSD is different from the one on Solaris
1815f757b1e9Smrgcase $host_os in
1816f757b1e9Smrg  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
1817f757b1e9Smrg	lint_name=splint
1818f757b1e9Smrg	lint_options="-badflag"
1819f757b1e9Smrg	;;
1820f757b1e9Smrg  *freebsd* | *netbsd*)
1821f757b1e9Smrg	lint_name=lint
1822f757b1e9Smrg	lint_options="-u -b"
1823f757b1e9Smrg	;;
1824f757b1e9Smrg  *solaris*)
1825f757b1e9Smrg	lint_name=lint
1826f757b1e9Smrg	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
1827f757b1e9Smrg	;;
1828f757b1e9Smrgesac
1829f46a6179Smrg
1830f757b1e9Smrg# Test for the presence of the program (either guessed by the code or spelled out by the user)
1831f757b1e9Smrgif test "x$use_lint" = x"yes" ; then
1832f757b1e9Smrg   AC_PATH_PROG([LINT], [$lint_name])
1833f757b1e9Smrg   if test "x$LINT" = "x"; then
1834f757b1e9Smrg        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
1835f757b1e9Smrg   fi
1836f757b1e9Smrgelif test "x$use_lint" = x"no" ; then
1837f757b1e9Smrg   if test "x$LINT" != "x"; then
1838f757b1e9Smrg      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
1839f757b1e9Smrg   fi
1840f757b1e9Smrgelse
1841f757b1e9Smrg   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
1842f757b1e9Smrgfi
1843f46a6179Smrg
1844f757b1e9Smrg# User supplied flags override default flags
1845f757b1e9Smrgif test "x$LINT_FLAGS" != "x"; then
1846f757b1e9Smrg   lint_options=$LINT_FLAGS
1847f757b1e9Smrgfi
1848f46a6179Smrg
1849f757b1e9SmrgAC_SUBST([LINT_FLAGS],[$lint_options])
1850f757b1e9SmrgAM_CONDITIONAL(LINT, [test "x$LINT" != x])
1851f46a6179Smrg
1852f757b1e9Smrg]) # XORG_WITH_LINT
185334345a63Smrg
1854f757b1e9Smrg# XORG_LINT_LIBRARY(LIBNAME)
1855f757b1e9Smrg# --------------------------
1856f757b1e9Smrg# Minimum version: 1.1.0
185783e5f723Smrg#
1858f757b1e9Smrg# Sets up flags for building lint libraries for checking programs that call
1859f757b1e9Smrg# functions in the library.
1860f757b1e9Smrg#
1861f757b1e9Smrg# Interface to module:
1862f757b1e9Smrg# LINTLIB		- Automake variable with the name of lint library file to make
1863f757b1e9Smrg# MAKE_LINT_LIB		- Automake conditional
1864f757b1e9Smrg#
1865f757b1e9Smrg# --enable-lint-library:  - 'yes' user instructs the module to created a lint library
1866f757b1e9Smrg#			  - 'no' user instructs the module not to create a lint library (default)
1867690143ccSmrg
1868f757b1e9SmrgAC_DEFUN([XORG_LINT_LIBRARY],[
1869f757b1e9SmrgAC_REQUIRE([XORG_WITH_LINT])
1870f757b1e9SmrgAC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
1871f757b1e9Smrg	[Create lint library (default: disabled)])],
1872f757b1e9Smrg	[make_lint_lib=$enableval], [make_lint_lib=no])
1873f757b1e9Smrg
1874f757b1e9Smrgif test "x$make_lint_lib" = x"yes" ; then
1875f757b1e9Smrg   LINTLIB=llib-l$1.ln
1876f757b1e9Smrg   if test "x$LINT" = "x"; then
1877f757b1e9Smrg        AC_MSG_ERROR([Cannot make lint library without --with-lint])
1878f757b1e9Smrg   fi
1879f757b1e9Smrgelif test "x$make_lint_lib" != x"no" ; then
1880f757b1e9Smrg   AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
18811d8c7986Smrgfi
18821d8c7986Smrg
1883f757b1e9SmrgAC_SUBST(LINTLIB)
1884f757b1e9SmrgAM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
18851d8c7986Smrg
1886f757b1e9Smrg]) # XORG_LINT_LIBRARY
1887f757b1e9Smrg
1888f757b1e9Smrg# XORG_COMPILER_BRAND
18891d8c7986Smrg# -------------------
1890f757b1e9Smrg# Minimum version: 1.14.0
1891690143ccSmrg#
1892f757b1e9Smrg# Checks for various brands of compilers and sets flags as appropriate:
1893f757b1e9Smrg#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
1894f757b1e9Smrg#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
1895f757b1e9Smrg#   clang compiler - sets CLANGCC to "yes"
1896f757b1e9Smrg#   Intel compiler - sets INTELCC to "yes"
1897f757b1e9Smrg#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
1898f757b1e9Smrg#
1899f757b1e9SmrgAC_DEFUN([XORG_COMPILER_BRAND], [
1900f757b1e9SmrgAC_LANG_CASE(
1901f757b1e9Smrg	[C], [
1902f757b1e9Smrg		AC_REQUIRE([AC_PROG_CC_C99])
1903f757b1e9Smrg	],
1904f757b1e9Smrg	[C++], [
1905f757b1e9Smrg		AC_REQUIRE([AC_PROG_CXX])
1906f757b1e9Smrg	]
1907f757b1e9Smrg)
1908f757b1e9SmrgAC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
1909f757b1e9SmrgAC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
1910f757b1e9SmrgAC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
1911f757b1e9Smrg]) # XORG_COMPILER_BRAND
1912690143ccSmrg
1913f757b1e9Smrg# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
1914f757b1e9Smrg# ---------------
1915f757b1e9Smrg# Minimum version: 1.16.0
1916f757b1e9Smrg#
1917f757b1e9Smrg# Test if the compiler works when passed the given flag as a command line argument.
1918f757b1e9Smrg# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
1919f757b1e9Smrg# next flag in the list until there are no more options.
1920f757b1e9Smrg#
1921f757b1e9Smrg# Note that this does not guarantee that the compiler supports the flag as some
1922f757b1e9Smrg# compilers will simply ignore arguments that they do not understand, but we do
1923f757b1e9Smrg# attempt to weed out false positives by using -Werror=unknown-warning-option and
1924f757b1e9Smrg# -Werror=unused-command-line-argument
1925f757b1e9Smrg#
1926f757b1e9SmrgAC_DEFUN([XORG_TESTSET_CFLAG], [
1927f757b1e9Smrgm4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
1928f757b1e9Smrgm4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
1929690143ccSmrg
1930f757b1e9SmrgAC_LANG_COMPILER_REQUIRE
1931690143ccSmrg
1932f757b1e9SmrgAC_LANG_CASE(
1933f757b1e9Smrg	[C], [
1934f757b1e9Smrg		AC_REQUIRE([AC_PROG_CC_C99])
1935f757b1e9Smrg		define([PREFIX], [C])
1936f757b1e9Smrg		define([CACHE_PREFIX], [cc])
1937f757b1e9Smrg		define([COMPILER], [$CC])
1938f757b1e9Smrg	],
1939f757b1e9Smrg	[C++], [
1940f757b1e9Smrg		define([PREFIX], [CXX])
1941f757b1e9Smrg		define([CACHE_PREFIX], [cxx])
1942f757b1e9Smrg		define([COMPILER], [$CXX])
1943f757b1e9Smrg	]
1944f757b1e9Smrg)
19451d8c7986Smrg
1946f757b1e9Smrg[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
19471d8c7986Smrg
1948f757b1e9Smrgif test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
1949f757b1e9Smrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
1950f757b1e9Smrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
1951f757b1e9Smrg			[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
1952f757b1e9Smrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
1953f757b1e9Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
1954f757b1e9Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
1955f757b1e9Smrg	[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
1956f757b1e9Smrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
195783e5f723Smrgfi
195883e5f723Smrg
1959f757b1e9Smrgif test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
1960f757b1e9Smrg	if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
1961f757b1e9Smrg		PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
1962f757b1e9Smrg	fi
1963f757b1e9Smrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
1964f757b1e9Smrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
1965f757b1e9Smrg			[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
1966f757b1e9Smrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
1967f757b1e9Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
1968f757b1e9Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
1969f757b1e9Smrg	[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
1970f757b1e9Smrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
1971f757b1e9Smrgfi
197283e5f723Smrg
1973f757b1e9Smrgfound="no"
1974f757b1e9Smrgm4_foreach([flag], m4_cdr($@), [
1975f757b1e9Smrg	if test $found = "no" ; then
1976f757b1e9Smrg		if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
1977f757b1e9Smrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
1978f757b1e9Smrg		fi
1979690143ccSmrg
1980f757b1e9Smrg		if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
1981f757b1e9Smrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
1982f757b1e9Smrg		fi
1983690143ccSmrg
1984f757b1e9Smrg		PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
1985690143ccSmrg
1986f757b1e9Smrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
1987f757b1e9Smrg		AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
1988f757b1e9Smrg		cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
1989f757b1e9Smrg		AC_CACHE_VAL($cacheid,
1990f757b1e9Smrg			     [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
1991f757b1e9Smrg					     [eval $cacheid=yes],
1992f757b1e9Smrg					     [eval $cacheid=no])])
1993690143ccSmrg
1994f757b1e9Smrg		PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
1995690143ccSmrg
1996f757b1e9Smrg		eval supported=\$$cacheid
1997f757b1e9Smrg		AC_MSG_RESULT([$supported])
1998f757b1e9Smrg		if test "$supported" = "yes" ; then
1999f757b1e9Smrg			$1="$$1 ]flag["
2000f757b1e9Smrg			found="yes"
2001f757b1e9Smrg		fi
2002f757b1e9Smrg	fi
2003f757b1e9Smrg])
2004f757b1e9Smrg]) # XORG_TESTSET_CFLAG
2005690143ccSmrg
2006f757b1e9Smrg# XORG_COMPILER_FLAGS
2007f757b1e9Smrg# ---------------
2008f757b1e9Smrg# Minimum version: 1.16.0
2009f757b1e9Smrg#
2010f757b1e9Smrg# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
2011f757b1e9Smrg# arguments supported by the selected compiler which do NOT alter the generated
2012f757b1e9Smrg# code.  These arguments will cause the compiler to print various warnings
2013f757b1e9Smrg# during compilation AND turn a conservative set of warnings into errors.
2014f757b1e9Smrg#
2015f757b1e9Smrg# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
2016f757b1e9Smrg# future versions of util-macros as options are added to new compilers.
2017f757b1e9Smrg#
2018f757b1e9SmrgAC_DEFUN([XORG_COMPILER_FLAGS], [
2019f757b1e9SmrgAC_REQUIRE([XORG_COMPILER_BRAND])
2020690143ccSmrg
2021f757b1e9SmrgAC_ARG_ENABLE(selective-werror,
2022f757b1e9Smrg              AS_HELP_STRING([--disable-selective-werror],
2023f757b1e9Smrg                             [Turn off selective compiler errors. (default: enabled)]),
2024f757b1e9Smrg              [SELECTIVE_WERROR=$enableval],
2025f757b1e9Smrg              [SELECTIVE_WERROR=yes])
2026690143ccSmrg
2027f757b1e9SmrgAC_LANG_CASE(
2028f757b1e9Smrg        [C], [
2029f757b1e9Smrg                define([PREFIX], [C])
2030f757b1e9Smrg        ],
2031f757b1e9Smrg        [C++], [
2032f757b1e9Smrg                define([PREFIX], [CXX])
2033f757b1e9Smrg        ]
2034f757b1e9Smrg)
2035f757b1e9Smrg# -v is too short to test reliably with XORG_TESTSET_CFLAG
2036f757b1e9Smrgif test "x$SUNCC" = "xyes"; then
2037f757b1e9Smrg    [BASE_]PREFIX[FLAGS]="-v"
2038f757b1e9Smrgelse
2039f757b1e9Smrg    [BASE_]PREFIX[FLAGS]=""
2040690143ccSmrgfi
2041690143ccSmrg
2042f757b1e9Smrg# This chunk of warnings were those that existed in the legacy CWARNFLAGS
2043f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
2044f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
2045f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
2046f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
2047690143ccSmrg
2048f757b1e9SmrgAC_LANG_CASE(
2049f757b1e9Smrg	[C], [
2050f757b1e9Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
2051f757b1e9Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
2052f757b1e9Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
2053f757b1e9Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
2054f757b1e9Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
2055f757b1e9Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
2056f757b1e9Smrg	]
2057f757b1e9Smrg)
20581d8c7986Smrg
2059f757b1e9Smrg# This chunk adds additional warnings that could catch undesired effects.
2060f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
2061f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
2062f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
2063f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
2064f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
2065f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
2066f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
2067690143ccSmrg
2068f757b1e9Smrg# These are currently disabled because they are noisy.  They will be enabled
2069f757b1e9Smrg# in the future once the codebase is sufficiently modernized to silence
2070f757b1e9Smrg# them.  For now, I don't want them to drown out the other warnings.
2071f757b1e9Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
2072f757b1e9Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
2073f757b1e9Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
2074f757b1e9Smrg
2075f757b1e9Smrg# Turn some warnings into errors, so we don't accidently get successful builds
2076f757b1e9Smrg# when there are problems that should be fixed.
2077f757b1e9Smrg
2078f757b1e9Smrgif test "x$SELECTIVE_WERROR" = "xyes" ; then
2079f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
2080f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
2081f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
2082f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
2083f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
2084f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
2085f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
2086f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
2087f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
2088f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
2089f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
2090f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
2091f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
20921d8c7986Smrgelse
2093f757b1e9SmrgAC_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])
2094f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
2095f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
2096f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
2097f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
2098f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
2099f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
2100f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
2101f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
2102f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
2103f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
2104f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
2105f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
2106f757b1e9SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
21071d8c7986Smrgfi
2108690143ccSmrg
2109f757b1e9SmrgAC_SUBST([BASE_]PREFIX[FLAGS])
2110f757b1e9Smrg]) # XORG_COMPILER_FLAGS
21111d8c7986Smrg
2112f757b1e9Smrg# XORG_CWARNFLAGS
2113f757b1e9Smrg# ---------------
2114f757b1e9Smrg# Minimum version: 1.2.0
2115f757b1e9Smrg# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
21161d8c7986Smrg#
2117f757b1e9Smrg# Defines CWARNFLAGS to enable C compiler warnings.
21181d8c7986Smrg#
2119f757b1e9Smrg# This function is deprecated because it defines -fno-strict-aliasing
2120f757b1e9Smrg# which alters the code generated by the compiler.  If -fno-strict-aliasing
2121f757b1e9Smrg# is needed, then it should be added explicitly in the module when
2122f757b1e9Smrg# it is updated to use BASE_CFLAGS.
21231d8c7986Smrg#
2124f757b1e9SmrgAC_DEFUN([XORG_CWARNFLAGS], [
2125f757b1e9SmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
2126f757b1e9SmrgAC_REQUIRE([XORG_COMPILER_BRAND])
2127f757b1e9SmrgAC_LANG_CASE(
2128f757b1e9Smrg	[C], [
2129f757b1e9Smrg		CWARNFLAGS="$BASE_CFLAGS"
2130f757b1e9Smrg		if  test "x$GCC" = xyes ; then
2131f757b1e9Smrg		    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
2132f757b1e9Smrg		fi
2133f757b1e9Smrg		AC_SUBST(CWARNFLAGS)
2134f757b1e9Smrg	]
2135f757b1e9Smrg)
2136f757b1e9Smrg]) # XORG_CWARNFLAGS
2137f757b1e9Smrg
2138f757b1e9Smrg# XORG_STRICT_OPTION
2139f757b1e9Smrg# -----------------------
2140f757b1e9Smrg# Minimum version: 1.3.0
21411d8c7986Smrg#
2142f757b1e9Smrg# Add configure option to enable strict compilation flags, such as treating
2143f757b1e9Smrg# warnings as fatal errors.
2144f757b1e9Smrg# If --enable-strict-compilation is passed to configure, adds strict flags to
2145f757b1e9Smrg# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
2146f757b1e9Smrg#
2147f757b1e9Smrg# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
2148f757b1e9Smrg# when strict compilation is unconditionally desired.
2149f757b1e9SmrgAC_DEFUN([XORG_STRICT_OPTION], [
2150f757b1e9SmrgAC_REQUIRE([XORG_CWARNFLAGS])
2151f757b1e9SmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
21521d8c7986Smrg
2153f757b1e9SmrgAC_ARG_ENABLE(strict-compilation,
2154f757b1e9Smrg			  AS_HELP_STRING([--enable-strict-compilation],
2155f757b1e9Smrg			  [Enable all warnings from compiler and make them errors (default: disabled)]),
2156f757b1e9Smrg			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
21571d8c7986Smrg
2158f757b1e9SmrgAC_LANG_CASE(
2159f757b1e9Smrg        [C], [
2160f757b1e9Smrg                define([PREFIX], [C])
2161f757b1e9Smrg        ],
2162f757b1e9Smrg        [C++], [
2163f757b1e9Smrg                define([PREFIX], [CXX])
2164f757b1e9Smrg        ]
2165f757b1e9Smrg)
21661d8c7986Smrg
2167f757b1e9Smrg[STRICT_]PREFIX[FLAGS]=""
2168f757b1e9SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
2169f757b1e9SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
2170f757b1e9Smrg
2171f757b1e9Smrg# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
2172f757b1e9Smrg# activate it with -Werror, so we add it here explicitly.
2173f757b1e9SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
2174f757b1e9Smrg
2175f757b1e9Smrgif test "x$STRICT_COMPILE" = "xyes"; then
2176f757b1e9Smrg    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
2177f757b1e9Smrg    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
2178f757b1e9Smrgfi
2179f757b1e9SmrgAC_SUBST([STRICT_]PREFIX[FLAGS])
2180f757b1e9SmrgAC_SUBST([BASE_]PREFIX[FLAGS])
2181f757b1e9SmrgAC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
2182f757b1e9Smrg]) # XORG_STRICT_OPTION
2183f757b1e9Smrg
2184f757b1e9Smrg# XORG_DEFAULT_OPTIONS
2185f757b1e9Smrg# --------------------
2186f757b1e9Smrg# Minimum version: 1.3.0
21871d8c7986Smrg#
2188f757b1e9Smrg# Defines default options for X.Org modules.
21891d8c7986Smrg#
2190f757b1e9SmrgAC_DEFUN([XORG_DEFAULT_OPTIONS], [
2191f757b1e9SmrgAC_REQUIRE([AC_PROG_INSTALL])
2192f757b1e9SmrgXORG_COMPILER_FLAGS
2193f757b1e9SmrgXORG_CWARNFLAGS
2194f757b1e9SmrgXORG_STRICT_OPTION
2195f757b1e9SmrgXORG_RELEASE_VERSION
2196f757b1e9SmrgXORG_CHANGELOG
2197f757b1e9SmrgXORG_INSTALL
2198f757b1e9SmrgXORG_MANPAGE_SECTIONS
2199f757b1e9Smrgm4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
2200f757b1e9Smrg    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
2201f757b1e9Smrg]) # XORG_DEFAULT_OPTIONS
2202f757b1e9Smrg
2203f757b1e9Smrg# XORG_INSTALL()
2204f757b1e9Smrg# ----------------
2205f757b1e9Smrg# Minimum version: 1.4.0
22061d8c7986Smrg#
2207f757b1e9Smrg# Defines the variable INSTALL_CMD as the command to copy
2208f757b1e9Smrg# INSTALL from $prefix/share/util-macros.
22091d8c7986Smrg#
2210f757b1e9SmrgAC_DEFUN([XORG_INSTALL], [
2211f757b1e9SmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
2212f757b1e9Smrgmacros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
2213f757b1e9SmrgINSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
2214f757b1e9Smrgmv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
2215bfe6082cSmrg|| (rm -f \$(top_srcdir)/.INSTALL.tmp; test -e \$(top_srcdir)/INSTALL || ( \
2216bfe6082cSmrgtouch \$(top_srcdir)/INSTALL; \
2217bfe6082cSmrgecho 'failed to copy INSTALL from util-macros: installing empty INSTALL.' >&2))"
2218f757b1e9SmrgAC_SUBST([INSTALL_CMD])
2219f757b1e9Smrg]) # XORG_INSTALL
2220f757b1e9Smrgdnl Copyright 2005 Red Hat, Inc
2221f757b1e9Smrgdnl
2222f757b1e9Smrgdnl Permission to use, copy, modify, distribute, and sell this software and its
2223f757b1e9Smrgdnl documentation for any purpose is hereby granted without fee, provided that
2224f757b1e9Smrgdnl the above copyright notice appear in all copies and that both that
2225f757b1e9Smrgdnl copyright notice and this permission notice appear in supporting
2226f757b1e9Smrgdnl documentation.
2227f757b1e9Smrgdnl
2228f757b1e9Smrgdnl The above copyright notice and this permission notice shall be included
2229f757b1e9Smrgdnl in all copies or substantial portions of the Software.
2230f757b1e9Smrgdnl
2231f757b1e9Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2232f757b1e9Smrgdnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2233f757b1e9Smrgdnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2234f757b1e9Smrgdnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
2235f757b1e9Smrgdnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2236f757b1e9Smrgdnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2237f757b1e9Smrgdnl OTHER DEALINGS IN THE SOFTWARE.
2238f757b1e9Smrgdnl
2239f757b1e9Smrgdnl Except as contained in this notice, the name of the copyright holders shall
2240f757b1e9Smrgdnl not be used in advertising or otherwise to promote the sale, use or
2241f757b1e9Smrgdnl other dealings in this Software without prior written authorization
2242f757b1e9Smrgdnl from the copyright holders.
2243f757b1e9Smrgdnl
22441d8c7986Smrg
2245f757b1e9Smrg# XORG_RELEASE_VERSION
2246f757b1e9Smrg# --------------------
2247f757b1e9Smrg# Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use.
22481d8c7986Smrg
2249f757b1e9SmrgAC_DEFUN([XORG_RELEASE_VERSION],[
2250f757b1e9Smrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
2251f757b1e9Smrg		[`echo $PACKAGE_VERSION | cut -d . -f 1`],
2252f757b1e9Smrg		[Major version of this package])
2253f757b1e9Smrg	PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1`
2254f757b1e9Smrg	if test "x$PVM" = "x"; then
2255f757b1e9Smrg		PVM="0"
2256f757b1e9Smrg	fi
2257f757b1e9Smrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
2258f757b1e9Smrg		[$PVM],
2259f757b1e9Smrg		[Minor version of this package])
2260f757b1e9Smrg	PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1`
2261f757b1e9Smrg	if test "x$PVP" = "x"; then
2262f757b1e9Smrg		PVP="0"
2263f757b1e9Smrg	fi
2264f757b1e9Smrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
2265f757b1e9Smrg		[$PVP],
2266f757b1e9Smrg		[Patch version of this package])
2267f757b1e9Smrg])
22681d8c7986Smrg
2269f757b1e9Smrg# XORG_CHANGELOG()
22701d8c7986Smrg# ----------------
2271f757b1e9Smrg# Minimum version: 1.2.0
22721d8c7986Smrg#
2273f757b1e9Smrg# Defines the variable CHANGELOG_CMD as the command to generate
2274f757b1e9Smrg# ChangeLog from git.
22751d8c7986Smrg#
22761d8c7986Smrg#
2277f757b1e9SmrgAC_DEFUN([XORG_CHANGELOG], [
2278bfe6082cSmrgCHANGELOG_CMD="((GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp) 2>/dev/null && \
2279f757b1e9Smrgmv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
2280bfe6082cSmrg|| (rm -f \$(top_srcdir)/.changelog.tmp; test -e \$(top_srcdir)/ChangeLog || ( \
2281bfe6082cSmrgtouch \$(top_srcdir)/ChangeLog; \
2282bfe6082cSmrgecho 'git failed to create ChangeLog: installing empty ChangeLog.' >&2))"
2283f757b1e9SmrgAC_SUBST([CHANGELOG_CMD])
2284f757b1e9Smrg]) # XORG_CHANGELOG
22851d8c7986Smrg
2286bfe6082cSmrg# Copyright (C) 2002-2020 Free Software Foundation, Inc.
22871d8c7986Smrg#
2288f757b1e9Smrg# This file is free software; the Free Software Foundation
2289f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2290f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
22911d8c7986Smrg
2292f757b1e9Smrg# AM_AUTOMAKE_VERSION(VERSION)
2293f757b1e9Smrg# ----------------------------
2294f757b1e9Smrg# Automake X.Y traces this macro to ensure aclocal.m4 has been
2295f757b1e9Smrg# generated from the m4 files accompanying Automake X.Y.
2296f757b1e9Smrg# (This private macro should not be called outside this file.)
2297f757b1e9SmrgAC_DEFUN([AM_AUTOMAKE_VERSION],
2298bfe6082cSmrg[am__api_version='1.16'
2299f757b1e9Smrgdnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
2300f757b1e9Smrgdnl require some minimum version.  Point them to the right macro.
2301bfe6082cSmrgm4_if([$1], [1.16.2], [],
2302f757b1e9Smrg      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
2303f757b1e9Smrg])
2304c82dfdfbSmrg
2305f757b1e9Smrg# _AM_AUTOCONF_VERSION(VERSION)
2306f757b1e9Smrg# -----------------------------
2307f757b1e9Smrg# aclocal traces this macro to find the Autoconf version.
2308f757b1e9Smrg# This is a private macro too.  Using m4_define simplifies
2309f757b1e9Smrg# the logic in aclocal, which can simply ignore this definition.
2310f757b1e9Smrgm4_define([_AM_AUTOCONF_VERSION], [])
2311c82dfdfbSmrg
2312f757b1e9Smrg# AM_SET_CURRENT_AUTOMAKE_VERSION
2313f757b1e9Smrg# -------------------------------
2314f757b1e9Smrg# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
2315f757b1e9Smrg# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
2316f757b1e9SmrgAC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
2317bfe6082cSmrg[AM_AUTOMAKE_VERSION([1.16.2])dnl
2318f757b1e9Smrgm4_ifndef([AC_AUTOCONF_VERSION],
2319f757b1e9Smrg  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
2320f757b1e9Smrg_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
23211d8c7986Smrg
2322f757b1e9Smrg# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
2323f757b1e9Smrg
2324bfe6082cSmrg# Copyright (C) 2001-2020 Free Software Foundation, Inc.
23251d8c7986Smrg#
2326f757b1e9Smrg# This file is free software; the Free Software Foundation
2327f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2328f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
2329f757b1e9Smrg
2330f757b1e9Smrg# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
2331f757b1e9Smrg# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
2332f757b1e9Smrg# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
23331d8c7986Smrg#
2334f757b1e9Smrg# Of course, Automake must honor this variable whenever it calls a
2335f757b1e9Smrg# tool from the auxiliary directory.  The problem is that $srcdir (and
2336f757b1e9Smrg# therefore $ac_aux_dir as well) can be either absolute or relative,
2337f757b1e9Smrg# depending on how configure is run.  This is pretty annoying, since
2338f757b1e9Smrg# it makes $ac_aux_dir quite unusable in subdirectories: in the top
2339f757b1e9Smrg# source directory, any form will work fine, but in subdirectories a
2340f757b1e9Smrg# relative path needs to be adjusted first.
23411d8c7986Smrg#
2342f757b1e9Smrg# $ac_aux_dir/missing
2343f757b1e9Smrg#    fails when called from a subdirectory if $ac_aux_dir is relative
2344f757b1e9Smrg# $top_srcdir/$ac_aux_dir/missing
2345f757b1e9Smrg#    fails if $ac_aux_dir is absolute,
2346f757b1e9Smrg#    fails when called from a subdirectory in a VPATH build with
2347f757b1e9Smrg#          a relative $ac_aux_dir
23481d8c7986Smrg#
2349f757b1e9Smrg# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
2350f757b1e9Smrg# are both prefixed by $srcdir.  In an in-source build this is usually
2351f757b1e9Smrg# harmless because $srcdir is '.', but things will broke when you
2352f757b1e9Smrg# start a VPATH build or use an absolute $srcdir.
23531d8c7986Smrg#
2354f757b1e9Smrg# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
2355f757b1e9Smrg# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
2356f757b1e9Smrg#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
2357f757b1e9Smrg# and then we would define $MISSING as
2358f757b1e9Smrg#   MISSING="\${SHELL} $am_aux_dir/missing"
2359f757b1e9Smrg# This will work as long as MISSING is not called from configure, because
2360f757b1e9Smrg# unfortunately $(top_srcdir) has no meaning in configure.
2361f757b1e9Smrg# However there are other variables, like CC, which are often used in
2362f757b1e9Smrg# configure, and could therefore not use this "fixed" $ac_aux_dir.
23631d8c7986Smrg#
2364f757b1e9Smrg# Another solution, used here, is to always expand $ac_aux_dir to an
2365f757b1e9Smrg# absolute PATH.  The drawback is that using absolute paths prevent a
2366f757b1e9Smrg# configured tree to be moved without reconfiguration.
2367f757b1e9Smrg
2368f757b1e9SmrgAC_DEFUN([AM_AUX_DIR_EXPAND],
2369f757b1e9Smrg[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
2370f757b1e9Smrg# Expand $ac_aux_dir to an absolute path.
2371f757b1e9Smrgam_aux_dir=`cd "$ac_aux_dir" && pwd`
2372f757b1e9Smrg])
2373f757b1e9Smrg
2374f757b1e9Smrg# AM_CONDITIONAL                                            -*- Autoconf -*-
2375f757b1e9Smrg
2376bfe6082cSmrg# Copyright (C) 1997-2020 Free Software Foundation, Inc.
23771d8c7986Smrg#
2378f757b1e9Smrg# This file is free software; the Free Software Foundation
2379f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2380f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
23811d8c7986Smrg
2382f757b1e9Smrg# AM_CONDITIONAL(NAME, SHELL-CONDITION)
2383f757b1e9Smrg# -------------------------------------
2384f757b1e9Smrg# Define a conditional.
2385f757b1e9SmrgAC_DEFUN([AM_CONDITIONAL],
2386f757b1e9Smrg[AC_PREREQ([2.52])dnl
2387f757b1e9Smrg m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
2388f757b1e9Smrg       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
2389f757b1e9SmrgAC_SUBST([$1_TRUE])dnl
2390f757b1e9SmrgAC_SUBST([$1_FALSE])dnl
2391f757b1e9Smrg_AM_SUBST_NOTMAKE([$1_TRUE])dnl
2392f757b1e9Smrg_AM_SUBST_NOTMAKE([$1_FALSE])dnl
2393f757b1e9Smrgm4_define([_AM_COND_VALUE_$1], [$2])dnl
2394f757b1e9Smrgif $2; then
2395f757b1e9Smrg  $1_TRUE=
2396f757b1e9Smrg  $1_FALSE='#'
23971d8c7986Smrgelse
2398f757b1e9Smrg  $1_TRUE='#'
2399f757b1e9Smrg  $1_FALSE=
24001d8c7986Smrgfi
2401f757b1e9SmrgAC_CONFIG_COMMANDS_PRE(
2402f757b1e9Smrg[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
2403f757b1e9Smrg  AC_MSG_ERROR([[conditional "$1" was never defined.
2404f757b1e9SmrgUsually this means the macro was only invoked conditionally.]])
2405f757b1e9Smrgfi])])
24061d8c7986Smrg
2407bfe6082cSmrg# Copyright (C) 1999-2020 Free Software Foundation, Inc.
2408f757b1e9Smrg#
2409f757b1e9Smrg# This file is free software; the Free Software Foundation
2410f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2411f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
2412690143ccSmrg
2413690143ccSmrg
2414f757b1e9Smrg# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
2415f757b1e9Smrg# written in clear, in which case automake, when reading aclocal.m4,
2416f757b1e9Smrg# will think it sees a *use*, and therefore will trigger all it's
2417f757b1e9Smrg# C support machinery.  Also note that it means that autoscan, seeing
2418f757b1e9Smrg# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
24191d8c7986Smrg
2420f757b1e9Smrg
2421f757b1e9Smrg# _AM_DEPENDENCIES(NAME)
2422f757b1e9Smrg# ----------------------
2423f757b1e9Smrg# See how the compiler implements dependency checking.
2424f757b1e9Smrg# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
2425f757b1e9Smrg# We try a few techniques and use that to set a single cache variable.
24261d8c7986Smrg#
2427f757b1e9Smrg# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
2428f757b1e9Smrg# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
2429f757b1e9Smrg# dependency, and given that the user is not expected to run this macro,
2430f757b1e9Smrg# just rely on AC_PROG_CC.
2431f757b1e9SmrgAC_DEFUN([_AM_DEPENDENCIES],
2432f757b1e9Smrg[AC_REQUIRE([AM_SET_DEPDIR])dnl
2433f757b1e9SmrgAC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
2434f757b1e9SmrgAC_REQUIRE([AM_MAKE_INCLUDE])dnl
2435f757b1e9SmrgAC_REQUIRE([AM_DEP_TRACK])dnl
24361d8c7986Smrg
2437f757b1e9Smrgm4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
2438f757b1e9Smrg      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
2439f757b1e9Smrg      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
2440f757b1e9Smrg      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
2441f757b1e9Smrg      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
2442f757b1e9Smrg      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
2443f757b1e9Smrg                    [depcc="$$1"   am_compiler_list=])
24441d8c7986Smrg
2445f757b1e9SmrgAC_CACHE_CHECK([dependency style of $depcc],
2446f757b1e9Smrg               [am_cv_$1_dependencies_compiler_type],
2447f757b1e9Smrg[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
2448f757b1e9Smrg  # We make a subdir and do the tests there.  Otherwise we can end up
2449f757b1e9Smrg  # making bogus files that we don't know about and never remove.  For
2450f757b1e9Smrg  # instance it was reported that on HP-UX the gcc test will end up
2451f757b1e9Smrg  # making a dummy file named 'D' -- because '-MD' means "put the output
2452f757b1e9Smrg  # in D".
2453f757b1e9Smrg  rm -rf conftest.dir
2454f757b1e9Smrg  mkdir conftest.dir
2455f757b1e9Smrg  # Copy depcomp to subdir because otherwise we won't find it if we're
2456f757b1e9Smrg  # using a relative directory.
2457f757b1e9Smrg  cp "$am_depcomp" conftest.dir
2458f757b1e9Smrg  cd conftest.dir
2459f757b1e9Smrg  # We will build objects and dependencies in a subdirectory because
2460f757b1e9Smrg  # it helps to detect inapplicable dependency modes.  For instance
2461f757b1e9Smrg  # both Tru64's cc and ICC support -MD to output dependencies as a
2462f757b1e9Smrg  # side effect of compilation, but ICC will put the dependencies in
2463f757b1e9Smrg  # the current directory while Tru64 will put them in the object
2464f757b1e9Smrg  # directory.
2465f757b1e9Smrg  mkdir sub
24661d8c7986Smrg
2467f757b1e9Smrg  am_cv_$1_dependencies_compiler_type=none
2468f757b1e9Smrg  if test "$am_compiler_list" = ""; then
2469f757b1e9Smrg     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
2470f757b1e9Smrg  fi
2471f757b1e9Smrg  am__universal=false
2472f757b1e9Smrg  m4_case([$1], [CC],
2473f757b1e9Smrg    [case " $depcc " in #(
2474f757b1e9Smrg     *\ -arch\ *\ -arch\ *) am__universal=true ;;
2475f757b1e9Smrg     esac],
2476f757b1e9Smrg    [CXX],
2477f757b1e9Smrg    [case " $depcc " in #(
2478f757b1e9Smrg     *\ -arch\ *\ -arch\ *) am__universal=true ;;
2479f757b1e9Smrg     esac])
2480c82dfdfbSmrg
2481f757b1e9Smrg  for depmode in $am_compiler_list; do
2482f757b1e9Smrg    # Setup a source with many dependencies, because some compilers
2483f757b1e9Smrg    # like to wrap large dependency lists on column 80 (with \), and
2484f757b1e9Smrg    # we should not choose a depcomp mode which is confused by this.
2485f757b1e9Smrg    #
2486f757b1e9Smrg    # We need to recreate these files for each test, as the compiler may
2487f757b1e9Smrg    # overwrite some of them when testing with obscure command lines.
2488f757b1e9Smrg    # This happens at least with the AIX C compiler.
2489f757b1e9Smrg    : > sub/conftest.c
2490f757b1e9Smrg    for i in 1 2 3 4 5 6; do
2491f757b1e9Smrg      echo '#include "conftst'$i'.h"' >> sub/conftest.c
2492f757b1e9Smrg      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
2493f757b1e9Smrg      # Solaris 10 /bin/sh.
2494f757b1e9Smrg      echo '/* dummy */' > sub/conftst$i.h
2495f757b1e9Smrg    done
2496f757b1e9Smrg    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
2497c82dfdfbSmrg
2498f757b1e9Smrg    # We check with '-c' and '-o' for the sake of the "dashmstdout"
2499f757b1e9Smrg    # mode.  It turns out that the SunPro C++ compiler does not properly
2500f757b1e9Smrg    # handle '-M -o', and we need to detect this.  Also, some Intel
2501f757b1e9Smrg    # versions had trouble with output in subdirs.
2502f757b1e9Smrg    am__obj=sub/conftest.${OBJEXT-o}
2503f757b1e9Smrg    am__minus_obj="-o $am__obj"
2504f757b1e9Smrg    case $depmode in
2505f757b1e9Smrg    gcc)
2506f757b1e9Smrg      # This depmode causes a compiler race in universal mode.
2507f757b1e9Smrg      test "$am__universal" = false || continue
2508f757b1e9Smrg      ;;
2509f757b1e9Smrg    nosideeffect)
2510f757b1e9Smrg      # After this tag, mechanisms are not by side-effect, so they'll
2511f757b1e9Smrg      # only be used when explicitly requested.
2512f757b1e9Smrg      if test "x$enable_dependency_tracking" = xyes; then
2513f757b1e9Smrg	continue
2514f757b1e9Smrg      else
2515f757b1e9Smrg	break
2516f757b1e9Smrg      fi
2517f757b1e9Smrg      ;;
2518f757b1e9Smrg    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
2519f757b1e9Smrg      # This compiler won't grok '-c -o', but also, the minuso test has
2520f757b1e9Smrg      # not run yet.  These depmodes are late enough in the game, and
2521f757b1e9Smrg      # so weak that their functioning should not be impacted.
2522f757b1e9Smrg      am__obj=conftest.${OBJEXT-o}
2523f757b1e9Smrg      am__minus_obj=
2524f757b1e9Smrg      ;;
2525f757b1e9Smrg    none) break ;;
2526f757b1e9Smrg    esac
2527f757b1e9Smrg    if depmode=$depmode \
2528f757b1e9Smrg       source=sub/conftest.c object=$am__obj \
2529f757b1e9Smrg       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
2530f757b1e9Smrg       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
2531f757b1e9Smrg         >/dev/null 2>conftest.err &&
2532f757b1e9Smrg       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
2533f757b1e9Smrg       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
2534f757b1e9Smrg       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
2535f757b1e9Smrg       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
2536f757b1e9Smrg      # icc doesn't choke on unknown options, it will just issue warnings
2537f757b1e9Smrg      # or remarks (even with -Werror).  So we grep stderr for any message
2538f757b1e9Smrg      # that says an option was ignored or not supported.
2539f757b1e9Smrg      # When given -MP, icc 7.0 and 7.1 complain thusly:
2540f757b1e9Smrg      #   icc: Command line warning: ignoring option '-M'; no argument required
2541f757b1e9Smrg      # The diagnosis changed in icc 8.0:
2542f757b1e9Smrg      #   icc: Command line remark: option '-MP' not supported
2543f757b1e9Smrg      if (grep 'ignoring option' conftest.err ||
2544f757b1e9Smrg          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
2545f757b1e9Smrg        am_cv_$1_dependencies_compiler_type=$depmode
2546f757b1e9Smrg        break
2547f757b1e9Smrg      fi
2548f757b1e9Smrg    fi
2549f757b1e9Smrg  done
25501d8c7986Smrg
2551f757b1e9Smrg  cd ..
2552f757b1e9Smrg  rm -rf conftest.dir
25531d8c7986Smrgelse
2554f757b1e9Smrg  am_cv_$1_dependencies_compiler_type=none
25551d8c7986Smrgfi
2556f757b1e9Smrg])
2557f757b1e9SmrgAC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
2558f757b1e9SmrgAM_CONDITIONAL([am__fastdep$1], [
2559f757b1e9Smrg  test "x$enable_dependency_tracking" != xno \
2560f757b1e9Smrg  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
2561f757b1e9Smrg])
25621d8c7986Smrg
25631d8c7986Smrg
2564f757b1e9Smrg# AM_SET_DEPDIR
2565f757b1e9Smrg# -------------
2566f757b1e9Smrg# Choose a directory name for dependency files.
2567f757b1e9Smrg# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
2568f757b1e9SmrgAC_DEFUN([AM_SET_DEPDIR],
2569f757b1e9Smrg[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
2570f757b1e9SmrgAC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
2571f757b1e9Smrg])
2572f757b1e9Smrg
2573f757b1e9Smrg
2574f757b1e9Smrg# AM_DEP_TRACK
2575f757b1e9Smrg# ------------
2576f757b1e9SmrgAC_DEFUN([AM_DEP_TRACK],
2577f757b1e9Smrg[AC_ARG_ENABLE([dependency-tracking], [dnl
2578f757b1e9SmrgAS_HELP_STRING(
2579f757b1e9Smrg  [--enable-dependency-tracking],
2580f757b1e9Smrg  [do not reject slow dependency extractors])
2581f757b1e9SmrgAS_HELP_STRING(
2582f757b1e9Smrg  [--disable-dependency-tracking],
2583f757b1e9Smrg  [speeds up one-time build])])
2584f757b1e9Smrgif test "x$enable_dependency_tracking" != xno; then
2585f757b1e9Smrg  am_depcomp="$ac_aux_dir/depcomp"
2586f757b1e9Smrg  AMDEPBACKSLASH='\'
2587f757b1e9Smrg  am__nodep='_no'
2588f757b1e9Smrgfi
2589f757b1e9SmrgAM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
2590f757b1e9SmrgAC_SUBST([AMDEPBACKSLASH])dnl
2591f757b1e9Smrg_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
2592f757b1e9SmrgAC_SUBST([am__nodep])dnl
2593f757b1e9Smrg_AM_SUBST_NOTMAKE([am__nodep])dnl
2594f757b1e9Smrg])
25951d8c7986Smrg
2596f757b1e9Smrg# Generate code to set up dependency tracking.              -*- Autoconf -*-
2597690143ccSmrg
2598bfe6082cSmrg# Copyright (C) 1999-2020 Free Software Foundation, Inc.
25991d8c7986Smrg#
2600f757b1e9Smrg# This file is free software; the Free Software Foundation
2601f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2602f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
260383e5f723Smrg
2604f757b1e9Smrg# _AM_OUTPUT_DEPENDENCY_COMMANDS
2605f757b1e9Smrg# ------------------------------
2606f757b1e9SmrgAC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
2607f757b1e9Smrg[{
2608f757b1e9Smrg  # Older Autoconf quotes --file arguments for eval, but not when files
2609f757b1e9Smrg  # are listed without --file.  Let's play safe and only enable the eval
2610f757b1e9Smrg  # if we detect the quoting.
2611bfe6082cSmrg  # TODO: see whether this extra hack can be removed once we start
2612bfe6082cSmrg  # requiring Autoconf 2.70 or later.
2613bfe6082cSmrg  AS_CASE([$CONFIG_FILES],
2614bfe6082cSmrg          [*\'*], [eval set x "$CONFIG_FILES"],
2615bfe6082cSmrg          [*], [set x $CONFIG_FILES])
2616f757b1e9Smrg  shift
2617bfe6082cSmrg  # Used to flag and report bootstrapping failures.
2618bfe6082cSmrg  am_rc=0
2619bfe6082cSmrg  for am_mf
2620f757b1e9Smrg  do
2621f757b1e9Smrg    # Strip MF so we end up with the name of the file.
2622bfe6082cSmrg    am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'`
2623bfe6082cSmrg    # Check whether this is an Automake generated Makefile which includes
2624bfe6082cSmrg    # dependency-tracking related rules and includes.
2625bfe6082cSmrg    # Grep'ing the whole file directly is not great: AIX grep has a line
2626f757b1e9Smrg    # limit of 2048, but all sed's we know have understand at least 4000.
2627bfe6082cSmrg    sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
2628bfe6082cSmrg      || continue
2629bfe6082cSmrg    am_dirpart=`AS_DIRNAME(["$am_mf"])`
2630bfe6082cSmrg    am_filepart=`AS_BASENAME(["$am_mf"])`
2631bfe6082cSmrg    AM_RUN_LOG([cd "$am_dirpart" \
2632bfe6082cSmrg      && sed -e '/# am--include-marker/d' "$am_filepart" \
2633bfe6082cSmrg        | $MAKE -f - am--depfiles]) || am_rc=$?
2634f757b1e9Smrg  done
2635bfe6082cSmrg  if test $am_rc -ne 0; then
2636bfe6082cSmrg    AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
2637bfe6082cSmrg    for automatic dependency tracking.  If GNU make was not used, consider
2638bfe6082cSmrg    re-running the configure script with MAKE="gmake" (or whatever is
2639bfe6082cSmrg    necessary).  You can also try re-running configure with the
2640bfe6082cSmrg    '--disable-dependency-tracking' option to at least be able to build
2641bfe6082cSmrg    the package (albeit without support for automatic dependency tracking).])
2642bfe6082cSmrg  fi
2643bfe6082cSmrg  AS_UNSET([am_dirpart])
2644bfe6082cSmrg  AS_UNSET([am_filepart])
2645bfe6082cSmrg  AS_UNSET([am_mf])
2646bfe6082cSmrg  AS_UNSET([am_rc])
2647bfe6082cSmrg  rm -f conftest-deps.mk
2648f757b1e9Smrg}
2649f757b1e9Smrg])# _AM_OUTPUT_DEPENDENCY_COMMANDS
2650f757b1e9Smrg
2651f757b1e9Smrg
2652f757b1e9Smrg# AM_OUTPUT_DEPENDENCY_COMMANDS
2653f757b1e9Smrg# -----------------------------
2654f757b1e9Smrg# This macro should only be invoked once -- use via AC_REQUIRE.
26551d8c7986Smrg#
2656bfe6082cSmrg# This code is only required when automatic dependency tracking is enabled.
2657bfe6082cSmrg# This creates each '.Po' and '.Plo' makefile fragment that we'll need in
2658bfe6082cSmrg# order to bootstrap the dependency handling code.
2659f757b1e9SmrgAC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
2660f757b1e9Smrg[AC_CONFIG_COMMANDS([depfiles],
2661f757b1e9Smrg     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
2662bfe6082cSmrg     [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
2663f757b1e9Smrg
2664f757b1e9Smrg# Do all the work for Automake.                             -*- Autoconf -*-
2665f757b1e9Smrg
2666bfe6082cSmrg# Copyright (C) 1996-2020 Free Software Foundation, Inc.
26671d8c7986Smrg#
2668f757b1e9Smrg# This file is free software; the Free Software Foundation
2669f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2670f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
2671690143ccSmrg
2672f757b1e9Smrg# This macro actually does too much.  Some checks are only needed if
2673f757b1e9Smrg# your package does certain things.  But this isn't really a big deal.
267483e5f723Smrg
2675f757b1e9Smrgdnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
2676f757b1e9Smrgm4_define([AC_PROG_CC],
2677f757b1e9Smrgm4_defn([AC_PROG_CC])
2678f757b1e9Smrg[_AM_PROG_CC_C_O
2679f757b1e9Smrg])
2680690143ccSmrg
2681f757b1e9Smrg# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
2682f757b1e9Smrg# AM_INIT_AUTOMAKE([OPTIONS])
2683f757b1e9Smrg# -----------------------------------------------
2684f757b1e9Smrg# The call with PACKAGE and VERSION arguments is the old style
2685f757b1e9Smrg# call (pre autoconf-2.50), which is being phased out.  PACKAGE
2686f757b1e9Smrg# and VERSION should now be passed to AC_INIT and removed from
2687f757b1e9Smrg# the call to AM_INIT_AUTOMAKE.
2688f757b1e9Smrg# We support both call styles for the transition.  After
2689f757b1e9Smrg# the next Automake release, Autoconf can make the AC_INIT
2690f757b1e9Smrg# arguments mandatory, and then we can depend on a new Autoconf
2691f757b1e9Smrg# release and drop the old call support.
2692f757b1e9SmrgAC_DEFUN([AM_INIT_AUTOMAKE],
2693f757b1e9Smrg[AC_PREREQ([2.65])dnl
2694f757b1e9Smrgdnl Autoconf wants to disallow AM_ names.  We explicitly allow
2695f757b1e9Smrgdnl the ones we care about.
2696f757b1e9Smrgm4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
2697f757b1e9SmrgAC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
2698f757b1e9SmrgAC_REQUIRE([AC_PROG_INSTALL])dnl
2699f757b1e9Smrgif test "`cd $srcdir && pwd`" != "`pwd`"; then
2700f757b1e9Smrg  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
2701f757b1e9Smrg  # is not polluted with repeated "-I."
2702f757b1e9Smrg  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
2703f757b1e9Smrg  # test to see if srcdir already configured
2704f757b1e9Smrg  if test -f $srcdir/config.status; then
2705f757b1e9Smrg    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
27061d8c7986Smrg  fi
27071d8c7986Smrgfi
270883e5f723Smrg
2709f757b1e9Smrg# test whether we have cygpath
2710f757b1e9Smrgif test -z "$CYGPATH_W"; then
2711f757b1e9Smrg  if (cygpath --version) >/dev/null 2>/dev/null; then
2712f757b1e9Smrg    CYGPATH_W='cygpath -w'
2713f757b1e9Smrg  else
2714f757b1e9Smrg    CYGPATH_W=echo
27151d8c7986Smrg  fi
271683e5f723Smrgfi
2717f757b1e9SmrgAC_SUBST([CYGPATH_W])
271883e5f723Smrg
2719f757b1e9Smrg# Define the identity of the package.
2720f757b1e9Smrgdnl Distinguish between old-style and new-style calls.
2721f757b1e9Smrgm4_ifval([$2],
2722f757b1e9Smrg[AC_DIAGNOSE([obsolete],
2723f757b1e9Smrg             [$0: two- and three-arguments forms are deprecated.])
2724f757b1e9Smrgm4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
2725f757b1e9Smrg AC_SUBST([PACKAGE], [$1])dnl
2726f757b1e9Smrg AC_SUBST([VERSION], [$2])],
2727f757b1e9Smrg[_AM_SET_OPTIONS([$1])dnl
2728f757b1e9Smrgdnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
2729f757b1e9Smrgm4_if(
2730f757b1e9Smrg  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
2731f757b1e9Smrg  [ok:ok],,
2732f757b1e9Smrg  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
2733f757b1e9Smrg AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
2734f757b1e9Smrg AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
27351d8c7986Smrg
2736f757b1e9Smrg_AM_IF_OPTION([no-define],,
2737f757b1e9Smrg[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
2738f757b1e9Smrg AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
2739690143ccSmrg
2740f757b1e9Smrg# Some tools Automake needs.
2741f757b1e9SmrgAC_REQUIRE([AM_SANITY_CHECK])dnl
2742f757b1e9SmrgAC_REQUIRE([AC_ARG_PROGRAM])dnl
2743f757b1e9SmrgAM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
2744f757b1e9SmrgAM_MISSING_PROG([AUTOCONF], [autoconf])
2745f757b1e9SmrgAM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
2746f757b1e9SmrgAM_MISSING_PROG([AUTOHEADER], [autoheader])
2747f757b1e9SmrgAM_MISSING_PROG([MAKEINFO], [makeinfo])
2748f757b1e9SmrgAC_REQUIRE([AM_PROG_INSTALL_SH])dnl
2749f757b1e9SmrgAC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
2750f757b1e9SmrgAC_REQUIRE([AC_PROG_MKDIR_P])dnl
2751f757b1e9Smrg# For better backward compatibility.  To be removed once Automake 1.9.x
2752f757b1e9Smrg# dies out for good.  For more background, see:
2753bfe6082cSmrg# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
2754bfe6082cSmrg# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
2755f757b1e9SmrgAC_SUBST([mkdir_p], ['$(MKDIR_P)'])
2756f757b1e9Smrg# We need awk for the "check" target (and possibly the TAP driver).  The
2757f757b1e9Smrg# system "awk" is bad on some platforms.
2758f757b1e9SmrgAC_REQUIRE([AC_PROG_AWK])dnl
2759f757b1e9SmrgAC_REQUIRE([AC_PROG_MAKE_SET])dnl
2760f757b1e9SmrgAC_REQUIRE([AM_SET_LEADING_DOT])dnl
2761f757b1e9Smrg_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
2762f757b1e9Smrg	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
2763f757b1e9Smrg			     [_AM_PROG_TAR([v7])])])
2764f757b1e9Smrg_AM_IF_OPTION([no-dependencies],,
2765f757b1e9Smrg[AC_PROVIDE_IFELSE([AC_PROG_CC],
2766f757b1e9Smrg		  [_AM_DEPENDENCIES([CC])],
2767f757b1e9Smrg		  [m4_define([AC_PROG_CC],
2768f757b1e9Smrg			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
2769f757b1e9SmrgAC_PROVIDE_IFELSE([AC_PROG_CXX],
2770f757b1e9Smrg		  [_AM_DEPENDENCIES([CXX])],
2771f757b1e9Smrg		  [m4_define([AC_PROG_CXX],
2772f757b1e9Smrg			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
2773f757b1e9SmrgAC_PROVIDE_IFELSE([AC_PROG_OBJC],
2774f757b1e9Smrg		  [_AM_DEPENDENCIES([OBJC])],
2775f757b1e9Smrg		  [m4_define([AC_PROG_OBJC],
2776f757b1e9Smrg			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
2777f757b1e9SmrgAC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
2778f757b1e9Smrg		  [_AM_DEPENDENCIES([OBJCXX])],
2779f757b1e9Smrg		  [m4_define([AC_PROG_OBJCXX],
2780f757b1e9Smrg			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
2781f757b1e9Smrg])
2782f757b1e9SmrgAC_REQUIRE([AM_SILENT_RULES])dnl
2783f757b1e9Smrgdnl The testsuite driver may need to know about EXEEXT, so add the
2784f757b1e9Smrgdnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
2785f757b1e9Smrgdnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
2786f757b1e9SmrgAC_CONFIG_COMMANDS_PRE(dnl
2787f757b1e9Smrg[m4_provide_if([_AM_COMPILER_EXEEXT],
2788f757b1e9Smrg  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
278983e5f723Smrg
2790f757b1e9Smrg# POSIX will say in a future version that running "rm -f" with no argument
2791f757b1e9Smrg# is OK; and we want to be able to make that assumption in our Makefile
2792f757b1e9Smrg# recipes.  So use an aggressive probe to check that the usage we want is
2793f757b1e9Smrg# actually supported "in the wild" to an acceptable degree.
2794f757b1e9Smrg# See automake bug#10828.
2795f757b1e9Smrg# To make any issue more visible, cause the running configure to be aborted
2796f757b1e9Smrg# by default if the 'rm' program in use doesn't match our expectations; the
2797f757b1e9Smrg# user can still override this though.
2798f757b1e9Smrgif rm -f && rm -fr && rm -rf; then : OK; else
2799f757b1e9Smrg  cat >&2 <<'END'
2800f757b1e9SmrgOops!
280183e5f723Smrg
2802f757b1e9SmrgYour 'rm' program seems unable to run without file operands specified
2803f757b1e9Smrgon the command line, even when the '-f' option is present.  This is contrary
2804f757b1e9Smrgto the behaviour of most rm programs out there, and not conforming with
2805f757b1e9Smrgthe upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
2806690143ccSmrg
2807f757b1e9SmrgPlease tell bug-automake@gnu.org about your system, including the value
2808f757b1e9Smrgof your $PATH and any error possibly output before this message.  This
2809f757b1e9Smrgcan help us improve future automake versions.
2810690143ccSmrg
2811f757b1e9SmrgEND
2812f757b1e9Smrg  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
2813f757b1e9Smrg    echo 'Configuration will proceed anyway, since you have set the' >&2
2814f757b1e9Smrg    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
2815f757b1e9Smrg    echo >&2
2816f757b1e9Smrg  else
2817f757b1e9Smrg    cat >&2 <<'END'
2818f757b1e9SmrgAborting the configuration process, to ensure you take notice of the issue.
281983e5f723Smrg
2820f757b1e9SmrgYou can download and install GNU coreutils to get an 'rm' implementation
2821bfe6082cSmrgthat behaves properly: <https://www.gnu.org/software/coreutils/>.
2822690143ccSmrg
2823f757b1e9SmrgIf you want to complete the configuration process using your problematic
2824f757b1e9Smrg'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
2825f757b1e9Smrgto "yes", and re-run configure.
282683e5f723Smrg
2827f757b1e9SmrgEND
2828f757b1e9Smrg    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
2829f757b1e9Smrg  fi
28301d8c7986Smrgfi
2831f757b1e9Smrgdnl The trailing newline in this macro's definition is deliberate, for
2832f757b1e9Smrgdnl backward compatibility and to allow trailing 'dnl'-style comments
2833f757b1e9Smrgdnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
2834f757b1e9Smrg])
2835690143ccSmrg
2836f757b1e9Smrgdnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
2837f757b1e9Smrgdnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
2838f757b1e9Smrgdnl mangled by Autoconf and run in a shell conditional statement.
2839f757b1e9Smrgm4_define([_AC_COMPILER_EXEEXT],
2840f757b1e9Smrgm4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
284183e5f723Smrg
2842f757b1e9Smrg# When config.status generates a header, we must update the stamp-h file.
2843f757b1e9Smrg# This file resides in the same directory as the config header
2844f757b1e9Smrg# that is generated.  The stamp files are numbered to have different names.
2845690143ccSmrg
2846f757b1e9Smrg# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
2847f757b1e9Smrg# loop where config.status creates the headers, so we can generate
2848f757b1e9Smrg# our stamp files there.
2849f757b1e9SmrgAC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
2850f757b1e9Smrg[# Compute $1's index in $config_headers.
2851f757b1e9Smrg_am_arg=$1
2852f757b1e9Smrg_am_stamp_count=1
2853f757b1e9Smrgfor _am_header in $config_headers :; do
2854f757b1e9Smrg  case $_am_header in
2855f757b1e9Smrg    $_am_arg | $_am_arg:* )
2856f757b1e9Smrg      break ;;
2857f757b1e9Smrg    * )
2858f757b1e9Smrg      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
2859f757b1e9Smrg  esac
2860f757b1e9Smrgdone
2861f757b1e9Smrgecho "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
2862f757b1e9Smrg
2863bfe6082cSmrg# Copyright (C) 2001-2020 Free Software Foundation, Inc.
286483e5f723Smrg#
2865f757b1e9Smrg# This file is free software; the Free Software Foundation
2866f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2867f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
2868690143ccSmrg
2869f757b1e9Smrg# AM_PROG_INSTALL_SH
2870f757b1e9Smrg# ------------------
2871f757b1e9Smrg# Define $install_sh.
2872f757b1e9SmrgAC_DEFUN([AM_PROG_INSTALL_SH],
2873f757b1e9Smrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2874f757b1e9Smrgif test x"${install_sh+set}" != xset; then
2875f757b1e9Smrg  case $am_aux_dir in
2876f757b1e9Smrg  *\ * | *\	*)
2877f757b1e9Smrg    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
2878f757b1e9Smrg  *)
2879f757b1e9Smrg    install_sh="\${SHELL} $am_aux_dir/install-sh"
2880f757b1e9Smrg  esac
2881f757b1e9Smrgfi
2882f757b1e9SmrgAC_SUBST([install_sh])])
2883690143ccSmrg
2884bfe6082cSmrg# Copyright (C) 2003-2020 Free Software Foundation, Inc.
2885f757b1e9Smrg#
2886f757b1e9Smrg# This file is free software; the Free Software Foundation
2887f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2888f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
2889690143ccSmrg
2890f757b1e9Smrg# Check whether the underlying file-system supports filenames
2891f757b1e9Smrg# with a leading dot.  For instance MS-DOS doesn't.
2892f757b1e9SmrgAC_DEFUN([AM_SET_LEADING_DOT],
2893f757b1e9Smrg[rm -rf .tst 2>/dev/null
2894f757b1e9Smrgmkdir .tst 2>/dev/null
2895f757b1e9Smrgif test -d .tst; then
2896f757b1e9Smrg  am__leading_dot=.
289783e5f723Smrgelse
2898f757b1e9Smrg  am__leading_dot=_
28991d8c7986Smrgfi
2900f757b1e9Smrgrmdir .tst 2>/dev/null
2901f757b1e9SmrgAC_SUBST([am__leading_dot])])
290283e5f723Smrg
2903f757b1e9Smrg# Check to see how 'make' treats includes.	            -*- Autoconf -*-
290483e5f723Smrg
2905bfe6082cSmrg# Copyright (C) 2001-2020 Free Software Foundation, Inc.
29061d8c7986Smrg#
2907f757b1e9Smrg# This file is free software; the Free Software Foundation
2908f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2909f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
2910f46a6179Smrg
2911f757b1e9Smrg# AM_MAKE_INCLUDE()
2912f757b1e9Smrg# -----------------
2913bfe6082cSmrg# Check whether make has an 'include' directive that can support all
2914bfe6082cSmrg# the idioms we need for our automatic dependency tracking code.
2915f757b1e9SmrgAC_DEFUN([AM_MAKE_INCLUDE],
2916bfe6082cSmrg[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive])
2917bfe6082cSmrgcat > confinc.mk << 'END'
2918f757b1e9Smrgam__doit:
2919bfe6082cSmrg	@echo this is the am__doit target >confinc.out
2920f757b1e9Smrg.PHONY: am__doit
2921f757b1e9SmrgEND
2922f757b1e9Smrgam__include="#"
2923f757b1e9Smrgam__quote=
2924bfe6082cSmrg# BSD make does it like this.
2925bfe6082cSmrgecho '.include "confinc.mk" # ignored' > confmf.BSD
2926bfe6082cSmrg# Other make implementations (GNU, Solaris 10, AIX) do it like this.
2927bfe6082cSmrgecho 'include confinc.mk # ignored' > confmf.GNU
2928bfe6082cSmrg_am_result=no
2929bfe6082cSmrgfor s in GNU BSD; do
2930bfe6082cSmrg  AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out])
2931bfe6082cSmrg  AS_CASE([$?:`cat confinc.out 2>/dev/null`],
2932bfe6082cSmrg      ['0:this is the am__doit target'],
2933bfe6082cSmrg      [AS_CASE([$s],
2934bfe6082cSmrg          [BSD], [am__include='.include' am__quote='"'],
2935bfe6082cSmrg          [am__include='include' am__quote=''])])
2936bfe6082cSmrg  if test "$am__include" != "#"; then
2937bfe6082cSmrg    _am_result="yes ($s style)"
2938bfe6082cSmrg    break
2939bfe6082cSmrg  fi
2940bfe6082cSmrgdone
2941bfe6082cSmrgrm -f confinc.* confmf.*
2942bfe6082cSmrgAC_MSG_RESULT([${_am_result}])
2943bfe6082cSmrgAC_SUBST([am__include])])
2944bfe6082cSmrgAC_SUBST([am__quote])])
29455fac8b10Smrg
2946f757b1e9Smrg# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
294783e5f723Smrg
2948bfe6082cSmrg# Copyright (C) 1997-2020 Free Software Foundation, Inc.
29491d8c7986Smrg#
2950f757b1e9Smrg# This file is free software; the Free Software Foundation
2951f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2952f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
295383e5f723Smrg
2954f757b1e9Smrg# AM_MISSING_PROG(NAME, PROGRAM)
2955f757b1e9Smrg# ------------------------------
2956f757b1e9SmrgAC_DEFUN([AM_MISSING_PROG],
2957f757b1e9Smrg[AC_REQUIRE([AM_MISSING_HAS_RUN])
2958f757b1e9Smrg$1=${$1-"${am_missing_run}$2"}
2959f757b1e9SmrgAC_SUBST($1)])
29601d8c7986Smrg
2961f757b1e9Smrg# AM_MISSING_HAS_RUN
2962f757b1e9Smrg# ------------------
2963f757b1e9Smrg# Define MISSING if not defined so far and test if it is modern enough.
2964f757b1e9Smrg# If it is, set am_missing_run to use it, otherwise, to nothing.
2965f757b1e9SmrgAC_DEFUN([AM_MISSING_HAS_RUN],
2966f757b1e9Smrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2967f757b1e9SmrgAC_REQUIRE_AUX_FILE([missing])dnl
2968f757b1e9Smrgif test x"${MISSING+set}" != xset; then
2969f757b1e9Smrg  case $am_aux_dir in
2970f757b1e9Smrg  *\ * | *\	*)
2971f757b1e9Smrg    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
2972f757b1e9Smrg  *)
2973f757b1e9Smrg    MISSING="\${SHELL} $am_aux_dir/missing" ;;
2974f757b1e9Smrg  esac
2975f46a6179Smrgfi
2976f757b1e9Smrg# Use eval to expand $SHELL
2977f757b1e9Smrgif eval "$MISSING --is-lightweight"; then
2978f757b1e9Smrg  am_missing_run="$MISSING "
2979f757b1e9Smrgelse
2980f757b1e9Smrg  am_missing_run=
2981f757b1e9Smrg  AC_MSG_WARN(['missing' script is too old or missing])
29821d8c7986Smrgfi
2983f757b1e9Smrg])
298434345a63Smrg
2985f757b1e9Smrg# Helper functions for option handling.                     -*- Autoconf -*-
29861d8c7986Smrg
2987bfe6082cSmrg# Copyright (C) 2001-2020 Free Software Foundation, Inc.
2988f757b1e9Smrg#
2989f757b1e9Smrg# This file is free software; the Free Software Foundation
2990f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
2991f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
29921d8c7986Smrg
2993f757b1e9Smrg# _AM_MANGLE_OPTION(NAME)
2994f757b1e9Smrg# -----------------------
2995f757b1e9SmrgAC_DEFUN([_AM_MANGLE_OPTION],
2996f757b1e9Smrg[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
29971d8c7986Smrg
2998f757b1e9Smrg# _AM_SET_OPTION(NAME)
2999f757b1e9Smrg# --------------------
3000f757b1e9Smrg# Set option NAME.  Presently that only means defining a flag for this option.
3001f757b1e9SmrgAC_DEFUN([_AM_SET_OPTION],
3002f757b1e9Smrg[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
30031d8c7986Smrg
3004f757b1e9Smrg# _AM_SET_OPTIONS(OPTIONS)
3005f757b1e9Smrg# ------------------------
3006f757b1e9Smrg# OPTIONS is a space-separated list of Automake options.
3007f757b1e9SmrgAC_DEFUN([_AM_SET_OPTIONS],
3008f757b1e9Smrg[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
30091d8c7986Smrg
3010f757b1e9Smrg# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
3011f757b1e9Smrg# -------------------------------------------
3012f757b1e9Smrg# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
3013f757b1e9SmrgAC_DEFUN([_AM_IF_OPTION],
3014f757b1e9Smrg[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
3015690143ccSmrg
3016bfe6082cSmrg# Copyright (C) 1999-2020 Free Software Foundation, Inc.
30171d8c7986Smrg#
3018f757b1e9Smrg# This file is free software; the Free Software Foundation
3019f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
3020f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
30211d8c7986Smrg
3022f757b1e9Smrg# _AM_PROG_CC_C_O
3023f757b1e9Smrg# ---------------
3024f757b1e9Smrg# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
3025f757b1e9Smrg# to automatically call this.
3026f757b1e9SmrgAC_DEFUN([_AM_PROG_CC_C_O],
3027f757b1e9Smrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
3028f757b1e9SmrgAC_REQUIRE_AUX_FILE([compile])dnl
3029f757b1e9SmrgAC_LANG_PUSH([C])dnl
3030f757b1e9SmrgAC_CACHE_CHECK(
3031f757b1e9Smrg  [whether $CC understands -c and -o together],
3032f757b1e9Smrg  [am_cv_prog_cc_c_o],
3033f757b1e9Smrg  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
3034f757b1e9Smrg  # Make sure it works both with $CC and with simple cc.
3035f757b1e9Smrg  # Following AC_PROG_CC_C_O, we do the test twice because some
3036f757b1e9Smrg  # compilers refuse to overwrite an existing .o file with -o,
3037f757b1e9Smrg  # though they will create one.
3038f757b1e9Smrg  am_cv_prog_cc_c_o=yes
3039f757b1e9Smrg  for am_i in 1 2; do
3040f757b1e9Smrg    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
3041f757b1e9Smrg         && test -f conftest2.$ac_objext; then
3042f757b1e9Smrg      : OK
3043f757b1e9Smrg    else
3044f757b1e9Smrg      am_cv_prog_cc_c_o=no
3045f757b1e9Smrg      break
3046f757b1e9Smrg    fi
3047f757b1e9Smrg  done
3048f757b1e9Smrg  rm -f core conftest*
3049f757b1e9Smrg  unset am_i])
3050f757b1e9Smrgif test "$am_cv_prog_cc_c_o" != yes; then
3051f757b1e9Smrg   # Losing compiler, so override with the script.
3052f757b1e9Smrg   # FIXME: It is wrong to rewrite CC.
3053f757b1e9Smrg   # But if we don't then we get into trouble of one sort or another.
3054f757b1e9Smrg   # A longer-term fix would be to have automake use am__CC in this case,
3055f757b1e9Smrg   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
3056f757b1e9Smrg   CC="$am_aux_dir/compile $CC"
3057690143ccSmrgfi
3058f757b1e9SmrgAC_LANG_POP([C])])
3059f46a6179Smrg
3060f757b1e9Smrg# For backward compatibility.
3061f757b1e9SmrgAC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
3062f757b1e9Smrg
3063bfe6082cSmrg# Copyright (C) 2001-2020 Free Software Foundation, Inc.
3064f757b1e9Smrg#
3065f757b1e9Smrg# This file is free software; the Free Software Foundation
3066f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
3067f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
3068f757b1e9Smrg
3069f757b1e9Smrg# AM_RUN_LOG(COMMAND)
3070f757b1e9Smrg# -------------------
3071f757b1e9Smrg# Run COMMAND, save the exit status in ac_status, and log it.
3072f757b1e9Smrg# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
3073f757b1e9SmrgAC_DEFUN([AM_RUN_LOG],
3074f757b1e9Smrg[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
3075f757b1e9Smrg   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
3076f757b1e9Smrg   ac_status=$?
3077f757b1e9Smrg   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
3078f757b1e9Smrg   (exit $ac_status); }])
30791d8c7986Smrg
3080f757b1e9Smrg# Check to make sure that the build environment is sane.    -*- Autoconf -*-
30811d8c7986Smrg
3082bfe6082cSmrg# Copyright (C) 1996-2020 Free Software Foundation, Inc.
3083f757b1e9Smrg#
3084f757b1e9Smrg# This file is free software; the Free Software Foundation
3085f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
3086f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
30871d8c7986Smrg
3088f757b1e9Smrg# AM_SANITY_CHECK
3089f757b1e9Smrg# ---------------
3090f757b1e9SmrgAC_DEFUN([AM_SANITY_CHECK],
3091f757b1e9Smrg[AC_MSG_CHECKING([whether build environment is sane])
3092f757b1e9Smrg# Reject unsafe characters in $srcdir or the absolute working directory
3093f757b1e9Smrg# name.  Accept space and tab only in the latter.
3094f757b1e9Smrgam_lf='
3095f757b1e9Smrg'
3096f757b1e9Smrgcase `pwd` in
3097f757b1e9Smrg  *[[\\\"\#\$\&\'\`$am_lf]]*)
3098f757b1e9Smrg    AC_MSG_ERROR([unsafe absolute working directory name]);;
3099f757b1e9Smrgesac
3100f757b1e9Smrgcase $srcdir in
3101f757b1e9Smrg  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
3102f757b1e9Smrg    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
3103f757b1e9Smrgesac
31041d8c7986Smrg
3105f757b1e9Smrg# Do 'set' in a subshell so we don't clobber the current shell's
3106f757b1e9Smrg# arguments.  Must try -L first in case configure is actually a
3107f757b1e9Smrg# symlink; some systems play weird games with the mod time of symlinks
3108f757b1e9Smrg# (eg FreeBSD returns the mod time of the symlink's containing
3109f757b1e9Smrg# directory).
3110f757b1e9Smrgif (
3111f757b1e9Smrg   am_has_slept=no
3112f757b1e9Smrg   for am_try in 1 2; do
3113f757b1e9Smrg     echo "timestamp, slept: $am_has_slept" > conftest.file
3114f757b1e9Smrg     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
3115f757b1e9Smrg     if test "$[*]" = "X"; then
3116f757b1e9Smrg	# -L didn't work.
3117f757b1e9Smrg	set X `ls -t "$srcdir/configure" conftest.file`
3118f757b1e9Smrg     fi
3119f757b1e9Smrg     if test "$[*]" != "X $srcdir/configure conftest.file" \
3120f757b1e9Smrg	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
31211d8c7986Smrg
3122f757b1e9Smrg	# If neither matched, then we have a broken ls.  This can happen
3123f757b1e9Smrg	# if, for instance, CONFIG_SHELL is bash and it inherits a
3124f757b1e9Smrg	# broken ls alias from the environment.  This has actually
3125f757b1e9Smrg	# happened.  Such a system could not be considered "sane".
3126f757b1e9Smrg	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
3127f757b1e9Smrg  alias in your environment])
3128f757b1e9Smrg     fi
3129f757b1e9Smrg     if test "$[2]" = conftest.file || test $am_try -eq 2; then
3130f757b1e9Smrg       break
3131f757b1e9Smrg     fi
3132f757b1e9Smrg     # Just in case.
3133f757b1e9Smrg     sleep 1
3134f757b1e9Smrg     am_has_slept=yes
3135f757b1e9Smrg   done
3136f757b1e9Smrg   test "$[2]" = conftest.file
3137f757b1e9Smrg   )
3138f757b1e9Smrgthen
3139f757b1e9Smrg   # Ok.
3140f757b1e9Smrg   :
31411d8c7986Smrgelse
3142f757b1e9Smrg   AC_MSG_ERROR([newly created file is older than distributed files!
3143f757b1e9SmrgCheck your system clock])
31441d8c7986Smrgfi
3145f757b1e9SmrgAC_MSG_RESULT([yes])
3146f757b1e9Smrg# If we didn't sleep, we still need to ensure time stamps of config.status and
3147f757b1e9Smrg# generated files are strictly newer.
3148f757b1e9Smrgam_sleep_pid=
3149f757b1e9Smrgif grep 'slept: no' conftest.file >/dev/null 2>&1; then
3150f757b1e9Smrg  ( sleep 1 ) &
3151f757b1e9Smrg  am_sleep_pid=$!
3152f757b1e9Smrgfi
3153f757b1e9SmrgAC_CONFIG_COMMANDS_PRE(
3154f757b1e9Smrg  [AC_MSG_CHECKING([that generated files are newer than configure])
3155f757b1e9Smrg   if test -n "$am_sleep_pid"; then
3156f757b1e9Smrg     # Hide warnings about reused PIDs.
3157f757b1e9Smrg     wait $am_sleep_pid 2>/dev/null
3158f757b1e9Smrg   fi
3159f757b1e9Smrg   AC_MSG_RESULT([done])])
3160f757b1e9Smrgrm -f conftest.file
3161f757b1e9Smrg])
31621d8c7986Smrg
3163bfe6082cSmrg# Copyright (C) 2009-2020 Free Software Foundation, Inc.
31641d8c7986Smrg#
3165f757b1e9Smrg# This file is free software; the Free Software Foundation
3166f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
3167f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
316883e5f723Smrg
3169f757b1e9Smrg# AM_SILENT_RULES([DEFAULT])
3170f757b1e9Smrg# --------------------------
3171f757b1e9Smrg# Enable less verbose build rules; with the default set to DEFAULT
3172f757b1e9Smrg# ("yes" being less verbose, "no" or empty being verbose).
3173f757b1e9SmrgAC_DEFUN([AM_SILENT_RULES],
3174f757b1e9Smrg[AC_ARG_ENABLE([silent-rules], [dnl
3175f757b1e9SmrgAS_HELP_STRING(
3176f757b1e9Smrg  [--enable-silent-rules],
3177f757b1e9Smrg  [less verbose build output (undo: "make V=1")])
3178f757b1e9SmrgAS_HELP_STRING(
3179f757b1e9Smrg  [--disable-silent-rules],
3180f757b1e9Smrg  [verbose build output (undo: "make V=0")])dnl
3181f757b1e9Smrg])
3182f757b1e9Smrgcase $enable_silent_rules in @%:@ (((
3183f757b1e9Smrg  yes) AM_DEFAULT_VERBOSITY=0;;
3184f757b1e9Smrg   no) AM_DEFAULT_VERBOSITY=1;;
3185f757b1e9Smrg    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
3186f757b1e9Smrgesac
3187f757b1e9Smrgdnl
3188f757b1e9Smrgdnl A few 'make' implementations (e.g., NonStop OS and NextStep)
3189f757b1e9Smrgdnl do not support nested variable expansions.
3190f757b1e9Smrgdnl See automake bug#9928 and bug#10237.
3191f757b1e9Smrgam_make=${MAKE-make}
3192f757b1e9SmrgAC_CACHE_CHECK([whether $am_make supports nested variables],
3193f757b1e9Smrg   [am_cv_make_support_nested_variables],
3194f757b1e9Smrg   [if AS_ECHO([['TRUE=$(BAR$(V))
3195f757b1e9SmrgBAR0=false
3196f757b1e9SmrgBAR1=true
3197f757b1e9SmrgV=1
3198f757b1e9Smrgam__doit:
3199f757b1e9Smrg	@$(TRUE)
3200f757b1e9Smrg.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
3201f757b1e9Smrg  am_cv_make_support_nested_variables=yes
3202f757b1e9Smrgelse
3203f757b1e9Smrg  am_cv_make_support_nested_variables=no
3204f757b1e9Smrgfi])
3205f757b1e9Smrgif test $am_cv_make_support_nested_variables = yes; then
3206f757b1e9Smrg  dnl Using '$V' instead of '$(V)' breaks IRIX make.
3207f757b1e9Smrg  AM_V='$(V)'
3208f757b1e9Smrg  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
3209f757b1e9Smrgelse
3210f757b1e9Smrg  AM_V=$AM_DEFAULT_VERBOSITY
3211f757b1e9Smrg  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
3212f757b1e9Smrgfi
3213f757b1e9SmrgAC_SUBST([AM_V])dnl
3214f757b1e9SmrgAM_SUBST_NOTMAKE([AM_V])dnl
3215f757b1e9SmrgAC_SUBST([AM_DEFAULT_V])dnl
3216f757b1e9SmrgAM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
3217f757b1e9SmrgAC_SUBST([AM_DEFAULT_VERBOSITY])dnl
3218f757b1e9SmrgAM_BACKSLASH='\'
3219f757b1e9SmrgAC_SUBST([AM_BACKSLASH])dnl
3220f757b1e9Smrg_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
3221f757b1e9Smrg])
3222f757b1e9Smrg
3223bfe6082cSmrg# Copyright (C) 2001-2020 Free Software Foundation, Inc.
32241d8c7986Smrg#
3225f757b1e9Smrg# This file is free software; the Free Software Foundation
3226f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
3227f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
3228f757b1e9Smrg
3229f757b1e9Smrg# AM_PROG_INSTALL_STRIP
3230f757b1e9Smrg# ---------------------
3231f757b1e9Smrg# One issue with vendor 'install' (even GNU) is that you can't
3232f757b1e9Smrg# specify the program used to strip binaries.  This is especially
3233f757b1e9Smrg# annoying in cross-compiling environments, where the build's strip
3234f757b1e9Smrg# is unlikely to handle the host's binaries.
3235f757b1e9Smrg# Fortunately install-sh will honor a STRIPPROG variable, so we
3236f757b1e9Smrg# always use install-sh in "make install-strip", and initialize
3237f757b1e9Smrg# STRIPPROG with the value of the STRIP variable (set by the user).
3238f757b1e9SmrgAC_DEFUN([AM_PROG_INSTALL_STRIP],
3239f757b1e9Smrg[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
3240f757b1e9Smrg# Installed binaries are usually stripped using 'strip' when the user
3241f757b1e9Smrg# run "make install-strip".  However 'strip' might not be the right
3242f757b1e9Smrg# tool to use in cross-compilation environments, therefore Automake
3243f757b1e9Smrg# will honor the 'STRIP' environment variable to overrule this program.
3244f757b1e9Smrgdnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
3245f757b1e9Smrgif test "$cross_compiling" != no; then
3246f757b1e9Smrg  AC_CHECK_TOOL([STRIP], [strip], :)
3247f757b1e9Smrgfi
3248f757b1e9SmrgINSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
3249f757b1e9SmrgAC_SUBST([INSTALL_STRIP_PROGRAM])])
325083e5f723Smrg
3251bfe6082cSmrg# Copyright (C) 2006-2020 Free Software Foundation, Inc.
3252f757b1e9Smrg#
3253f757b1e9Smrg# This file is free software; the Free Software Foundation
3254f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
3255f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
325634345a63Smrg
3257f757b1e9Smrg# _AM_SUBST_NOTMAKE(VARIABLE)
3258f757b1e9Smrg# ---------------------------
3259f757b1e9Smrg# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
3260f757b1e9Smrg# This macro is traced by Automake.
3261f757b1e9SmrgAC_DEFUN([_AM_SUBST_NOTMAKE])
3262f46a6179Smrg
3263f757b1e9Smrg# AM_SUBST_NOTMAKE(VARIABLE)
3264f757b1e9Smrg# --------------------------
3265f757b1e9Smrg# Public sister of _AM_SUBST_NOTMAKE.
3266f757b1e9SmrgAC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
3267f46a6179Smrg
3268f757b1e9Smrg# Check how to create a tarball.                            -*- Autoconf -*-
32695fac8b10Smrg
3270bfe6082cSmrg# Copyright (C) 2004-2020 Free Software Foundation, Inc.
3271f757b1e9Smrg#
3272f757b1e9Smrg# This file is free software; the Free Software Foundation
3273f757b1e9Smrg# gives unlimited permission to copy and/or distribute it,
3274f757b1e9Smrg# with or without modifications, as long as this notice is preserved.
3275f46a6179Smrg
3276f757b1e9Smrg# _AM_PROG_TAR(FORMAT)
3277f46a6179Smrg# --------------------
3278f757b1e9Smrg# Check how to create a tarball in format FORMAT.
3279f757b1e9Smrg# FORMAT should be one of 'v7', 'ustar', or 'pax'.
3280f46a6179Smrg#
3281f757b1e9Smrg# Substitute a variable $(am__tar) that is a command
3282f757b1e9Smrg# writing to stdout a FORMAT-tarball containing the directory
3283f757b1e9Smrg# $tardir.
3284f757b1e9Smrg#     tardir=directory && $(am__tar) > result.tar
32851d8c7986Smrg#
3286f757b1e9Smrg# Substitute a variable $(am__untar) that extract such
3287f757b1e9Smrg# a tarball read from stdin.
3288f757b1e9Smrg#     $(am__untar) < result.tar
32891d8c7986Smrg#
3290f757b1e9SmrgAC_DEFUN([_AM_PROG_TAR],
3291f757b1e9Smrg[# Always define AMTAR for backward compatibility.  Yes, it's still used
3292f757b1e9Smrg# in the wild :-(  We should find a proper way to deprecate it ...
3293f757b1e9SmrgAC_SUBST([AMTAR], ['$${TAR-tar}'])
3294f46a6179Smrg
3295f757b1e9Smrg# We'll loop over all known methods to create a tar archive until one works.
3296f757b1e9Smrg_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
3297c82dfdfbSmrg
3298f757b1e9Smrgm4_if([$1], [v7],
3299f757b1e9Smrg  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
3300f46a6179Smrg
3301f757b1e9Smrg  [m4_case([$1],
3302f757b1e9Smrg    [ustar],
3303f757b1e9Smrg     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
3304f757b1e9Smrg      # There is notably a 21 bits limit for the UID and the GID.  In fact,
3305f757b1e9Smrg      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
3306f757b1e9Smrg      # and bug#13588).
3307f757b1e9Smrg      am_max_uid=2097151 # 2^21 - 1
3308f757b1e9Smrg      am_max_gid=$am_max_uid
3309f757b1e9Smrg      # The $UID and $GID variables are not portable, so we need to resort
3310f757b1e9Smrg      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
3311f757b1e9Smrg      # below are definitely unexpected, so allow the users to see them
3312f757b1e9Smrg      # (that is, avoid stderr redirection).
3313f757b1e9Smrg      am_uid=`id -u || echo unknown`
3314f757b1e9Smrg      am_gid=`id -g || echo unknown`
3315f757b1e9Smrg      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
3316f757b1e9Smrg      if test $am_uid -le $am_max_uid; then
3317f757b1e9Smrg         AC_MSG_RESULT([yes])
3318f757b1e9Smrg      else
3319f757b1e9Smrg         AC_MSG_RESULT([no])
3320f757b1e9Smrg         _am_tools=none
3321f757b1e9Smrg      fi
3322f757b1e9Smrg      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
3323f757b1e9Smrg      if test $am_gid -le $am_max_gid; then
3324f757b1e9Smrg         AC_MSG_RESULT([yes])
3325f757b1e9Smrg      else
3326f757b1e9Smrg        AC_MSG_RESULT([no])
3327f757b1e9Smrg        _am_tools=none
3328f757b1e9Smrg      fi],
3329f757b1e9Smrg
3330f757b1e9Smrg  [pax],
3331f757b1e9Smrg    [],
3332f757b1e9Smrg
3333f757b1e9Smrg  [m4_fatal([Unknown tar format])])
3334f757b1e9Smrg
3335f757b1e9Smrg  AC_MSG_CHECKING([how to create a $1 tar archive])
3336f757b1e9Smrg
3337f757b1e9Smrg  # Go ahead even if we have the value already cached.  We do so because we
3338f757b1e9Smrg  # need to set the values for the 'am__tar' and 'am__untar' variables.
3339f757b1e9Smrg  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
3340f757b1e9Smrg
3341f757b1e9Smrg  for _am_tool in $_am_tools; do
3342f757b1e9Smrg    case $_am_tool in
3343f757b1e9Smrg    gnutar)
3344f757b1e9Smrg      for _am_tar in tar gnutar gtar; do
3345f757b1e9Smrg        AM_RUN_LOG([$_am_tar --version]) && break
3346f757b1e9Smrg      done
3347f757b1e9Smrg      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
3348f757b1e9Smrg      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
3349f757b1e9Smrg      am__untar="$_am_tar -xf -"
3350f757b1e9Smrg      ;;
3351f757b1e9Smrg    plaintar)
3352f757b1e9Smrg      # Must skip GNU tar: if it does not support --format= it doesn't create
3353f757b1e9Smrg      # ustar tarball either.
3354f757b1e9Smrg      (tar --version) >/dev/null 2>&1 && continue
3355f757b1e9Smrg      am__tar='tar chf - "$$tardir"'
3356f757b1e9Smrg      am__tar_='tar chf - "$tardir"'
3357f757b1e9Smrg      am__untar='tar xf -'
3358f757b1e9Smrg      ;;
3359f757b1e9Smrg    pax)
3360f757b1e9Smrg      am__tar='pax -L -x $1 -w "$$tardir"'
3361f757b1e9Smrg      am__tar_='pax -L -x $1 -w "$tardir"'
3362f757b1e9Smrg      am__untar='pax -r'
3363f757b1e9Smrg      ;;
3364f757b1e9Smrg    cpio)
3365f757b1e9Smrg      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
3366f757b1e9Smrg      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
3367f757b1e9Smrg      am__untar='cpio -i -H $1 -d'
3368f757b1e9Smrg      ;;
3369f757b1e9Smrg    none)
3370f757b1e9Smrg      am__tar=false
3371f757b1e9Smrg      am__tar_=false
3372f757b1e9Smrg      am__untar=false
3373f757b1e9Smrg      ;;
3374f757b1e9Smrg    esac
3375f757b1e9Smrg
3376f757b1e9Smrg    # If the value was cached, stop now.  We just wanted to have am__tar
3377f757b1e9Smrg    # and am__untar set.
3378f757b1e9Smrg    test -n "${am_cv_prog_tar_$1}" && break
3379f757b1e9Smrg
3380f757b1e9Smrg    # tar/untar a dummy directory, and stop if the command works.
3381f757b1e9Smrg    rm -rf conftest.dir
3382f757b1e9Smrg    mkdir conftest.dir
3383f757b1e9Smrg    echo GrepMe > conftest.dir/file
3384f757b1e9Smrg    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
3385f757b1e9Smrg    rm -rf conftest.dir
3386f757b1e9Smrg    if test -s conftest.tar; then
3387f757b1e9Smrg      AM_RUN_LOG([$am__untar <conftest.tar])
3388f757b1e9Smrg      AM_RUN_LOG([cat conftest.dir/file])
3389f757b1e9Smrg      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
3390f757b1e9Smrg    fi
3391f757b1e9Smrg  done
3392f757b1e9Smrg  rm -rf conftest.dir
3393f757b1e9Smrg
3394f757b1e9Smrg  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
3395f757b1e9Smrg  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
3396f757b1e9Smrg
3397f757b1e9SmrgAC_SUBST([am__tar])
3398f757b1e9SmrgAC_SUBST([am__untar])
3399f757b1e9Smrg]) # _AM_PROG_TAR
3400f46a6179Smrg
3401