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