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