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