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