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