aclocal.m4 revision 69ef5f27
1# generated automatically by aclocal 1.14.1 -*- 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.69],,
18[m4_warning([this file was generated for autoconf 2.69.
19You have another version of autoconf.  It may work, but is not guaranteed to.
20If you have problems, you may need to regenerate the build system entirely.
21To do so, use the procedure documented by the package, typically 'autoreconf'.])])
22
23# 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.1], [],
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.1])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# Check to see how 'make' treats includes.	            -*- Autoconf -*-
646
647# Copyright (C) 2001-2013 Free Software Foundation, Inc.
648#
649# This file is free software; the Free Software Foundation
650# gives unlimited permission to copy and/or distribute it,
651# with or without modifications, as long as this notice is preserved.
652
653# AM_MAKE_INCLUDE()
654# -----------------
655# Check to see how make treats includes.
656AC_DEFUN([AM_MAKE_INCLUDE],
657[am_make=${MAKE-make}
658cat > confinc << 'END'
659am__doit:
660	@echo this is the am__doit target
661.PHONY: am__doit
662END
663# If we don't find an include directive, just comment out the code.
664AC_MSG_CHECKING([for style of include used by $am_make])
665am__include="#"
666am__quote=
667_am_result=none
668# First try GNU make style include.
669echo "include confinc" > confmf
670# Ignore all kinds of additional output from 'make'.
671case `$am_make -s -f confmf 2> /dev/null` in #(
672*the\ am__doit\ target*)
673  am__include=include
674  am__quote=
675  _am_result=GNU
676  ;;
677esac
678# Now try BSD make style include.
679if test "$am__include" = "#"; then
680   echo '.include "confinc"' > confmf
681   case `$am_make -s -f confmf 2> /dev/null` in #(
682   *the\ am__doit\ target*)
683     am__include=.include
684     am__quote="\""
685     _am_result=BSD
686     ;;
687   esac
688fi
689AC_SUBST([am__include])
690AC_SUBST([am__quote])
691AC_MSG_RESULT([$_am_result])
692rm -f confinc confmf
693])
694
695# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
696
697# Copyright (C) 1997-2013 Free Software Foundation, Inc.
698#
699# This file is free software; the Free Software Foundation
700# gives unlimited permission to copy and/or distribute it,
701# with or without modifications, as long as this notice is preserved.
702
703# AM_MISSING_PROG(NAME, PROGRAM)
704# ------------------------------
705AC_DEFUN([AM_MISSING_PROG],
706[AC_REQUIRE([AM_MISSING_HAS_RUN])
707$1=${$1-"${am_missing_run}$2"}
708AC_SUBST($1)])
709
710# AM_MISSING_HAS_RUN
711# ------------------
712# Define MISSING if not defined so far and test if it is modern enough.
713# If it is, set am_missing_run to use it, otherwise, to nothing.
714AC_DEFUN([AM_MISSING_HAS_RUN],
715[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
716AC_REQUIRE_AUX_FILE([missing])dnl
717if test x"${MISSING+set}" != xset; then
718  case $am_aux_dir in
719  *\ * | *\	*)
720    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
721  *)
722    MISSING="\${SHELL} $am_aux_dir/missing" ;;
723  esac
724fi
725# Use eval to expand $SHELL
726if eval "$MISSING --is-lightweight"; then
727  am_missing_run="$MISSING "
728else
729  am_missing_run=
730  AC_MSG_WARN(['missing' script is too old or missing])
731fi
732])
733
734# Helper functions for option handling.                     -*- Autoconf -*-
735
736# Copyright (C) 2001-2013 Free Software Foundation, Inc.
737#
738# This file is free software; the Free Software Foundation
739# gives unlimited permission to copy and/or distribute it,
740# with or without modifications, as long as this notice is preserved.
741
742# _AM_MANGLE_OPTION(NAME)
743# -----------------------
744AC_DEFUN([_AM_MANGLE_OPTION],
745[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
746
747# _AM_SET_OPTION(NAME)
748# --------------------
749# Set option NAME.  Presently that only means defining a flag for this option.
750AC_DEFUN([_AM_SET_OPTION],
751[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
752
753# _AM_SET_OPTIONS(OPTIONS)
754# ------------------------
755# OPTIONS is a space-separated list of Automake options.
756AC_DEFUN([_AM_SET_OPTIONS],
757[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
758
759# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
760# -------------------------------------------
761# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
762AC_DEFUN([_AM_IF_OPTION],
763[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
764
765# Copyright (C) 1999-2013 Free Software Foundation, Inc.
766#
767# This file is free software; the Free Software Foundation
768# gives unlimited permission to copy and/or distribute it,
769# with or without modifications, as long as this notice is preserved.
770
771# _AM_PROG_CC_C_O
772# ---------------
773# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
774# to automatically call this.
775AC_DEFUN([_AM_PROG_CC_C_O],
776[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
777AC_REQUIRE_AUX_FILE([compile])dnl
778AC_LANG_PUSH([C])dnl
779AC_CACHE_CHECK(
780  [whether $CC understands -c and -o together],
781  [am_cv_prog_cc_c_o],
782  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
783  # Make sure it works both with $CC and with simple cc.
784  # Following AC_PROG_CC_C_O, we do the test twice because some
785  # compilers refuse to overwrite an existing .o file with -o,
786  # though they will create one.
787  am_cv_prog_cc_c_o=yes
788  for am_i in 1 2; do
789    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
790         && test -f conftest2.$ac_objext; then
791      : OK
792    else
793      am_cv_prog_cc_c_o=no
794      break
795    fi
796  done
797  rm -f core conftest*
798  unset am_i])
799if test "$am_cv_prog_cc_c_o" != yes; then
800   # Losing compiler, so override with the script.
801   # FIXME: It is wrong to rewrite CC.
802   # But if we don't then we get into trouble of one sort or another.
803   # A longer-term fix would be to have automake use am__CC in this case,
804   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
805   CC="$am_aux_dir/compile $CC"
806fi
807AC_LANG_POP([C])])
808
809# For backward compatibility.
810AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
811
812# Copyright (C) 2001-2013 Free Software Foundation, Inc.
813#
814# This file is free software; the Free Software Foundation
815# gives unlimited permission to copy and/or distribute it,
816# with or without modifications, as long as this notice is preserved.
817
818# AM_RUN_LOG(COMMAND)
819# -------------------
820# Run COMMAND, save the exit status in ac_status, and log it.
821# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
822AC_DEFUN([AM_RUN_LOG],
823[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
824   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
825   ac_status=$?
826   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
827   (exit $ac_status); }])
828
829# Check to make sure that the build environment is sane.    -*- Autoconf -*-
830
831# Copyright (C) 1996-2013 Free Software Foundation, Inc.
832#
833# This file is free software; the Free Software Foundation
834# gives unlimited permission to copy and/or distribute it,
835# with or without modifications, as long as this notice is preserved.
836
837# AM_SANITY_CHECK
838# ---------------
839AC_DEFUN([AM_SANITY_CHECK],
840[AC_MSG_CHECKING([whether build environment is sane])
841# Reject unsafe characters in $srcdir or the absolute working directory
842# name.  Accept space and tab only in the latter.
843am_lf='
844'
845case `pwd` in
846  *[[\\\"\#\$\&\'\`$am_lf]]*)
847    AC_MSG_ERROR([unsafe absolute working directory name]);;
848esac
849case $srcdir in
850  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
851    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
852esac
853
854# Do 'set' in a subshell so we don't clobber the current shell's
855# arguments.  Must try -L first in case configure is actually a
856# symlink; some systems play weird games with the mod time of symlinks
857# (eg FreeBSD returns the mod time of the symlink's containing
858# directory).
859if (
860   am_has_slept=no
861   for am_try in 1 2; do
862     echo "timestamp, slept: $am_has_slept" > conftest.file
863     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
864     if test "$[*]" = "X"; then
865	# -L didn't work.
866	set X `ls -t "$srcdir/configure" conftest.file`
867     fi
868     if test "$[*]" != "X $srcdir/configure conftest.file" \
869	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
870
871	# If neither matched, then we have a broken ls.  This can happen
872	# if, for instance, CONFIG_SHELL is bash and it inherits a
873	# broken ls alias from the environment.  This has actually
874	# happened.  Such a system could not be considered "sane".
875	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
876  alias in your environment])
877     fi
878     if test "$[2]" = conftest.file || test $am_try -eq 2; then
879       break
880     fi
881     # Just in case.
882     sleep 1
883     am_has_slept=yes
884   done
885   test "$[2]" = conftest.file
886   )
887then
888   # Ok.
889   :
890else
891   AC_MSG_ERROR([newly created file is older than distributed files!
892Check your system clock])
893fi
894AC_MSG_RESULT([yes])
895# If we didn't sleep, we still need to ensure time stamps of config.status and
896# generated files are strictly newer.
897am_sleep_pid=
898if grep 'slept: no' conftest.file >/dev/null 2>&1; then
899  ( sleep 1 ) &
900  am_sleep_pid=$!
901fi
902AC_CONFIG_COMMANDS_PRE(
903  [AC_MSG_CHECKING([that generated files are newer than configure])
904   if test -n "$am_sleep_pid"; then
905     # Hide warnings about reused PIDs.
906     wait $am_sleep_pid 2>/dev/null
907   fi
908   AC_MSG_RESULT([done])])
909rm -f conftest.file
910])
911
912# Copyright (C) 2009-2013 Free Software Foundation, Inc.
913#
914# This file is free software; the Free Software Foundation
915# gives unlimited permission to copy and/or distribute it,
916# with or without modifications, as long as this notice is preserved.
917
918# AM_SILENT_RULES([DEFAULT])
919# --------------------------
920# Enable less verbose build rules; with the default set to DEFAULT
921# ("yes" being less verbose, "no" or empty being verbose).
922AC_DEFUN([AM_SILENT_RULES],
923[AC_ARG_ENABLE([silent-rules], [dnl
924AS_HELP_STRING(
925  [--enable-silent-rules],
926  [less verbose build output (undo: "make V=1")])
927AS_HELP_STRING(
928  [--disable-silent-rules],
929  [verbose build output (undo: "make V=0")])dnl
930])
931case $enable_silent_rules in @%:@ (((
932  yes) AM_DEFAULT_VERBOSITY=0;;
933   no) AM_DEFAULT_VERBOSITY=1;;
934    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
935esac
936dnl
937dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
938dnl do not support nested variable expansions.
939dnl See automake bug#9928 and bug#10237.
940am_make=${MAKE-make}
941AC_CACHE_CHECK([whether $am_make supports nested variables],
942   [am_cv_make_support_nested_variables],
943   [if AS_ECHO([['TRUE=$(BAR$(V))
944BAR0=false
945BAR1=true
946V=1
947am__doit:
948	@$(TRUE)
949.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
950  am_cv_make_support_nested_variables=yes
951else
952  am_cv_make_support_nested_variables=no
953fi])
954if test $am_cv_make_support_nested_variables = yes; then
955  dnl Using '$V' instead of '$(V)' breaks IRIX make.
956  AM_V='$(V)'
957  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
958else
959  AM_V=$AM_DEFAULT_VERBOSITY
960  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
961fi
962AC_SUBST([AM_V])dnl
963AM_SUBST_NOTMAKE([AM_V])dnl
964AC_SUBST([AM_DEFAULT_V])dnl
965AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
966AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
967AM_BACKSLASH='\'
968AC_SUBST([AM_BACKSLASH])dnl
969_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
970])
971
972# Copyright (C) 2001-2013 Free Software Foundation, Inc.
973#
974# This file is free software; the Free Software Foundation
975# gives unlimited permission to copy and/or distribute it,
976# with or without modifications, as long as this notice is preserved.
977
978# AM_PROG_INSTALL_STRIP
979# ---------------------
980# One issue with vendor 'install' (even GNU) is that you can't
981# specify the program used to strip binaries.  This is especially
982# annoying in cross-compiling environments, where the build's strip
983# is unlikely to handle the host's binaries.
984# Fortunately install-sh will honor a STRIPPROG variable, so we
985# always use install-sh in "make install-strip", and initialize
986# STRIPPROG with the value of the STRIP variable (set by the user).
987AC_DEFUN([AM_PROG_INSTALL_STRIP],
988[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
989# Installed binaries are usually stripped using 'strip' when the user
990# run "make install-strip".  However 'strip' might not be the right
991# tool to use in cross-compilation environments, therefore Automake
992# will honor the 'STRIP' environment variable to overrule this program.
993dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
994if test "$cross_compiling" != no; then
995  AC_CHECK_TOOL([STRIP], [strip], :)
996fi
997INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
998AC_SUBST([INSTALL_STRIP_PROGRAM])])
999
1000# Copyright (C) 2006-2013 Free Software Foundation, Inc.
1001#
1002# This file is free software; the Free Software Foundation
1003# gives unlimited permission to copy and/or distribute it,
1004# with or without modifications, as long as this notice is preserved.
1005
1006# _AM_SUBST_NOTMAKE(VARIABLE)
1007# ---------------------------
1008# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
1009# This macro is traced by Automake.
1010AC_DEFUN([_AM_SUBST_NOTMAKE])
1011
1012# AM_SUBST_NOTMAKE(VARIABLE)
1013# --------------------------
1014# Public sister of _AM_SUBST_NOTMAKE.
1015AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
1016
1017# Check how to create a tarball.                            -*- Autoconf -*-
1018
1019# Copyright (C) 2004-2013 Free Software Foundation, Inc.
1020#
1021# This file is free software; the Free Software Foundation
1022# gives unlimited permission to copy and/or distribute it,
1023# with or without modifications, as long as this notice is preserved.
1024
1025# _AM_PROG_TAR(FORMAT)
1026# --------------------
1027# Check how to create a tarball in format FORMAT.
1028# FORMAT should be one of 'v7', 'ustar', or 'pax'.
1029#
1030# Substitute a variable $(am__tar) that is a command
1031# writing to stdout a FORMAT-tarball containing the directory
1032# $tardir.
1033#     tardir=directory && $(am__tar) > result.tar
1034#
1035# Substitute a variable $(am__untar) that extract such
1036# a tarball read from stdin.
1037#     $(am__untar) < result.tar
1038#
1039AC_DEFUN([_AM_PROG_TAR],
1040[# Always define AMTAR for backward compatibility.  Yes, it's still used
1041# in the wild :-(  We should find a proper way to deprecate it ...
1042AC_SUBST([AMTAR], ['$${TAR-tar}'])
1043
1044# We'll loop over all known methods to create a tar archive until one works.
1045_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
1046
1047m4_if([$1], [v7],
1048  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
1049
1050  [m4_case([$1],
1051    [ustar],
1052     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
1053      # There is notably a 21 bits limit for the UID and the GID.  In fact,
1054      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
1055      # and bug#13588).
1056      am_max_uid=2097151 # 2^21 - 1
1057      am_max_gid=$am_max_uid
1058      # The $UID and $GID variables are not portable, so we need to resort
1059      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
1060      # below are definitely unexpected, so allow the users to see them
1061      # (that is, avoid stderr redirection).
1062      am_uid=`id -u || echo unknown`
1063      am_gid=`id -g || echo unknown`
1064      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
1065      if test $am_uid -le $am_max_uid; then
1066         AC_MSG_RESULT([yes])
1067      else
1068         AC_MSG_RESULT([no])
1069         _am_tools=none
1070      fi
1071      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
1072      if test $am_gid -le $am_max_gid; then
1073         AC_MSG_RESULT([yes])
1074      else
1075        AC_MSG_RESULT([no])
1076        _am_tools=none
1077      fi],
1078
1079  [pax],
1080    [],
1081
1082  [m4_fatal([Unknown tar format])])
1083
1084  AC_MSG_CHECKING([how to create a $1 tar archive])
1085
1086  # Go ahead even if we have the value already cached.  We do so because we
1087  # need to set the values for the 'am__tar' and 'am__untar' variables.
1088  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
1089
1090  for _am_tool in $_am_tools; do
1091    case $_am_tool in
1092    gnutar)
1093      for _am_tar in tar gnutar gtar; do
1094        AM_RUN_LOG([$_am_tar --version]) && break
1095      done
1096      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
1097      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
1098      am__untar="$_am_tar -xf -"
1099      ;;
1100    plaintar)
1101      # Must skip GNU tar: if it does not support --format= it doesn't create
1102      # ustar tarball either.
1103      (tar --version) >/dev/null 2>&1 && continue
1104      am__tar='tar chf - "$$tardir"'
1105      am__tar_='tar chf - "$tardir"'
1106      am__untar='tar xf -'
1107      ;;
1108    pax)
1109      am__tar='pax -L -x $1 -w "$$tardir"'
1110      am__tar_='pax -L -x $1 -w "$tardir"'
1111      am__untar='pax -r'
1112      ;;
1113    cpio)
1114      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
1115      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
1116      am__untar='cpio -i -H $1 -d'
1117      ;;
1118    none)
1119      am__tar=false
1120      am__tar_=false
1121      am__untar=false
1122      ;;
1123    esac
1124
1125    # If the value was cached, stop now.  We just wanted to have am__tar
1126    # and am__untar set.
1127    test -n "${am_cv_prog_tar_$1}" && break
1128
1129    # tar/untar a dummy directory, and stop if the command works.
1130    rm -rf conftest.dir
1131    mkdir conftest.dir
1132    echo GrepMe > conftest.dir/file
1133    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
1134    rm -rf conftest.dir
1135    if test -s conftest.tar; then
1136      AM_RUN_LOG([$am__untar <conftest.tar])
1137      AM_RUN_LOG([cat conftest.dir/file])
1138      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
1139    fi
1140  done
1141  rm -rf conftest.dir
1142
1143  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
1144  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
1145
1146AC_SUBST([am__tar])
1147AC_SUBST([am__untar])
1148]) # _AM_PROG_TAR
1149
1150# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
1151# 
1152# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1153#
1154# This program is free software; you can redistribute it and/or modify
1155# it under the terms of the GNU General Public License as published by
1156# the Free Software Foundation; either version 2 of the License, or
1157# (at your option) any later version.
1158#
1159# This program is distributed in the hope that it will be useful, but
1160# WITHOUT ANY WARRANTY; without even the implied warranty of
1161# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1162# General Public License for more details.
1163#
1164# You should have received a copy of the GNU General Public License
1165# along with this program; if not, write to the Free Software
1166# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1167#
1168# As a special exception to the GNU General Public License, if you
1169# distribute this file as part of a program that contains a
1170# configuration script generated by Autoconf, you may include it under
1171# the same distribution terms that you use for the rest of that program.
1172
1173# PKG_PROG_PKG_CONFIG([MIN-VERSION])
1174# ----------------------------------
1175AC_DEFUN([PKG_PROG_PKG_CONFIG],
1176[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
1177m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
1178AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
1179if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1180	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1181fi
1182if test -n "$PKG_CONFIG"; then
1183	_pkg_min_version=m4_default([$1], [0.9.0])
1184	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1185	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1186		AC_MSG_RESULT([yes])
1187	else
1188		AC_MSG_RESULT([no])
1189		PKG_CONFIG=""
1190	fi
1191		
1192fi[]dnl
1193])# PKG_PROG_PKG_CONFIG
1194
1195# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1196#
1197# Check to see whether a particular set of modules exists.  Similar
1198# to PKG_CHECK_MODULES(), but does not set variables or print errors.
1199#
1200#
1201# Similar to PKG_CHECK_MODULES, make sure that the first instance of
1202# this or PKG_CHECK_MODULES is called, or make sure to call
1203# PKG_CHECK_EXISTS manually
1204# --------------------------------------------------------------
1205AC_DEFUN([PKG_CHECK_EXISTS],
1206[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1207if test -n "$PKG_CONFIG" && \
1208    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
1209  m4_ifval([$2], [$2], [:])
1210m4_ifvaln([$3], [else
1211  $3])dnl
1212fi])
1213
1214
1215# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
1216# ---------------------------------------------
1217m4_define([_PKG_CONFIG],
1218[if test -n "$$1"; then
1219    pkg_cv_[]$1="$$1"
1220 elif test -n "$PKG_CONFIG"; then
1221    PKG_CHECK_EXISTS([$3],
1222                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
1223		     [pkg_failed=yes])
1224 else
1225    pkg_failed=untried
1226fi[]dnl
1227])# _PKG_CONFIG
1228
1229# _PKG_SHORT_ERRORS_SUPPORTED
1230# -----------------------------
1231AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
1232[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1233if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1234        _pkg_short_errors_supported=yes
1235else
1236        _pkg_short_errors_supported=no
1237fi[]dnl
1238])# _PKG_SHORT_ERRORS_SUPPORTED
1239
1240
1241# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1242# [ACTION-IF-NOT-FOUND])
1243#
1244#
1245# Note that if there is a possibility the first call to
1246# PKG_CHECK_MODULES might not happen, you should be sure to include an
1247# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
1248#
1249#
1250# --------------------------------------------------------------
1251AC_DEFUN([PKG_CHECK_MODULES],
1252[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1253AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
1254AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
1255
1256pkg_failed=no
1257AC_MSG_CHECKING([for $1])
1258
1259_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
1260_PKG_CONFIG([$1][_LIBS], [libs], [$2])
1261
1262m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
1263and $1[]_LIBS to avoid the need to call pkg-config.
1264See the pkg-config man page for more details.])
1265
1266if test $pkg_failed = yes; then
1267        _PKG_SHORT_ERRORS_SUPPORTED
1268        if test $_pkg_short_errors_supported = yes; then
1269	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
1270        else 
1271	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
1272        fi
1273	# Put the nasty error message in config.log where it belongs
1274	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
1275
1276	ifelse([$4], , [AC_MSG_ERROR(dnl
1277[Package requirements ($2) were not met:
1278
1279$$1_PKG_ERRORS
1280
1281Consider adjusting the PKG_CONFIG_PATH environment variable if you
1282installed software in a non-standard prefix.
1283
1284_PKG_TEXT
1285])],
1286		[AC_MSG_RESULT([no])
1287                $4])
1288elif test $pkg_failed = untried; then
1289	ifelse([$4], , [AC_MSG_FAILURE(dnl
1290[The pkg-config script could not be found or is too old.  Make sure it
1291is in your PATH or set the PKG_CONFIG environment variable to the full
1292path to pkg-config.
1293
1294_PKG_TEXT
1295
1296To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
1297		[$4])
1298else
1299	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
1300	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
1301        AC_MSG_RESULT([yes])
1302	ifelse([$3], , :, [$3])
1303fi[]dnl
1304])# PKG_CHECK_MODULES
1305
1306dnl xorg-macros.m4.  Generated from xorg-macros.m4.in xorgversion.m4 by configure.
1307dnl
1308dnl Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
1309dnl
1310dnl Permission is hereby granted, free of charge, to any person obtaining a
1311dnl copy of this software and associated documentation files (the "Software"),
1312dnl to deal in the Software without restriction, including without limitation
1313dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
1314dnl and/or sell copies of the Software, and to permit persons to whom the
1315dnl Software is furnished to do so, subject to the following conditions:
1316dnl
1317dnl The above copyright notice and this permission notice (including the next
1318dnl paragraph) shall be included in all copies or substantial portions of the
1319dnl Software.
1320dnl
1321dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1322dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1323dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1324dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1325dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1326dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1327dnl DEALINGS IN THE SOFTWARE.
1328
1329# XORG_MACROS_VERSION(required-version)
1330# -------------------------------------
1331# Minimum version: 1.1.0
1332#
1333# If you're using a macro added in Version 1.1 or newer, include this in
1334# your configure.ac with the minimum required version, such as:
1335# XORG_MACROS_VERSION(1.1)
1336#
1337# To ensure that this macro is defined, also add:
1338# m4_ifndef([XORG_MACROS_VERSION],
1339#     [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
1340#
1341#
1342# See the "minimum version" comment for each macro you use to see what
1343# version you require.
1344m4_defun([XORG_MACROS_VERSION],[
1345m4_define([vers_have], [1.19.0])
1346m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
1347m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
1348m4_if(m4_cmp(maj_have, maj_needed), 0,,
1349    [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
1350m4_if(m4_version_compare(vers_have, [$1]), -1,
1351    [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
1352m4_undefine([vers_have])
1353m4_undefine([maj_have])
1354m4_undefine([maj_needed])
1355]) # XORG_MACROS_VERSION
1356
1357# XORG_PROG_RAWCPP()
1358# ------------------
1359# Minimum version: 1.0.0
1360#
1361# Find cpp program and necessary flags for use in pre-processing text files
1362# such as man pages and config files
1363AC_DEFUN([XORG_PROG_RAWCPP],[
1364AC_REQUIRE([AC_PROG_CPP])
1365AC_PATH_PROGS(RAWCPP, [cpp], [${CPP}],
1366   [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
1367
1368# Check for flag to avoid builtin definitions - assumes unix is predefined,
1369# which is not the best choice for supporting other OS'es, but covers most
1370# of the ones we need for now.
1371AC_MSG_CHECKING([if $RAWCPP requires -undef])
1372AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
1373if test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
1374	AC_MSG_RESULT([no])
1375else
1376	if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
1377		RAWCPPFLAGS=-undef
1378		AC_MSG_RESULT([yes])
1379	# under Cygwin unix is still defined even with -undef
1380	elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
1381		RAWCPPFLAGS="-undef -ansi"
1382		AC_MSG_RESULT([yes, with -ansi])
1383	else
1384		AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef.  I don't know what to do.])
1385	fi
1386fi
1387rm -f conftest.$ac_ext
1388
1389AC_MSG_CHECKING([if $RAWCPP requires -traditional])
1390AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
1391if test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
1392	AC_MSG_RESULT([no])
1393else
1394	if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
1395		TRADITIONALCPPFLAGS="-traditional"
1396		RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
1397		AC_MSG_RESULT([yes])
1398	else
1399		AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
1400	fi
1401fi
1402rm -f conftest.$ac_ext
1403AC_SUBST(RAWCPPFLAGS)
1404AC_SUBST(TRADITIONALCPPFLAGS)
1405]) # XORG_PROG_RAWCPP
1406
1407# XORG_MANPAGE_SECTIONS()
1408# -----------------------
1409# Minimum version: 1.0.0
1410#
1411# Determine which sections man pages go in for the different man page types
1412# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
1413# Not sure if there's any better way than just hardcoding by OS name.
1414# Override default settings by setting environment variables
1415# Added MAN_SUBSTS in version 1.8
1416# Added AC_PROG_SED in version 1.8
1417
1418AC_DEFUN([XORG_MANPAGE_SECTIONS],[
1419AC_REQUIRE([AC_CANONICAL_HOST])
1420AC_REQUIRE([AC_PROG_SED])
1421
1422if test x$APP_MAN_SUFFIX = x    ; then
1423    APP_MAN_SUFFIX=1
1424fi
1425if test x$APP_MAN_DIR = x    ; then
1426    APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
1427fi
1428
1429if test x$LIB_MAN_SUFFIX = x    ; then
1430    LIB_MAN_SUFFIX=3
1431fi
1432if test x$LIB_MAN_DIR = x    ; then
1433    LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
1434fi
1435
1436if test x$FILE_MAN_SUFFIX = x    ; then
1437    case $host_os in
1438	solaris*)	FILE_MAN_SUFFIX=4  ;;
1439	*)		FILE_MAN_SUFFIX=5  ;;
1440    esac
1441fi
1442if test x$FILE_MAN_DIR = x    ; then
1443    FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
1444fi
1445
1446if test x$MISC_MAN_SUFFIX = x    ; then
1447    case $host_os in
1448	solaris*)	MISC_MAN_SUFFIX=5  ;;
1449	*)		MISC_MAN_SUFFIX=7  ;;
1450    esac
1451fi
1452if test x$MISC_MAN_DIR = x    ; then
1453    MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
1454fi
1455
1456if test x$DRIVER_MAN_SUFFIX = x    ; then
1457    case $host_os in
1458	solaris*)	DRIVER_MAN_SUFFIX=7  ;;
1459	*)		DRIVER_MAN_SUFFIX=4  ;;
1460    esac
1461fi
1462if test x$DRIVER_MAN_DIR = x    ; then
1463    DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
1464fi
1465
1466if test x$ADMIN_MAN_SUFFIX = x    ; then
1467    case $host_os in
1468	solaris*)	ADMIN_MAN_SUFFIX=1m ;;
1469	*)		ADMIN_MAN_SUFFIX=8  ;;
1470    esac
1471fi
1472if test x$ADMIN_MAN_DIR = x    ; then
1473    ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
1474fi
1475
1476
1477AC_SUBST([APP_MAN_SUFFIX])
1478AC_SUBST([LIB_MAN_SUFFIX])
1479AC_SUBST([FILE_MAN_SUFFIX])
1480AC_SUBST([MISC_MAN_SUFFIX])
1481AC_SUBST([DRIVER_MAN_SUFFIX])
1482AC_SUBST([ADMIN_MAN_SUFFIX])
1483AC_SUBST([APP_MAN_DIR])
1484AC_SUBST([LIB_MAN_DIR])
1485AC_SUBST([FILE_MAN_DIR])
1486AC_SUBST([MISC_MAN_DIR])
1487AC_SUBST([DRIVER_MAN_DIR])
1488AC_SUBST([ADMIN_MAN_DIR])
1489
1490XORG_MAN_PAGE="X Version 11"
1491AC_SUBST([XORG_MAN_PAGE])
1492MAN_SUBSTS="\
1493	-e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
1494	-e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
1495	-e 's|__xservername__|Xorg|g' \
1496	-e 's|__xconfigfile__|xorg.conf|g' \
1497	-e 's|__projectroot__|\$(prefix)|g' \
1498	-e 's|__apploaddir__|\$(appdefaultdir)|g' \
1499	-e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
1500	-e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
1501	-e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
1502	-e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
1503	-e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
1504	-e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
1505AC_SUBST([MAN_SUBSTS])
1506
1507]) # XORG_MANPAGE_SECTIONS
1508
1509# XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
1510# ------------------------
1511# Minimum version: 1.7.0
1512#
1513# Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
1514# provided by xorg-sgml-doctools, if installed.
1515AC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
1516AC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
1517XORG_SGML_PATH=
1518PKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
1519    [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
1520    [m4_ifval([$1],[:],
1521        [if test x"$cross_compiling" != x"yes" ; then
1522            AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
1523                          [XORG_SGML_PATH=$prefix/share/sgml])
1524         fi])
1525    ])
1526
1527# Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
1528# the path and the name of the doc stylesheet
1529if test "x$XORG_SGML_PATH" != "x" ; then
1530   AC_MSG_RESULT([$XORG_SGML_PATH])
1531   STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
1532   XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
1533else
1534   AC_MSG_RESULT([no])
1535fi
1536
1537AC_SUBST(XORG_SGML_PATH)
1538AC_SUBST(STYLESHEET_SRCDIR)
1539AC_SUBST(XSL_STYLESHEET)
1540AM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
1541]) # XORG_CHECK_SGML_DOCTOOLS
1542
1543# XORG_CHECK_LINUXDOC
1544# -------------------
1545# Minimum version: 1.0.0
1546#
1547# Defines the variable MAKE_TEXT if the necessary tools and
1548# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
1549# Whether or not the necessary tools and files are found can be checked
1550# with the AM_CONDITIONAL "BUILD_LINUXDOC"
1551AC_DEFUN([XORG_CHECK_LINUXDOC],[
1552AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
1553AC_REQUIRE([XORG_WITH_PS2PDF])
1554
1555AC_PATH_PROG(LINUXDOC, linuxdoc)
1556
1557AC_MSG_CHECKING([whether to build documentation])
1558
1559if test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
1560   BUILDDOC=yes
1561else
1562   BUILDDOC=no
1563fi
1564
1565AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
1566
1567AC_MSG_RESULT([$BUILDDOC])
1568
1569AC_MSG_CHECKING([whether to build pdf documentation])
1570
1571if test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
1572   BUILDPDFDOC=yes
1573else
1574   BUILDPDFDOC=no
1575fi
1576
1577AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
1578
1579AC_MSG_RESULT([$BUILDPDFDOC])
1580
1581MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
1582MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
1583MAKE_PDF="$PS2PDF"
1584MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
1585
1586AC_SUBST(MAKE_TEXT)
1587AC_SUBST(MAKE_PS)
1588AC_SUBST(MAKE_PDF)
1589AC_SUBST(MAKE_HTML)
1590]) # XORG_CHECK_LINUXDOC
1591
1592# XORG_CHECK_DOCBOOK
1593# -------------------
1594# Minimum version: 1.0.0
1595#
1596# Checks for the ability to build output formats from SGML DocBook source.
1597# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
1598# indicates whether the necessary tools and files are found and, if set,
1599# $(MAKE_XXX) blah.sgml will produce blah.xxx.
1600AC_DEFUN([XORG_CHECK_DOCBOOK],[
1601AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
1602
1603BUILDTXTDOC=no
1604BUILDPDFDOC=no
1605BUILDPSDOC=no
1606BUILDHTMLDOC=no
1607
1608AC_PATH_PROG(DOCBOOKPS, docbook2ps)
1609AC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
1610AC_PATH_PROG(DOCBOOKHTML, docbook2html)
1611AC_PATH_PROG(DOCBOOKTXT, docbook2txt)
1612
1613AC_MSG_CHECKING([whether to build text documentation])
1614if test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
1615   test x$BUILD_TXTDOC != xno; then
1616	BUILDTXTDOC=yes
1617fi
1618AM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
1619AC_MSG_RESULT([$BUILDTXTDOC])
1620
1621AC_MSG_CHECKING([whether to build PDF documentation])
1622if test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
1623   test x$BUILD_PDFDOC != xno; then
1624	BUILDPDFDOC=yes
1625fi
1626AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
1627AC_MSG_RESULT([$BUILDPDFDOC])
1628
1629AC_MSG_CHECKING([whether to build PostScript documentation])
1630if test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
1631   test x$BUILD_PSDOC != xno; then
1632	BUILDPSDOC=yes
1633fi
1634AM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
1635AC_MSG_RESULT([$BUILDPSDOC])
1636
1637AC_MSG_CHECKING([whether to build HTML documentation])
1638if test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
1639   test x$BUILD_HTMLDOC != xno; then
1640	BUILDHTMLDOC=yes
1641fi
1642AM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
1643AC_MSG_RESULT([$BUILDHTMLDOC])
1644
1645MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
1646MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
1647MAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
1648MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
1649
1650AC_SUBST(MAKE_TEXT)
1651AC_SUBST(MAKE_PS)
1652AC_SUBST(MAKE_PDF)
1653AC_SUBST(MAKE_HTML)
1654]) # XORG_CHECK_DOCBOOK
1655
1656# XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
1657# ----------------
1658# Minimum version: 1.5.0
1659# Minimum version for optional DEFAULT argument: 1.11.0
1660#
1661# Documentation tools are not always available on all platforms and sometimes
1662# not at the appropriate level. This macro enables a module to test for the
1663# presence of the tool and obtain it's path in separate variables. Coupled with
1664# the --with-xmlto option, it allows maximum flexibilty in making decisions
1665# as whether or not to use the xmlto package. When DEFAULT is not specified,
1666# --with-xmlto assumes 'auto'.
1667#
1668# Interface to module:
1669# HAVE_XMLTO: 	used in makefiles to conditionally generate documentation
1670# XMLTO:	returns the path of the xmlto program found
1671#		returns the path set by the user in the environment
1672# --with-xmlto:	'yes' user instructs the module to use xmlto
1673#		'no' user instructs the module not to use xmlto
1674#
1675# Added in version 1.10.0
1676# HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
1677#                  xmlto for text output requires either lynx, links, or w3m browsers
1678#
1679# If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
1680#
1681AC_DEFUN([XORG_WITH_XMLTO],[
1682AC_ARG_VAR([XMLTO], [Path to xmlto command])
1683m4_define([_defopt], m4_default([$2], [auto]))
1684AC_ARG_WITH(xmlto,
1685	AS_HELP_STRING([--with-xmlto],
1686	   [Use xmlto to regenerate documentation (default: ]_defopt[)]),
1687	   [use_xmlto=$withval], [use_xmlto=]_defopt)
1688m4_undefine([_defopt])
1689
1690if test "x$use_xmlto" = x"auto"; then
1691   AC_PATH_PROG([XMLTO], [xmlto])
1692   if test "x$XMLTO" = "x"; then
1693        AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
1694	have_xmlto=no
1695   else
1696        have_xmlto=yes
1697   fi
1698elif test "x$use_xmlto" = x"yes" ; then
1699   AC_PATH_PROG([XMLTO], [xmlto])
1700   if test "x$XMLTO" = "x"; then
1701        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
1702   fi
1703   have_xmlto=yes
1704elif test "x$use_xmlto" = x"no" ; then
1705   if test "x$XMLTO" != "x"; then
1706      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
1707   fi
1708   have_xmlto=no
1709else
1710   AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
1711fi
1712
1713# Test for a minimum version of xmlto, if provided.
1714m4_ifval([$1],
1715[if test "$have_xmlto" = yes; then
1716    # scrape the xmlto version
1717    AC_MSG_CHECKING([the xmlto version])
1718    xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
1719    AC_MSG_RESULT([$xmlto_version])
1720    AS_VERSION_COMPARE([$xmlto_version], [$1],
1721        [if test "x$use_xmlto" = xauto; then
1722            AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
1723            have_xmlto=no
1724        else
1725            AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
1726        fi])
1727fi])
1728
1729# Test for the ability of xmlto to generate a text target
1730have_xmlto_text=no
1731cat > conftest.xml << "EOF"
1732EOF
1733AS_IF([test "$have_xmlto" = yes],
1734      [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
1735             [have_xmlto_text=yes],
1736             [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])
1737rm -f conftest.xml
1738AM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
1739AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
1740]) # XORG_WITH_XMLTO
1741
1742# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
1743# --------------------------------------------
1744# Minimum version: 1.12.0
1745# Minimum version for optional DEFAULT argument: 1.12.0
1746#
1747# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
1748# XML-based language used for the transformation of XML documents.
1749# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
1750# It is used under the cover by xmlto to generate html files from DocBook/XML.
1751# The XSLT processor is often used as a standalone tool for transformations.
1752# It should not be assumed that this tool is used only to work with documnetation.
1753# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
1754#
1755# Interface to module:
1756# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
1757# XSLTPROC:	 returns the path of the xsltproc program found
1758#		 returns the path set by the user in the environment
1759# --with-xsltproc: 'yes' user instructs the module to use xsltproc
1760#		  'no' user instructs the module not to use xsltproc
1761# have_xsltproc: returns yes if xsltproc found in PATH or no
1762#
1763# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
1764#
1765AC_DEFUN([XORG_WITH_XSLTPROC],[
1766AC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
1767# Preserves the interface, should it be implemented later
1768m4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
1769m4_define([_defopt], m4_default([$2], [auto]))
1770AC_ARG_WITH(xsltproc,
1771	AS_HELP_STRING([--with-xsltproc],
1772	   [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
1773	   [use_xsltproc=$withval], [use_xsltproc=]_defopt)
1774m4_undefine([_defopt])
1775
1776if test "x$use_xsltproc" = x"auto"; then
1777   AC_PATH_PROG([XSLTPROC], [xsltproc])
1778   if test "x$XSLTPROC" = "x"; then
1779        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
1780	have_xsltproc=no
1781   else
1782        have_xsltproc=yes
1783   fi
1784elif test "x$use_xsltproc" = x"yes" ; then
1785   AC_PATH_PROG([XSLTPROC], [xsltproc])
1786   if test "x$XSLTPROC" = "x"; then
1787        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
1788   fi
1789   have_xsltproc=yes
1790elif test "x$use_xsltproc" = x"no" ; then
1791   if test "x$XSLTPROC" != "x"; then
1792      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
1793   fi
1794   have_xsltproc=no
1795else
1796   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
1797fi
1798
1799AM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
1800]) # XORG_WITH_XSLTPROC
1801
1802# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
1803# ----------------------------------------
1804# Minimum version: 1.15.0
1805#
1806# PERL (Practical Extraction and Report Language) is a language optimized for
1807# scanning arbitrary text files, extracting information from those text files,
1808# and printing reports based on that information.
1809#
1810# When DEFAULT is not specified, --with-perl assumes 'auto'.
1811#
1812# Interface to module:
1813# HAVE_PERL: used in makefiles to conditionally scan text files
1814# PERL:	     returns the path of the perl program found
1815#	     returns the path set by the user in the environment
1816# --with-perl: 'yes' user instructs the module to use perl
1817#	       'no' user instructs the module not to use perl
1818# have_perl: returns yes if perl found in PATH or no
1819#
1820# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
1821#
1822AC_DEFUN([XORG_WITH_PERL],[
1823AC_ARG_VAR([PERL], [Path to perl command])
1824# Preserves the interface, should it be implemented later
1825m4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
1826m4_define([_defopt], m4_default([$2], [auto]))
1827AC_ARG_WITH(perl,
1828	AS_HELP_STRING([--with-perl],
1829	   [Use perl for extracting information from files (default: ]_defopt[)]),
1830	   [use_perl=$withval], [use_perl=]_defopt)
1831m4_undefine([_defopt])
1832
1833if test "x$use_perl" = x"auto"; then
1834   AC_PATH_PROG([PERL], [perl])
1835   if test "x$PERL" = "x"; then
1836        AC_MSG_WARN([perl not found - cannot extract information and report])
1837	have_perl=no
1838   else
1839        have_perl=yes
1840   fi
1841elif test "x$use_perl" = x"yes" ; then
1842   AC_PATH_PROG([PERL], [perl])
1843   if test "x$PERL" = "x"; then
1844        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
1845   fi
1846   have_perl=yes
1847elif test "x$use_perl" = x"no" ; then
1848   if test "x$PERL" != "x"; then
1849      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
1850   fi
1851   have_perl=no
1852else
1853   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
1854fi
1855
1856AM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
1857]) # XORG_WITH_PERL
1858
1859# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
1860# ----------------
1861# Minimum version: 1.5.0
1862# Minimum version for optional DEFAULT argument: 1.11.0
1863#
1864# Documentation tools are not always available on all platforms and sometimes
1865# not at the appropriate level. This macro enables a module to test for the
1866# presence of the tool and obtain it's path in separate variables. Coupled with
1867# the --with-asciidoc option, it allows maximum flexibilty in making decisions
1868# as whether or not to use the asciidoc package. When DEFAULT is not specified,
1869# --with-asciidoc assumes 'auto'.
1870#
1871# Interface to module:
1872# HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
1873# ASCIIDOC:	 returns the path of the asciidoc program found
1874#		 returns the path set by the user in the environment
1875# --with-asciidoc: 'yes' user instructs the module to use asciidoc
1876#		  'no' user instructs the module not to use asciidoc
1877#
1878# If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
1879#
1880AC_DEFUN([XORG_WITH_ASCIIDOC],[
1881AC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
1882m4_define([_defopt], m4_default([$2], [auto]))
1883AC_ARG_WITH(asciidoc,
1884	AS_HELP_STRING([--with-asciidoc],
1885	   [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
1886	   [use_asciidoc=$withval], [use_asciidoc=]_defopt)
1887m4_undefine([_defopt])
1888
1889if test "x$use_asciidoc" = x"auto"; then
1890   AC_PATH_PROG([ASCIIDOC], [asciidoc])
1891   if test "x$ASCIIDOC" = "x"; then
1892        AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
1893	have_asciidoc=no
1894   else
1895        have_asciidoc=yes
1896   fi
1897elif test "x$use_asciidoc" = x"yes" ; then
1898   AC_PATH_PROG([ASCIIDOC], [asciidoc])
1899   if test "x$ASCIIDOC" = "x"; then
1900        AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
1901   fi
1902   have_asciidoc=yes
1903elif test "x$use_asciidoc" = x"no" ; then
1904   if test "x$ASCIIDOC" != "x"; then
1905      AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
1906   fi
1907   have_asciidoc=no
1908else
1909   AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
1910fi
1911m4_ifval([$1],
1912[if test "$have_asciidoc" = yes; then
1913    # scrape the asciidoc version
1914    AC_MSG_CHECKING([the asciidoc version])
1915    asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
1916    AC_MSG_RESULT([$asciidoc_version])
1917    AS_VERSION_COMPARE([$asciidoc_version], [$1],
1918        [if test "x$use_asciidoc" = xauto; then
1919            AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
1920            have_asciidoc=no
1921        else
1922            AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
1923        fi])
1924fi])
1925AM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
1926]) # XORG_WITH_ASCIIDOC
1927
1928# XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
1929# -------------------------------------------
1930# Minimum version: 1.5.0
1931# Minimum version for optional DEFAULT argument: 1.11.0
1932# Minimum version for optional DOT checking: 1.18.0
1933#
1934# Documentation tools are not always available on all platforms and sometimes
1935# not at the appropriate level. This macro enables a module to test for the
1936# presence of the tool and obtain it's path in separate variables. Coupled with
1937# the --with-doxygen option, it allows maximum flexibilty in making decisions
1938# as whether or not to use the doxygen package. When DEFAULT is not specified,
1939# --with-doxygen assumes 'auto'.
1940#
1941# Interface to module:
1942# HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
1943# DOXYGEN:	 returns the path of the doxygen program found
1944#		 returns the path set by the user in the environment
1945# --with-doxygen: 'yes' user instructs the module to use doxygen
1946#		  'no' user instructs the module not to use doxygen
1947#
1948# If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
1949#
1950AC_DEFUN([XORG_WITH_DOXYGEN],[
1951AC_ARG_VAR([DOXYGEN], [Path to doxygen command])
1952AC_ARG_VAR([DOT], [Path to the dot graphics utility])
1953m4_define([_defopt], m4_default([$2], [auto]))
1954AC_ARG_WITH(doxygen,
1955	AS_HELP_STRING([--with-doxygen],
1956	   [Use doxygen to regenerate documentation (default: ]_defopt[)]),
1957	   [use_doxygen=$withval], [use_doxygen=]_defopt)
1958m4_undefine([_defopt])
1959
1960if test "x$use_doxygen" = x"auto"; then
1961   AC_PATH_PROG([DOXYGEN], [doxygen])
1962   if test "x$DOXYGEN" = "x"; then
1963        AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
1964	have_doxygen=no
1965   else
1966        have_doxygen=yes
1967   fi
1968elif test "x$use_doxygen" = x"yes" ; then
1969   AC_PATH_PROG([DOXYGEN], [doxygen])
1970   if test "x$DOXYGEN" = "x"; then
1971        AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
1972   fi
1973   have_doxygen=yes
1974elif test "x$use_doxygen" = x"no" ; then
1975   if test "x$DOXYGEN" != "x"; then
1976      AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
1977   fi
1978   have_doxygen=no
1979else
1980   AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
1981fi
1982m4_ifval([$1],
1983[if test "$have_doxygen" = yes; then
1984    # scrape the doxygen version
1985    AC_MSG_CHECKING([the doxygen version])
1986    doxygen_version=`$DOXYGEN --version 2>/dev/null`
1987    AC_MSG_RESULT([$doxygen_version])
1988    AS_VERSION_COMPARE([$doxygen_version], [$1],
1989        [if test "x$use_doxygen" = xauto; then
1990            AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
1991            have_doxygen=no
1992        else
1993            AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
1994        fi])
1995fi])
1996
1997dnl Check for DOT if we have doxygen. The caller decides if it is mandatory
1998dnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
1999dnl 	HAVE_DOT = @HAVE_DOT@
2000HAVE_DOT=no
2001if test "x$have_doxygen" = "xyes"; then
2002  AC_PATH_PROG([DOT], [dot])
2003    if test "x$DOT" != "x"; then
2004      HAVE_DOT=yes
2005    fi
2006fi
2007
2008AC_SUBST([HAVE_DOT])
2009AM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
2010AM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
2011]) # XORG_WITH_DOXYGEN
2012
2013# XORG_WITH_GROFF([DEFAULT])
2014# ----------------
2015# Minimum version: 1.6.0
2016# Minimum version for optional DEFAULT argument: 1.11.0
2017#
2018# Documentation tools are not always available on all platforms and sometimes
2019# not at the appropriate level. This macro enables a module to test for the
2020# presence of the tool and obtain it's path in separate variables. Coupled with
2021# the --with-groff option, it allows maximum flexibilty in making decisions
2022# as whether or not to use the groff package. When DEFAULT is not specified,
2023# --with-groff assumes 'auto'.
2024#
2025# Interface to module:
2026# HAVE_GROFF:	 used in makefiles to conditionally generate documentation
2027# HAVE_GROFF_MM: the memorandum macros (-mm) package
2028# HAVE_GROFF_MS: the -ms macros package
2029# GROFF:	 returns the path of the groff program found
2030#		 returns the path set by the user in the environment
2031# --with-groff:	 'yes' user instructs the module to use groff
2032#		 'no' user instructs the module not to use groff
2033#
2034# Added in version 1.9.0:
2035# HAVE_GROFF_HTML: groff has dependencies to output HTML format:
2036#		   pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
2037#		   psselect from the psutils package.
2038#		   the ghostcript package. Refer to the grohtml man pages
2039#
2040# If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
2041#
2042# OS and distros often splits groff in a basic and full package, the former
2043# having the groff program and the later having devices, fonts and macros
2044# Checking for the groff executable is not enough.
2045#
2046# If macros are missing, we cannot assume that groff is useless, so we don't
2047# unset HAVE_GROFF or GROFF env variables.
2048# HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
2049#
2050AC_DEFUN([XORG_WITH_GROFF],[
2051AC_ARG_VAR([GROFF], [Path to groff command])
2052m4_define([_defopt], m4_default([$1], [auto]))
2053AC_ARG_WITH(groff,
2054	AS_HELP_STRING([--with-groff],
2055	   [Use groff to regenerate documentation (default: ]_defopt[)]),
2056	   [use_groff=$withval], [use_groff=]_defopt)
2057m4_undefine([_defopt])
2058
2059if test "x$use_groff" = x"auto"; then
2060   AC_PATH_PROG([GROFF], [groff])
2061   if test "x$GROFF" = "x"; then
2062        AC_MSG_WARN([groff not found - documentation targets will be skipped])
2063	have_groff=no
2064   else
2065        have_groff=yes
2066   fi
2067elif test "x$use_groff" = x"yes" ; then
2068   AC_PATH_PROG([GROFF], [groff])
2069   if test "x$GROFF" = "x"; then
2070        AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
2071   fi
2072   have_groff=yes
2073elif test "x$use_groff" = x"no" ; then
2074   if test "x$GROFF" != "x"; then
2075      AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
2076   fi
2077   have_groff=no
2078else
2079   AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
2080fi
2081
2082# We have groff, test for the presence of the macro packages
2083if test "x$have_groff" = x"yes"; then
2084    AC_MSG_CHECKING([for ${GROFF} -ms macros])
2085    if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
2086        groff_ms_works=yes
2087    else
2088        groff_ms_works=no
2089    fi
2090    AC_MSG_RESULT([$groff_ms_works])
2091    AC_MSG_CHECKING([for ${GROFF} -mm macros])
2092    if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
2093        groff_mm_works=yes
2094    else
2095        groff_mm_works=no
2096    fi
2097    AC_MSG_RESULT([$groff_mm_works])
2098fi
2099
2100# We have groff, test for HTML dependencies, one command per package
2101if test "x$have_groff" = x"yes"; then
2102   AC_PATH_PROGS(GS_PATH, [gs gswin32c])
2103   AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
2104   AC_PATH_PROG(PSSELECT_PATH, [psselect])
2105   if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
2106      have_groff_html=yes
2107   else
2108      have_groff_html=no
2109      AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
2110   fi
2111fi
2112
2113# Set Automake conditionals for Makefiles
2114AM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
2115AM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
2116AM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
2117AM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
2118]) # XORG_WITH_GROFF
2119
2120# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
2121# ---------------------------------------
2122# Minimum version: 1.6.0
2123# Minimum version for optional DEFAULT argument: 1.11.0
2124# Minimum version for optional MIN-VERSION argument: 1.15.0
2125#
2126# Documentation tools are not always available on all platforms and sometimes
2127# not at the appropriate level. This macro enables a module to test for the
2128# presence of the tool and obtain it's path in separate variables. Coupled with
2129# the --with-fop option, it allows maximum flexibilty in making decisions
2130# as whether or not to use the fop package. When DEFAULT is not specified,
2131# --with-fop assumes 'auto'.
2132#
2133# Interface to module:
2134# HAVE_FOP: 	used in makefiles to conditionally generate documentation
2135# FOP:	 	returns the path of the fop program found
2136#		returns the path set by the user in the environment
2137# --with-fop: 	'yes' user instructs the module to use fop
2138#		'no' user instructs the module not to use fop
2139#
2140# If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
2141#
2142AC_DEFUN([XORG_WITH_FOP],[
2143AC_ARG_VAR([FOP], [Path to fop command])
2144m4_define([_defopt], m4_default([$2], [auto]))
2145AC_ARG_WITH(fop,
2146	AS_HELP_STRING([--with-fop],
2147	   [Use fop to regenerate documentation (default: ]_defopt[)]),
2148	   [use_fop=$withval], [use_fop=]_defopt)
2149m4_undefine([_defopt])
2150
2151if test "x$use_fop" = x"auto"; then
2152   AC_PATH_PROG([FOP], [fop])
2153   if test "x$FOP" = "x"; then
2154        AC_MSG_WARN([fop not found - documentation targets will be skipped])
2155	have_fop=no
2156   else
2157        have_fop=yes
2158   fi
2159elif test "x$use_fop" = x"yes" ; then
2160   AC_PATH_PROG([FOP], [fop])
2161   if test "x$FOP" = "x"; then
2162        AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
2163   fi
2164   have_fop=yes
2165elif test "x$use_fop" = x"no" ; then
2166   if test "x$FOP" != "x"; then
2167      AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
2168   fi
2169   have_fop=no
2170else
2171   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
2172fi
2173
2174# Test for a minimum version of fop, if provided.
2175m4_ifval([$1],
2176[if test "$have_fop" = yes; then
2177    # scrape the fop version
2178    AC_MSG_CHECKING([for fop minimum version])
2179    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
2180    AC_MSG_RESULT([$fop_version])
2181    AS_VERSION_COMPARE([$fop_version], [$1],
2182        [if test "x$use_fop" = xauto; then
2183            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
2184            have_fop=no
2185        else
2186            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
2187        fi])
2188fi])
2189AM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
2190]) # XORG_WITH_FOP
2191
2192# XORG_WITH_M4([MIN-VERSION])
2193# ---------------------------
2194# Minimum version: 1.19.0
2195#
2196# This macro attempts to locate an m4 macro processor which supports
2197# -I option and is only useful for modules relying on M4 in order to
2198# expand macros in source code files.
2199#
2200# Interface to module:
2201# M4:	 	returns the path of the m4 program found
2202#		returns the path set by the user in the environment
2203#
2204AC_DEFUN([XORG_WITH_M4], [
2205AC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
2206   [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
2207       [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
2208         ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
2209   [AC_MSG_ERROR([could not find m4 that supports -I option])],
2210   [$PATH:/usr/gnu/bin])])
2211
2212AC_SUBST([M4], [$ac_cv_path_M4])
2213]) # XORG_WITH_M4
2214
2215# XORG_WITH_PS2PDF([DEFAULT])
2216# ----------------
2217# Minimum version: 1.6.0
2218# Minimum version for optional DEFAULT argument: 1.11.0
2219#
2220# Documentation tools are not always available on all platforms and sometimes
2221# not at the appropriate level. This macro enables a module to test for the
2222# presence of the tool and obtain it's path in separate variables. Coupled with
2223# the --with-ps2pdf option, it allows maximum flexibilty in making decisions
2224# as whether or not to use the ps2pdf package. When DEFAULT is not specified,
2225# --with-ps2pdf assumes 'auto'.
2226#
2227# Interface to module:
2228# HAVE_PS2PDF: 	used in makefiles to conditionally generate documentation
2229# PS2PDF:	returns the path of the ps2pdf program found
2230#		returns the path set by the user in the environment
2231# --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
2232#		 'no' user instructs the module not to use ps2pdf
2233#
2234# If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
2235#
2236AC_DEFUN([XORG_WITH_PS2PDF],[
2237AC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
2238m4_define([_defopt], m4_default([$1], [auto]))
2239AC_ARG_WITH(ps2pdf,
2240	AS_HELP_STRING([--with-ps2pdf],
2241	   [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
2242	   [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
2243m4_undefine([_defopt])
2244
2245if test "x$use_ps2pdf" = x"auto"; then
2246   AC_PATH_PROG([PS2PDF], [ps2pdf])
2247   if test "x$PS2PDF" = "x"; then
2248        AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
2249	have_ps2pdf=no
2250   else
2251        have_ps2pdf=yes
2252   fi
2253elif test "x$use_ps2pdf" = x"yes" ; then
2254   AC_PATH_PROG([PS2PDF], [ps2pdf])
2255   if test "x$PS2PDF" = "x"; then
2256        AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
2257   fi
2258   have_ps2pdf=yes
2259elif test "x$use_ps2pdf" = x"no" ; then
2260   if test "x$PS2PDF" != "x"; then
2261      AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
2262   fi
2263   have_ps2pdf=no
2264else
2265   AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
2266fi
2267AM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
2268]) # XORG_WITH_PS2PDF
2269
2270# XORG_ENABLE_DOCS (enable_docs=yes)
2271# ----------------
2272# Minimum version: 1.6.0
2273#
2274# Documentation tools are not always available on all platforms and sometimes
2275# not at the appropriate level. This macro enables a builder to skip all
2276# documentation targets except traditional man pages.
2277# Combined with the specific tool checking macros XORG_WITH_*, it provides
2278# maximum flexibilty in controlling documentation building.
2279# Refer to:
2280# XORG_WITH_XMLTO         --with-xmlto
2281# XORG_WITH_ASCIIDOC      --with-asciidoc
2282# XORG_WITH_DOXYGEN       --with-doxygen
2283# XORG_WITH_FOP           --with-fop
2284# XORG_WITH_GROFF         --with-groff
2285# XORG_WITH_PS2PDF        --with-ps2pdf
2286#
2287# Interface to module:
2288# ENABLE_DOCS: 	  used in makefiles to conditionally generate documentation
2289# --enable-docs: 'yes' user instructs the module to generate docs
2290#		 'no' user instructs the module not to generate docs
2291# parm1:	specify the default value, yes or no.
2292#
2293AC_DEFUN([XORG_ENABLE_DOCS],[
2294m4_define([docs_default], m4_default([$1], [yes]))
2295AC_ARG_ENABLE(docs,
2296	AS_HELP_STRING([--enable-docs],
2297	   [Enable building the documentation (default: ]docs_default[)]),
2298	   [build_docs=$enableval], [build_docs=]docs_default)
2299m4_undefine([docs_default])
2300AM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
2301AC_MSG_CHECKING([whether to build documentation])
2302AC_MSG_RESULT([$build_docs])
2303]) # XORG_ENABLE_DOCS
2304
2305# XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
2306# ----------------
2307# Minimum version: 1.6.0
2308#
2309# This macro enables a builder to skip all developer documentation.
2310# Combined with the specific tool checking macros XORG_WITH_*, it provides
2311# maximum flexibilty in controlling documentation building.
2312# Refer to:
2313# XORG_WITH_XMLTO         --with-xmlto
2314# XORG_WITH_ASCIIDOC      --with-asciidoc
2315# XORG_WITH_DOXYGEN       --with-doxygen
2316# XORG_WITH_FOP           --with-fop
2317# XORG_WITH_GROFF         --with-groff
2318# XORG_WITH_PS2PDF        --with-ps2pdf
2319#
2320# Interface to module:
2321# ENABLE_DEVEL_DOCS:	used in makefiles to conditionally generate developer docs
2322# --enable-devel-docs:	'yes' user instructs the module to generate developer docs
2323#			'no' user instructs the module not to generate developer docs
2324# parm1:		specify the default value, yes or no.
2325#
2326AC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
2327m4_define([devel_default], m4_default([$1], [yes]))
2328AC_ARG_ENABLE(devel-docs,
2329	AS_HELP_STRING([--enable-devel-docs],
2330	   [Enable building the developer documentation (default: ]devel_default[)]),
2331	   [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
2332m4_undefine([devel_default])
2333AM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
2334AC_MSG_CHECKING([whether to build developer documentation])
2335AC_MSG_RESULT([$build_devel_docs])
2336]) # XORG_ENABLE_DEVEL_DOCS
2337
2338# XORG_ENABLE_SPECS (enable_specs=yes)
2339# ----------------
2340# Minimum version: 1.6.0
2341#
2342# This macro enables a builder to skip all functional specification targets.
2343# Combined with the specific tool checking macros XORG_WITH_*, it provides
2344# maximum flexibilty in controlling documentation building.
2345# Refer to:
2346# XORG_WITH_XMLTO         --with-xmlto
2347# XORG_WITH_ASCIIDOC      --with-asciidoc
2348# XORG_WITH_DOXYGEN       --with-doxygen
2349# XORG_WITH_FOP           --with-fop
2350# XORG_WITH_GROFF         --with-groff
2351# XORG_WITH_PS2PDF        --with-ps2pdf
2352#
2353# Interface to module:
2354# ENABLE_SPECS:		used in makefiles to conditionally generate specs
2355# --enable-specs:	'yes' user instructs the module to generate specs
2356#			'no' user instructs the module not to generate specs
2357# parm1:		specify the default value, yes or no.
2358#
2359AC_DEFUN([XORG_ENABLE_SPECS],[
2360m4_define([spec_default], m4_default([$1], [yes]))
2361AC_ARG_ENABLE(specs,
2362	AS_HELP_STRING([--enable-specs],
2363	   [Enable building the specs (default: ]spec_default[)]),
2364	   [build_specs=$enableval], [build_specs=]spec_default)
2365m4_undefine([spec_default])
2366AM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
2367AC_MSG_CHECKING([whether to build functional specifications])
2368AC_MSG_RESULT([$build_specs])
2369]) # XORG_ENABLE_SPECS
2370
2371# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
2372# ----------------------------------------------
2373# Minimum version: 1.13.0
2374#
2375# This macro enables a builder to enable/disable unit testing
2376# It makes no assumption about the test cases implementation
2377# Test cases may or may not use Automake "Support for test suites"
2378# They may or may not use the software utility library GLib
2379#
2380# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
2381# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
2382# The variable enable_unit_tests is used by other macros in this file.
2383#
2384# Interface to module:
2385# ENABLE_UNIT_TESTS:	used in makefiles to conditionally build tests
2386# enable_unit_tests:    used in configure.ac for additional configuration
2387# --enable-unit-tests:	'yes' user instructs the module to build tests
2388#			'no' user instructs the module not to build tests
2389# parm1:		specify the default value, yes or no.
2390#
2391AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
2392AC_BEFORE([$0], [XORG_WITH_GLIB])
2393AC_BEFORE([$0], [XORG_LD_WRAP])
2394AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
2395m4_define([_defopt], m4_default([$1], [auto]))
2396AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
2397	[Enable building unit test cases (default: ]_defopt[)]),
2398	[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
2399m4_undefine([_defopt])
2400AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
2401AC_MSG_CHECKING([whether to build unit test cases])
2402AC_MSG_RESULT([$enable_unit_tests])
2403]) # XORG_ENABLE_UNIT_TESTS
2404
2405# XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
2406# ------------------------------------------------------
2407# Minimum version: 1.17.0
2408#
2409# This macro enables a builder to enable/disable integration testing
2410# It makes no assumption about the test cases' implementation
2411# Test cases may or may not use Automake "Support for test suites"
2412#
2413# Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
2414# usually requires less dependencies and may be built and run under less
2415# stringent environments than integration tests.
2416#
2417# Interface to module:
2418# ENABLE_INTEGRATION_TESTS:   used in makefiles to conditionally build tests
2419# enable_integration_tests:   used in configure.ac for additional configuration
2420# --enable-integration-tests: 'yes' user instructs the module to build tests
2421#                             'no' user instructs the module not to build tests
2422# parm1:                      specify the default value, yes or no.
2423#
2424AC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
2425AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
2426m4_define([_defopt], m4_default([$1], [auto]))
2427AC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
2428	[Enable building integration test cases (default: ]_defopt[)]),
2429	[enable_integration_tests=$enableval],
2430	[enable_integration_tests=]_defopt)
2431m4_undefine([_defopt])
2432AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
2433	[test "x$enable_integration_tests" != xno])
2434AC_MSG_CHECKING([whether to build unit test cases])
2435AC_MSG_RESULT([$enable_integration_tests])
2436]) # XORG_ENABLE_INTEGRATION_TESTS
2437
2438# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
2439# ----------------------------------------
2440# Minimum version: 1.13.0
2441#
2442# GLib is a library which provides advanced data structures and functions.
2443# This macro enables a module to test for the presence of Glib.
2444#
2445# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
2446# Otherwise the value of $enable_unit_tests is blank.
2447#
2448# Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
2449# test support usually requires less dependencies and may be built and run under
2450# less stringent environments than integration tests.
2451#
2452# Interface to module:
2453# HAVE_GLIB: used in makefiles to conditionally build targets
2454# with_glib: used in configure.ac to know if GLib has been found
2455# --with-glib:	'yes' user instructs the module to use glib
2456#		'no' user instructs the module not to use glib
2457#
2458AC_DEFUN([XORG_WITH_GLIB],[
2459AC_REQUIRE([PKG_PROG_PKG_CONFIG])
2460m4_define([_defopt], m4_default([$2], [auto]))
2461AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
2462	[Use GLib library for unit testing (default: ]_defopt[)]),
2463	[with_glib=$withval], [with_glib=]_defopt)
2464m4_undefine([_defopt])
2465
2466have_glib=no
2467# Do not probe GLib if user explicitly disabled unit testing
2468if test "x$enable_unit_tests" != x"no"; then
2469  # Do not probe GLib if user explicitly disabled it
2470  if test "x$with_glib" != x"no"; then
2471    m4_ifval(
2472      [$1],
2473      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
2474      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
2475    )
2476  fi
2477fi
2478
2479# Not having GLib when unit testing has been explicitly requested is an error
2480if test "x$enable_unit_tests" = x"yes"; then
2481  if test "x$have_glib" = x"no"; then
2482    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
2483  fi
2484fi
2485
2486# Having unit testing disabled when GLib has been explicitly requested is an error
2487if test "x$enable_unit_tests" = x"no"; then
2488  if test "x$with_glib" = x"yes"; then
2489    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
2490  fi
2491fi
2492
2493# Not having GLib when it has been explicitly requested is an error
2494if test "x$with_glib" = x"yes"; then
2495  if test "x$have_glib" = x"no"; then
2496    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
2497  fi
2498fi
2499
2500AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
2501]) # XORG_WITH_GLIB
2502
2503# XORG_LD_WRAP([required|optional])
2504# ---------------------------------
2505# Minimum version: 1.13.0
2506#
2507# Check if linker supports -wrap, passed via compiler flags
2508#
2509# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
2510# Otherwise the value of $enable_unit_tests is blank.
2511#
2512# Argument added in 1.16.0 - default is "required", to match existing behavior
2513# of returning an error if enable_unit_tests is yes, and ld -wrap is not
2514# available, an argument of "optional" allows use when some unit tests require
2515# ld -wrap and others do not.
2516#
2517AC_DEFUN([XORG_LD_WRAP],[
2518XORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
2519    [AC_LANG_PROGRAM([#include <stdlib.h>
2520                      void __wrap_exit(int status) { return; }],
2521                     [exit(0);])])
2522# Not having ld wrap when unit testing has been explicitly requested is an error
2523if test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
2524  if test "x$have_ld_wrap" = x"no"; then
2525    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
2526  fi
2527fi
2528AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
2529#
2530]) # XORG_LD_WRAP
2531
2532# XORG_CHECK_LINKER_FLAGS
2533# -----------------------
2534# SYNOPSIS
2535#
2536#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
2537#
2538# DESCRIPTION
2539#
2540#   Check whether the given linker FLAGS work with the current language's
2541#   linker, or whether they give an error.
2542#
2543#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
2544#   success/failure.
2545#
2546#   PROGRAM-SOURCE is the program source to link with, if needed
2547#
2548#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
2549#
2550# LICENSE
2551#
2552#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
2553#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
2554#   Copyright (c) 2009 Matteo Frigo
2555#
2556#   This program is free software: you can redistribute it and/or modify it
2557#   under the terms of the GNU General Public License as published by the
2558#   Free Software Foundation, either version 3 of the License, or (at your
2559#   option) any later version.
2560#
2561#   This program is distributed in the hope that it will be useful, but
2562#   WITHOUT ANY WARRANTY; without even the implied warranty of
2563#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
2564#   Public License for more details.
2565#
2566#   You should have received a copy of the GNU General Public License along
2567#   with this program. If not, see <http://www.gnu.org/licenses/>.
2568#
2569#   As a special exception, the respective Autoconf Macro's copyright owner
2570#   gives unlimited permission to copy, distribute and modify the configure
2571#   scripts that are the output of Autoconf when processing the Macro. You
2572#   need not follow the terms of the GNU General Public License when using
2573#   or distributing such scripts, even though portions of the text of the
2574#   Macro appear in them. The GNU General Public License (GPL) does govern
2575#   all other use of the material that constitutes the Autoconf Macro.
2576#
2577#   This special exception to the GPL applies to versions of the Autoconf
2578#   Macro released by the Autoconf Archive. When you make and distribute a
2579#   modified version of the Autoconf Macro, you may extend this special
2580#   exception to the GPL to apply to your modified version as well.#
2581AC_DEFUN([XORG_CHECK_LINKER_FLAGS],
2582[AC_MSG_CHECKING([whether the linker accepts $1])
2583dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
2584AS_LITERAL_IF([$1],
2585  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
2586      ax_save_FLAGS=$LDFLAGS
2587      LDFLAGS="$1"
2588      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
2589        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
2590        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
2591      LDFLAGS=$ax_save_FLAGS])],
2592  [ax_save_FLAGS=$LDFLAGS
2593   LDFLAGS="$1"
2594   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
2595     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
2596     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
2597   LDFLAGS=$ax_save_FLAGS])
2598eval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
2599AC_MSG_RESULT($xorg_check_linker_flags)
2600if test "x$xorg_check_linker_flags" = xyes; then
2601	m4_default([$2], :)
2602else
2603	m4_default([$3], :)
2604fi
2605]) # XORG_CHECK_LINKER_FLAGS
2606
2607# XORG_MEMORY_CHECK_FLAGS
2608# -----------------------
2609# Minimum version: 1.16.0
2610#
2611# This macro attempts to find appropriate memory checking functionality
2612# for various platforms which unit testing code may use to catch various
2613# forms of memory allocation and access errors in testing.
2614#
2615# Interface to module:
2616# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
2617#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
2618#
2619# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
2620#
2621AC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
2622
2623AC_REQUIRE([AC_CANONICAL_HOST])
2624AC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
2625           [Environment variables to enable memory checking in tests])
2626
2627# Check for different types of support on different platforms
2628case $host_os in
2629    solaris*)
2630        AC_CHECK_LIB([umem], [umem_alloc],
2631            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
2632        ;;
2633    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
2634        # both directly and inverted, so should not be 0 or 255.
2635        malloc_debug_env='MALLOC_PERTURB_=15'
2636        ;;
2637    darwin*)
2638        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
2639        ;;
2640    *bsd*)
2641        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
2642        ;;
2643esac
2644
2645# User supplied flags override default flags
2646if test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
2647    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
2648fi
2649
2650AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
2651]) # XORG_WITH_LINT
2652
2653# XORG_CHECK_MALLOC_ZERO
2654# ----------------------
2655# Minimum version: 1.0.0
2656#
2657# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
2658# malloc(0) returns NULL.  Packages should add one of these cflags to
2659# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
2660AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
2661AC_ARG_ENABLE(malloc0returnsnull,
2662	AS_HELP_STRING([--enable-malloc0returnsnull],
2663		       [malloc(0) returns NULL (default: auto)]),
2664	[MALLOC_ZERO_RETURNS_NULL=$enableval],
2665	[MALLOC_ZERO_RETURNS_NULL=auto])
2666
2667AC_MSG_CHECKING([whether malloc(0) returns NULL])
2668if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
2669AC_CACHE_VAL([xorg_cv_malloc0_returns_null],
2670	[AC_RUN_IFELSE([AC_LANG_PROGRAM([
2671#include <stdlib.h>
2672],[
2673    char *m0, *r0, *c0, *p;
2674    m0 = malloc(0);
2675    p = malloc(10);
2676    r0 = realloc(p,0);
2677    c0 = calloc(0,10);
2678    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
2679])],
2680		[xorg_cv_malloc0_returns_null=yes],
2681		[xorg_cv_malloc0_returns_null=no])])
2682MALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null
2683fi
2684AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
2685
2686if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
2687	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
2688	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
2689	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
2690else
2691	MALLOC_ZERO_CFLAGS=""
2692	XMALLOC_ZERO_CFLAGS=""
2693	XTMALLOC_ZERO_CFLAGS=""
2694fi
2695
2696AC_SUBST([MALLOC_ZERO_CFLAGS])
2697AC_SUBST([XMALLOC_ZERO_CFLAGS])
2698AC_SUBST([XTMALLOC_ZERO_CFLAGS])
2699]) # XORG_CHECK_MALLOC_ZERO
2700
2701# XORG_WITH_LINT()
2702# ----------------
2703# Minimum version: 1.1.0
2704#
2705# This macro enables the use of a tool that flags some suspicious and
2706# non-portable constructs (likely to be bugs) in C language source code.
2707# It will attempt to locate the tool and use appropriate options.
2708# There are various lint type tools on different platforms.
2709#
2710# Interface to module:
2711# LINT:		returns the path to the tool found on the platform
2712#		or the value set to LINT on the configure cmd line
2713#		also an Automake conditional
2714# LINT_FLAGS:	an Automake variable with appropriate flags
2715#
2716# --with-lint:	'yes' user instructs the module to use lint
2717#		'no' user instructs the module not to use lint (default)
2718#
2719# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
2720# If the user sets the value of LINT_FLAGS, they are used verbatim.
2721#
2722AC_DEFUN([XORG_WITH_LINT],[
2723
2724AC_ARG_VAR([LINT], [Path to a lint-style command])
2725AC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
2726AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
2727		[Use a lint-style source code checker (default: disabled)])],
2728		[use_lint=$withval], [use_lint=no])
2729
2730# Obtain platform specific info like program name and options
2731# The lint program on FreeBSD and NetBSD is different from the one on Solaris
2732case $host_os in
2733  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
2734	lint_name=splint
2735	lint_options="-badflag"
2736	;;
2737  *freebsd* | *netbsd*)
2738	lint_name=lint
2739	lint_options="-u -b"
2740	;;
2741  *solaris*)
2742	lint_name=lint
2743	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
2744	;;
2745esac
2746
2747# Test for the presence of the program (either guessed by the code or spelled out by the user)
2748if test "x$use_lint" = x"yes" ; then
2749   AC_PATH_PROG([LINT], [$lint_name])
2750   if test "x$LINT" = "x"; then
2751        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
2752   fi
2753elif test "x$use_lint" = x"no" ; then
2754   if test "x$LINT" != "x"; then
2755      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
2756   fi
2757else
2758   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
2759fi
2760
2761# User supplied flags override default flags
2762if test "x$LINT_FLAGS" != "x"; then
2763   lint_options=$LINT_FLAGS
2764fi
2765
2766AC_SUBST([LINT_FLAGS],[$lint_options])
2767AM_CONDITIONAL(LINT, [test "x$LINT" != x])
2768
2769]) # XORG_WITH_LINT
2770
2771# XORG_LINT_LIBRARY(LIBNAME)
2772# --------------------------
2773# Minimum version: 1.1.0
2774#
2775# Sets up flags for building lint libraries for checking programs that call
2776# functions in the library.
2777#
2778# Interface to module:
2779# LINTLIB		- Automake variable with the name of lint library file to make
2780# MAKE_LINT_LIB		- Automake conditional
2781#
2782# --enable-lint-library:  - 'yes' user instructs the module to created a lint library
2783#			  - 'no' user instructs the module not to create a lint library (default)
2784
2785AC_DEFUN([XORG_LINT_LIBRARY],[
2786AC_REQUIRE([XORG_WITH_LINT])
2787AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
2788	[Create lint library (default: disabled)])],
2789	[make_lint_lib=$enableval], [make_lint_lib=no])
2790
2791if test "x$make_lint_lib" = x"yes" ; then
2792   LINTLIB=llib-l$1.ln
2793   if test "x$LINT" = "x"; then
2794        AC_MSG_ERROR([Cannot make lint library without --with-lint])
2795   fi
2796elif test "x$make_lint_lib" != x"no" ; then
2797   AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
2798fi
2799
2800AC_SUBST(LINTLIB)
2801AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
2802
2803]) # XORG_LINT_LIBRARY
2804
2805# XORG_COMPILER_BRAND
2806# -------------------
2807# Minimum version: 1.14.0
2808#
2809# Checks for various brands of compilers and sets flags as appropriate:
2810#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
2811#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
2812#   clang compiler - sets CLANGCC to "yes"
2813#   Intel compiler - sets INTELCC to "yes"
2814#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
2815#
2816AC_DEFUN([XORG_COMPILER_BRAND], [
2817AC_LANG_CASE(
2818	[C], [
2819		AC_REQUIRE([AC_PROG_CC_C99])
2820	],
2821	[C++], [
2822		AC_REQUIRE([AC_PROG_CXX])
2823	]
2824)
2825AC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
2826AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
2827AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
2828]) # XORG_COMPILER_BRAND
2829
2830# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
2831# ---------------
2832# Minimum version: 1.16.0
2833#
2834# Test if the compiler works when passed the given flag as a command line argument.
2835# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
2836# next flag in the list until there are no more options.
2837#
2838# Note that this does not guarantee that the compiler supports the flag as some
2839# compilers will simply ignore arguments that they do not understand, but we do
2840# attempt to weed out false positives by using -Werror=unknown-warning-option and
2841# -Werror=unused-command-line-argument
2842#
2843AC_DEFUN([XORG_TESTSET_CFLAG], [
2844m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
2845m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
2846
2847AC_LANG_COMPILER_REQUIRE
2848
2849AC_LANG_CASE(
2850	[C], [
2851		AC_REQUIRE([AC_PROG_CC_C99])
2852		define([PREFIX], [C])
2853		define([CACHE_PREFIX], [cc])
2854		define([COMPILER], [$CC])
2855	],
2856	[C++], [
2857		define([PREFIX], [CXX])
2858		define([CACHE_PREFIX], [cxx])
2859		define([COMPILER], [$CXX])
2860	]
2861)
2862
2863[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
2864
2865if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
2866	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
2867	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
2868			[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
2869			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
2870					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
2871					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
2872	[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
2873	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
2874fi
2875
2876if test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
2877	if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
2878		PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
2879	fi
2880	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
2881	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
2882			[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
2883			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
2884					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
2885					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
2886	[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
2887	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
2888fi
2889
2890found="no"
2891m4_foreach([flag], m4_cdr($@), [
2892	if test $found = "no" ; then
2893		if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
2894			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
2895		fi
2896
2897		if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
2898			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
2899		fi
2900
2901		PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
2902
2903dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
2904		AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
2905		cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
2906		AC_CACHE_VAL($cacheid,
2907			     [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
2908					     [eval $cacheid=yes],
2909					     [eval $cacheid=no])])
2910
2911		PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
2912
2913		eval supported=\$$cacheid
2914		AC_MSG_RESULT([$supported])
2915		if test "$supported" = "yes" ; then
2916			$1="$$1 ]flag["
2917			found="yes"
2918		fi
2919	fi
2920])
2921]) # XORG_TESTSET_CFLAG
2922
2923# XORG_COMPILER_FLAGS
2924# ---------------
2925# Minimum version: 1.16.0
2926#
2927# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
2928# arguments supported by the selected compiler which do NOT alter the generated
2929# code.  These arguments will cause the compiler to print various warnings
2930# during compilation AND turn a conservative set of warnings into errors.
2931#
2932# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
2933# future versions of util-macros as options are added to new compilers.
2934#
2935AC_DEFUN([XORG_COMPILER_FLAGS], [
2936AC_REQUIRE([XORG_COMPILER_BRAND])
2937
2938AC_ARG_ENABLE(selective-werror,
2939              AS_HELP_STRING([--disable-selective-werror],
2940                             [Turn off selective compiler errors. (default: enabled)]),
2941              [SELECTIVE_WERROR=$enableval],
2942              [SELECTIVE_WERROR=yes])
2943
2944AC_LANG_CASE(
2945        [C], [
2946                define([PREFIX], [C])
2947        ],
2948        [C++], [
2949                define([PREFIX], [CXX])
2950        ]
2951)
2952# -v is too short to test reliably with XORG_TESTSET_CFLAG
2953if test "x$SUNCC" = "xyes"; then
2954    [BASE_]PREFIX[FLAGS]="-v"
2955else
2956    [BASE_]PREFIX[FLAGS]=""
2957fi
2958
2959# This chunk of warnings were those that existed in the legacy CWARNFLAGS
2960XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
2961XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
2962XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
2963XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
2964
2965AC_LANG_CASE(
2966	[C], [
2967		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
2968		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
2969		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
2970		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
2971		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
2972		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
2973	]
2974)
2975
2976# This chunk adds additional warnings that could catch undesired effects.
2977XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
2978XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
2979XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
2980XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
2981XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
2982XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
2983XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
2984
2985# These are currently disabled because they are noisy.  They will be enabled
2986# in the future once the codebase is sufficiently modernized to silence
2987# them.  For now, I don't want them to drown out the other warnings.
2988# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
2989# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
2990# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
2991
2992# Turn some warnings into errors, so we don't accidently get successful builds
2993# when there are problems that should be fixed.
2994
2995if test "x$SELECTIVE_WERROR" = "xyes" ; then
2996XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
2997XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
2998XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
2999XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
3000XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
3001XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
3002XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
3003XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
3004XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
3005XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
3006XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
3007XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
3008XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
3009else
3010AC_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])
3011XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
3012XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
3013XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
3014XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
3015XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
3016XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
3017XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
3018XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
3019XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
3020XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
3021XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
3022XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
3023XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
3024fi
3025
3026AC_SUBST([BASE_]PREFIX[FLAGS])
3027]) # XORG_COMPILER_FLAGS
3028
3029# XORG_CWARNFLAGS
3030# ---------------
3031# Minimum version: 1.2.0
3032# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
3033#
3034# Defines CWARNFLAGS to enable C compiler warnings.
3035#
3036# This function is deprecated because it defines -fno-strict-aliasing
3037# which alters the code generated by the compiler.  If -fno-strict-aliasing
3038# is needed, then it should be added explicitly in the module when
3039# it is updated to use BASE_CFLAGS.
3040#
3041AC_DEFUN([XORG_CWARNFLAGS], [
3042AC_REQUIRE([XORG_COMPILER_FLAGS])
3043AC_REQUIRE([XORG_COMPILER_BRAND])
3044AC_LANG_CASE(
3045	[C], [
3046		CWARNFLAGS="$BASE_CFLAGS"
3047		if  test "x$GCC" = xyes ; then
3048		    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
3049		fi
3050		AC_SUBST(CWARNFLAGS)
3051	]
3052)
3053]) # XORG_CWARNFLAGS
3054
3055# XORG_STRICT_OPTION
3056# -----------------------
3057# Minimum version: 1.3.0
3058#
3059# Add configure option to enable strict compilation flags, such as treating
3060# warnings as fatal errors.
3061# If --enable-strict-compilation is passed to configure, adds strict flags to
3062# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
3063#
3064# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
3065# when strict compilation is unconditionally desired.
3066AC_DEFUN([XORG_STRICT_OPTION], [
3067AC_REQUIRE([XORG_CWARNFLAGS])
3068AC_REQUIRE([XORG_COMPILER_FLAGS])
3069
3070AC_ARG_ENABLE(strict-compilation,
3071			  AS_HELP_STRING([--enable-strict-compilation],
3072			  [Enable all warnings from compiler and make them errors (default: disabled)]),
3073			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
3074
3075AC_LANG_CASE(
3076        [C], [
3077                define([PREFIX], [C])
3078        ],
3079        [C++], [
3080                define([PREFIX], [CXX])
3081        ]
3082)
3083
3084[STRICT_]PREFIX[FLAGS]=""
3085XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
3086XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
3087
3088# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
3089# activate it with -Werror, so we add it here explicitly.
3090XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
3091
3092if test "x$STRICT_COMPILE" = "xyes"; then
3093    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
3094    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
3095fi
3096AC_SUBST([STRICT_]PREFIX[FLAGS])
3097AC_SUBST([BASE_]PREFIX[FLAGS])
3098AC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
3099]) # XORG_STRICT_OPTION
3100
3101# XORG_DEFAULT_OPTIONS
3102# --------------------
3103# Minimum version: 1.3.0
3104#
3105# Defines default options for X.Org modules.
3106#
3107AC_DEFUN([XORG_DEFAULT_OPTIONS], [
3108AC_REQUIRE([AC_PROG_INSTALL])
3109XORG_COMPILER_FLAGS
3110XORG_CWARNFLAGS
3111XORG_STRICT_OPTION
3112XORG_RELEASE_VERSION
3113XORG_CHANGELOG
3114XORG_INSTALL
3115XORG_MANPAGE_SECTIONS
3116m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
3117    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
3118]) # XORG_DEFAULT_OPTIONS
3119
3120# XORG_INSTALL()
3121# ----------------
3122# Minimum version: 1.4.0
3123#
3124# Defines the variable INSTALL_CMD as the command to copy
3125# INSTALL from $prefix/share/util-macros.
3126#
3127AC_DEFUN([XORG_INSTALL], [
3128AC_REQUIRE([PKG_PROG_PKG_CONFIG])
3129macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
3130INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
3131mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
3132|| (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \
3133echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
3134AC_SUBST([INSTALL_CMD])
3135]) # XORG_INSTALL
3136dnl Copyright 2005 Red Hat, Inc
3137dnl
3138dnl Permission to use, copy, modify, distribute, and sell this software and its
3139dnl documentation for any purpose is hereby granted without fee, provided that
3140dnl the above copyright notice appear in all copies and that both that
3141dnl copyright notice and this permission notice appear in supporting
3142dnl documentation.
3143dnl
3144dnl The above copyright notice and this permission notice shall be included
3145dnl in all copies or substantial portions of the Software.
3146dnl
3147dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3148dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3149dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
3150dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
3151dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
3152dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3153dnl OTHER DEALINGS IN THE SOFTWARE.
3154dnl
3155dnl Except as contained in this notice, the name of the copyright holders shall
3156dnl not be used in advertising or otherwise to promote the sale, use or
3157dnl other dealings in this Software without prior written authorization
3158dnl from the copyright holders.
3159dnl
3160
3161# XORG_RELEASE_VERSION
3162# --------------------
3163# Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use.
3164
3165AC_DEFUN([XORG_RELEASE_VERSION],[
3166	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
3167		[`echo $PACKAGE_VERSION | cut -d . -f 1`],
3168		[Major version of this package])
3169	PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1`
3170	if test "x$PVM" = "x"; then
3171		PVM="0"
3172	fi
3173	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
3174		[$PVM],
3175		[Minor version of this package])
3176	PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1`
3177	if test "x$PVP" = "x"; then
3178		PVP="0"
3179	fi
3180	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
3181		[$PVP],
3182		[Patch version of this package])
3183])
3184
3185# XORG_CHANGELOG()
3186# ----------------
3187# Minimum version: 1.2.0
3188#
3189# Defines the variable CHANGELOG_CMD as the command to generate
3190# ChangeLog from git.
3191#
3192#
3193AC_DEFUN([XORG_CHANGELOG], [
3194CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp && \
3195mv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
3196|| (rm -f \$(top_srcdir)/.changelog.tmp; touch \$(top_srcdir)/ChangeLog; \
3197echo 'git directory not found: installing possibly empty changelog.' >&2)"
3198AC_SUBST([CHANGELOG_CMD])
3199]) # XORG_CHANGELOG
3200
3201