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