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