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