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