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