aclocal.m4 revision e1db7cd1
1# generated automatically by aclocal 1.17 -*- Autoconf -*-
2
3# Copyright (C) 1996-2024 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.72],,
18[m4_warning([this file was generated for autoconf 2.72.
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-2024 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.17'
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.17], [],
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.17])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-2024 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-2024 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-2024 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 thus:
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-2024 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# _AM_OUTPUT_DEPENDENCY_COMMANDS
342# ------------------------------
343AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
344[{
345  # Older Autoconf quotes --file arguments for eval, but not when files
346  # are listed without --file.  Let's play safe and only enable the eval
347  # if we detect the quoting.
348  # TODO: see whether this extra hack can be removed once we start
349  # requiring Autoconf 2.70 or later.
350  AS_CASE([$CONFIG_FILES],
351          [*\'*], [eval set x "$CONFIG_FILES"],
352          [*], [set x $CONFIG_FILES])
353  shift
354  # Used to flag and report bootstrapping failures.
355  am_rc=0
356  for am_mf
357  do
358    # Strip MF so we end up with the name of the file.
359    am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'`
360    # Check whether this is an Automake generated Makefile which includes
361    # dependency-tracking related rules and includes.
362    # Grep'ing the whole file directly is not great: AIX grep has a line
363    # limit of 2048, but all sed's we know have understand at least 4000.
364    sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
365      || continue
366    am_dirpart=`AS_DIRNAME(["$am_mf"])`
367    am_filepart=`AS_BASENAME(["$am_mf"])`
368    AM_RUN_LOG([cd "$am_dirpart" \
369      && sed -e '/# am--include-marker/d' "$am_filepart" \
370        | $MAKE -f - am--depfiles]) || am_rc=$?
371  done
372  if test $am_rc -ne 0; then
373    AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
374    for automatic dependency tracking.  If GNU make was not used, consider
375    re-running the configure script with MAKE="gmake" (or whatever is
376    necessary).  You can also try re-running configure with the
377    '--disable-dependency-tracking' option to at least be able to build
378    the package (albeit without support for automatic dependency tracking).])
379  fi
380  AS_UNSET([am_dirpart])
381  AS_UNSET([am_filepart])
382  AS_UNSET([am_mf])
383  AS_UNSET([am_rc])
384  rm -f conftest-deps.mk
385}
386])# _AM_OUTPUT_DEPENDENCY_COMMANDS
387
388
389# AM_OUTPUT_DEPENDENCY_COMMANDS
390# -----------------------------
391# This macro should only be invoked once -- use via AC_REQUIRE.
392#
393# This code is only required when automatic dependency tracking is enabled.
394# This creates each '.Po' and '.Plo' makefile fragment that we'll need in
395# order to bootstrap the dependency handling code.
396AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
397[AC_CONFIG_COMMANDS([depfiles],
398     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
399     [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
400
401# Do all the work for Automake.                             -*- Autoconf -*-
402
403# Copyright (C) 1996-2024 Free Software Foundation, Inc.
404#
405# This file is free software; the Free Software Foundation
406# gives unlimited permission to copy and/or distribute it,
407# with or without modifications, as long as this notice is preserved.
408
409# This macro actually does too much.  Some checks are only needed if
410# your package does certain things.  But this isn't really a big deal.
411
412dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
413m4_define([AC_PROG_CC],
414m4_defn([AC_PROG_CC])
415[_AM_PROG_CC_C_O
416])
417
418# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
419# AM_INIT_AUTOMAKE([OPTIONS])
420# -----------------------------------------------
421# The call with PACKAGE and VERSION arguments is the old style
422# call (pre autoconf-2.50), which is being phased out.  PACKAGE
423# and VERSION should now be passed to AC_INIT and removed from
424# the call to AM_INIT_AUTOMAKE.
425# We support both call styles for the transition.  After
426# the next Automake release, Autoconf can make the AC_INIT
427# arguments mandatory, and then we can depend on a new Autoconf
428# release and drop the old call support.
429AC_DEFUN([AM_INIT_AUTOMAKE],
430[AC_PREREQ([2.65])dnl
431m4_ifdef([_$0_ALREADY_INIT],
432  [m4_fatal([$0 expanded multiple times
433]m4_defn([_$0_ALREADY_INIT]))],
434  [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
435dnl Autoconf wants to disallow AM_ names.  We explicitly allow
436dnl the ones we care about.
437m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
438AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
439AC_REQUIRE([AC_PROG_INSTALL])dnl
440if test "`cd $srcdir && pwd`" != "`pwd`"; then
441  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
442  # is not polluted with repeated "-I."
443  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
444  # test to see if srcdir already configured
445  if test -f $srcdir/config.status; then
446    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
447  fi
448fi
449
450# test whether we have cygpath
451if test -z "$CYGPATH_W"; then
452  if (cygpath --version) >/dev/null 2>/dev/null; then
453    CYGPATH_W='cygpath -w'
454  else
455    CYGPATH_W=echo
456  fi
457fi
458AC_SUBST([CYGPATH_W])
459
460# Define the identity of the package.
461dnl Distinguish between old-style and new-style calls.
462m4_ifval([$2],
463[AC_DIAGNOSE([obsolete],
464             [$0: two- and three-arguments forms are deprecated.])
465m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
466 AC_SUBST([PACKAGE], [$1])dnl
467 AC_SUBST([VERSION], [$2])],
468[_AM_SET_OPTIONS([$1])dnl
469dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
470m4_if(
471  m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
472  [ok:ok],,
473  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
474 AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
475 AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
476
477_AM_IF_OPTION([no-define],,
478[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
479 AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
480
481# Some tools Automake needs.
482AC_REQUIRE([AM_SANITY_CHECK])dnl
483AC_REQUIRE([AC_ARG_PROGRAM])dnl
484AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
485AM_MISSING_PROG([AUTOCONF], [autoconf])
486AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
487AM_MISSING_PROG([AUTOHEADER], [autoheader])
488AM_MISSING_PROG([MAKEINFO], [makeinfo])
489AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
490AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
491AC_REQUIRE([AC_PROG_MKDIR_P])dnl
492# For better backward compatibility.  To be removed once Automake 1.9.x
493# dies out for good.  For more background, see:
494# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
495# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
496AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
497# We need awk for the "check" target (and possibly the TAP driver).  The
498# system "awk" is bad on some platforms.
499AC_REQUIRE([AC_PROG_AWK])dnl
500AC_REQUIRE([AC_PROG_MAKE_SET])dnl
501AC_REQUIRE([AM_SET_LEADING_DOT])dnl
502_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
503	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
504			     [_AM_PROG_TAR([v7])])])
505_AM_IF_OPTION([no-dependencies],,
506[AC_PROVIDE_IFELSE([AC_PROG_CC],
507		  [_AM_DEPENDENCIES([CC])],
508		  [m4_define([AC_PROG_CC],
509			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
510AC_PROVIDE_IFELSE([AC_PROG_CXX],
511		  [_AM_DEPENDENCIES([CXX])],
512		  [m4_define([AC_PROG_CXX],
513			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
514AC_PROVIDE_IFELSE([AC_PROG_OBJC],
515		  [_AM_DEPENDENCIES([OBJC])],
516		  [m4_define([AC_PROG_OBJC],
517			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
518AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
519		  [_AM_DEPENDENCIES([OBJCXX])],
520		  [m4_define([AC_PROG_OBJCXX],
521			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
522])
523# Variables for tags utilities; see am/tags.am
524if test -z "$CTAGS"; then
525  CTAGS=ctags
526fi
527AC_SUBST([CTAGS])
528if test -z "$ETAGS"; then
529  ETAGS=etags
530fi
531AC_SUBST([ETAGS])
532if test -z "$CSCOPE"; then
533  CSCOPE=cscope
534fi
535AC_SUBST([CSCOPE])
536
537AC_REQUIRE([_AM_SILENT_RULES])dnl
538dnl The testsuite driver may need to know about EXEEXT, so add the
539dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
540dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
541AC_CONFIG_COMMANDS_PRE(dnl
542[m4_provide_if([_AM_COMPILER_EXEEXT],
543  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
544
545AC_REQUIRE([_AM_PROG_RM_F])
546AC_REQUIRE([_AM_PROG_XARGS_N])
547
548dnl The trailing newline in this macro's definition is deliberate, for
549dnl backward compatibility and to allow trailing 'dnl'-style comments
550dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
551])
552
553dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
554dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
555dnl mangled by Autoconf and run in a shell conditional statement.
556m4_define([_AC_COMPILER_EXEEXT],
557m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
558
559# When config.status generates a header, we must update the stamp-h file.
560# This file resides in the same directory as the config header
561# that is generated.  The stamp files are numbered to have different names.
562
563# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
564# loop where config.status creates the headers, so we can generate
565# our stamp files there.
566AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
567[# Compute $1's index in $config_headers.
568_am_arg=$1
569_am_stamp_count=1
570for _am_header in $config_headers :; do
571  case $_am_header in
572    $_am_arg | $_am_arg:* )
573      break ;;
574    * )
575      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
576  esac
577done
578echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
579
580# Copyright (C) 2001-2024 Free Software Foundation, Inc.
581#
582# This file is free software; the Free Software Foundation
583# gives unlimited permission to copy and/or distribute it,
584# with or without modifications, as long as this notice is preserved.
585
586# AM_PROG_INSTALL_SH
587# ------------------
588# Define $install_sh.
589AC_DEFUN([AM_PROG_INSTALL_SH],
590[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
591if test x"${install_sh+set}" != xset; then
592  case $am_aux_dir in
593  *\ * | *\	*)
594    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
595  *)
596    install_sh="\${SHELL} $am_aux_dir/install-sh"
597  esac
598fi
599AC_SUBST([install_sh])])
600
601# Copyright (C) 2003-2024 Free Software Foundation, Inc.
602#
603# This file is free software; the Free Software Foundation
604# gives unlimited permission to copy and/or distribute it,
605# with or without modifications, as long as this notice is preserved.
606
607# Check whether the underlying file-system supports filenames
608# with a leading dot.  For instance MS-DOS doesn't.
609AC_DEFUN([AM_SET_LEADING_DOT],
610[rm -rf .tst 2>/dev/null
611mkdir .tst 2>/dev/null
612if test -d .tst; then
613  am__leading_dot=.
614else
615  am__leading_dot=_
616fi
617rmdir .tst 2>/dev/null
618AC_SUBST([am__leading_dot])])
619
620# Check to see how 'make' treats includes.	            -*- Autoconf -*-
621
622# Copyright (C) 2001-2024 Free Software Foundation, Inc.
623#
624# This file is free software; the Free Software Foundation
625# gives unlimited permission to copy and/or distribute it,
626# with or without modifications, as long as this notice is preserved.
627
628# AM_MAKE_INCLUDE()
629# -----------------
630# Check whether make has an 'include' directive that can support all
631# the idioms we need for our automatic dependency tracking code.
632AC_DEFUN([AM_MAKE_INCLUDE],
633[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive])
634cat > confinc.mk << 'END'
635am__doit:
636	@echo this is the am__doit target >confinc.out
637.PHONY: am__doit
638END
639am__include="#"
640am__quote=
641# BSD make does it like this.
642echo '.include "confinc.mk" # ignored' > confmf.BSD
643# Other make implementations (GNU, Solaris 10, AIX) do it like this.
644echo 'include confinc.mk # ignored' > confmf.GNU
645_am_result=no
646for s in GNU BSD; do
647  AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out])
648  AS_CASE([$?:`cat confinc.out 2>/dev/null`],
649      ['0:this is the am__doit target'],
650      [AS_CASE([$s],
651          [BSD], [am__include='.include' am__quote='"'],
652          [am__include='include' am__quote=''])])
653  if test "$am__include" != "#"; then
654    _am_result="yes ($s style)"
655    break
656  fi
657done
658rm -f confinc.* confmf.*
659AC_MSG_RESULT([${_am_result}])
660AC_SUBST([am__include])])
661AC_SUBST([am__quote])])
662
663# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
664
665# Copyright (C) 1997-2024 Free Software Foundation, Inc.
666#
667# This file is free software; the Free Software Foundation
668# gives unlimited permission to copy and/or distribute it,
669# with or without modifications, as long as this notice is preserved.
670
671# AM_MISSING_PROG(NAME, PROGRAM)
672# ------------------------------
673AC_DEFUN([AM_MISSING_PROG],
674[AC_REQUIRE([AM_MISSING_HAS_RUN])
675$1=${$1-"${am_missing_run}$2"}
676AC_SUBST($1)])
677
678# AM_MISSING_HAS_RUN
679# ------------------
680# Define MISSING if not defined so far and test if it is modern enough.
681# If it is, set am_missing_run to use it, otherwise, to nothing.
682AC_DEFUN([AM_MISSING_HAS_RUN],
683[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
684AC_REQUIRE_AUX_FILE([missing])dnl
685if test x"${MISSING+set}" != xset; then
686  MISSING="\${SHELL} '$am_aux_dir/missing'"
687fi
688# Use eval to expand $SHELL
689if eval "$MISSING --is-lightweight"; then
690  am_missing_run="$MISSING "
691else
692  am_missing_run=
693  AC_MSG_WARN(['missing' script is too old or missing])
694fi
695])
696
697# Helper functions for option handling.                     -*- Autoconf -*-
698
699# Copyright (C) 2001-2024 Free Software Foundation, Inc.
700#
701# This file is free software; the Free Software Foundation
702# gives unlimited permission to copy and/or distribute it,
703# with or without modifications, as long as this notice is preserved.
704
705# _AM_MANGLE_OPTION(NAME)
706# -----------------------
707AC_DEFUN([_AM_MANGLE_OPTION],
708[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
709
710# _AM_SET_OPTION(NAME)
711# --------------------
712# Set option NAME.  Presently that only means defining a flag for this option.
713AC_DEFUN([_AM_SET_OPTION],
714[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
715
716# _AM_SET_OPTIONS(OPTIONS)
717# ------------------------
718# OPTIONS is a space-separated list of Automake options.
719AC_DEFUN([_AM_SET_OPTIONS],
720[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
721
722# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
723# -------------------------------------------
724# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
725AC_DEFUN([_AM_IF_OPTION],
726[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
727
728# Copyright (C) 1999-2024 Free Software Foundation, Inc.
729#
730# This file is free software; the Free Software Foundation
731# gives unlimited permission to copy and/or distribute it,
732# with or without modifications, as long as this notice is preserved.
733
734# _AM_PROG_CC_C_O
735# ---------------
736# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
737# to automatically call this.
738AC_DEFUN([_AM_PROG_CC_C_O],
739[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
740AC_REQUIRE_AUX_FILE([compile])dnl
741AC_LANG_PUSH([C])dnl
742AC_CACHE_CHECK(
743  [whether $CC understands -c and -o together],
744  [am_cv_prog_cc_c_o],
745  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
746  # Make sure it works both with $CC and with simple cc.
747  # Following AC_PROG_CC_C_O, we do the test twice because some
748  # compilers refuse to overwrite an existing .o file with -o,
749  # though they will create one.
750  am_cv_prog_cc_c_o=yes
751  for am_i in 1 2; do
752    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
753         && test -f conftest2.$ac_objext; then
754      : OK
755    else
756      am_cv_prog_cc_c_o=no
757      break
758    fi
759  done
760  rm -f core conftest*
761  unset am_i])
762if test "$am_cv_prog_cc_c_o" != yes; then
763   # Losing compiler, so override with the script.
764   # FIXME: It is wrong to rewrite CC.
765   # But if we don't then we get into trouble of one sort or another.
766   # A longer-term fix would be to have automake use am__CC in this case,
767   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
768   CC="$am_aux_dir/compile $CC"
769fi
770AC_LANG_POP([C])])
771
772# For backward compatibility.
773AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
774
775# Copyright (C) 2022-2024 Free Software Foundation, Inc.
776#
777# This file is free software; the Free Software Foundation
778# gives unlimited permission to copy and/or distribute it,
779# with or without modifications, as long as this notice is preserved.
780
781# _AM_PROG_RM_F
782# ---------------
783# Check whether 'rm -f' without any arguments works.
784# https://bugs.gnu.org/10828
785AC_DEFUN([_AM_PROG_RM_F],
786[am__rm_f_notfound=
787AS_IF([(rm -f && rm -fr && rm -rf) 2>/dev/null], [], [am__rm_f_notfound='""'])
788AC_SUBST(am__rm_f_notfound)
789])
790
791# Copyright (C) 2001-2024 Free Software Foundation, Inc.
792#
793# This file is free software; the Free Software Foundation
794# gives unlimited permission to copy and/or distribute it,
795# with or without modifications, as long as this notice is preserved.
796
797# AM_RUN_LOG(COMMAND)
798# -------------------
799# Run COMMAND, save the exit status in ac_status, and log it.
800# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
801AC_DEFUN([AM_RUN_LOG],
802[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
803   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
804   ac_status=$?
805   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
806   (exit $ac_status); }])
807
808# Check to make sure that the build environment is sane.    -*- Autoconf -*-
809
810# Copyright (C) 1996-2024 Free Software Foundation, Inc.
811#
812# This file is free software; the Free Software Foundation
813# gives unlimited permission to copy and/or distribute it,
814# with or without modifications, as long as this notice is preserved.
815
816# _AM_SLEEP_FRACTIONAL_SECONDS
817# ----------------------------
818AC_DEFUN([_AM_SLEEP_FRACTIONAL_SECONDS], [dnl
819AC_CACHE_CHECK([whether sleep supports fractional seconds],
820               am_cv_sleep_fractional_seconds, [dnl
821AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=yes],
822                                 [am_cv_sleep_fractional_seconds=no])
823])])
824
825# _AM_FILESYSTEM_TIMESTAMP_RESOLUTION
826# -----------------------------------
827# Determine the filesystem's resolution for file modification
828# timestamps.  The coarsest we know of is FAT, with a resolution
829# of only two seconds, even with the most recent "exFAT" extensions.
830# The finest (e.g. ext4 with large inodes, XFS, ZFS) is one
831# nanosecond, matching clock_gettime.  However, it is probably not
832# possible to delay execution of a shell script for less than one
833# millisecond, due to process creation overhead and scheduling
834# granularity, so we don't check for anything finer than that. (See below.)
835AC_DEFUN([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl
836AC_REQUIRE([_AM_SLEEP_FRACTIONAL_SECONDS])
837AC_CACHE_CHECK([filesystem timestamp resolution],
838               am_cv_filesystem_timestamp_resolution, [dnl
839# Default to the worst case.
840am_cv_filesystem_timestamp_resolution=2
841
842# Only try to go finer than 1 sec if sleep can do it.
843# Don't try 1 sec, because if 0.01 sec and 0.1 sec don't work,
844# - 1 sec is not much of a win compared to 2 sec, and
845# - it takes 2 seconds to perform the test whether 1 sec works.
846# 
847# Instead, just use the default 2s on platforms that have 1s resolution,
848# accept the extra 1s delay when using $sleep in the Automake tests, in
849# exchange for not incurring the 2s delay for running the test for all
850# packages.
851#
852am_try_resolutions=
853if test "$am_cv_sleep_fractional_seconds" = yes; then
854  # Even a millisecond often causes a bunch of false positives,
855  # so just try a hundredth of a second. The time saved between .001 and
856  # .01 is not terribly consequential.
857  am_try_resolutions="0.01 0.1 $am_try_resolutions"
858fi
859
860# In order to catch current-generation FAT out, we must *modify* files
861# that already exist; the *creation* timestamp is finer.  Use names
862# that make ls -t sort them differently when they have equal
863# timestamps than when they have distinct timestamps, keeping
864# in mind that ls -t prints the *newest* file first.
865rm -f conftest.ts?
866: > conftest.ts1
867: > conftest.ts2
868: > conftest.ts3
869
870# Make sure ls -t actually works.  Do 'set' in a subshell so we don't
871# clobber the current shell's arguments. (Outer-level square brackets
872# are removed by m4; they're present so that m4 does not expand
873# <dollar><star>; be careful, easy to get confused.)
874if (
875     set X `[ls -t conftest.ts[12]]` &&
876     {
877       test "$[]*" != "X conftest.ts1 conftest.ts2" ||
878       test "$[]*" != "X conftest.ts2 conftest.ts1";
879     }
880); then :; else
881  # If neither matched, then we have a broken ls.  This can happen
882  # if, for instance, CONFIG_SHELL is bash and it inherits a
883  # broken ls alias from the environment.  This has actually
884  # happened.  Such a system could not be considered "sane".
885  _AS_ECHO_UNQUOTED(
886    ["Bad output from ls -t: \"`[ls -t conftest.ts[12]]`\""],
887    [AS_MESSAGE_LOG_FD])
888  AC_MSG_FAILURE([ls -t produces unexpected output.
889Make sure there is not a broken ls alias in your environment.])
890fi
891
892for am_try_res in $am_try_resolutions; do
893  # Any one fine-grained sleep might happen to cross the boundary
894  # between two values of a coarser actual resolution, but if we do
895  # two fine-grained sleeps in a row, at least one of them will fall
896  # entirely within a coarse interval.
897  echo alpha > conftest.ts1
898  sleep $am_try_res
899  echo beta > conftest.ts2
900  sleep $am_try_res
901  echo gamma > conftest.ts3
902
903  # We assume that 'ls -t' will make use of high-resolution
904  # timestamps if the operating system supports them at all.
905  if (set X `ls -t conftest.ts?` &&
906      test "$[]2" = conftest.ts3 &&
907      test "$[]3" = conftest.ts2 &&
908      test "$[]4" = conftest.ts1); then
909    #
910    # Ok, ls -t worked. If we're at a resolution of 1 second, we're done,
911    # because we don't need to test make.
912    make_ok=true
913    if test $am_try_res != 1; then
914      # But if we've succeeded so far with a subsecond resolution, we
915      # have one more thing to check: make. It can happen that
916      # everything else supports the subsecond mtimes, but make doesn't;
917      # notably on macOS, which ships make 3.81 from 2006 (the last one
918      # released under GPLv2). https://bugs.gnu.org/68808
919      # 
920      # We test $MAKE if it is defined in the environment, else "make".
921      # It might get overridden later, but our hope is that in practice
922      # it does not matter: it is the system "make" which is (by far)
923      # the most likely to be broken, whereas if the user overrides it,
924      # probably they did so with a better, or at least not worse, make.
925      # https://lists.gnu.org/archive/html/automake/2024-06/msg00051.html
926      #
927      # Create a Makefile (real tab character here):
928      rm -f conftest.mk
929      echo 'conftest.ts1: conftest.ts2' >conftest.mk
930      echo '	touch conftest.ts2' >>conftest.mk
931      #
932      # Now, running
933      #   touch conftest.ts1; touch conftest.ts2; make
934      # should touch ts1 because ts2 is newer. This could happen by luck,
935      # but most often, it will fail if make's support is insufficient. So
936      # test for several consecutive successes.
937      #
938      # (We reuse conftest.ts[12] because we still want to modify existing
939      # files, not create new ones, per above.)
940      n=0
941      make=${MAKE-make}
942      until test $n -eq 3; do
943        echo one > conftest.ts1
944        sleep $am_try_res
945        echo two > conftest.ts2 # ts2 should now be newer than ts1
946        if $make -f conftest.mk | grep 'up to date' >/dev/null; then
947          make_ok=false
948          break # out of $n loop
949        fi
950        n=`expr $n + 1`
951      done
952    fi
953    #
954    if $make_ok; then
955      # Everything we know to check worked out, so call this resolution good.
956      am_cv_filesystem_timestamp_resolution=$am_try_res
957      break # out of $am_try_res loop
958    fi
959    # Otherwise, we'll go on to check the next resolution.
960  fi
961done
962rm -f conftest.ts?
963# (end _am_filesystem_timestamp_resolution)
964])])
965
966# AM_SANITY_CHECK
967# ---------------
968AC_DEFUN([AM_SANITY_CHECK],
969[AC_REQUIRE([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION])
970# This check should not be cached, as it may vary across builds of
971# different projects.
972AC_MSG_CHECKING([whether build environment is sane])
973# Reject unsafe characters in $srcdir or the absolute working directory
974# name.  Accept space and tab only in the latter.
975am_lf='
976'
977case `pwd` in
978  *[[\\\"\#\$\&\'\`$am_lf]]*)
979    AC_MSG_ERROR([unsafe absolute working directory name]);;
980esac
981case $srcdir in
982  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
983    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
984esac
985
986# Do 'set' in a subshell so we don't clobber the current shell's
987# arguments.  Must try -L first in case configure is actually a
988# symlink; some systems play weird games with the mod time of symlinks
989# (eg FreeBSD returns the mod time of the symlink's containing
990# directory).
991am_build_env_is_sane=no
992am_has_slept=no
993rm -f conftest.file
994for am_try in 1 2; do
995  echo "timestamp, slept: $am_has_slept" > conftest.file
996  if (
997    set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
998    if test "$[]*" = "X"; then
999      # -L didn't work.
1000      set X `ls -t "$srcdir/configure" conftest.file`
1001    fi
1002    test "$[]2" = conftest.file
1003  ); then
1004    am_build_env_is_sane=yes
1005    break
1006  fi
1007  # Just in case.
1008  sleep "$am_cv_filesystem_timestamp_resolution"
1009  am_has_slept=yes
1010done
1011
1012AC_MSG_RESULT([$am_build_env_is_sane])
1013if test "$am_build_env_is_sane" = no; then
1014  AC_MSG_ERROR([newly created file is older than distributed files!
1015Check your system clock])
1016fi
1017
1018# If we didn't sleep, we still need to ensure time stamps of config.status and
1019# generated files are strictly newer.
1020am_sleep_pid=
1021AS_IF([test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1],, [dnl
1022  ( sleep "$am_cv_filesystem_timestamp_resolution" ) &
1023  am_sleep_pid=$!
1024])
1025AC_CONFIG_COMMANDS_PRE(
1026  [AC_MSG_CHECKING([that generated files are newer than configure])
1027   if test -n "$am_sleep_pid"; then
1028     # Hide warnings about reused PIDs.
1029     wait $am_sleep_pid 2>/dev/null
1030   fi
1031   AC_MSG_RESULT([done])])
1032rm -f conftest.file
1033])
1034
1035# Copyright (C) 2009-2024 Free Software Foundation, Inc.
1036#
1037# This file is free software; the Free Software Foundation
1038# gives unlimited permission to copy and/or distribute it,
1039# with or without modifications, as long as this notice is preserved.
1040
1041# _AM_SILENT_RULES
1042# ----------------
1043# Enable less verbose build rules support.
1044AC_DEFUN([_AM_SILENT_RULES],
1045[AM_DEFAULT_VERBOSITY=1
1046AC_ARG_ENABLE([silent-rules], [dnl
1047AS_HELP_STRING(
1048  [--enable-silent-rules],
1049  [less verbose build output (undo: "make V=1")])
1050AS_HELP_STRING(
1051  [--disable-silent-rules],
1052  [verbose build output (undo: "make V=0")])dnl
1053])
1054dnl
1055dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
1056dnl do not support nested variable expansions.
1057dnl See automake bug#9928 and bug#10237.
1058am_make=${MAKE-make}
1059AC_CACHE_CHECK([whether $am_make supports nested variables],
1060   [am_cv_make_support_nested_variables],
1061   [if AS_ECHO([['TRUE=$(BAR$(V))
1062BAR0=false
1063BAR1=true
1064V=1
1065am__doit:
1066	@$(TRUE)
1067.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
1068  am_cv_make_support_nested_variables=yes
1069else
1070  am_cv_make_support_nested_variables=no
1071fi])
1072AC_SUBST([AM_V])dnl
1073AM_SUBST_NOTMAKE([AM_V])dnl
1074AC_SUBST([AM_DEFAULT_V])dnl
1075AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
1076AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
1077AM_BACKSLASH='\'
1078AC_SUBST([AM_BACKSLASH])dnl
1079_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
1080dnl Delay evaluation of AM_DEFAULT_VERBOSITY to the end to allow multiple calls
1081dnl to AM_SILENT_RULES to change the default value.
1082AC_CONFIG_COMMANDS_PRE([dnl
1083case $enable_silent_rules in @%:@ (((
1084  yes) AM_DEFAULT_VERBOSITY=0;;
1085   no) AM_DEFAULT_VERBOSITY=1;;
1086esac
1087if test $am_cv_make_support_nested_variables = yes; then
1088  dnl Using '$V' instead of '$(V)' breaks IRIX make.
1089  AM_V='$(V)'
1090  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
1091else
1092  AM_V=$AM_DEFAULT_VERBOSITY
1093  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
1094fi
1095])dnl
1096])
1097
1098# AM_SILENT_RULES([DEFAULT])
1099# --------------------------
1100# Set the default verbosity level to DEFAULT ("yes" being less verbose, "no" or
1101# empty being verbose).
1102AC_DEFUN([AM_SILENT_RULES],
1103[AC_REQUIRE([_AM_SILENT_RULES])
1104AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1])])
1105
1106# Copyright (C) 2001-2024 Free Software Foundation, Inc.
1107#
1108# This file is free software; the Free Software Foundation
1109# gives unlimited permission to copy and/or distribute it,
1110# with or without modifications, as long as this notice is preserved.
1111
1112# AM_PROG_INSTALL_STRIP
1113# ---------------------
1114# One issue with vendor 'install' (even GNU) is that you can't
1115# specify the program used to strip binaries.  This is especially
1116# annoying in cross-compiling environments, where the build's strip
1117# is unlikely to handle the host's binaries.
1118# Fortunately install-sh will honor a STRIPPROG variable, so we
1119# always use install-sh in "make install-strip", and initialize
1120# STRIPPROG with the value of the STRIP variable (set by the user).
1121AC_DEFUN([AM_PROG_INSTALL_STRIP],
1122[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
1123# Installed binaries are usually stripped using 'strip' when the user
1124# run "make install-strip".  However 'strip' might not be the right
1125# tool to use in cross-compilation environments, therefore Automake
1126# will honor the 'STRIP' environment variable to overrule this program.
1127dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
1128if test "$cross_compiling" != no; then
1129  AC_CHECK_TOOL([STRIP], [strip], :)
1130fi
1131INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
1132AC_SUBST([INSTALL_STRIP_PROGRAM])])
1133
1134# Copyright (C) 2006-2024 Free Software Foundation, Inc.
1135#
1136# This file is free software; the Free Software Foundation
1137# gives unlimited permission to copy and/or distribute it,
1138# with or without modifications, as long as this notice is preserved.
1139
1140# _AM_SUBST_NOTMAKE(VARIABLE)
1141# ---------------------------
1142# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
1143# This macro is traced by Automake.
1144AC_DEFUN([_AM_SUBST_NOTMAKE])
1145
1146# AM_SUBST_NOTMAKE(VARIABLE)
1147# --------------------------
1148# Public sister of _AM_SUBST_NOTMAKE.
1149AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
1150
1151# Check how to create a tarball.                            -*- Autoconf -*-
1152
1153# Copyright (C) 2004-2024 Free Software Foundation, Inc.
1154#
1155# This file is free software; the Free Software Foundation
1156# gives unlimited permission to copy and/or distribute it,
1157# with or without modifications, as long as this notice is preserved.
1158
1159# _AM_PROG_TAR(FORMAT)
1160# --------------------
1161# Check how to create a tarball in format FORMAT.
1162# FORMAT should be one of 'v7', 'ustar', or 'pax'.
1163#
1164# Substitute a variable $(am__tar) that is a command
1165# writing to stdout a FORMAT-tarball containing the directory
1166# $tardir.
1167#     tardir=directory && $(am__tar) > result.tar
1168#
1169# Substitute a variable $(am__untar) that extract such
1170# a tarball read from stdin.
1171#     $(am__untar) < result.tar
1172#
1173AC_DEFUN([_AM_PROG_TAR],
1174[# Always define AMTAR for backward compatibility.  Yes, it's still used
1175# in the wild :-(  We should find a proper way to deprecate it ...
1176AC_SUBST([AMTAR], ['$${TAR-tar}'])
1177
1178# We'll loop over all known methods to create a tar archive until one works.
1179_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
1180
1181m4_if([$1], [v7],
1182  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
1183
1184  [m4_case([$1],
1185    [ustar],
1186     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
1187      # There is notably a 21 bits limit for the UID and the GID.  In fact,
1188      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
1189      # and bug#13588).
1190      am_max_uid=2097151 # 2^21 - 1
1191      am_max_gid=$am_max_uid
1192      # The $UID and $GID variables are not portable, so we need to resort
1193      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
1194      # below are definitely unexpected, so allow the users to see them
1195      # (that is, avoid stderr redirection).
1196      am_uid=`id -u || echo unknown`
1197      am_gid=`id -g || echo unknown`
1198      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
1199      if test x$am_uid = xunknown; then
1200        AC_MSG_WARN([ancient id detected; assuming current UID is ok, but dist-ustar might not work])
1201      elif test $am_uid -le $am_max_uid; then
1202        AC_MSG_RESULT([yes])
1203      else
1204        AC_MSG_RESULT([no])
1205        _am_tools=none
1206      fi
1207      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
1208      if test x$gm_gid = xunknown; then
1209        AC_MSG_WARN([ancient id detected; assuming current GID is ok, but dist-ustar might not work])
1210      elif test $am_gid -le $am_max_gid; then
1211        AC_MSG_RESULT([yes])
1212      else
1213        AC_MSG_RESULT([no])
1214        _am_tools=none
1215      fi],
1216
1217  [pax],
1218    [],
1219
1220  [m4_fatal([Unknown tar format])])
1221
1222  AC_MSG_CHECKING([how to create a $1 tar archive])
1223
1224  # Go ahead even if we have the value already cached.  We do so because we
1225  # need to set the values for the 'am__tar' and 'am__untar' variables.
1226  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
1227
1228  for _am_tool in $_am_tools; do
1229    case $_am_tool in
1230    gnutar)
1231      for _am_tar in tar gnutar gtar; do
1232        AM_RUN_LOG([$_am_tar --version]) && break
1233      done
1234      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
1235      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
1236      am__untar="$_am_tar -xf -"
1237      ;;
1238    plaintar)
1239      # Must skip GNU tar: if it does not support --format= it doesn't create
1240      # ustar tarball either.
1241      (tar --version) >/dev/null 2>&1 && continue
1242      am__tar='tar chf - "$$tardir"'
1243      am__tar_='tar chf - "$tardir"'
1244      am__untar='tar xf -'
1245      ;;
1246    pax)
1247      am__tar='pax -L -x $1 -w "$$tardir"'
1248      am__tar_='pax -L -x $1 -w "$tardir"'
1249      am__untar='pax -r'
1250      ;;
1251    cpio)
1252      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
1253      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
1254      am__untar='cpio -i -H $1 -d'
1255      ;;
1256    none)
1257      am__tar=false
1258      am__tar_=false
1259      am__untar=false
1260      ;;
1261    esac
1262
1263    # If the value was cached, stop now.  We just wanted to have am__tar
1264    # and am__untar set.
1265    test -n "${am_cv_prog_tar_$1}" && break
1266
1267    # tar/untar a dummy directory, and stop if the command works.
1268    rm -rf conftest.dir
1269    mkdir conftest.dir
1270    echo GrepMe > conftest.dir/file
1271    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
1272    rm -rf conftest.dir
1273    if test -s conftest.tar; then
1274      AM_RUN_LOG([$am__untar <conftest.tar])
1275      AM_RUN_LOG([cat conftest.dir/file])
1276      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
1277    fi
1278  done
1279  rm -rf conftest.dir
1280
1281  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
1282  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
1283
1284AC_SUBST([am__tar])
1285AC_SUBST([am__untar])
1286]) # _AM_PROG_TAR
1287
1288# Copyright (C) 2022-2024 Free Software Foundation, Inc.
1289#
1290# This file is free software; the Free Software Foundation
1291# gives unlimited permission to copy and/or distribute it,
1292# with or without modifications, as long as this notice is preserved.
1293
1294# _AM_PROG_XARGS_N
1295# ----------------
1296# Check whether 'xargs -n' works.  It should work everywhere, so the fallback
1297# is not optimized at all as we never expect to use it.
1298AC_DEFUN([_AM_PROG_XARGS_N],
1299[AC_CACHE_CHECK([xargs -n works], am_cv_xargs_n_works, [dnl
1300AS_IF([test "`echo 1 2 3 | xargs -n2 echo`" = "1 2
13013"], [am_cv_xargs_n_works=yes], [am_cv_xargs_n_works=no])])
1302AS_IF([test "$am_cv_xargs_n_works" = yes], [am__xargs_n='xargs -n'], [dnl
1303  am__xargs_n='am__xargs_n () { shift; sed "s/ /\\n/g" | while read am__xargs_n_arg; do "$@" "$am__xargs_n_arg"; done; }'
1304])dnl
1305AC_SUBST(am__xargs_n)
1306])
1307
1308dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
1309dnl serial 11 (pkg-config-0.29)
1310dnl
1311dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1312dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
1313dnl
1314dnl This program is free software; you can redistribute it and/or modify
1315dnl it under the terms of the GNU General Public License as published by
1316dnl the Free Software Foundation; either version 2 of the License, or
1317dnl (at your option) any later version.
1318dnl
1319dnl This program is distributed in the hope that it will be useful, but
1320dnl WITHOUT ANY WARRANTY; without even the implied warranty of
1321dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1322dnl General Public License for more details.
1323dnl
1324dnl You should have received a copy of the GNU General Public License
1325dnl along with this program; if not, write to the Free Software
1326dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1327dnl 02111-1307, USA.
1328dnl
1329dnl As a special exception to the GNU General Public License, if you
1330dnl distribute this file as part of a program that contains a
1331dnl configuration script generated by Autoconf, you may include it under
1332dnl the same distribution terms that you use for the rest of that
1333dnl program.
1334
1335dnl PKG_PREREQ(MIN-VERSION)
1336dnl -----------------------
1337dnl Since: 0.29
1338dnl
1339dnl Verify that the version of the pkg-config macros are at least
1340dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
1341dnl installed version of pkg-config, this checks the developer's version
1342dnl of pkg.m4 when generating configure.
1343dnl
1344dnl To ensure that this macro is defined, also add:
1345dnl m4_ifndef([PKG_PREREQ],
1346dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
1347dnl
1348dnl See the "Since" comment for each macro you use to see what version
1349dnl of the macros you require.
1350m4_defun([PKG_PREREQ],
1351[m4_define([PKG_MACROS_VERSION], [0.29])
1352m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
1353    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
1354])dnl PKG_PREREQ
1355
1356dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
1357dnl ----------------------------------
1358dnl Since: 0.16
1359dnl
1360dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
1361dnl first found in the path. Checks that the version of pkg-config found
1362dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
1363dnl used since that's the first version where most current features of
1364dnl pkg-config existed.
1365AC_DEFUN([PKG_PROG_PKG_CONFIG],
1366[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
1367m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
1368m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
1369AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
1370AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
1371AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
1372
1373if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1374	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1375fi
1376if test -n "$PKG_CONFIG"; then
1377	_pkg_min_version=m4_default([$1], [0.9.0])
1378	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1379	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1380		AC_MSG_RESULT([yes])
1381	else
1382		AC_MSG_RESULT([no])
1383		PKG_CONFIG=""
1384	fi
1385fi[]dnl
1386])dnl PKG_PROG_PKG_CONFIG
1387
1388dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1389dnl -------------------------------------------------------------------
1390dnl Since: 0.18
1391dnl
1392dnl Check to see whether a particular set of modules exists. Similar to
1393dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
1394dnl
1395dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1396dnl only at the first occurence in configure.ac, so if the first place
1397dnl it's called might be skipped (such as if it is within an "if", you
1398dnl have to call PKG_CHECK_EXISTS manually
1399AC_DEFUN([PKG_CHECK_EXISTS],
1400[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1401if test -n "$PKG_CONFIG" && \
1402    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
1403  m4_default([$2], [:])
1404m4_ifvaln([$3], [else
1405  $3])dnl
1406fi])
1407
1408dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
1409dnl ---------------------------------------------
1410dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
1411dnl pkg_failed based on the result.
1412m4_define([_PKG_CONFIG],
1413[if test -n "$$1"; then
1414    pkg_cv_[]$1="$$1"
1415 elif test -n "$PKG_CONFIG"; then
1416    PKG_CHECK_EXISTS([$3],
1417                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
1418		      test "x$?" != "x0" && pkg_failed=yes ],
1419		     [pkg_failed=yes])
1420 else
1421    pkg_failed=untried
1422fi[]dnl
1423])dnl _PKG_CONFIG
1424
1425dnl _PKG_SHORT_ERRORS_SUPPORTED
1426dnl ---------------------------
1427dnl Internal check to see if pkg-config supports short errors.
1428AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
1429[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1430if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1431        _pkg_short_errors_supported=yes
1432else
1433        _pkg_short_errors_supported=no
1434fi[]dnl
1435])dnl _PKG_SHORT_ERRORS_SUPPORTED
1436
1437
1438dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1439dnl   [ACTION-IF-NOT-FOUND])
1440dnl --------------------------------------------------------------
1441dnl Since: 0.4.0
1442dnl
1443dnl Note that if there is a possibility the first call to
1444dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
1445dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
1446AC_DEFUN([PKG_CHECK_MODULES],
1447[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1448AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
1449AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
1450
1451pkg_failed=no
1452AC_MSG_CHECKING([for $1])
1453
1454_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
1455_PKG_CONFIG([$1][_LIBS], [libs], [$2])
1456
1457m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
1458and $1[]_LIBS to avoid the need to call pkg-config.
1459See the pkg-config man page for more details.])
1460
1461if test $pkg_failed = yes; then
1462   	AC_MSG_RESULT([no])
1463        _PKG_SHORT_ERRORS_SUPPORTED
1464        if test $_pkg_short_errors_supported = yes; then
1465	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
1466        else 
1467	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
1468        fi
1469	# Put the nasty error message in config.log where it belongs
1470	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
1471
1472	m4_default([$4], [AC_MSG_ERROR(
1473[Package requirements ($2) were not met:
1474
1475$$1_PKG_ERRORS
1476
1477Consider adjusting the PKG_CONFIG_PATH environment variable if you
1478installed software in a non-standard prefix.
1479
1480_PKG_TEXT])[]dnl
1481        ])
1482elif test $pkg_failed = untried; then
1483     	AC_MSG_RESULT([no])
1484	m4_default([$4], [AC_MSG_FAILURE(
1485[The pkg-config script could not be found or is too old.  Make sure it
1486is in your PATH or set the PKG_CONFIG environment variable to the full
1487path to pkg-config.
1488
1489_PKG_TEXT
1490
1491To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
1492        ])
1493else
1494	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
1495	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
1496        AC_MSG_RESULT([yes])
1497	$3
1498fi[]dnl
1499])dnl PKG_CHECK_MODULES
1500
1501
1502dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1503dnl   [ACTION-IF-NOT-FOUND])
1504dnl ---------------------------------------------------------------------
1505dnl Since: 0.29
1506dnl
1507dnl Checks for existence of MODULES and gathers its build flags with
1508dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
1509dnl and VARIABLE-PREFIX_LIBS from --libs.
1510dnl
1511dnl Note that if there is a possibility the first call to
1512dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
1513dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
1514dnl configure.ac.
1515AC_DEFUN([PKG_CHECK_MODULES_STATIC],
1516[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1517_save_PKG_CONFIG=$PKG_CONFIG
1518PKG_CONFIG="$PKG_CONFIG --static"
1519PKG_CHECK_MODULES($@)
1520PKG_CONFIG=$_save_PKG_CONFIG[]dnl
1521])dnl PKG_CHECK_MODULES_STATIC
1522
1523
1524dnl PKG_INSTALLDIR([DIRECTORY])
1525dnl -------------------------
1526dnl Since: 0.27
1527dnl
1528dnl Substitutes the variable pkgconfigdir as the location where a module
1529dnl should install pkg-config .pc files. By default the directory is
1530dnl $libdir/pkgconfig, but the default can be changed by passing
1531dnl DIRECTORY. The user can override through the --with-pkgconfigdir
1532dnl parameter.
1533AC_DEFUN([PKG_INSTALLDIR],
1534[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
1535m4_pushdef([pkg_description],
1536    [pkg-config installation directory @<:@]pkg_default[@:>@])
1537AC_ARG_WITH([pkgconfigdir],
1538    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
1539    [with_pkgconfigdir=]pkg_default)
1540AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
1541m4_popdef([pkg_default])
1542m4_popdef([pkg_description])
1543])dnl PKG_INSTALLDIR
1544
1545
1546dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
1547dnl --------------------------------
1548dnl Since: 0.27
1549dnl
1550dnl Substitutes the variable noarch_pkgconfigdir as the location where a
1551dnl module should install arch-independent pkg-config .pc files. By
1552dnl default the directory is $datadir/pkgconfig, but the default can be
1553dnl changed by passing DIRECTORY. The user can override through the
1554dnl --with-noarch-pkgconfigdir parameter.
1555AC_DEFUN([PKG_NOARCH_INSTALLDIR],
1556[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
1557m4_pushdef([pkg_description],
1558    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
1559AC_ARG_WITH([noarch-pkgconfigdir],
1560    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
1561    [with_noarch_pkgconfigdir=]pkg_default)
1562AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
1563m4_popdef([pkg_default])
1564m4_popdef([pkg_description])
1565])dnl PKG_NOARCH_INSTALLDIR
1566
1567
1568dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
1569dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1570dnl -------------------------------------------
1571dnl Since: 0.28
1572dnl
1573dnl Retrieves the value of the pkg-config variable for the given module.
1574AC_DEFUN([PKG_CHECK_VAR],
1575[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1576AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
1577
1578_PKG_CONFIG([$1], [variable="][$3]["], [$2])
1579AS_VAR_COPY([$1], [pkg_cv_][$1])
1580
1581AS_VAR_IF([$1], [""], [$5], [$4])dnl
1582])dnl PKG_CHECK_VAR
1583
1584dnl fontutil.m4.  Generated from fontutil.m4.in by configure.
1585dnl
1586dnl This file comes from X.Org's font-util 1.4.1
1587dnl
1588dnl Copyright (c) 2009, 2023, Oracle and/or its affiliates.
1589dnl
1590dnl Permission is hereby granted, free of charge, to any person obtaining a
1591dnl copy of this software and associated documentation files (the "Software"),
1592dnl to deal in the Software without restriction, including without limitation
1593dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
1594dnl and/or sell copies of the Software, and to permit persons to whom the
1595dnl Software is furnished to do so, subject to the following conditions:
1596dnl
1597dnl The above copyright notice and this permission notice (including the next
1598dnl paragraph) shall be included in all copies or substantial portions of the
1599dnl Software.
1600dnl
1601dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1602dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1603dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1604dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1605dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1606dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1607dnl DEALINGS IN THE SOFTWARE.
1608dnl
1609dnl --------------------------------------------------------------------
1610dnl
1611dnl Copyright 2005 Red Hat, Inc
1612dnl
1613dnl Permission to use, copy, modify, distribute, and sell this software and its
1614dnl documentation for any purpose is hereby granted without fee, provided that
1615dnl the above copyright notice appear in all copies and that both that
1616dnl copyright notice and this permission notice appear in supporting
1617dnl documentation.
1618dnl
1619dnl The above copyright notice and this permission notice shall be included
1620dnl in all copies or substantial portions of the Software.
1621dnl
1622dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1623dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1624dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1625dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
1626dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1627dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1628dnl OTHER DEALINGS IN THE SOFTWARE.
1629dnl
1630dnl Except as contained in this notice, the name of the copyright holders shall
1631dnl not be used in advertising or otherwise to promote the sale, use or
1632dnl other dealings in this Software without prior written authorization
1633dnl from the copyright holders.
1634
1635# XORG_FONT_MACROS_VERSION(required-version)
1636# ------------------------------------------
1637# Minimum version: 1.1.0
1638#
1639# If you're using a macro added in Version 1.1 or newer, include this in
1640# your configure.ac with the minimum required version, such as:
1641# XORG_FONT_MACROS_VERSION(1.1)
1642#
1643# To ensure that this macro is defined, also add:
1644# m4_ifndef([XORG_FONT_MACROS_VERSION],
1645#     [m4_fatal([must install X.Org font-util 1.1 or later before running autoconf/autogen])])
1646#
1647#
1648# See the "minimum version" comment for each macro you use to see what
1649# version you require.
1650m4_defun([XORG_FONT_MACROS_VERSION],[
1651m4_define([vers_have], [1.4.1])
1652m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
1653m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
1654m4_if(m4_cmp(maj_have, maj_needed), 0,,
1655    [m4_fatal([font-util major version ]maj_needed[ is required but ]vers_have[ found])])
1656m4_if(m4_version_compare(vers_have, [$1]), -1,
1657    [m4_fatal([font-util version $1 or higher is required but ]vers_have[ found])])
1658m4_undefine([vers_have])
1659m4_undefine([maj_have])
1660m4_undefine([maj_needed])
1661]) # XORG_FONT_MACROS_VERSION
1662
1663# XORG_FONT_CHECK_{maps}()
1664# ------------------------
1665# Minimum version: 1.0.0
1666# These macros add --enable/disable-{maps} where {maps} are ISO8859-*,
1667# JISX0201 or KOI8_R.  By default, they are all enabled.
1668
1669AC_DEFUN([XORG_FONT_CHECK_ISO8859_1], [XORG_FONT_CHECK_ENCODING(ISO8859-1)])
1670AC_DEFUN([XORG_FONT_CHECK_ISO8859_2], [XORG_FONT_CHECK_ENCODING(ISO8859-2)])
1671AC_DEFUN([XORG_FONT_CHECK_ISO8859_3], [XORG_FONT_CHECK_ENCODING(ISO8859-3)])
1672AC_DEFUN([XORG_FONT_CHECK_ISO8859_4], [XORG_FONT_CHECK_ENCODING(ISO8859-4)])
1673AC_DEFUN([XORG_FONT_CHECK_ISO8859_5], [XORG_FONT_CHECK_ENCODING(ISO8859-5)])
1674AC_DEFUN([XORG_FONT_CHECK_ISO8859_6], [XORG_FONT_CHECK_ENCODING(ISO8859-6)])
1675AC_DEFUN([XORG_FONT_CHECK_ISO8859_7], [XORG_FONT_CHECK_ENCODING(ISO8859-7)])
1676AC_DEFUN([XORG_FONT_CHECK_ISO8859_8], [XORG_FONT_CHECK_ENCODING(ISO8859-8)])
1677AC_DEFUN([XORG_FONT_CHECK_ISO8859_9], [XORG_FONT_CHECK_ENCODING(ISO8859-9)])
1678AC_DEFUN([XORG_FONT_CHECK_ISO8859_10],[XORG_FONT_CHECK_ENCODING(ISO8859-10)])
1679AC_DEFUN([XORG_FONT_CHECK_ISO8859_11],[XORG_FONT_CHECK_ENCODING(ISO8859-11)])
1680AC_DEFUN([XORG_FONT_CHECK_ISO8859_12],[XORG_FONT_CHECK_ENCODING(ISO8859-12)])
1681AC_DEFUN([XORG_FONT_CHECK_ISO8859_13],[XORG_FONT_CHECK_ENCODING(ISO8859-13)])
1682AC_DEFUN([XORG_FONT_CHECK_ISO8859_14],[XORG_FONT_CHECK_ENCODING(ISO8859-14)])
1683AC_DEFUN([XORG_FONT_CHECK_ISO8859_15],[XORG_FONT_CHECK_ENCODING(ISO8859-15)])
1684AC_DEFUN([XORG_FONT_CHECK_ISO8859_16],[XORG_FONT_CHECK_ENCODING(ISO8859-16)])
1685AC_DEFUN([XORG_FONT_CHECK_JISX0201],  [XORG_FONT_CHECK_ENCODING(JISX0201)])
1686AC_DEFUN([XORG_FONT_CHECK_KOI8_R],    [XORG_FONT_CHECK_ENCODING(KOI8-R)])
1687
1688# XORG_FONT_CHECK_ENCODING(encoding)
1689# ----------------------------------
1690# Minimum version: 1.1.0
1691# This macro adds --enable/disable-<encoding>, enabled by default.
1692# It replaced individual copies of this code in the above macros in 1.1.
1693# Currently assumes encoding names will be all upper-case - add m4_toupper
1694# calls if this is not true in the future.
1695
1696AC_DEFUN([XORG_FONT_CHECK_ENCODING],[
1697	AC_ARG_ENABLE(m4_tolower($1),
1698		AS_HELP_STRING(m4_join([-], [--disable], m4_tolower($1)),
1699				[Build $1 fonts (default: yes)]),
1700		[AS_TR_SH($1)=$enableval])
1701	AC_MSG_CHECKING([whether to build $1 fonts])
1702	AC_MSG_RESULT($[AS_TR_SH($1)])
1703	AM_CONDITIONAL(AS_TR_SH($1), [test "x$AS_TR_SH($1)" = xyes])
1704]) # XORG_FONT_CHECK_ENCODING
1705
1706# XORG_FONT_CHECK_ENCODING_LIST(encoding1 encoding2....)
1707# -----------------------------------------------------
1708# Minimum version: 1.1.0
1709# Call XORG_FONT_CHECK_ENCODING for multiple encodings at once.
1710# Add a shorthand --enable/disable-all-encodings option.
1711
1712AC_DEFUN([XORG_FONT_CHECK_ENCODING_LIST],[
1713	AC_ARG_ENABLE([all-encodings],
1714		AS_HELP_STRING([--disable-all-encodings],
1715				[Disable building of all font encodings]),
1716		[m4_foreach_w([enc], [$1], [
1717			AS_TR_SH(enc)=$enableval
1718		])],
1719		[m4_foreach_w([enc], [$1], [
1720			AS_TR_SH(enc)=yes
1721		])])
1722	m4_foreach_w([enc], [$1], [XORG_FONT_CHECK_ENCODING(enc)])
1723]) # XORG_FONT_CHECK_ENCODING_LIST
1724
1725# XORG_FONT_REQUIRED_PROG(VARNAME, progname)
1726# ------------------------------------------
1727# Minimum version: 1.1.0
1728#
1729# Simple wrapper around AC_PATH_PROG that errors if not found
1730#
1731
1732AC_DEFUN([XORG_FONT_REQUIRED_PROG],[
1733	AC_PATH_PROG($1, $2)
1734	if test x"$$1" = x; then
1735		AC_MSG_ERROR([$2 is required to build $PACKAGE_NAME.])
1736	fi
1737])
1738
1739
1740# XORG_FONT_FCCACHE()
1741# -------------------
1742# Minimum version: 1.1.0
1743#
1744# Set FCCACHE to path to fc-cache (fontconfig cache builder) if found
1745# Set RUN_FCCACHE to a rule suitable for substituting into a makefile
1746# to run fc-cache if found and not installing to $DESTDIR and not
1747# cross-compiling
1748#
1749# fc-cache is optional, not required, and should be skipped when making
1750# packages (installing to $DESTDIR) or cross-compiling
1751#
1752AC_DEFUN([XORG_FONT_FCCACHE],[
1753	AC_PATH_PROG(FCCACHE, fc-cache)
1754	FCCACHE_WARN='echo "** Warning: fonts.cache not built" ; echo "** Generate this file manually on host system using fc-cache"'
1755	if test x"$FCCACHE" = x || test x"$cross_compiling" != x"no" ; then
1756		RUN_FCCACHE="${FCCACHE_WARN}"
1757	else
1758		RUN_FCCACHE='@(if test -z "$(DESTDIR)"; then echo $(FCCACHE) $(fontdir); $(FCCACHE) $(fontdir); else'
1759		RUN_FCCACHE="${RUN_FCCACHE} ${FCCACHE_WARN} ; fi)"
1760	fi
1761	AC_SUBST([RUN_FCCACHE])
1762])
1763
1764# XORG_FONT_MKFONTDIR()
1765# -------------------
1766# Minimum version: 1.3.0
1767#
1768# Set MKFONTDIR to path to mkfontdir.
1769#
1770# If cross-compiling, and if mkdir is not found, use a shell command
1771# which warns mkfontdir needs to be run on the target
1772#
1773# If not cross-compiling, mkfontdir must be found
1774#
1775AC_DEFUN([XORG_FONT_MKFONTDIR],[
1776	if test x"$cross_compiling" != x"no" ; then
1777		AC_PATH_PROG(MKFONTDIR, mkfontdir, "")
1778		MKFONTDIR_WARN='echo "** Warning: mkfontdir not run" ; echo "** Run mkfontdir manually on host system"'
1779
1780		if test x"$MKFONTDIR" = x; then
1781			MKFONTDIR="${MKFONTDIR_WARN} ; echo '** mkfontdir'"
1782		fi
1783	else
1784		XORG_FONT_REQUIRED_PROG(MKFONTDIR, mkfontdir)
1785	fi
1786
1787	AC_SUBST([MKFONTDIR])
1788])
1789
1790# XORG_FONT_COMMON_UTILS()
1791# ------------------------
1792# Minimum version: 1.1.0
1793#
1794# Call XORG_FONT_REQUIRED_PROG for programs needed for all font types
1795
1796AC_DEFUN([XORG_FONT_COMMON_UTILS],[
1797	XORG_FONT_FCCACHE
1798	XORG_FONT_MKFONTDIR
1799])
1800
1801# XORG_FONT_SCALED_UTILS()
1802# ------------------------
1803# Minimum version: 1.1.0
1804#
1805# Call XORG_FONT_REQUIRED_PROG for programs needed for scalable fonts
1806# (TrueType, OpenType, Type1)
1807
1808AC_DEFUN([XORG_FONT_SCALED_UTILS],[
1809	XORG_FONT_COMMON_UTILS
1810	XORG_FONT_REQUIRED_PROG(MKFONTSCALE, mkfontscale)
1811])
1812
1813# XORG_FONT_BDF_UTILS()
1814# ---------------------
1815# Minimum version: 1.1.0
1816#
1817# Call XORG_FONT_REQUIRED_PROG for programs needed for BDF format bitmap fonts
1818# Also call XORG_FONT_CHECK_COMPRESSION to determine how to compress the
1819# PCF output files created by bdftopcf
1820
1821AC_DEFUN([XORG_FONT_BDF_UTILS],[
1822	XORG_FONT_COMMON_UTILS
1823	XORG_FONT_REQUIRED_PROG(BDFTOPCF, bdftopcf)
1824	XORG_FONT_CHECK_COMPRESSION
1825])
1826
1827# XORG_FONT_CHECK_COMPRESSION()
1828# -----------------------------
1829# Minimum version: 1.1.0
1830#
1831# Offer a --with-compression flag to control what compression method is
1832# used for pcf font files.   Offers all the methods currently supported
1833# by libXfont, including no compression.
1834#
1835# If COMPRESS_FLAGS is not set, and the compression method has flags needed
1836# for reproducible builds, such as gzip -n to not record timestamp, will
1837# set COMPRESS_FLAGS to those options.
1838
1839AC_DEFUN([XORG_FONT_CHECK_COMPRESSION],[
1840	AC_MSG_CHECKING([font compression method])
1841	AC_ARG_WITH(compression,
1842	 [AS_HELP_STRING([--with-compression=<no|compress|gzip|bzip2>],
1843			 [compression method to use on pcf fonts])],
1844         [compression="$withval"], [compression="yes"])
1845	if test x"$compression" = "xyes" ; then
1846		compression="gzip"
1847	fi
1848	AC_MSG_RESULT([${compression}])
1849	case ${compression} in
1850	 *compress)	COMPRESS_SUFFIX=".Z" ;;
1851	 *gzip)		COMPRESS_SUFFIX=".gz" ;
1852			COMPRESS_FLAGS="${COMPRESS_FLAGS--n}" ;;
1853	 *bzip2)	COMPRESS_SUFFIX=".bz2" ;;
1854	 no|none)	COMPRESS_SUFFIX="" ; COMPRESS="cat" ;;
1855	 *) AC_MSG_ERROR([${compression} is not a supported compression method]) ;;
1856	esac
1857	if test x"$COMPRESS_SUFFIX" != "x" ; then
1858	   XORG_FONT_REQUIRED_PROG(COMPRESS, ${compression})
1859	fi
1860	AC_MSG_CHECKING([options to font compression command])
1861	AC_MSG_RESULT([${COMPRESS_FLAGS:-none}])
1862	AC_SUBST([COMPRESS_FLAGS])
1863	AC_SUBST([COMPRESS_SUFFIX])
1864])
1865
1866# XORG_FONT_UCS2ANY()
1867# -------------------
1868# Minimum version: 1.1.0
1869#
1870# Call XORG_FONT_REQUIRED_PROG for ucs2any program needed for splitting
1871# Unicode-encoded BDF format bitmap fonts into subsets for older encodings.
1872# Also call pkg-config to find the directory with the encoding files needed
1873# by ucs2any, and export it as MAPFILES_PATH to the Makefiles
1874
1875AC_DEFUN([XORG_FONT_UCS2ANY],[
1876	AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1877	XORG_FONT_REQUIRED_PROG(UCS2ANY, ucs2any)
1878	PKG_CHECK_MODULES(MAPS, [fontutil])
1879	AC_MSG_CHECKING([for ucs2any encoding data files])
1880	MAPFILES_PATH=`$PKG_CONFIG --variable=mapdir fontutil`
1881	AC_SUBST(MAPFILES_PATH)
1882	AC_MSG_RESULT([${MAPFILES_PATH}])
1883])
1884
1885
1886
1887# XORG_FONT_FC_CONFDIR()
1888# --------------------
1889# Minimum version: 1.2.0
1890#
1891# Sets FC_CONFDIR to the fontconfig config directory
1892# (which should be --with-confdir=... when building fontconfig)
1893# found from:
1894#	--with-fc-confdir=...
1895#	pkg-config --variable=confdir fontconfig
1896#	${sysconfdir}/fonts
1897
1898AC_DEFUN([XORG_FONT_FC_CONFDIR],[
1899	dnl Ensure $PKG_CONFIG is set first
1900	AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1901
1902	AC_MSG_CHECKING([for fontconfig's configuration directory])
1903	AC_ARG_WITH(fc-confdir,
1904		    AS_HELP_STRING([--with-fc-confdir=DIR],
1905			   [Path to fontconfig's configuration directory]),
1906		    [FC_CONFDIR="$withval"])
1907	# if --with-fc-confdir was not specified
1908	if test "x${FC_CONFDIR}" = "x"; then
1909		FC_CONFDIR=`$PKG_CONFIG --variable=confdir fontconfig`
1910	fi
1911	# ...and if pkg-config didn't find confdir in fontconfig.pc...
1912	if test "x${FC_CONFDIR}" = "x"; then
1913		FC_CONFDIR="${sysconfdir}/fonts"
1914	fi
1915	AC_SUBST(FC_CONFDIR)
1916	AC_MSG_RESULT([${FC_CONFDIR}])
1917])
1918
1919
1920
1921# XORG_FONTROOTDIR()
1922# --------------------
1923# Minimum version: 1.1.0
1924#
1925# Sets FONTROOTDIR to the root directory for font files.  Uses the first
1926# found from:
1927#	--with-fontrootdir
1928#	pkg-config --variable=fontrootdir fontutil
1929#	${datadir}/fonts/X11
1930
1931AC_DEFUN([XORG_FONTROOTDIR],[
1932	dnl Ensure $PKG_CONFIG is set first
1933	AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1934
1935	AC_MSG_CHECKING([for root directory for font files])
1936	AC_ARG_WITH(fontrootdir,
1937		    AS_HELP_STRING([--with-fontrootdir=DIR],
1938			   [Path to root directory for font files]),
1939		    [FONTROOTDIR="$withval"])
1940	# if --with-fontrootdir not specified...
1941	if test "x${FONTROOTDIR}" = "x"; then
1942		FONTROOTDIR=`$PKG_CONFIG --variable=fontrootdir fontutil`
1943	fi
1944	# ...and if pkg-config didn't find fontdir in fontutil.pc...
1945	if test "x${FONTROOTDIR}" = "x"; then
1946		FONTROOTDIR="${datadir}/fonts/X11"
1947	fi
1948	AC_SUBST(FONTROOTDIR)
1949	AC_MSG_RESULT([${FONTROOTDIR}])
1950])
1951
1952# XORG_FONTSUBDIR(variable, flag, subdir)
1953# ---------------------------------------
1954# Minimum version: 1.1.0
1955#
1956# Offer a --with-<flag> flag to control directory for font installation
1957# Default is the specified <subdir> of the font root directory.
1958# Sets <variable> to the selected directory
1959
1960AC_DEFUN([XORG_FONTSUBDIR],[
1961	AC_REQUIRE([XORG_FONTROOTDIR])
1962
1963	AC_MSG_CHECKING([for directory for $3 files])
1964	AC_ARG_WITH($2,
1965		    [AS_HELP_STRING([--with-$2=DIR],
1966				    [Path to $3 files [FONTROOTDIR/$3]])],
1967		    [$1="${withval}"], [$1='${FONTROOTDIR}/$3'])
1968	AC_SUBST($1)
1969	AC_MSG_RESULT([${$1}])
1970]) # XORG_FONTSUBDIR
1971
1972# XORG_FONTDIR(subdir)
1973# --------------------
1974# Minimum version: 1.1.0
1975#
1976# Offer a --with-fontdir flag to control directory for font installation
1977# Default is the specified subdir of the font root directory.
1978# Sets FONTDIR to the selected directory
1979
1980AC_DEFUN([XORG_FONTDIR],[XORG_FONTSUBDIR([FONTDIR], [fontdir], [$1])])
1981
1982dnl xorg-macros.m4.  Generated from xorg-macros.m4.in xorgversion.m4 by configure.
1983dnl
1984dnl Copyright (c) 2005, 2023, Oracle and/or its affiliates.
1985dnl
1986dnl Permission is hereby granted, free of charge, to any person obtaining a
1987dnl copy of this software and associated documentation files (the "Software"),
1988dnl to deal in the Software without restriction, including without limitation
1989dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
1990dnl and/or sell copies of the Software, and to permit persons to whom the
1991dnl Software is furnished to do so, subject to the following conditions:
1992dnl
1993dnl The above copyright notice and this permission notice (including the next
1994dnl paragraph) shall be included in all copies or substantial portions of the
1995dnl Software.
1996dnl
1997dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1998dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1999dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
2000dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2001dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2002dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2003dnl DEALINGS IN THE SOFTWARE.
2004
2005# XORG_MACROS_VERSION(required-version)
2006# -------------------------------------
2007# Minimum version: 1.1.0
2008#
2009# If you're using a macro added in Version 1.1 or newer, include this in
2010# your configure.ac with the minimum required version, such as:
2011# XORG_MACROS_VERSION(1.1)
2012#
2013# To ensure that this macro is defined, also add:
2014# m4_ifndef([XORG_MACROS_VERSION],
2015#     [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
2016#
2017#
2018# See the "minimum version" comment for each macro you use to see what
2019# version you require.
2020m4_defun([XORG_MACROS_VERSION],[
2021m4_define([vers_have], [1.20.1])
2022m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
2023m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
2024m4_if(m4_cmp(maj_have, maj_needed), 0,,
2025    [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
2026m4_if(m4_version_compare(vers_have, [$1]), -1,
2027    [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
2028m4_undefine([vers_have])
2029m4_undefine([maj_have])
2030m4_undefine([maj_needed])
2031]) # XORG_MACROS_VERSION
2032
2033# XORG_PROG_RAWCPP()
2034# ------------------
2035# Minimum version: 1.0.0
2036#
2037# Find cpp program and necessary flags for use in pre-processing text files
2038# such as man pages and config files
2039AC_DEFUN([XORG_PROG_RAWCPP],[
2040AC_REQUIRE([AC_PROG_CPP])
2041AC_PATH_TOOL(RAWCPP, [cpp], [${CPP}],
2042   [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
2043
2044# Check for flag to avoid builtin definitions - assumes unix is predefined,
2045# which is not the best choice for supporting other OS'es, but covers most
2046# of the ones we need for now.
2047AC_MSG_CHECKING([if $RAWCPP requires -undef])
2048AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
2049if test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
2050	AC_MSG_RESULT([no])
2051else
2052	if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
2053		RAWCPPFLAGS=-undef
2054		AC_MSG_RESULT([yes])
2055	# under Cygwin unix is still defined even with -undef
2056	elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
2057		RAWCPPFLAGS="-undef -ansi"
2058		AC_MSG_RESULT([yes, with -ansi])
2059	else
2060		AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef.  I don't know what to do.])
2061	fi
2062fi
2063rm -f conftest.$ac_ext
2064
2065AC_MSG_CHECKING([if $RAWCPP requires -traditional])
2066AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
2067if test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   "'` -eq 1 ; then
2068	AC_MSG_RESULT([no])
2069else
2070	if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve   "'` -eq 1 ; then
2071		TRADITIONALCPPFLAGS="-traditional"
2072		RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
2073		AC_MSG_RESULT([yes])
2074	else
2075		AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
2076	fi
2077fi
2078rm -f conftest.$ac_ext
2079AC_SUBST(RAWCPPFLAGS)
2080AC_SUBST(TRADITIONALCPPFLAGS)
2081]) # XORG_PROG_RAWCPP
2082
2083# XORG_MANPAGE_SECTIONS()
2084# -----------------------
2085# Minimum version: 1.0.0
2086#
2087# Determine which sections man pages go in for the different man page types
2088# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
2089# Not sure if there's any better way than just hardcoding by OS name.
2090# Override default settings by setting environment variables
2091# Added MAN_SUBSTS in version 1.8
2092# Added AC_PROG_SED in version 1.8
2093
2094AC_DEFUN([XORG_MANPAGE_SECTIONS],[
2095AC_REQUIRE([AC_CANONICAL_HOST])
2096AC_REQUIRE([AC_PROG_SED])
2097
2098case $host_os in
2099    solaris*)
2100        # Solaris 2.0 - 11.3 use SysV man page section numbers, so we
2101        # check for a man page file found in later versions that use
2102        # traditional section numbers instead
2103        AC_CHECK_FILE([/usr/share/man/man7/attributes.7],
2104                [SYSV_MAN_SECTIONS=false], [SYSV_MAN_SECTIONS=true])
2105        ;;
2106    *) SYSV_MAN_SECTIONS=false ;;
2107esac
2108
2109if test x$APP_MAN_SUFFIX = x    ; then
2110    APP_MAN_SUFFIX=1
2111fi
2112if test x$APP_MAN_DIR = x    ; then
2113    APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
2114fi
2115
2116if test x$LIB_MAN_SUFFIX = x    ; then
2117    LIB_MAN_SUFFIX=3
2118fi
2119if test x$LIB_MAN_DIR = x    ; then
2120    LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
2121fi
2122
2123if test x$FILE_MAN_SUFFIX = x    ; then
2124    case $SYSV_MAN_SECTIONS in
2125	true)				FILE_MAN_SUFFIX=4  ;;
2126	*)				FILE_MAN_SUFFIX=5  ;;
2127    esac
2128fi
2129if test x$FILE_MAN_DIR = x    ; then
2130    FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
2131fi
2132
2133if test x$MISC_MAN_SUFFIX = x    ; then
2134    case $SYSV_MAN_SECTIONS in
2135	true)				MISC_MAN_SUFFIX=5  ;;
2136	*)				MISC_MAN_SUFFIX=7  ;;
2137    esac
2138fi
2139if test x$MISC_MAN_DIR = x    ; then
2140    MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
2141fi
2142
2143if test x$DRIVER_MAN_SUFFIX = x    ; then
2144    case $SYSV_MAN_SECTIONS in
2145	true)				DRIVER_MAN_SUFFIX=7  ;;
2146	*)				DRIVER_MAN_SUFFIX=4  ;;
2147    esac
2148fi
2149if test x$DRIVER_MAN_DIR = x    ; then
2150    DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
2151fi
2152
2153if test x$ADMIN_MAN_SUFFIX = x    ; then
2154    case $SYSV_MAN_SECTIONS in
2155	true)				ADMIN_MAN_SUFFIX=1m ;;
2156	*)				ADMIN_MAN_SUFFIX=8  ;;
2157    esac
2158fi
2159if test x$ADMIN_MAN_DIR = x    ; then
2160    ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
2161fi
2162
2163
2164AC_SUBST([APP_MAN_SUFFIX])
2165AC_SUBST([LIB_MAN_SUFFIX])
2166AC_SUBST([FILE_MAN_SUFFIX])
2167AC_SUBST([MISC_MAN_SUFFIX])
2168AC_SUBST([DRIVER_MAN_SUFFIX])
2169AC_SUBST([ADMIN_MAN_SUFFIX])
2170AC_SUBST([APP_MAN_DIR])
2171AC_SUBST([LIB_MAN_DIR])
2172AC_SUBST([FILE_MAN_DIR])
2173AC_SUBST([MISC_MAN_DIR])
2174AC_SUBST([DRIVER_MAN_DIR])
2175AC_SUBST([ADMIN_MAN_DIR])
2176
2177XORG_MAN_PAGE="X Version 11"
2178AC_SUBST([XORG_MAN_PAGE])
2179MAN_SUBSTS="\
2180	-e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
2181	-e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
2182	-e 's|__xservername__|Xorg|g' \
2183	-e 's|__xconfigfile__|xorg.conf|g' \
2184	-e 's|__projectroot__|\$(prefix)|g' \
2185	-e 's|__apploaddir__|\$(appdefaultdir)|g' \
2186	-e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
2187	-e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
2188	-e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
2189	-e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
2190	-e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
2191	-e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
2192AC_SUBST([MAN_SUBSTS])
2193
2194]) # XORG_MANPAGE_SECTIONS
2195
2196# XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
2197# ------------------------
2198# Minimum version: 1.7.0
2199#
2200# Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
2201# provided by xorg-sgml-doctools, if installed.
2202AC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
2203AC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
2204XORG_SGML_PATH=
2205PKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
2206    [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
2207    [m4_ifval([$1],[:],
2208        [if test x"$cross_compiling" != x"yes" ; then
2209            AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
2210                          [XORG_SGML_PATH=$prefix/share/sgml])
2211         fi])
2212    ])
2213
2214# Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
2215# the path and the name of the doc stylesheet
2216if test "x$XORG_SGML_PATH" != "x" ; then
2217   AC_MSG_RESULT([$XORG_SGML_PATH])
2218   STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
2219   XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
2220else
2221   AC_MSG_RESULT([no])
2222fi
2223
2224AC_SUBST(XORG_SGML_PATH)
2225AC_SUBST(STYLESHEET_SRCDIR)
2226AC_SUBST(XSL_STYLESHEET)
2227AM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
2228]) # XORG_CHECK_SGML_DOCTOOLS
2229
2230# XORG_CHECK_LINUXDOC
2231# -------------------
2232# Minimum version: 1.0.0
2233#
2234# Defines the variable MAKE_TEXT if the necessary tools and
2235# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
2236# Whether or not the necessary tools and files are found can be checked
2237# with the AM_CONDITIONAL "BUILD_LINUXDOC"
2238AC_DEFUN([XORG_CHECK_LINUXDOC],[
2239AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
2240AC_REQUIRE([XORG_WITH_PS2PDF])
2241
2242AC_PATH_PROG(LINUXDOC, linuxdoc)
2243
2244AC_MSG_CHECKING([whether to build documentation])
2245
2246if test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
2247   BUILDDOC=yes
2248else
2249   BUILDDOC=no
2250fi
2251
2252AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
2253
2254AC_MSG_RESULT([$BUILDDOC])
2255
2256AC_MSG_CHECKING([whether to build pdf documentation])
2257
2258if test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
2259   BUILDPDFDOC=yes
2260else
2261   BUILDPDFDOC=no
2262fi
2263
2264AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
2265
2266AC_MSG_RESULT([$BUILDPDFDOC])
2267
2268MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
2269MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
2270MAKE_PDF="$PS2PDF"
2271MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
2272
2273AC_SUBST(MAKE_TEXT)
2274AC_SUBST(MAKE_PS)
2275AC_SUBST(MAKE_PDF)
2276AC_SUBST(MAKE_HTML)
2277]) # XORG_CHECK_LINUXDOC
2278
2279# XORG_CHECK_DOCBOOK
2280# -------------------
2281# Minimum version: 1.0.0
2282#
2283# Checks for the ability to build output formats from SGML DocBook source.
2284# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
2285# indicates whether the necessary tools and files are found and, if set,
2286# $(MAKE_XXX) blah.sgml will produce blah.xxx.
2287AC_DEFUN([XORG_CHECK_DOCBOOK],[
2288AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
2289
2290BUILDTXTDOC=no
2291BUILDPDFDOC=no
2292BUILDPSDOC=no
2293BUILDHTMLDOC=no
2294
2295AC_PATH_PROG(DOCBOOKPS, docbook2ps)
2296AC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
2297AC_PATH_PROG(DOCBOOKHTML, docbook2html)
2298AC_PATH_PROG(DOCBOOKTXT, docbook2txt)
2299
2300AC_MSG_CHECKING([whether to build text documentation])
2301if test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
2302   test x$BUILD_TXTDOC != xno; then
2303	BUILDTXTDOC=yes
2304fi
2305AM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
2306AC_MSG_RESULT([$BUILDTXTDOC])
2307
2308AC_MSG_CHECKING([whether to build PDF documentation])
2309if test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
2310   test x$BUILD_PDFDOC != xno; then
2311	BUILDPDFDOC=yes
2312fi
2313AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
2314AC_MSG_RESULT([$BUILDPDFDOC])
2315
2316AC_MSG_CHECKING([whether to build PostScript documentation])
2317if test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
2318   test x$BUILD_PSDOC != xno; then
2319	BUILDPSDOC=yes
2320fi
2321AM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
2322AC_MSG_RESULT([$BUILDPSDOC])
2323
2324AC_MSG_CHECKING([whether to build HTML documentation])
2325if test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
2326   test x$BUILD_HTMLDOC != xno; then
2327	BUILDHTMLDOC=yes
2328fi
2329AM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
2330AC_MSG_RESULT([$BUILDHTMLDOC])
2331
2332MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
2333MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
2334MAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
2335MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
2336
2337AC_SUBST(MAKE_TEXT)
2338AC_SUBST(MAKE_PS)
2339AC_SUBST(MAKE_PDF)
2340AC_SUBST(MAKE_HTML)
2341]) # XORG_CHECK_DOCBOOK
2342
2343# XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
2344# ----------------
2345# Minimum version: 1.5.0
2346# Minimum version for optional DEFAULT argument: 1.11.0
2347#
2348# Documentation tools are not always available on all platforms and sometimes
2349# not at the appropriate level. This macro enables a module to test for the
2350# presence of the tool and obtain it's path in separate variables. Coupled with
2351# the --with-xmlto option, it allows maximum flexibility in making decisions
2352# as whether or not to use the xmlto package. When DEFAULT is not specified,
2353# --with-xmlto assumes 'auto'.
2354#
2355# Interface to module:
2356# HAVE_XMLTO: 	used in makefiles to conditionally generate documentation
2357# XMLTO:	returns the path of the xmlto program found
2358#		returns the path set by the user in the environment
2359# --with-xmlto:	'yes' user instructs the module to use xmlto
2360#		'no' user instructs the module not to use xmlto
2361#
2362# Added in version 1.10.0
2363# HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
2364#                  xmlto for text output requires either lynx, links, or w3m browsers
2365#
2366# If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
2367#
2368AC_DEFUN([XORG_WITH_XMLTO],[
2369AC_ARG_VAR([XMLTO], [Path to xmlto command])
2370m4_define([_defopt], m4_default([$2], [auto]))
2371AC_ARG_WITH(xmlto,
2372	AS_HELP_STRING([--with-xmlto],
2373	   [Use xmlto to regenerate documentation (default: ]_defopt[)]),
2374	   [use_xmlto=$withval], [use_xmlto=]_defopt)
2375m4_undefine([_defopt])
2376
2377if test "x$use_xmlto" = x"auto"; then
2378   AC_PATH_PROG([XMLTO], [xmlto])
2379   if test "x$XMLTO" = "x"; then
2380        AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
2381	have_xmlto=no
2382   else
2383        have_xmlto=yes
2384   fi
2385elif test "x$use_xmlto" = x"yes" ; then
2386   AC_PATH_PROG([XMLTO], [xmlto])
2387   if test "x$XMLTO" = "x"; then
2388        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
2389   fi
2390   have_xmlto=yes
2391elif test "x$use_xmlto" = x"no" ; then
2392   if test "x$XMLTO" != "x"; then
2393      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
2394   fi
2395   have_xmlto=no
2396else
2397   AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
2398fi
2399
2400# Test for a minimum version of xmlto, if provided.
2401m4_ifval([$1],
2402[if test "$have_xmlto" = yes; then
2403    # scrape the xmlto version
2404    AC_MSG_CHECKING([the xmlto version])
2405    xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
2406    AC_MSG_RESULT([$xmlto_version])
2407    AS_VERSION_COMPARE([$xmlto_version], [$1],
2408        [if test "x$use_xmlto" = xauto; then
2409            AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
2410            have_xmlto=no
2411        else
2412            AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
2413        fi])
2414fi])
2415
2416# Test for the ability of xmlto to generate a text target
2417#
2418# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
2419# following test for empty XML docbook files.
2420# For compatibility reasons use the following empty XML docbook file and if
2421# it fails try it again with a non-empty XML file.
2422have_xmlto_text=no
2423cat > conftest.xml << "EOF"
2424EOF
2425AS_IF([test "$have_xmlto" = yes],
2426      [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
2427             [have_xmlto_text=yes],
2428             [# Try it again with a non-empty XML file.
2429              cat > conftest.xml << "EOF"
2430<x></x>
2431EOF
2432              AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
2433                    [have_xmlto_text=yes],
2434                    [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])])
2435rm -f conftest.xml
2436AM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
2437AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
2438]) # XORG_WITH_XMLTO
2439
2440# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
2441# --------------------------------------------
2442# Minimum version: 1.12.0
2443# Minimum version for optional DEFAULT argument: 1.12.0
2444#
2445# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
2446# XML-based language used for the transformation of XML documents.
2447# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
2448# It is used under the cover by xmlto to generate html files from DocBook/XML.
2449# The XSLT processor is often used as a standalone tool for transformations.
2450# It should not be assumed that this tool is used only to work with documnetation.
2451# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
2452#
2453# Interface to module:
2454# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
2455# XSLTPROC:	 returns the path of the xsltproc program found
2456#		 returns the path set by the user in the environment
2457# --with-xsltproc: 'yes' user instructs the module to use xsltproc
2458#		  'no' user instructs the module not to use xsltproc
2459# have_xsltproc: returns yes if xsltproc found in PATH or no
2460#
2461# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
2462#
2463AC_DEFUN([XORG_WITH_XSLTPROC],[
2464AC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
2465# Preserves the interface, should it be implemented later
2466m4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
2467m4_define([_defopt], m4_default([$2], [auto]))
2468AC_ARG_WITH(xsltproc,
2469	AS_HELP_STRING([--with-xsltproc],
2470	   [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
2471	   [use_xsltproc=$withval], [use_xsltproc=]_defopt)
2472m4_undefine([_defopt])
2473
2474if test "x$use_xsltproc" = x"auto"; then
2475   AC_PATH_PROG([XSLTPROC], [xsltproc])
2476   if test "x$XSLTPROC" = "x"; then
2477        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
2478	have_xsltproc=no
2479   else
2480        have_xsltproc=yes
2481   fi
2482elif test "x$use_xsltproc" = x"yes" ; then
2483   AC_PATH_PROG([XSLTPROC], [xsltproc])
2484   if test "x$XSLTPROC" = "x"; then
2485        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
2486   fi
2487   have_xsltproc=yes
2488elif test "x$use_xsltproc" = x"no" ; then
2489   if test "x$XSLTPROC" != "x"; then
2490      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
2491   fi
2492   have_xsltproc=no
2493else
2494   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
2495fi
2496
2497AM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
2498]) # XORG_WITH_XSLTPROC
2499
2500# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
2501# ----------------------------------------
2502# Minimum version: 1.15.0
2503#
2504# PERL (Practical Extraction and Report Language) is a language optimized for
2505# scanning arbitrary text files, extracting information from those text files,
2506# and printing reports based on that information.
2507#
2508# When DEFAULT is not specified, --with-perl assumes 'auto'.
2509#
2510# Interface to module:
2511# HAVE_PERL: used in makefiles to conditionally scan text files
2512# PERL:	     returns the path of the perl program found
2513#	     returns the path set by the user in the environment
2514# --with-perl: 'yes' user instructs the module to use perl
2515#	       'no' user instructs the module not to use perl
2516# have_perl: returns yes if perl found in PATH or no
2517#
2518# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
2519#
2520AC_DEFUN([XORG_WITH_PERL],[
2521AC_ARG_VAR([PERL], [Path to perl command])
2522# Preserves the interface, should it be implemented later
2523m4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
2524m4_define([_defopt], m4_default([$2], [auto]))
2525AC_ARG_WITH(perl,
2526	AS_HELP_STRING([--with-perl],
2527	   [Use perl for extracting information from files (default: ]_defopt[)]),
2528	   [use_perl=$withval], [use_perl=]_defopt)
2529m4_undefine([_defopt])
2530
2531if test "x$use_perl" = x"auto"; then
2532   AC_PATH_PROG([PERL], [perl])
2533   if test "x$PERL" = "x"; then
2534        AC_MSG_WARN([perl not found - cannot extract information and report])
2535	have_perl=no
2536   else
2537        have_perl=yes
2538   fi
2539elif test "x$use_perl" = x"yes" ; then
2540   AC_PATH_PROG([PERL], [perl])
2541   if test "x$PERL" = "x"; then
2542        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
2543   fi
2544   have_perl=yes
2545elif test "x$use_perl" = x"no" ; then
2546   if test "x$PERL" != "x"; then
2547      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
2548   fi
2549   have_perl=no
2550else
2551   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
2552fi
2553
2554AM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
2555]) # XORG_WITH_PERL
2556
2557# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
2558# ----------------
2559# Minimum version: 1.5.0
2560# Minimum version for optional DEFAULT argument: 1.11.0
2561#
2562# Documentation tools are not always available on all platforms and sometimes
2563# not at the appropriate level. This macro enables a module to test for the
2564# presence of the tool and obtain it's path in separate variables. Coupled with
2565# the --with-asciidoc option, it allows maximum flexibility in making decisions
2566# as whether or not to use the asciidoc package. When DEFAULT is not specified,
2567# --with-asciidoc assumes 'auto'.
2568#
2569# Interface to module:
2570# HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
2571# ASCIIDOC:	 returns the path of the asciidoc program found
2572#		 returns the path set by the user in the environment
2573# --with-asciidoc: 'yes' user instructs the module to use asciidoc
2574#		  'no' user instructs the module not to use asciidoc
2575#
2576# If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
2577#
2578AC_DEFUN([XORG_WITH_ASCIIDOC],[
2579AC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
2580m4_define([_defopt], m4_default([$2], [auto]))
2581AC_ARG_WITH(asciidoc,
2582	AS_HELP_STRING([--with-asciidoc],
2583	   [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
2584	   [use_asciidoc=$withval], [use_asciidoc=]_defopt)
2585m4_undefine([_defopt])
2586
2587if test "x$use_asciidoc" = x"auto"; then
2588   AC_PATH_PROG([ASCIIDOC], [asciidoc])
2589   if test "x$ASCIIDOC" = "x"; then
2590        AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
2591	have_asciidoc=no
2592   else
2593        have_asciidoc=yes
2594   fi
2595elif test "x$use_asciidoc" = x"yes" ; then
2596   AC_PATH_PROG([ASCIIDOC], [asciidoc])
2597   if test "x$ASCIIDOC" = "x"; then
2598        AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
2599   fi
2600   have_asciidoc=yes
2601elif test "x$use_asciidoc" = x"no" ; then
2602   if test "x$ASCIIDOC" != "x"; then
2603      AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
2604   fi
2605   have_asciidoc=no
2606else
2607   AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
2608fi
2609m4_ifval([$1],
2610[if test "$have_asciidoc" = yes; then
2611    # scrape the asciidoc version
2612    AC_MSG_CHECKING([the asciidoc version])
2613    asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
2614    AC_MSG_RESULT([$asciidoc_version])
2615    AS_VERSION_COMPARE([$asciidoc_version], [$1],
2616        [if test "x$use_asciidoc" = xauto; then
2617            AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
2618            have_asciidoc=no
2619        else
2620            AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
2621        fi])
2622fi])
2623AM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
2624]) # XORG_WITH_ASCIIDOC
2625
2626# XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
2627# -------------------------------------------
2628# Minimum version: 1.5.0
2629# Minimum version for optional DEFAULT argument: 1.11.0
2630# Minimum version for optional DOT checking: 1.18.0
2631#
2632# Documentation tools are not always available on all platforms and sometimes
2633# not at the appropriate level. This macro enables a module to test for the
2634# presence of the tool and obtain it's path in separate variables. Coupled with
2635# the --with-doxygen option, it allows maximum flexibility in making decisions
2636# as whether or not to use the doxygen package. When DEFAULT is not specified,
2637# --with-doxygen assumes 'auto'.
2638#
2639# Interface to module:
2640# HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
2641# DOXYGEN:	 returns the path of the doxygen program found
2642#		 returns the path set by the user in the environment
2643# --with-doxygen: 'yes' user instructs the module to use doxygen
2644#		  'no' user instructs the module not to use doxygen
2645#
2646# If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
2647#
2648AC_DEFUN([XORG_WITH_DOXYGEN],[
2649AC_ARG_VAR([DOXYGEN], [Path to doxygen command])
2650AC_ARG_VAR([DOT], [Path to the dot graphics utility])
2651m4_define([_defopt], m4_default([$2], [auto]))
2652AC_ARG_WITH(doxygen,
2653	AS_HELP_STRING([--with-doxygen],
2654	   [Use doxygen to regenerate documentation (default: ]_defopt[)]),
2655	   [use_doxygen=$withval], [use_doxygen=]_defopt)
2656m4_undefine([_defopt])
2657
2658if test "x$use_doxygen" = x"auto"; then
2659   AC_PATH_PROG([DOXYGEN], [doxygen])
2660   if test "x$DOXYGEN" = "x"; then
2661        AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
2662	have_doxygen=no
2663   else
2664        have_doxygen=yes
2665   fi
2666elif test "x$use_doxygen" = x"yes" ; then
2667   AC_PATH_PROG([DOXYGEN], [doxygen])
2668   if test "x$DOXYGEN" = "x"; then
2669        AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
2670   fi
2671   have_doxygen=yes
2672elif test "x$use_doxygen" = x"no" ; then
2673   if test "x$DOXYGEN" != "x"; then
2674      AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
2675   fi
2676   have_doxygen=no
2677else
2678   AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
2679fi
2680m4_ifval([$1],
2681[if test "$have_doxygen" = yes; then
2682    # scrape the doxygen version
2683    AC_MSG_CHECKING([the doxygen version])
2684    doxygen_version=`$DOXYGEN --version 2>/dev/null`
2685    AC_MSG_RESULT([$doxygen_version])
2686    AS_VERSION_COMPARE([$doxygen_version], [$1],
2687        [if test "x$use_doxygen" = xauto; then
2688            AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
2689            have_doxygen=no
2690        else
2691            AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
2692        fi])
2693fi])
2694
2695dnl Check for DOT if we have doxygen. The caller decides if it is mandatory
2696dnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
2697dnl 	HAVE_DOT = @HAVE_DOT@
2698HAVE_DOT=no
2699if test "x$have_doxygen" = "xyes"; then
2700  AC_PATH_PROG([DOT], [dot])
2701    if test "x$DOT" != "x"; then
2702      HAVE_DOT=yes
2703    fi
2704fi
2705
2706AC_SUBST([HAVE_DOT])
2707AM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
2708AM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
2709]) # XORG_WITH_DOXYGEN
2710
2711# XORG_WITH_GROFF([DEFAULT])
2712# ----------------
2713# Minimum version: 1.6.0
2714# Minimum version for optional DEFAULT argument: 1.11.0
2715#
2716# Documentation tools are not always available on all platforms and sometimes
2717# not at the appropriate level. This macro enables a module to test for the
2718# presence of the tool and obtain it's path in separate variables. Coupled with
2719# the --with-groff option, it allows maximum flexibility in making decisions
2720# as whether or not to use the groff package. When DEFAULT is not specified,
2721# --with-groff assumes 'auto'.
2722#
2723# Interface to module:
2724# HAVE_GROFF:	 used in makefiles to conditionally generate documentation
2725# HAVE_GROFF_MM: the memorandum macros (-mm) package
2726# HAVE_GROFF_MS: the -ms macros package
2727# GROFF:	 returns the path of the groff program found
2728#		 returns the path set by the user in the environment
2729# --with-groff:	 'yes' user instructs the module to use groff
2730#		 'no' user instructs the module not to use groff
2731#
2732# Added in version 1.9.0:
2733# HAVE_GROFF_HTML: groff has dependencies to output HTML format:
2734#		   pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
2735#		   psselect from the psutils package.
2736#		   the ghostcript package. Refer to the grohtml man pages
2737#
2738# If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
2739#
2740# OS and distros often splits groff in a basic and full package, the former
2741# having the groff program and the later having devices, fonts and macros
2742# Checking for the groff executable is not enough.
2743#
2744# If macros are missing, we cannot assume that groff is useless, so we don't
2745# unset HAVE_GROFF or GROFF env variables.
2746# HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
2747#
2748AC_DEFUN([XORG_WITH_GROFF],[
2749AC_ARG_VAR([GROFF], [Path to groff command])
2750m4_define([_defopt], m4_default([$1], [auto]))
2751AC_ARG_WITH(groff,
2752	AS_HELP_STRING([--with-groff],
2753	   [Use groff to regenerate documentation (default: ]_defopt[)]),
2754	   [use_groff=$withval], [use_groff=]_defopt)
2755m4_undefine([_defopt])
2756
2757if test "x$use_groff" = x"auto"; then
2758   AC_PATH_PROG([GROFF], [groff])
2759   if test "x$GROFF" = "x"; then
2760        AC_MSG_WARN([groff not found - documentation targets will be skipped])
2761	have_groff=no
2762   else
2763        have_groff=yes
2764   fi
2765elif test "x$use_groff" = x"yes" ; then
2766   AC_PATH_PROG([GROFF], [groff])
2767   if test "x$GROFF" = "x"; then
2768        AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
2769   fi
2770   have_groff=yes
2771elif test "x$use_groff" = x"no" ; then
2772   if test "x$GROFF" != "x"; then
2773      AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
2774   fi
2775   have_groff=no
2776else
2777   AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
2778fi
2779
2780# We have groff, test for the presence of the macro packages
2781if test "x$have_groff" = x"yes"; then
2782    AC_MSG_CHECKING([for ${GROFF} -ms macros])
2783    if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
2784        groff_ms_works=yes
2785    else
2786        groff_ms_works=no
2787    fi
2788    AC_MSG_RESULT([$groff_ms_works])
2789    AC_MSG_CHECKING([for ${GROFF} -mm macros])
2790    if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
2791        groff_mm_works=yes
2792    else
2793        groff_mm_works=no
2794    fi
2795    AC_MSG_RESULT([$groff_mm_works])
2796fi
2797
2798# We have groff, test for HTML dependencies, one command per package
2799if test "x$have_groff" = x"yes"; then
2800   AC_PATH_PROGS(GS_PATH, [gs gswin32c])
2801   AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
2802   AC_PATH_PROG(PSSELECT_PATH, [psselect])
2803   if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
2804      have_groff_html=yes
2805   else
2806      have_groff_html=no
2807      AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
2808   fi
2809fi
2810
2811# Set Automake conditionals for Makefiles
2812AM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
2813AM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
2814AM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
2815AM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
2816]) # XORG_WITH_GROFF
2817
2818# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
2819# ---------------------------------------
2820# Minimum version: 1.6.0
2821# Minimum version for optional DEFAULT argument: 1.11.0
2822# Minimum version for optional MIN-VERSION argument: 1.15.0
2823#
2824# Documentation tools are not always available on all platforms and sometimes
2825# not at the appropriate level. This macro enables a module to test for the
2826# presence of the tool and obtain it's path in separate variables. Coupled with
2827# the --with-fop option, it allows maximum flexibility in making decisions
2828# as whether or not to use the fop package. When DEFAULT is not specified,
2829# --with-fop assumes 'auto'.
2830#
2831# Interface to module:
2832# HAVE_FOP: 	used in makefiles to conditionally generate documentation
2833# FOP:	 	returns the path of the fop program found
2834#		returns the path set by the user in the environment
2835# --with-fop: 	'yes' user instructs the module to use fop
2836#		'no' user instructs the module not to use fop
2837#
2838# If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
2839#
2840AC_DEFUN([XORG_WITH_FOP],[
2841AC_ARG_VAR([FOP], [Path to fop command])
2842m4_define([_defopt], m4_default([$2], [auto]))
2843AC_ARG_WITH(fop,
2844	AS_HELP_STRING([--with-fop],
2845	   [Use fop to regenerate documentation (default: ]_defopt[)]),
2846	   [use_fop=$withval], [use_fop=]_defopt)
2847m4_undefine([_defopt])
2848
2849if test "x$use_fop" = x"auto"; then
2850   AC_PATH_PROG([FOP], [fop])
2851   if test "x$FOP" = "x"; then
2852        AC_MSG_WARN([fop not found - documentation targets will be skipped])
2853	have_fop=no
2854   else
2855        have_fop=yes
2856   fi
2857elif test "x$use_fop" = x"yes" ; then
2858   AC_PATH_PROG([FOP], [fop])
2859   if test "x$FOP" = "x"; then
2860        AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
2861   fi
2862   have_fop=yes
2863elif test "x$use_fop" = x"no" ; then
2864   if test "x$FOP" != "x"; then
2865      AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
2866   fi
2867   have_fop=no
2868else
2869   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
2870fi
2871
2872# Test for a minimum version of fop, if provided.
2873m4_ifval([$1],
2874[if test "$have_fop" = yes; then
2875    # scrape the fop version
2876    AC_MSG_CHECKING([for fop minimum version])
2877    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
2878    AC_MSG_RESULT([$fop_version])
2879    AS_VERSION_COMPARE([$fop_version], [$1],
2880        [if test "x$use_fop" = xauto; then
2881            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
2882            have_fop=no
2883        else
2884            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
2885        fi])
2886fi])
2887AM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
2888]) # XORG_WITH_FOP
2889
2890# XORG_WITH_M4([MIN-VERSION])
2891# ---------------------------
2892# Minimum version: 1.19.0
2893#
2894# This macro attempts to locate an m4 macro processor which supports
2895# -I option and is only useful for modules relying on M4 in order to
2896# expand macros in source code files.
2897#
2898# Interface to module:
2899# M4:	 	returns the path of the m4 program found
2900#		returns the path set by the user in the environment
2901#
2902AC_DEFUN([XORG_WITH_M4], [
2903AC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
2904   [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
2905       [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
2906         ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
2907   [AC_MSG_ERROR([could not find m4 that supports -I option])],
2908   [$PATH:/usr/gnu/bin])])
2909
2910AC_SUBST([M4], [$ac_cv_path_M4])
2911]) # XORG_WITH_M4
2912
2913# XORG_WITH_PS2PDF([DEFAULT])
2914# ----------------
2915# Minimum version: 1.6.0
2916# Minimum version for optional DEFAULT argument: 1.11.0
2917#
2918# Documentation tools are not always available on all platforms and sometimes
2919# not at the appropriate level. This macro enables a module to test for the
2920# presence of the tool and obtain it's path in separate variables. Coupled with
2921# the --with-ps2pdf option, it allows maximum flexibility in making decisions
2922# as whether or not to use the ps2pdf package. When DEFAULT is not specified,
2923# --with-ps2pdf assumes 'auto'.
2924#
2925# Interface to module:
2926# HAVE_PS2PDF: 	used in makefiles to conditionally generate documentation
2927# PS2PDF:	returns the path of the ps2pdf program found
2928#		returns the path set by the user in the environment
2929# --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
2930#		 'no' user instructs the module not to use ps2pdf
2931#
2932# If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
2933#
2934AC_DEFUN([XORG_WITH_PS2PDF],[
2935AC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
2936m4_define([_defopt], m4_default([$1], [auto]))
2937AC_ARG_WITH(ps2pdf,
2938	AS_HELP_STRING([--with-ps2pdf],
2939	   [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
2940	   [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
2941m4_undefine([_defopt])
2942
2943if test "x$use_ps2pdf" = x"auto"; then
2944   AC_PATH_PROG([PS2PDF], [ps2pdf])
2945   if test "x$PS2PDF" = "x"; then
2946        AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
2947	have_ps2pdf=no
2948   else
2949        have_ps2pdf=yes
2950   fi
2951elif test "x$use_ps2pdf" = x"yes" ; then
2952   AC_PATH_PROG([PS2PDF], [ps2pdf])
2953   if test "x$PS2PDF" = "x"; then
2954        AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
2955   fi
2956   have_ps2pdf=yes
2957elif test "x$use_ps2pdf" = x"no" ; then
2958   if test "x$PS2PDF" != "x"; then
2959      AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
2960   fi
2961   have_ps2pdf=no
2962else
2963   AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
2964fi
2965AM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
2966]) # XORG_WITH_PS2PDF
2967
2968# XORG_ENABLE_DOCS (enable_docs=yes)
2969# ----------------
2970# Minimum version: 1.6.0
2971#
2972# Documentation tools are not always available on all platforms and sometimes
2973# not at the appropriate level. This macro enables a builder to skip all
2974# documentation targets except traditional man pages.
2975# Combined with the specific tool checking macros XORG_WITH_*, it provides
2976# maximum flexibility in controlling documentation building.
2977# Refer to:
2978# XORG_WITH_XMLTO         --with-xmlto
2979# XORG_WITH_ASCIIDOC      --with-asciidoc
2980# XORG_WITH_DOXYGEN       --with-doxygen
2981# XORG_WITH_FOP           --with-fop
2982# XORG_WITH_GROFF         --with-groff
2983# XORG_WITH_PS2PDF        --with-ps2pdf
2984#
2985# Interface to module:
2986# ENABLE_DOCS: 	  used in makefiles to conditionally generate documentation
2987# --enable-docs: 'yes' user instructs the module to generate docs
2988#		 'no' user instructs the module not to generate docs
2989# parm1:	specify the default value, yes or no.
2990#
2991AC_DEFUN([XORG_ENABLE_DOCS],[
2992m4_define([docs_default], m4_default([$1], [yes]))
2993AC_ARG_ENABLE(docs,
2994	AS_HELP_STRING([--enable-docs],
2995	   [Enable building the documentation (default: ]docs_default[)]),
2996	   [build_docs=$enableval], [build_docs=]docs_default)
2997m4_undefine([docs_default])
2998AM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
2999AC_MSG_CHECKING([whether to build documentation])
3000AC_MSG_RESULT([$build_docs])
3001]) # XORG_ENABLE_DOCS
3002
3003# XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
3004# ----------------
3005# Minimum version: 1.6.0
3006#
3007# This macro enables a builder to skip all developer documentation.
3008# Combined with the specific tool checking macros XORG_WITH_*, it provides
3009# maximum flexibility in controlling documentation building.
3010# Refer to:
3011# XORG_WITH_XMLTO         --with-xmlto
3012# XORG_WITH_ASCIIDOC      --with-asciidoc
3013# XORG_WITH_DOXYGEN       --with-doxygen
3014# XORG_WITH_FOP           --with-fop
3015# XORG_WITH_GROFF         --with-groff
3016# XORG_WITH_PS2PDF        --with-ps2pdf
3017#
3018# Interface to module:
3019# ENABLE_DEVEL_DOCS:	used in makefiles to conditionally generate developer docs
3020# --enable-devel-docs:	'yes' user instructs the module to generate developer docs
3021#			'no' user instructs the module not to generate developer docs
3022# parm1:		specify the default value, yes or no.
3023#
3024AC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
3025m4_define([devel_default], m4_default([$1], [yes]))
3026AC_ARG_ENABLE(devel-docs,
3027	AS_HELP_STRING([--enable-devel-docs],
3028	   [Enable building the developer documentation (default: ]devel_default[)]),
3029	   [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
3030m4_undefine([devel_default])
3031AM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
3032AC_MSG_CHECKING([whether to build developer documentation])
3033AC_MSG_RESULT([$build_devel_docs])
3034]) # XORG_ENABLE_DEVEL_DOCS
3035
3036# XORG_ENABLE_SPECS (enable_specs=yes)
3037# ----------------
3038# Minimum version: 1.6.0
3039#
3040# This macro enables a builder to skip all functional specification targets.
3041# Combined with the specific tool checking macros XORG_WITH_*, it provides
3042# maximum flexibility in controlling documentation building.
3043# Refer to:
3044# XORG_WITH_XMLTO         --with-xmlto
3045# XORG_WITH_ASCIIDOC      --with-asciidoc
3046# XORG_WITH_DOXYGEN       --with-doxygen
3047# XORG_WITH_FOP           --with-fop
3048# XORG_WITH_GROFF         --with-groff
3049# XORG_WITH_PS2PDF        --with-ps2pdf
3050#
3051# Interface to module:
3052# ENABLE_SPECS:		used in makefiles to conditionally generate specs
3053# --enable-specs:	'yes' user instructs the module to generate specs
3054#			'no' user instructs the module not to generate specs
3055# parm1:		specify the default value, yes or no.
3056#
3057AC_DEFUN([XORG_ENABLE_SPECS],[
3058m4_define([spec_default], m4_default([$1], [yes]))
3059AC_ARG_ENABLE(specs,
3060	AS_HELP_STRING([--enable-specs],
3061	   [Enable building the specs (default: ]spec_default[)]),
3062	   [build_specs=$enableval], [build_specs=]spec_default)
3063m4_undefine([spec_default])
3064AM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
3065AC_MSG_CHECKING([whether to build functional specifications])
3066AC_MSG_RESULT([$build_specs])
3067]) # XORG_ENABLE_SPECS
3068
3069# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
3070# ----------------------------------------------
3071# Minimum version: 1.13.0
3072#
3073# This macro enables a builder to enable/disable unit testing
3074# It makes no assumption about the test cases implementation
3075# Test cases may or may not use Automake "Support for test suites"
3076# They may or may not use the software utility library GLib
3077#
3078# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
3079# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
3080# The variable enable_unit_tests is used by other macros in this file.
3081#
3082# Interface to module:
3083# ENABLE_UNIT_TESTS:	used in makefiles to conditionally build tests
3084# enable_unit_tests:    used in configure.ac for additional configuration
3085# --enable-unit-tests:	'yes' user instructs the module to build tests
3086#			'no' user instructs the module not to build tests
3087# parm1:		specify the default value, yes or no.
3088#
3089AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
3090AC_BEFORE([$0], [XORG_WITH_GLIB])
3091AC_BEFORE([$0], [XORG_LD_WRAP])
3092AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
3093m4_define([_defopt], m4_default([$1], [auto]))
3094AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
3095	[Enable building unit test cases (default: ]_defopt[)]),
3096	[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
3097m4_undefine([_defopt])
3098AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
3099AC_MSG_CHECKING([whether to build unit test cases])
3100AC_MSG_RESULT([$enable_unit_tests])
3101]) # XORG_ENABLE_UNIT_TESTS
3102
3103# XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
3104# ------------------------------------------------------
3105# Minimum version: 1.17.0
3106#
3107# This macro enables a builder to enable/disable integration testing
3108# It makes no assumption about the test cases' implementation
3109# Test cases may or may not use Automake "Support for test suites"
3110#
3111# Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
3112# usually requires less dependencies and may be built and run under less
3113# stringent environments than integration tests.
3114#
3115# Interface to module:
3116# ENABLE_INTEGRATION_TESTS:   used in makefiles to conditionally build tests
3117# enable_integration_tests:   used in configure.ac for additional configuration
3118# --enable-integration-tests: 'yes' user instructs the module to build tests
3119#                             'no' user instructs the module not to build tests
3120# parm1:                      specify the default value, yes or no.
3121#
3122AC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
3123AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
3124m4_define([_defopt], m4_default([$1], [auto]))
3125AC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
3126	[Enable building integration test cases (default: ]_defopt[)]),
3127	[enable_integration_tests=$enableval],
3128	[enable_integration_tests=]_defopt)
3129m4_undefine([_defopt])
3130AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
3131	[test "x$enable_integration_tests" != xno])
3132AC_MSG_CHECKING([whether to build unit test cases])
3133AC_MSG_RESULT([$enable_integration_tests])
3134]) # XORG_ENABLE_INTEGRATION_TESTS
3135
3136# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
3137# ----------------------------------------
3138# Minimum version: 1.13.0
3139#
3140# GLib is a library which provides advanced data structures and functions.
3141# This macro enables a module to test for the presence of Glib.
3142#
3143# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
3144# Otherwise the value of $enable_unit_tests is blank.
3145#
3146# Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
3147# test support usually requires less dependencies and may be built and run under
3148# less stringent environments than integration tests.
3149#
3150# Interface to module:
3151# HAVE_GLIB: used in makefiles to conditionally build targets
3152# with_glib: used in configure.ac to know if GLib has been found
3153# --with-glib:	'yes' user instructs the module to use glib
3154#		'no' user instructs the module not to use glib
3155#
3156AC_DEFUN([XORG_WITH_GLIB],[
3157AC_REQUIRE([PKG_PROG_PKG_CONFIG])
3158m4_define([_defopt], m4_default([$2], [auto]))
3159AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
3160	[Use GLib library for unit testing (default: ]_defopt[)]),
3161	[with_glib=$withval], [with_glib=]_defopt)
3162m4_undefine([_defopt])
3163
3164have_glib=no
3165# Do not probe GLib if user explicitly disabled unit testing
3166if test "x$enable_unit_tests" != x"no"; then
3167  # Do not probe GLib if user explicitly disabled it
3168  if test "x$with_glib" != x"no"; then
3169    m4_ifval(
3170      [$1],
3171      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
3172      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
3173    )
3174  fi
3175fi
3176
3177# Not having GLib when unit testing has been explicitly requested is an error
3178if test "x$enable_unit_tests" = x"yes"; then
3179  if test "x$have_glib" = x"no"; then
3180    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
3181  fi
3182fi
3183
3184# Having unit testing disabled when GLib has been explicitly requested is an error
3185if test "x$enable_unit_tests" = x"no"; then
3186  if test "x$with_glib" = x"yes"; then
3187    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
3188  fi
3189fi
3190
3191# Not having GLib when it has been explicitly requested is an error
3192if test "x$with_glib" = x"yes"; then
3193  if test "x$have_glib" = x"no"; then
3194    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
3195  fi
3196fi
3197
3198AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
3199]) # XORG_WITH_GLIB
3200
3201# XORG_LD_WRAP([required|optional])
3202# ---------------------------------
3203# Minimum version: 1.13.0
3204#
3205# Check if linker supports -wrap, passed via compiler flags
3206#
3207# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
3208# Otherwise the value of $enable_unit_tests is blank.
3209#
3210# Argument added in 1.16.0 - default is "required", to match existing behavior
3211# of returning an error if enable_unit_tests is yes, and ld -wrap is not
3212# available, an argument of "optional" allows use when some unit tests require
3213# ld -wrap and others do not.
3214#
3215AC_DEFUN([XORG_LD_WRAP],[
3216XORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
3217    [AC_LANG_PROGRAM([#include <stdlib.h>
3218                      void __wrap_exit(int status) { return; }],
3219                     [exit(0);])])
3220# Not having ld wrap when unit testing has been explicitly requested is an error
3221if test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
3222  if test "x$have_ld_wrap" = x"no"; then
3223    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
3224  fi
3225fi
3226AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
3227#
3228]) # XORG_LD_WRAP
3229
3230# XORG_CHECK_LINKER_FLAGS
3231# -----------------------
3232# SYNOPSIS
3233#
3234#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
3235#
3236# DESCRIPTION
3237#
3238#   Check whether the given linker FLAGS work with the current language's
3239#   linker, or whether they give an error.
3240#
3241#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
3242#   success/failure.
3243#
3244#   PROGRAM-SOURCE is the program source to link with, if needed
3245#
3246#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
3247#
3248# LICENSE
3249#
3250#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
3251#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
3252#   Copyright (c) 2009 Matteo Frigo
3253#
3254#   This program is free software: you can redistribute it and/or modify it
3255#   under the terms of the GNU General Public License as published by the
3256#   Free Software Foundation, either version 3 of the License, or (at your
3257#   option) any later version.
3258#
3259#   This program is distributed in the hope that it will be useful, but
3260#   WITHOUT ANY WARRANTY; without even the implied warranty of
3261#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
3262#   Public License for more details.
3263#
3264#   You should have received a copy of the GNU General Public License along
3265#   with this program. If not, see <http://www.gnu.org/licenses/>.
3266#
3267#   As a special exception, the respective Autoconf Macro's copyright owner
3268#   gives unlimited permission to copy, distribute and modify the configure
3269#   scripts that are the output of Autoconf when processing the Macro. You
3270#   need not follow the terms of the GNU General Public License when using
3271#   or distributing such scripts, even though portions of the text of the
3272#   Macro appear in them. The GNU General Public License (GPL) does govern
3273#   all other use of the material that constitutes the Autoconf Macro.
3274#
3275#   This special exception to the GPL applies to versions of the Autoconf
3276#   Macro released by the Autoconf Archive. When you make and distribute a
3277#   modified version of the Autoconf Macro, you may extend this special
3278#   exception to the GPL to apply to your modified version as well.#
3279AC_DEFUN([XORG_CHECK_LINKER_FLAGS],
3280[AC_MSG_CHECKING([whether the linker accepts $1])
3281dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
3282AS_LITERAL_IF([$1],
3283  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
3284      ax_save_FLAGS=$LDFLAGS
3285      LDFLAGS="$1"
3286      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
3287        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
3288        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
3289      LDFLAGS=$ax_save_FLAGS])],
3290  [ax_save_FLAGS=$LDFLAGS
3291   LDFLAGS="$1"
3292   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
3293     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
3294     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
3295   LDFLAGS=$ax_save_FLAGS])
3296eval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
3297AC_MSG_RESULT($xorg_check_linker_flags)
3298if test "x$xorg_check_linker_flags" = xyes; then
3299	m4_default([$2], :)
3300else
3301	m4_default([$3], :)
3302fi
3303]) # XORG_CHECK_LINKER_FLAGS
3304
3305# XORG_MEMORY_CHECK_FLAGS
3306# -----------------------
3307# Minimum version: 1.16.0
3308#
3309# This macro attempts to find appropriate memory checking functionality
3310# for various platforms which unit testing code may use to catch various
3311# forms of memory allocation and access errors in testing.
3312#
3313# Interface to module:
3314# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
3315#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
3316#
3317# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
3318#
3319AC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
3320
3321AC_REQUIRE([AC_CANONICAL_HOST])
3322AC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
3323           [Environment variables to enable memory checking in tests])
3324
3325# Check for different types of support on different platforms
3326case $host_os in
3327    solaris*)
3328        AC_CHECK_LIB([umem], [umem_alloc],
3329            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
3330        ;;
3331    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
3332        # both directly and inverted, so should not be 0 or 255.
3333        malloc_debug_env='MALLOC_PERTURB_=15'
3334        ;;
3335    darwin*)
3336        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
3337        ;;
3338    *bsd*)
3339        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
3340        ;;
3341esac
3342
3343# User supplied flags override default flags
3344if test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
3345    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
3346fi
3347
3348AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
3349]) # XORG_WITH_LINT
3350
3351# XORG_CHECK_MALLOC_ZERO
3352# ----------------------
3353# Minimum version: 1.0.0
3354#
3355# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
3356# malloc(0) returns NULL.  Packages should add one of these cflags to
3357# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
3358AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
3359AC_ARG_ENABLE(malloc0returnsnull,
3360	AS_HELP_STRING([--enable-malloc0returnsnull],
3361		       [malloc(0) returns NULL (default: auto)]),
3362	[MALLOC_ZERO_RETURNS_NULL=$enableval],
3363	[MALLOC_ZERO_RETURNS_NULL=auto])
3364
3365AC_MSG_CHECKING([whether malloc(0) returns NULL])
3366if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
3367AC_CACHE_VAL([xorg_cv_malloc0_returns_null],
3368	[AC_RUN_IFELSE([AC_LANG_PROGRAM([
3369#include <stdlib.h>
3370],[
3371    char *m0, *r0, *c0, *p;
3372    m0 = malloc(0);
3373    p = malloc(10);
3374    r0 = realloc(p,0);
3375    c0 = calloc(0,10);
3376    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
3377])],
3378		[xorg_cv_malloc0_returns_null=yes],
3379		[xorg_cv_malloc0_returns_null=no])])
3380MALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null
3381fi
3382AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
3383
3384if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
3385	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
3386	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
3387	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
3388else
3389	MALLOC_ZERO_CFLAGS=""
3390	XMALLOC_ZERO_CFLAGS=""
3391	XTMALLOC_ZERO_CFLAGS=""
3392fi
3393
3394AC_SUBST([MALLOC_ZERO_CFLAGS])
3395AC_SUBST([XMALLOC_ZERO_CFLAGS])
3396AC_SUBST([XTMALLOC_ZERO_CFLAGS])
3397]) # XORG_CHECK_MALLOC_ZERO
3398
3399# XORG_WITH_LINT()
3400# ----------------
3401# Minimum version: 1.1.0
3402#
3403# This macro enables the use of a tool that flags some suspicious and
3404# non-portable constructs (likely to be bugs) in C language source code.
3405# It will attempt to locate the tool and use appropriate options.
3406# There are various lint type tools on different platforms.
3407#
3408# Interface to module:
3409# LINT:		returns the path to the tool found on the platform
3410#		or the value set to LINT on the configure cmd line
3411#		also an Automake conditional
3412# LINT_FLAGS:	an Automake variable with appropriate flags
3413#
3414# --with-lint:	'yes' user instructs the module to use lint
3415#		'no' user instructs the module not to use lint (default)
3416#
3417# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
3418# If the user sets the value of LINT_FLAGS, they are used verbatim.
3419#
3420AC_DEFUN([XORG_WITH_LINT],[
3421
3422AC_ARG_VAR([LINT], [Path to a lint-style command])
3423AC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
3424AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
3425		[Use a lint-style source code checker (default: disabled)])],
3426		[use_lint=$withval], [use_lint=no])
3427
3428# Obtain platform specific info like program name and options
3429# The lint program on FreeBSD and NetBSD is different from the one on Solaris
3430case $host_os in
3431  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
3432	lint_name=splint
3433	lint_options="-badflag"
3434	;;
3435  *freebsd* | *netbsd*)
3436	lint_name=lint
3437	lint_options="-u -b"
3438	;;
3439  *solaris*)
3440	lint_name=lint
3441	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
3442	;;
3443esac
3444
3445# Test for the presence of the program (either guessed by the code or spelled out by the user)
3446if test "x$use_lint" = x"yes" ; then
3447   AC_PATH_PROG([LINT], [$lint_name])
3448   if test "x$LINT" = "x"; then
3449        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
3450   fi
3451elif test "x$use_lint" = x"no" ; then
3452   if test "x$LINT" != "x"; then
3453      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
3454   fi
3455else
3456   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
3457fi
3458
3459# User supplied flags override default flags
3460if test "x$LINT_FLAGS" != "x"; then
3461   lint_options=$LINT_FLAGS
3462fi
3463
3464AC_SUBST([LINT_FLAGS],[$lint_options])
3465AM_CONDITIONAL(LINT, [test "x$LINT" != x])
3466
3467]) # XORG_WITH_LINT
3468
3469# XORG_LINT_LIBRARY(LIBNAME)
3470# --------------------------
3471# Minimum version: 1.1.0
3472#
3473# Sets up flags for building lint libraries for checking programs that call
3474# functions in the library.
3475#
3476# Interface to module:
3477# LINTLIB		- Automake variable with the name of lint library file to make
3478# MAKE_LINT_LIB		- Automake conditional
3479#
3480# --enable-lint-library:  - 'yes' user instructs the module to created a lint library
3481#			  - 'no' user instructs the module not to create a lint library (default)
3482
3483AC_DEFUN([XORG_LINT_LIBRARY],[
3484AC_REQUIRE([XORG_WITH_LINT])
3485AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
3486	[Create lint library (default: disabled)])],
3487	[make_lint_lib=$enableval], [make_lint_lib=no])
3488
3489if test "x$make_lint_lib" = x"yes" ; then
3490   LINTLIB=llib-l$1.ln
3491   if test "x$LINT" = "x"; then
3492        AC_MSG_ERROR([Cannot make lint library without --with-lint])
3493   fi
3494elif test "x$make_lint_lib" != x"no" ; then
3495   AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
3496fi
3497
3498AC_SUBST(LINTLIB)
3499AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
3500
3501]) # XORG_LINT_LIBRARY
3502
3503# XORG_COMPILER_BRAND
3504# -------------------
3505# Minimum version: 1.14.0
3506#
3507# Checks for various brands of compilers and sets flags as appropriate:
3508#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
3509#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
3510#   clang compiler - sets CLANGCC to "yes"
3511#   Intel compiler - sets INTELCC to "yes"
3512#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
3513#
3514AC_DEFUN([XORG_COMPILER_BRAND], [
3515AC_LANG_CASE(
3516	[C], [
3517		dnl autoconf-2.70 folded AC_PROG_CC_C99 into AC_PROG_CC
3518		dnl and complains that AC_PROG_CC_C99 is obsolete
3519		m4_version_prereq([2.70],
3520			[AC_REQUIRE([AC_PROG_CC])],
3521			[AC_REQUIRE([AC_PROG_CC_C99])])
3522	],
3523	[C++], [
3524		AC_REQUIRE([AC_PROG_CXX])
3525	]
3526)
3527AC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
3528AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
3529AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
3530]) # XORG_COMPILER_BRAND
3531
3532# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
3533# ---------------
3534# Minimum version: 1.16.0
3535#
3536# Test if the compiler works when passed the given flag as a command line argument.
3537# If it succeeds, the flag is appended to the given variable.  If not, it tries the
3538# next flag in the list until there are no more options.
3539#
3540# Note that this does not guarantee that the compiler supports the flag as some
3541# compilers will simply ignore arguments that they do not understand, but we do
3542# attempt to weed out false positives by using -Werror=unknown-warning-option and
3543# -Werror=unused-command-line-argument
3544#
3545AC_DEFUN([XORG_TESTSET_CFLAG], [
3546m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
3547m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
3548
3549AC_LANG_COMPILER_REQUIRE
3550
3551AC_LANG_CASE(
3552	[C], [
3553		dnl autoconf-2.70 folded AC_PROG_CC_C99 into AC_PROG_CC
3554		dnl and complains that AC_PROG_CC_C99 is obsolete
3555		m4_version_prereq([2.70],
3556			[AC_REQUIRE([AC_PROG_CC])],
3557			[AC_REQUIRE([AC_PROG_CC_C99])])
3558		define([PREFIX], [C])
3559		define([CACHE_PREFIX], [cc])
3560		define([COMPILER], [$CC])
3561	],
3562	[C++], [
3563		define([PREFIX], [CXX])
3564		define([CACHE_PREFIX], [cxx])
3565		define([COMPILER], [$CXX])
3566	]
3567)
3568
3569[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
3570
3571if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
3572	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
3573	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
3574			[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
3575			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
3576					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
3577					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
3578	[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
3579	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
3580fi
3581
3582if test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
3583	if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
3584		PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
3585	fi
3586	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
3587	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
3588			[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
3589			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
3590					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
3591					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
3592	[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
3593	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
3594fi
3595
3596found="no"
3597m4_foreach([flag], m4_cdr($@), [
3598	if test $found = "no" ; then
3599		if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
3600			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
3601		fi
3602
3603		if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
3604			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
3605		fi
3606
3607		PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
3608
3609dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
3610		AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
3611		cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
3612		AC_CACHE_VAL($cacheid,
3613			     [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
3614					     [eval $cacheid=yes],
3615					     [eval $cacheid=no])])
3616
3617		PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
3618
3619		eval supported=\$$cacheid
3620		AC_MSG_RESULT([$supported])
3621		if test "$supported" = "yes" ; then
3622			$1="$$1 ]flag["
3623			found="yes"
3624		fi
3625	fi
3626])
3627]) # XORG_TESTSET_CFLAG
3628
3629# XORG_COMPILER_FLAGS
3630# ---------------
3631# Minimum version: 1.16.0
3632#
3633# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
3634# arguments supported by the selected compiler which do NOT alter the generated
3635# code.  These arguments will cause the compiler to print various warnings
3636# during compilation AND turn a conservative set of warnings into errors.
3637#
3638# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
3639# future versions of util-macros as options are added to new compilers.
3640#
3641AC_DEFUN([XORG_COMPILER_FLAGS], [
3642AC_REQUIRE([XORG_COMPILER_BRAND])
3643
3644AC_ARG_ENABLE(selective-werror,
3645              AS_HELP_STRING([--disable-selective-werror],
3646                             [Turn off selective compiler errors. (default: enabled)]),
3647              [SELECTIVE_WERROR=$enableval],
3648              [SELECTIVE_WERROR=yes])
3649
3650AC_LANG_CASE(
3651        [C], [
3652                define([PREFIX], [C])
3653        ],
3654        [C++], [
3655                define([PREFIX], [CXX])
3656        ]
3657)
3658# -v is too short to test reliably with XORG_TESTSET_CFLAG
3659if test "x$SUNCC" = "xyes"; then
3660    [BASE_]PREFIX[FLAGS]="-v"
3661else
3662    [BASE_]PREFIX[FLAGS]=""
3663fi
3664
3665# This chunk of warnings were those that existed in the legacy CWARNFLAGS
3666XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
3667XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
3668XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
3669XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
3670
3671AC_LANG_CASE(
3672	[C], [
3673		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
3674		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
3675		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
3676		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
3677		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
3678		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
3679	]
3680)
3681
3682# This chunk adds additional warnings that could catch undesired effects.
3683XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
3684XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
3685XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
3686XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
3687XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
3688XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
3689XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
3690
3691# These are currently disabled because they are noisy.  They will be enabled
3692# in the future once the codebase is sufficiently modernized to silence
3693# them.  For now, I don't want them to drown out the other warnings.
3694# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
3695# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
3696# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
3697
3698# Turn some warnings into errors, so we don't accidentally get successful builds
3699# when there are problems that should be fixed.
3700
3701if test "x$SELECTIVE_WERROR" = "xyes" ; then
3702XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
3703XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
3704XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
3705XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
3706XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
3707XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
3708XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
3709XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
3710XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
3711XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
3712XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
3713XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
3714XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
3715else
3716AC_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])
3717XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
3718XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
3719XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
3720XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
3721XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
3722XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
3723XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
3724XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
3725XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
3726XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
3727XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
3728XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
3729XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
3730fi
3731
3732AC_SUBST([BASE_]PREFIX[FLAGS])
3733]) # XORG_COMPILER_FLAGS
3734
3735# XORG_CWARNFLAGS
3736# ---------------
3737# Minimum version: 1.2.0
3738# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
3739#
3740# Defines CWARNFLAGS to enable C compiler warnings.
3741#
3742# This function is deprecated because it defines -fno-strict-aliasing
3743# which alters the code generated by the compiler.  If -fno-strict-aliasing
3744# is needed, then it should be added explicitly in the module when
3745# it is updated to use BASE_CFLAGS.
3746#
3747AC_DEFUN([XORG_CWARNFLAGS], [
3748AC_REQUIRE([XORG_COMPILER_FLAGS])
3749AC_REQUIRE([XORG_COMPILER_BRAND])
3750AC_LANG_CASE(
3751	[C], [
3752		CWARNFLAGS="$BASE_CFLAGS"
3753		if  test "x$GCC" = xyes ; then
3754		    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
3755		fi
3756		AC_SUBST(CWARNFLAGS)
3757	]
3758)
3759]) # XORG_CWARNFLAGS
3760
3761# XORG_STRICT_OPTION
3762# -----------------------
3763# Minimum version: 1.3.0
3764#
3765# Add configure option to enable strict compilation flags, such as treating
3766# warnings as fatal errors.
3767# If --enable-strict-compilation is passed to configure, adds strict flags to
3768# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
3769#
3770# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
3771# when strict compilation is unconditionally desired.
3772AC_DEFUN([XORG_STRICT_OPTION], [
3773AC_REQUIRE([XORG_CWARNFLAGS])
3774AC_REQUIRE([XORG_COMPILER_FLAGS])
3775
3776AC_ARG_ENABLE(strict-compilation,
3777			  AS_HELP_STRING([--enable-strict-compilation],
3778			  [Enable all warnings from compiler and make them errors (default: disabled)]),
3779			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
3780
3781AC_LANG_CASE(
3782        [C], [
3783                define([PREFIX], [C])
3784        ],
3785        [C++], [
3786                define([PREFIX], [CXX])
3787        ]
3788)
3789
3790[STRICT_]PREFIX[FLAGS]=""
3791XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
3792XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
3793
3794# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
3795# activate it with -Werror, so we add it here explicitly.
3796XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
3797
3798if test "x$STRICT_COMPILE" = "xyes"; then
3799    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
3800    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
3801fi
3802AC_SUBST([STRICT_]PREFIX[FLAGS])
3803AC_SUBST([BASE_]PREFIX[FLAGS])
3804AC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
3805]) # XORG_STRICT_OPTION
3806
3807# XORG_DEFAULT_NOCODE_OPTIONS
3808# ---------------------------
3809# Minimum version: 1.20.0
3810#
3811# Defines default options for X.Org modules which don't compile code,
3812# such as fonts, bitmaps, cursors, and docs.
3813#
3814AC_DEFUN([XORG_DEFAULT_NOCODE_OPTIONS], [
3815AC_REQUIRE([AC_PROG_INSTALL])
3816XORG_RELEASE_VERSION
3817XORG_CHANGELOG
3818XORG_INSTALL
3819XORG_MANPAGE_SECTIONS
3820m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
3821    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
3822]) # XORG_DEFAULT_NOCODE_OPTIONS
3823
3824# XORG_DEFAULT_OPTIONS
3825# --------------------
3826# Minimum version: 1.3.0
3827#
3828# Defines default options for X.Org modules which compile code.
3829#
3830AC_DEFUN([XORG_DEFAULT_OPTIONS], [
3831AC_REQUIRE([AC_PROG_INSTALL])
3832XORG_COMPILER_FLAGS
3833XORG_CWARNFLAGS
3834XORG_STRICT_OPTION
3835XORG_DEFAULT_NOCODE_OPTIONS
3836]) # XORG_DEFAULT_OPTIONS
3837
3838# XORG_INSTALL()
3839# ----------------
3840# Minimum version: 1.4.0
3841#
3842# Defines the variable INSTALL_CMD as the command to copy
3843# INSTALL from $prefix/share/util-macros.
3844#
3845AC_DEFUN([XORG_INSTALL], [
3846AC_REQUIRE([PKG_PROG_PKG_CONFIG])
3847macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
3848INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
3849mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
3850|| (rm -f \$(top_srcdir)/.INSTALL.tmp; test -e \$(top_srcdir)/INSTALL || ( \
3851touch \$(top_srcdir)/INSTALL; \
3852echo 'failed to copy INSTALL from util-macros: installing empty INSTALL.' >&2))"
3853AC_SUBST([INSTALL_CMD])
3854]) # XORG_INSTALL
3855dnl Copyright 2005 Red Hat, Inc
3856dnl
3857dnl Permission to use, copy, modify, distribute, and sell this software and its
3858dnl documentation for any purpose is hereby granted without fee, provided that
3859dnl the above copyright notice appear in all copies and that both that
3860dnl copyright notice and this permission notice appear in supporting
3861dnl documentation.
3862dnl
3863dnl The above copyright notice and this permission notice shall be included
3864dnl in all copies or substantial portions of the Software.
3865dnl
3866dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3867dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3868dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
3869dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
3870dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
3871dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3872dnl OTHER DEALINGS IN THE SOFTWARE.
3873dnl
3874dnl Except as contained in this notice, the name of the copyright holders shall
3875dnl not be used in advertising or otherwise to promote the sale, use or
3876dnl other dealings in this Software without prior written authorization
3877dnl from the copyright holders.
3878dnl
3879
3880# XORG_RELEASE_VERSION
3881# --------------------
3882# Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use.
3883
3884AC_DEFUN([XORG_RELEASE_VERSION],[
3885	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
3886		[`echo $PACKAGE_VERSION | cut -d . -f 1`],
3887		[Major version of this package])
3888	PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1`
3889	if test "x$PVM" = "x"; then
3890		PVM="0"
3891	fi
3892	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
3893		[$PVM],
3894		[Minor version of this package])
3895	PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1`
3896	if test "x$PVP" = "x"; then
3897		PVP="0"
3898	fi
3899	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
3900		[$PVP],
3901		[Patch version of this package])
3902])
3903
3904# XORG_CHANGELOG()
3905# ----------------
3906# Minimum version: 1.2.0
3907#
3908# Defines the variable CHANGELOG_CMD as the command to generate
3909# ChangeLog from git.
3910#
3911#
3912AC_DEFUN([XORG_CHANGELOG], [
3913CHANGELOG_CMD="((GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp) 2>/dev/null && \
3914mv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
3915|| (rm -f \$(top_srcdir)/.changelog.tmp; test -e \$(top_srcdir)/ChangeLog || ( \
3916touch \$(top_srcdir)/ChangeLog; \
3917echo 'git failed to create ChangeLog: installing empty ChangeLog.' >&2))"
3918AC_SUBST([CHANGELOG_CMD])
3919]) # XORG_CHANGELOG
3920
3921dnl
3922dnl Copyright (c) 2005, Oracle and/or its affiliates.
3923dnl
3924dnl Permission is hereby granted, free of charge, to any person obtaining a
3925dnl copy of this software and associated documentation files (the "Software"),
3926dnl to deal in the Software without restriction, including without limitation
3927dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
3928dnl and/or sell copies of the Software, and to permit persons to whom the
3929dnl Software is furnished to do so, subject to the following conditions:
3930dnl
3931dnl The above copyright notice and this permission notice (including the next
3932dnl paragraph) shall be included in all copies or substantial portions of the
3933dnl Software.
3934dnl
3935dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3936dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3937dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
3938dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3939dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
3940dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
3941dnl DEALINGS IN THE SOFTWARE.
3942dnl
3943
3944# XTRANS_TCP_FLAGS()
3945# ------------------
3946# Find needed libraries for TCP sockets, and check for IPv6 support
3947AC_DEFUN([XTRANS_TCP_FLAGS],[
3948 # SVR4 hides these in libraries other than libc
3949 AC_SEARCH_LIBS(socket, [socket])
3950 AC_SEARCH_LIBS(gethostbyname, [nsl])
3951 if test "$ac_cv_search_socket$ac_cv_search_gethostbyname" = "nono"; then
3952   AC_CHECK_LIB([ws2_32],[main])
3953 fi
3954
3955 # Needs to come after above checks for libsocket & libnsl for SVR4 systems
3956 AC_ARG_ENABLE(ipv6,
3957	AS_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),
3958	[IPV6CONN=$enableval],
3959	[AC_CHECK_FUNC(getaddrinfo,[IPV6CONN=yes],[IPV6CONN=no])])
3960 AC_MSG_CHECKING([if IPv6 support should be built])
3961 if test "$IPV6CONN" = "yes"; then
3962	AC_DEFINE(IPv6,1,[Support IPv6 for TCP connections])
3963 fi
3964 AC_MSG_RESULT($IPV6CONN)
3965
3966 # 4.3BSD-Reno added a new member to struct sockaddr_in
3967 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
3968	AC_DEFINE([BSD44SOCKETS],1,
3969 	    [Define to 1 if `struct sockaddr_in' has a `sin_len' member]), [], [
3970#include <sys/types.h>
3971#include <sys/socket.h>
3972#include <netinet/in.h>
3973 ])
3974
3975 # POSIX.1g changed the type of pointer passed to getsockname/getpeername/etc.
3976 AC_CHECK_TYPES([socklen_t], [], [], [
3977AC_INCLUDES_DEFAULT
3978#include <sys/socket.h>])
3979
3980 # XPG4v2/UNIX95 added msg_control - check to see if we need to define
3981 # _XOPEN_SOURCE to get it (such as on Solaris)
3982 AC_CHECK_MEMBER([struct msghdr.msg_control], [], [],
3983                 [
3984AC_INCLUDES_DEFAULT
3985#include <sys/socket.h>
3986                 ])
3987 # First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03
3988 if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
3989     unset ac_cv_member_struct_msghdr_msg_control
3990     AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600])
3991     AC_CHECK_MEMBER([struct msghdr.msg_control],
3992                     [AC_DEFINE([_XOPEN_SOURCE], [600],
3993                       [Defined if needed to expose struct msghdr.msg_control])
3994                     ], [], [
3995#define _XOPEN_SOURCE 600
3996AC_INCLUDES_DEFAULT
3997#include <sys/socket.h>
3998                     ])
3999 fi
4000 # If that didn't work, fall back to XPG5/UNIX98 with C89
4001 if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
4002     unset ac_cv_member_struct_msghdr_msg_control
4003     AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500])
4004     AC_CHECK_MEMBER([struct msghdr.msg_control],
4005                     [AC_DEFINE([_XOPEN_SOURCE], [500],
4006                       [Defined if needed to expose struct msghdr.msg_control])
4007                     ], [], [
4008#define _XOPEN_SOURCE 500
4009AC_INCLUDES_DEFAULT
4010#include <sys/socket.h>
4011                     ])
4012 fi
4013
4014
4015]) # XTRANS_TCP_FLAGS
4016
4017# XTRANS_CONNECTION_FLAGS()
4018# -------------------------
4019# Standard checks for which Xtrans transports to use by the Xorg packages
4020# that use Xtrans functions
4021AC_DEFUN([XTRANS_CONNECTION_FLAGS],[
4022 AC_REQUIRE([AC_CANONICAL_HOST])
4023 [case $host_os in
4024	mingw*)	unixdef="no"   ;;
4025	*)	unixdef="yes"  ;;
4026 esac]
4027 AC_ARG_ENABLE(unix-transport,
4028	AS_HELP_STRING([--enable-unix-transport],[Enable UNIX domain socket transport]),
4029	[UNIXCONN=$enableval], [UNIXCONN=$unixdef])
4030 AC_MSG_CHECKING([if Xtrans should support UNIX socket connections])
4031 if test "$UNIXCONN" = "yes"; then
4032	AC_DEFINE(UNIXCONN,1,[Support UNIX socket connections])
4033 fi
4034 AC_MSG_RESULT($UNIXCONN)
4035 AC_ARG_ENABLE(tcp-transport,
4036	AS_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]),
4037	[TCPCONN=$enableval], [TCPCONN=yes])
4038 AC_MSG_CHECKING([if Xtrans should support TCP socket connections])
4039 AC_MSG_RESULT($TCPCONN)
4040 if test "$TCPCONN" = "yes"; then
4041	AC_DEFINE(TCPCONN,1,[Support TCP socket connections])
4042	XTRANS_TCP_FLAGS
4043 fi
4044 [case $host_os in
4045	solaris*)		localdef="yes" ;;
4046	*)			localdef="no"  ;;
4047 esac]
4048 AC_ARG_ENABLE(local-transport,
4049	AS_HELP_STRING([--enable-local-transport],[Enable os-specific local transport]),
4050	[LOCALCONN=$enableval], [LOCALCONN=$localdef])
4051 AC_MSG_CHECKING([if Xtrans should support os-specific local connections])
4052 AC_MSG_RESULT($LOCALCONN)
4053 if test "$LOCALCONN" = "yes"; then
4054	AC_DEFINE(LOCALCONN,1,[Support os-specific local connections])
4055 fi
4056
4057 # Other functions Xtrans may need
4058 AC_CHECK_FUNCS([strcasecmp strlcpy])
4059
4060]) # XTRANS_CONNECTION_FLAGS
4061
4062
4063# XTRANS_SECURE_RPC_FLAGS()
4064# -------------------------
4065# Check for Secure RPC functions - must come after XTRANS_TCP_FLAGS
4066# so that any necessary networking libraries are already found
4067AC_DEFUN([XTRANS_SECURE_RPC_FLAGS],
4068[AC_REQUIRE([XTRANS_TCP_FLAGS])
4069 AC_ARG_ENABLE(secure-rpc,
4070	AS_HELP_STRING([--enable-secure-rpc],[Enable Secure RPC]),
4071        [SECURE_RPC=$enableval], [SECURE_RPC="try"])
4072
4073 if test "x$SECURE_RPC" = "xyes" -o "x$SECURE_RPC" = "xtry" ; then
4074	FOUND_SECURE_RPC="no"
4075	AC_CHECK_FUNCS([authdes_seccreate authdes_create],
4076			[FOUND_SECURE_RPC="yes"])
4077	if test "x$FOUND_SECURE_RPC" = "xno" ; then
4078		if test "x$SECURE_RPC" = "xyes" ; then
4079	AC_MSG_ERROR([Secure RPC requested, but required functions not found])
4080		fi
4081		SECURE_RPC="no"
4082	else
4083		dnl FreeBSD keeps getsecretkey in librpcsvc
4084		AC_SEARCH_LIBS(getsecretkey, [rpcsvc])
4085		SECURE_RPC="yes"
4086	fi
4087 fi
4088 AC_MSG_CHECKING([if Secure RPC authentication ("SUN-DES-1") should be supported])
4089 if test "x$SECURE_RPC" = "xyes" ; then
4090	AC_DEFINE(SECURE_RPC, 1, [Support Secure RPC ("SUN-DES-1") authentication for X11 clients])
4091 fi
4092 AC_MSG_RESULT($SECURE_RPC)
4093]) # XTRANS_SECURE_RPC_FLAGS
4094
4095
4096m4_include([m4/ax_define_dir.m4])
4097