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