175b29833Smrg# generated automatically by aclocal 1.16.5 -*- Autoconf -*-
275b29833Smrg
375b29833Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
475b29833Smrg
575b29833Smrg# This file is free software; the Free Software Foundation
675b29833Smrg# gives unlimited permission to copy and/or distribute it,
775b29833Smrg# with or without modifications, as long as this notice is preserved.
875b29833Smrg
975b29833Smrg# This program is distributed in the hope that it will be useful,
1075b29833Smrg# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
1175b29833Smrg# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
1275b29833Smrg# PARTICULAR PURPOSE.
1375b29833Smrg
1475b29833Smrgm4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
1575b29833Smrgm4_ifndef([AC_AUTOCONF_VERSION],
1675b29833Smrg  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
1775b29833Smrgm4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
1875b29833Smrg[m4_warning([this file was generated for autoconf 2.71.
1975b29833SmrgYou have another version of autoconf.  It may work, but is not guaranteed to.
2075b29833SmrgIf you have problems, you may need to regenerate the build system entirely.
2175b29833SmrgTo do so, use the procedure documented by the package, typically 'autoreconf'.])])
2275b29833Smrg
2375b29833Smrg# Copyright (C) 2002-2021 Free Software Foundation, Inc.
2475b29833Smrg#
2575b29833Smrg# This file is free software; the Free Software Foundation
2675b29833Smrg# gives unlimited permission to copy and/or distribute it,
2775b29833Smrg# with or without modifications, as long as this notice is preserved.
2875b29833Smrg
2975b29833Smrg# AM_AUTOMAKE_VERSION(VERSION)
3075b29833Smrg# ----------------------------
3175b29833Smrg# Automake X.Y traces this macro to ensure aclocal.m4 has been
3275b29833Smrg# generated from the m4 files accompanying Automake X.Y.
3375b29833Smrg# (This private macro should not be called outside this file.)
3475b29833SmrgAC_DEFUN([AM_AUTOMAKE_VERSION],
3575b29833Smrg[am__api_version='1.16'
3675b29833Smrgdnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3775b29833Smrgdnl require some minimum version.  Point them to the right macro.
3875b29833Smrgm4_if([$1], [1.16.5], [],
3975b29833Smrg      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
4075b29833Smrg])
4175b29833Smrg
4275b29833Smrg# _AM_AUTOCONF_VERSION(VERSION)
4375b29833Smrg# -----------------------------
4475b29833Smrg# aclocal traces this macro to find the Autoconf version.
4575b29833Smrg# This is a private macro too.  Using m4_define simplifies
4675b29833Smrg# the logic in aclocal, which can simply ignore this definition.
4775b29833Smrgm4_define([_AM_AUTOCONF_VERSION], [])
4875b29833Smrg
4975b29833Smrg# AM_SET_CURRENT_AUTOMAKE_VERSION
5075b29833Smrg# -------------------------------
5175b29833Smrg# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
5275b29833Smrg# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
5375b29833SmrgAC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
5475b29833Smrg[AM_AUTOMAKE_VERSION([1.16.5])dnl
5575b29833Smrgm4_ifndef([AC_AUTOCONF_VERSION],
5675b29833Smrg  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
5775b29833Smrg_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
5875b29833Smrg
5975b29833Smrg# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
6075b29833Smrg
6175b29833Smrg# Copyright (C) 2001-2021 Free Software Foundation, Inc.
6275b29833Smrg#
6375b29833Smrg# This file is free software; the Free Software Foundation
6475b29833Smrg# gives unlimited permission to copy and/or distribute it,
6575b29833Smrg# with or without modifications, as long as this notice is preserved.
6675b29833Smrg
6775b29833Smrg# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
6875b29833Smrg# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
6975b29833Smrg# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
7075b29833Smrg#
7175b29833Smrg# Of course, Automake must honor this variable whenever it calls a
7275b29833Smrg# tool from the auxiliary directory.  The problem is that $srcdir (and
7375b29833Smrg# therefore $ac_aux_dir as well) can be either absolute or relative,
7475b29833Smrg# depending on how configure is run.  This is pretty annoying, since
7575b29833Smrg# it makes $ac_aux_dir quite unusable in subdirectories: in the top
7675b29833Smrg# source directory, any form will work fine, but in subdirectories a
7775b29833Smrg# relative path needs to be adjusted first.
7875b29833Smrg#
7975b29833Smrg# $ac_aux_dir/missing
8075b29833Smrg#    fails when called from a subdirectory if $ac_aux_dir is relative
8175b29833Smrg# $top_srcdir/$ac_aux_dir/missing
8275b29833Smrg#    fails if $ac_aux_dir is absolute,
8375b29833Smrg#    fails when called from a subdirectory in a VPATH build with
8475b29833Smrg#          a relative $ac_aux_dir
8575b29833Smrg#
8675b29833Smrg# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
8775b29833Smrg# are both prefixed by $srcdir.  In an in-source build this is usually
8875b29833Smrg# harmless because $srcdir is '.', but things will broke when you
8975b29833Smrg# start a VPATH build or use an absolute $srcdir.
9075b29833Smrg#
9175b29833Smrg# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
9275b29833Smrg# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
9375b29833Smrg#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
9475b29833Smrg# and then we would define $MISSING as
9575b29833Smrg#   MISSING="\${SHELL} $am_aux_dir/missing"
9675b29833Smrg# This will work as long as MISSING is not called from configure, because
9775b29833Smrg# unfortunately $(top_srcdir) has no meaning in configure.
9875b29833Smrg# However there are other variables, like CC, which are often used in
9975b29833Smrg# configure, and could therefore not use this "fixed" $ac_aux_dir.
10075b29833Smrg#
10175b29833Smrg# Another solution, used here, is to always expand $ac_aux_dir to an
10275b29833Smrg# absolute PATH.  The drawback is that using absolute paths prevent a
10375b29833Smrg# configured tree to be moved without reconfiguration.
10475b29833Smrg
10575b29833SmrgAC_DEFUN([AM_AUX_DIR_EXPAND],
10675b29833Smrg[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
10775b29833Smrg# Expand $ac_aux_dir to an absolute path.
10875b29833Smrgam_aux_dir=`cd "$ac_aux_dir" && pwd`
10975b29833Smrg])
11075b29833Smrg
11175b29833Smrg# Do all the work for Automake.                             -*- Autoconf -*-
11275b29833Smrg
11375b29833Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
11475b29833Smrg#
11575b29833Smrg# This file is free software; the Free Software Foundation
11675b29833Smrg# gives unlimited permission to copy and/or distribute it,
11775b29833Smrg# with or without modifications, as long as this notice is preserved.
11875b29833Smrg
11975b29833Smrg# This macro actually does too much.  Some checks are only needed if
12075b29833Smrg# your package does certain things.  But this isn't really a big deal.
12175b29833Smrg
12275b29833Smrgdnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
12375b29833Smrgm4_define([AC_PROG_CC],
12475b29833Smrgm4_defn([AC_PROG_CC])
12575b29833Smrg[_AM_PROG_CC_C_O
12675b29833Smrg])
12775b29833Smrg
12875b29833Smrg# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
12975b29833Smrg# AM_INIT_AUTOMAKE([OPTIONS])
13075b29833Smrg# -----------------------------------------------
13175b29833Smrg# The call with PACKAGE and VERSION arguments is the old style
13275b29833Smrg# call (pre autoconf-2.50), which is being phased out.  PACKAGE
13375b29833Smrg# and VERSION should now be passed to AC_INIT and removed from
13475b29833Smrg# the call to AM_INIT_AUTOMAKE.
13575b29833Smrg# We support both call styles for the transition.  After
13675b29833Smrg# the next Automake release, Autoconf can make the AC_INIT
13775b29833Smrg# arguments mandatory, and then we can depend on a new Autoconf
13875b29833Smrg# release and drop the old call support.
13975b29833SmrgAC_DEFUN([AM_INIT_AUTOMAKE],
14075b29833Smrg[AC_PREREQ([2.65])dnl
14175b29833Smrgm4_ifdef([_$0_ALREADY_INIT],
14275b29833Smrg  [m4_fatal([$0 expanded multiple times
14375b29833Smrg]m4_defn([_$0_ALREADY_INIT]))],
14475b29833Smrg  [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
14575b29833Smrgdnl Autoconf wants to disallow AM_ names.  We explicitly allow
14675b29833Smrgdnl the ones we care about.
14775b29833Smrgm4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
14875b29833SmrgAC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
14975b29833SmrgAC_REQUIRE([AC_PROG_INSTALL])dnl
15075b29833Smrgif test "`cd $srcdir && pwd`" != "`pwd`"; then
15175b29833Smrg  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
15275b29833Smrg  # is not polluted with repeated "-I."
15375b29833Smrg  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
15475b29833Smrg  # test to see if srcdir already configured
15575b29833Smrg  if test -f $srcdir/config.status; then
15675b29833Smrg    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
15775b29833Smrg  fi
15875b29833Smrgfi
15975b29833Smrg
16075b29833Smrg# test whether we have cygpath
16175b29833Smrgif test -z "$CYGPATH_W"; then
16275b29833Smrg  if (cygpath --version) >/dev/null 2>/dev/null; then
16375b29833Smrg    CYGPATH_W='cygpath -w'
16475b29833Smrg  else
16575b29833Smrg    CYGPATH_W=echo
16675b29833Smrg  fi
16775b29833Smrgfi
16875b29833SmrgAC_SUBST([CYGPATH_W])
16975b29833Smrg
17075b29833Smrg# Define the identity of the package.
17175b29833Smrgdnl Distinguish between old-style and new-style calls.
17275b29833Smrgm4_ifval([$2],
17375b29833Smrg[AC_DIAGNOSE([obsolete],
17475b29833Smrg             [$0: two- and three-arguments forms are deprecated.])
17575b29833Smrgm4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
17675b29833Smrg AC_SUBST([PACKAGE], [$1])dnl
17775b29833Smrg AC_SUBST([VERSION], [$2])],
17875b29833Smrg[_AM_SET_OPTIONS([$1])dnl
17975b29833Smrgdnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
18075b29833Smrgm4_if(
18175b29833Smrg  m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
18275b29833Smrg  [ok:ok],,
18375b29833Smrg  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
18475b29833Smrg AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
18575b29833Smrg AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
18675b29833Smrg
18775b29833Smrg_AM_IF_OPTION([no-define],,
18875b29833Smrg[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
18975b29833Smrg AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
19075b29833Smrg
19175b29833Smrg# Some tools Automake needs.
19275b29833SmrgAC_REQUIRE([AM_SANITY_CHECK])dnl
19375b29833SmrgAC_REQUIRE([AC_ARG_PROGRAM])dnl
19475b29833SmrgAM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
19575b29833SmrgAM_MISSING_PROG([AUTOCONF], [autoconf])
19675b29833SmrgAM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
19775b29833SmrgAM_MISSING_PROG([AUTOHEADER], [autoheader])
19875b29833SmrgAM_MISSING_PROG([MAKEINFO], [makeinfo])
19975b29833SmrgAC_REQUIRE([AM_PROG_INSTALL_SH])dnl
20075b29833SmrgAC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
20175b29833SmrgAC_REQUIRE([AC_PROG_MKDIR_P])dnl
20275b29833Smrg# For better backward compatibility.  To be removed once Automake 1.9.x
20375b29833Smrg# dies out for good.  For more background, see:
20475b29833Smrg# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
20575b29833Smrg# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
20675b29833SmrgAC_SUBST([mkdir_p], ['$(MKDIR_P)'])
20775b29833Smrg# We need awk for the "check" target (and possibly the TAP driver).  The
20875b29833Smrg# system "awk" is bad on some platforms.
20975b29833SmrgAC_REQUIRE([AC_PROG_AWK])dnl
21075b29833SmrgAC_REQUIRE([AC_PROG_MAKE_SET])dnl
21175b29833SmrgAC_REQUIRE([AM_SET_LEADING_DOT])dnl
21275b29833Smrg_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
21375b29833Smrg	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
21475b29833Smrg			     [_AM_PROG_TAR([v7])])])
21575b29833Smrg_AM_IF_OPTION([no-dependencies],,
21675b29833Smrg[AC_PROVIDE_IFELSE([AC_PROG_CC],
21775b29833Smrg		  [_AM_DEPENDENCIES([CC])],
21875b29833Smrg		  [m4_define([AC_PROG_CC],
21975b29833Smrg			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
22075b29833SmrgAC_PROVIDE_IFELSE([AC_PROG_CXX],
22175b29833Smrg		  [_AM_DEPENDENCIES([CXX])],
22275b29833Smrg		  [m4_define([AC_PROG_CXX],
22375b29833Smrg			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
22475b29833SmrgAC_PROVIDE_IFELSE([AC_PROG_OBJC],
22575b29833Smrg		  [_AM_DEPENDENCIES([OBJC])],
22675b29833Smrg		  [m4_define([AC_PROG_OBJC],
22775b29833Smrg			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
22875b29833SmrgAC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
22975b29833Smrg		  [_AM_DEPENDENCIES([OBJCXX])],
23075b29833Smrg		  [m4_define([AC_PROG_OBJCXX],
23175b29833Smrg			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
23275b29833Smrg])
23375b29833Smrg# Variables for tags utilities; see am/tags.am
23475b29833Smrgif test -z "$CTAGS"; then
23575b29833Smrg  CTAGS=ctags
23675b29833Smrgfi
23775b29833SmrgAC_SUBST([CTAGS])
23875b29833Smrgif test -z "$ETAGS"; then
23975b29833Smrg  ETAGS=etags
24075b29833Smrgfi
24175b29833SmrgAC_SUBST([ETAGS])
24275b29833Smrgif test -z "$CSCOPE"; then
24375b29833Smrg  CSCOPE=cscope
24475b29833Smrgfi
24575b29833SmrgAC_SUBST([CSCOPE])
24675b29833Smrg
24775b29833SmrgAC_REQUIRE([AM_SILENT_RULES])dnl
24875b29833Smrgdnl The testsuite driver may need to know about EXEEXT, so add the
24975b29833Smrgdnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
25075b29833Smrgdnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
25175b29833SmrgAC_CONFIG_COMMANDS_PRE(dnl
25275b29833Smrg[m4_provide_if([_AM_COMPILER_EXEEXT],
25375b29833Smrg  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
25475b29833Smrg
25575b29833Smrg# POSIX will say in a future version that running "rm -f" with no argument
25675b29833Smrg# is OK; and we want to be able to make that assumption in our Makefile
25775b29833Smrg# recipes.  So use an aggressive probe to check that the usage we want is
25875b29833Smrg# actually supported "in the wild" to an acceptable degree.
25975b29833Smrg# See automake bug#10828.
26075b29833Smrg# To make any issue more visible, cause the running configure to be aborted
26175b29833Smrg# by default if the 'rm' program in use doesn't match our expectations; the
26275b29833Smrg# user can still override this though.
26375b29833Smrgif rm -f && rm -fr && rm -rf; then : OK; else
26475b29833Smrg  cat >&2 <<'END'
26575b29833SmrgOops!
26675b29833Smrg
26775b29833SmrgYour 'rm' program seems unable to run without file operands specified
26875b29833Smrgon the command line, even when the '-f' option is present.  This is contrary
26975b29833Smrgto the behaviour of most rm programs out there, and not conforming with
27075b29833Smrgthe upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
27175b29833Smrg
27275b29833SmrgPlease tell bug-automake@gnu.org about your system, including the value
27375b29833Smrgof your $PATH and any error possibly output before this message.  This
27475b29833Smrgcan help us improve future automake versions.
27575b29833Smrg
27675b29833SmrgEND
27775b29833Smrg  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
27875b29833Smrg    echo 'Configuration will proceed anyway, since you have set the' >&2
27975b29833Smrg    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
28075b29833Smrg    echo >&2
28175b29833Smrg  else
28275b29833Smrg    cat >&2 <<'END'
28375b29833SmrgAborting the configuration process, to ensure you take notice of the issue.
28475b29833Smrg
28575b29833SmrgYou can download and install GNU coreutils to get an 'rm' implementation
28675b29833Smrgthat behaves properly: <https://www.gnu.org/software/coreutils/>.
28775b29833Smrg
28875b29833SmrgIf you want to complete the configuration process using your problematic
28975b29833Smrg'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
29075b29833Smrgto "yes", and re-run configure.
29175b29833Smrg
29275b29833SmrgEND
29375b29833Smrg    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
29475b29833Smrg  fi
29575b29833Smrgfi
29675b29833Smrgdnl The trailing newline in this macro's definition is deliberate, for
29775b29833Smrgdnl backward compatibility and to allow trailing 'dnl'-style comments
29875b29833Smrgdnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
29975b29833Smrg])
30075b29833Smrg
30175b29833Smrgdnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
30275b29833Smrgdnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
30375b29833Smrgdnl mangled by Autoconf and run in a shell conditional statement.
30475b29833Smrgm4_define([_AC_COMPILER_EXEEXT],
30575b29833Smrgm4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
30675b29833Smrg
30775b29833Smrg# When config.status generates a header, we must update the stamp-h file.
30875b29833Smrg# This file resides in the same directory as the config header
30975b29833Smrg# that is generated.  The stamp files are numbered to have different names.
31075b29833Smrg
31175b29833Smrg# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
31275b29833Smrg# loop where config.status creates the headers, so we can generate
31375b29833Smrg# our stamp files there.
31475b29833SmrgAC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
31575b29833Smrg[# Compute $1's index in $config_headers.
31675b29833Smrg_am_arg=$1
31775b29833Smrg_am_stamp_count=1
31875b29833Smrgfor _am_header in $config_headers :; do
31975b29833Smrg  case $_am_header in
32075b29833Smrg    $_am_arg | $_am_arg:* )
32175b29833Smrg      break ;;
32275b29833Smrg    * )
32375b29833Smrg      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
32475b29833Smrg  esac
32575b29833Smrgdone
32675b29833Smrgecho "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
32775b29833Smrg
32875b29833Smrg# Copyright (C) 2001-2021 Free Software Foundation, Inc.
32975b29833Smrg#
33075b29833Smrg# This file is free software; the Free Software Foundation
33175b29833Smrg# gives unlimited permission to copy and/or distribute it,
33275b29833Smrg# with or without modifications, as long as this notice is preserved.
33375b29833Smrg
33475b29833Smrg# AM_PROG_INSTALL_SH
33575b29833Smrg# ------------------
33675b29833Smrg# Define $install_sh.
33775b29833SmrgAC_DEFUN([AM_PROG_INSTALL_SH],
33875b29833Smrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
33975b29833Smrgif test x"${install_sh+set}" != xset; then
34075b29833Smrg  case $am_aux_dir in
34175b29833Smrg  *\ * | *\	*)
34275b29833Smrg    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
34375b29833Smrg  *)
34475b29833Smrg    install_sh="\${SHELL} $am_aux_dir/install-sh"
34575b29833Smrg  esac
34675b29833Smrgfi
34775b29833SmrgAC_SUBST([install_sh])])
34875b29833Smrg
34975b29833Smrg# Copyright (C) 2003-2021 Free Software Foundation, Inc.
35075b29833Smrg#
35175b29833Smrg# This file is free software; the Free Software Foundation
35275b29833Smrg# gives unlimited permission to copy and/or distribute it,
35375b29833Smrg# with or without modifications, as long as this notice is preserved.
35475b29833Smrg
35575b29833Smrg# Check whether the underlying file-system supports filenames
35675b29833Smrg# with a leading dot.  For instance MS-DOS doesn't.
35775b29833SmrgAC_DEFUN([AM_SET_LEADING_DOT],
35875b29833Smrg[rm -rf .tst 2>/dev/null
35975b29833Smrgmkdir .tst 2>/dev/null
36075b29833Smrgif test -d .tst; then
36175b29833Smrg  am__leading_dot=.
36275b29833Smrgelse
36375b29833Smrg  am__leading_dot=_
36475b29833Smrgfi
36575b29833Smrgrmdir .tst 2>/dev/null
36675b29833SmrgAC_SUBST([am__leading_dot])])
36775b29833Smrg
36875b29833Smrg# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
36975b29833Smrg
37075b29833Smrg# Copyright (C) 1997-2021 Free Software Foundation, Inc.
37175b29833Smrg#
37275b29833Smrg# This file is free software; the Free Software Foundation
37375b29833Smrg# gives unlimited permission to copy and/or distribute it,
37475b29833Smrg# with or without modifications, as long as this notice is preserved.
37575b29833Smrg
37675b29833Smrg# AM_MISSING_PROG(NAME, PROGRAM)
37775b29833Smrg# ------------------------------
37875b29833SmrgAC_DEFUN([AM_MISSING_PROG],
37975b29833Smrg[AC_REQUIRE([AM_MISSING_HAS_RUN])
38075b29833Smrg$1=${$1-"${am_missing_run}$2"}
38175b29833SmrgAC_SUBST($1)])
38275b29833Smrg
38375b29833Smrg# AM_MISSING_HAS_RUN
38475b29833Smrg# ------------------
38575b29833Smrg# Define MISSING if not defined so far and test if it is modern enough.
38675b29833Smrg# If it is, set am_missing_run to use it, otherwise, to nothing.
38775b29833SmrgAC_DEFUN([AM_MISSING_HAS_RUN],
38875b29833Smrg[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
38975b29833SmrgAC_REQUIRE_AUX_FILE([missing])dnl
39075b29833Smrgif test x"${MISSING+set}" != xset; then
39175b29833Smrg  MISSING="\${SHELL} '$am_aux_dir/missing'"
39275b29833Smrgfi
39375b29833Smrg# Use eval to expand $SHELL
39475b29833Smrgif eval "$MISSING --is-lightweight"; then
39575b29833Smrg  am_missing_run="$MISSING "
39675b29833Smrgelse
39775b29833Smrg  am_missing_run=
39875b29833Smrg  AC_MSG_WARN(['missing' script is too old or missing])
39975b29833Smrgfi
40075b29833Smrg])
40175b29833Smrg
40275b29833Smrg# Helper functions for option handling.                     -*- Autoconf -*-
40375b29833Smrg
40475b29833Smrg# Copyright (C) 2001-2021 Free Software Foundation, Inc.
40575b29833Smrg#
40675b29833Smrg# This file is free software; the Free Software Foundation
40775b29833Smrg# gives unlimited permission to copy and/or distribute it,
40875b29833Smrg# with or without modifications, as long as this notice is preserved.
40975b29833Smrg
41075b29833Smrg# _AM_MANGLE_OPTION(NAME)
41175b29833Smrg# -----------------------
41275b29833SmrgAC_DEFUN([_AM_MANGLE_OPTION],
41375b29833Smrg[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
41475b29833Smrg
41575b29833Smrg# _AM_SET_OPTION(NAME)
41675b29833Smrg# --------------------
41775b29833Smrg# Set option NAME.  Presently that only means defining a flag for this option.
41875b29833SmrgAC_DEFUN([_AM_SET_OPTION],
41975b29833Smrg[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
42075b29833Smrg
42175b29833Smrg# _AM_SET_OPTIONS(OPTIONS)
42275b29833Smrg# ------------------------
42375b29833Smrg# OPTIONS is a space-separated list of Automake options.
42475b29833SmrgAC_DEFUN([_AM_SET_OPTIONS],
42575b29833Smrg[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
42675b29833Smrg
42775b29833Smrg# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
42875b29833Smrg# -------------------------------------------
42975b29833Smrg# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
43075b29833SmrgAC_DEFUN([_AM_IF_OPTION],
43175b29833Smrg[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
43275b29833Smrg
43375b29833Smrg# Check to make sure that the build environment is sane.    -*- Autoconf -*-
43475b29833Smrg
43575b29833Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
43675b29833Smrg#
43775b29833Smrg# This file is free software; the Free Software Foundation
43875b29833Smrg# gives unlimited permission to copy and/or distribute it,
43975b29833Smrg# with or without modifications, as long as this notice is preserved.
44075b29833Smrg
44175b29833Smrg# AM_SANITY_CHECK
44275b29833Smrg# ---------------
44375b29833SmrgAC_DEFUN([AM_SANITY_CHECK],
44475b29833Smrg[AC_MSG_CHECKING([whether build environment is sane])
44575b29833Smrg# Reject unsafe characters in $srcdir or the absolute working directory
44675b29833Smrg# name.  Accept space and tab only in the latter.
44775b29833Smrgam_lf='
44875b29833Smrg'
44975b29833Smrgcase `pwd` in
45075b29833Smrg  *[[\\\"\#\$\&\'\`$am_lf]]*)
45175b29833Smrg    AC_MSG_ERROR([unsafe absolute working directory name]);;
45275b29833Smrgesac
45375b29833Smrgcase $srcdir in
45475b29833Smrg  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
45575b29833Smrg    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
45675b29833Smrgesac
45775b29833Smrg
45875b29833Smrg# Do 'set' in a subshell so we don't clobber the current shell's
45975b29833Smrg# arguments.  Must try -L first in case configure is actually a
46075b29833Smrg# symlink; some systems play weird games with the mod time of symlinks
46175b29833Smrg# (eg FreeBSD returns the mod time of the symlink's containing
46275b29833Smrg# directory).
46375b29833Smrgif (
46475b29833Smrg   am_has_slept=no
46575b29833Smrg   for am_try in 1 2; do
46675b29833Smrg     echo "timestamp, slept: $am_has_slept" > conftest.file
46775b29833Smrg     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
46875b29833Smrg     if test "$[*]" = "X"; then
46975b29833Smrg	# -L didn't work.
47075b29833Smrg	set X `ls -t "$srcdir/configure" conftest.file`
47175b29833Smrg     fi
47275b29833Smrg     if test "$[*]" != "X $srcdir/configure conftest.file" \
47375b29833Smrg	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
47475b29833Smrg
47575b29833Smrg	# If neither matched, then we have a broken ls.  This can happen
47675b29833Smrg	# if, for instance, CONFIG_SHELL is bash and it inherits a
47775b29833Smrg	# broken ls alias from the environment.  This has actually
47875b29833Smrg	# happened.  Such a system could not be considered "sane".
47975b29833Smrg	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
48075b29833Smrg  alias in your environment])
48175b29833Smrg     fi
48275b29833Smrg     if test "$[2]" = conftest.file || test $am_try -eq 2; then
48375b29833Smrg       break
48475b29833Smrg     fi
48575b29833Smrg     # Just in case.
48675b29833Smrg     sleep 1
48775b29833Smrg     am_has_slept=yes
48875b29833Smrg   done
48975b29833Smrg   test "$[2]" = conftest.file
49075b29833Smrg   )
49175b29833Smrgthen
49275b29833Smrg   # Ok.
49375b29833Smrg   :
49475b29833Smrgelse
49575b29833Smrg   AC_MSG_ERROR([newly created file is older than distributed files!
49675b29833SmrgCheck your system clock])
49775b29833Smrgfi
49875b29833SmrgAC_MSG_RESULT([yes])
49975b29833Smrg# If we didn't sleep, we still need to ensure time stamps of config.status and
50075b29833Smrg# generated files are strictly newer.
50175b29833Smrgam_sleep_pid=
50275b29833Smrgif grep 'slept: no' conftest.file >/dev/null 2>&1; then
50375b29833Smrg  ( sleep 1 ) &
50475b29833Smrg  am_sleep_pid=$!
50575b29833Smrgfi
50675b29833SmrgAC_CONFIG_COMMANDS_PRE(
50775b29833Smrg  [AC_MSG_CHECKING([that generated files are newer than configure])
50875b29833Smrg   if test -n "$am_sleep_pid"; then
50975b29833Smrg     # Hide warnings about reused PIDs.
51075b29833Smrg     wait $am_sleep_pid 2>/dev/null
51175b29833Smrg   fi
51275b29833Smrg   AC_MSG_RESULT([done])])
51375b29833Smrgrm -f conftest.file
51475b29833Smrg])
51575b29833Smrg
51675b29833Smrg# Copyright (C) 2009-2021 Free Software Foundation, Inc.
51775b29833Smrg#
51875b29833Smrg# This file is free software; the Free Software Foundation
51975b29833Smrg# gives unlimited permission to copy and/or distribute it,
52075b29833Smrg# with or without modifications, as long as this notice is preserved.
52175b29833Smrg
52275b29833Smrg# AM_SILENT_RULES([DEFAULT])
52375b29833Smrg# --------------------------
52475b29833Smrg# Enable less verbose build rules; with the default set to DEFAULT
52575b29833Smrg# ("yes" being less verbose, "no" or empty being verbose).
52675b29833SmrgAC_DEFUN([AM_SILENT_RULES],
52775b29833Smrg[AC_ARG_ENABLE([silent-rules], [dnl
52875b29833SmrgAS_HELP_STRING(
52975b29833Smrg  [--enable-silent-rules],
53075b29833Smrg  [less verbose build output (undo: "make V=1")])
53175b29833SmrgAS_HELP_STRING(
53275b29833Smrg  [--disable-silent-rules],
53375b29833Smrg  [verbose build output (undo: "make V=0")])dnl
53475b29833Smrg])
53575b29833Smrgcase $enable_silent_rules in @%:@ (((
53675b29833Smrg  yes) AM_DEFAULT_VERBOSITY=0;;
53775b29833Smrg   no) AM_DEFAULT_VERBOSITY=1;;
53875b29833Smrg    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
53975b29833Smrgesac
54075b29833Smrgdnl
54175b29833Smrgdnl A few 'make' implementations (e.g., NonStop OS and NextStep)
54275b29833Smrgdnl do not support nested variable expansions.
54375b29833Smrgdnl See automake bug#9928 and bug#10237.
54475b29833Smrgam_make=${MAKE-make}
54575b29833SmrgAC_CACHE_CHECK([whether $am_make supports nested variables],
54675b29833Smrg   [am_cv_make_support_nested_variables],
54775b29833Smrg   [if AS_ECHO([['TRUE=$(BAR$(V))
54875b29833SmrgBAR0=false
54975b29833SmrgBAR1=true
55075b29833SmrgV=1
55175b29833Smrgam__doit:
55275b29833Smrg	@$(TRUE)
55375b29833Smrg.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
55475b29833Smrg  am_cv_make_support_nested_variables=yes
55575b29833Smrgelse
55675b29833Smrg  am_cv_make_support_nested_variables=no
55775b29833Smrgfi])
55875b29833Smrgif test $am_cv_make_support_nested_variables = yes; then
55975b29833Smrg  dnl Using '$V' instead of '$(V)' breaks IRIX make.
56075b29833Smrg  AM_V='$(V)'
56175b29833Smrg  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
56275b29833Smrgelse
56375b29833Smrg  AM_V=$AM_DEFAULT_VERBOSITY
56475b29833Smrg  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
56575b29833Smrgfi
56675b29833SmrgAC_SUBST([AM_V])dnl
56775b29833SmrgAM_SUBST_NOTMAKE([AM_V])dnl
56875b29833SmrgAC_SUBST([AM_DEFAULT_V])dnl
56975b29833SmrgAM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
57075b29833SmrgAC_SUBST([AM_DEFAULT_VERBOSITY])dnl
57175b29833SmrgAM_BACKSLASH='\'
57275b29833SmrgAC_SUBST([AM_BACKSLASH])dnl
57375b29833Smrg_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
57475b29833Smrg])
57575b29833Smrg
57675b29833Smrg# Copyright (C) 2001-2021 Free Software Foundation, Inc.
57775b29833Smrg#
57875b29833Smrg# This file is free software; the Free Software Foundation
57975b29833Smrg# gives unlimited permission to copy and/or distribute it,
58075b29833Smrg# with or without modifications, as long as this notice is preserved.
58175b29833Smrg
58275b29833Smrg# AM_PROG_INSTALL_STRIP
58375b29833Smrg# ---------------------
58475b29833Smrg# One issue with vendor 'install' (even GNU) is that you can't
58575b29833Smrg# specify the program used to strip binaries.  This is especially
58675b29833Smrg# annoying in cross-compiling environments, where the build's strip
58775b29833Smrg# is unlikely to handle the host's binaries.
58875b29833Smrg# Fortunately install-sh will honor a STRIPPROG variable, so we
58975b29833Smrg# always use install-sh in "make install-strip", and initialize
59075b29833Smrg# STRIPPROG with the value of the STRIP variable (set by the user).
59175b29833SmrgAC_DEFUN([AM_PROG_INSTALL_STRIP],
59275b29833Smrg[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
59375b29833Smrg# Installed binaries are usually stripped using 'strip' when the user
59475b29833Smrg# run "make install-strip".  However 'strip' might not be the right
59575b29833Smrg# tool to use in cross-compilation environments, therefore Automake
59675b29833Smrg# will honor the 'STRIP' environment variable to overrule this program.
59775b29833Smrgdnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
59875b29833Smrgif test "$cross_compiling" != no; then
59975b29833Smrg  AC_CHECK_TOOL([STRIP], [strip], :)
60075b29833Smrgfi
60175b29833SmrgINSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
60275b29833SmrgAC_SUBST([INSTALL_STRIP_PROGRAM])])
60375b29833Smrg
60475b29833Smrg# Copyright (C) 2006-2021 Free Software Foundation, Inc.
60575b29833Smrg#
60675b29833Smrg# This file is free software; the Free Software Foundation
60775b29833Smrg# gives unlimited permission to copy and/or distribute it,
60875b29833Smrg# with or without modifications, as long as this notice is preserved.
60975b29833Smrg
61075b29833Smrg# _AM_SUBST_NOTMAKE(VARIABLE)
61175b29833Smrg# ---------------------------
61275b29833Smrg# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
61375b29833Smrg# This macro is traced by Automake.
61475b29833SmrgAC_DEFUN([_AM_SUBST_NOTMAKE])
61575b29833Smrg
61675b29833Smrg# AM_SUBST_NOTMAKE(VARIABLE)
61775b29833Smrg# --------------------------
61875b29833Smrg# Public sister of _AM_SUBST_NOTMAKE.
61975b29833SmrgAC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
62075b29833Smrg
62175b29833Smrg# Check how to create a tarball.                            -*- Autoconf -*-
62275b29833Smrg
62375b29833Smrg# Copyright (C) 2004-2021 Free Software Foundation, Inc.
62475b29833Smrg#
62575b29833Smrg# This file is free software; the Free Software Foundation
62675b29833Smrg# gives unlimited permission to copy and/or distribute it,
62775b29833Smrg# with or without modifications, as long as this notice is preserved.
62875b29833Smrg
62975b29833Smrg# _AM_PROG_TAR(FORMAT)
63075b29833Smrg# --------------------
63175b29833Smrg# Check how to create a tarball in format FORMAT.
63275b29833Smrg# FORMAT should be one of 'v7', 'ustar', or 'pax'.
63375b29833Smrg#
63475b29833Smrg# Substitute a variable $(am__tar) that is a command
63575b29833Smrg# writing to stdout a FORMAT-tarball containing the directory
63675b29833Smrg# $tardir.
63775b29833Smrg#     tardir=directory && $(am__tar) > result.tar
63875b29833Smrg#
63975b29833Smrg# Substitute a variable $(am__untar) that extract such
64075b29833Smrg# a tarball read from stdin.
64175b29833Smrg#     $(am__untar) < result.tar
64275b29833Smrg#
64375b29833SmrgAC_DEFUN([_AM_PROG_TAR],
64475b29833Smrg[# Always define AMTAR for backward compatibility.  Yes, it's still used
64575b29833Smrg# in the wild :-(  We should find a proper way to deprecate it ...
64675b29833SmrgAC_SUBST([AMTAR], ['$${TAR-tar}'])
64775b29833Smrg
64875b29833Smrg# We'll loop over all known methods to create a tar archive until one works.
64975b29833Smrg_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
65075b29833Smrg
65175b29833Smrgm4_if([$1], [v7],
65275b29833Smrg  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
65375b29833Smrg
65475b29833Smrg  [m4_case([$1],
65575b29833Smrg    [ustar],
65675b29833Smrg     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
65775b29833Smrg      # There is notably a 21 bits limit for the UID and the GID.  In fact,
65875b29833Smrg      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
65975b29833Smrg      # and bug#13588).
66075b29833Smrg      am_max_uid=2097151 # 2^21 - 1
66175b29833Smrg      am_max_gid=$am_max_uid
66275b29833Smrg      # The $UID and $GID variables are not portable, so we need to resort
66375b29833Smrg      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
66475b29833Smrg      # below are definitely unexpected, so allow the users to see them
66575b29833Smrg      # (that is, avoid stderr redirection).
66675b29833Smrg      am_uid=`id -u || echo unknown`
66775b29833Smrg      am_gid=`id -g || echo unknown`
66875b29833Smrg      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
66975b29833Smrg      if test $am_uid -le $am_max_uid; then
67075b29833Smrg         AC_MSG_RESULT([yes])
67175b29833Smrg      else
67275b29833Smrg         AC_MSG_RESULT([no])
67375b29833Smrg         _am_tools=none
67475b29833Smrg      fi
67575b29833Smrg      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
67675b29833Smrg      if test $am_gid -le $am_max_gid; then
67775b29833Smrg         AC_MSG_RESULT([yes])
67875b29833Smrg      else
67975b29833Smrg        AC_MSG_RESULT([no])
68075b29833Smrg        _am_tools=none
68175b29833Smrg      fi],
68275b29833Smrg
68375b29833Smrg  [pax],
68475b29833Smrg    [],
68575b29833Smrg
68675b29833Smrg  [m4_fatal([Unknown tar format])])
68775b29833Smrg
68875b29833Smrg  AC_MSG_CHECKING([how to create a $1 tar archive])
68975b29833Smrg
69075b29833Smrg  # Go ahead even if we have the value already cached.  We do so because we
69175b29833Smrg  # need to set the values for the 'am__tar' and 'am__untar' variables.
69275b29833Smrg  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
69375b29833Smrg
69475b29833Smrg  for _am_tool in $_am_tools; do
69575b29833Smrg    case $_am_tool in
69675b29833Smrg    gnutar)
69775b29833Smrg      for _am_tar in tar gnutar gtar; do
69875b29833Smrg        AM_RUN_LOG([$_am_tar --version]) && break
69975b29833Smrg      done
70075b29833Smrg      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
70175b29833Smrg      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
70275b29833Smrg      am__untar="$_am_tar -xf -"
70375b29833Smrg      ;;
70475b29833Smrg    plaintar)
70575b29833Smrg      # Must skip GNU tar: if it does not support --format= it doesn't create
70675b29833Smrg      # ustar tarball either.
70775b29833Smrg      (tar --version) >/dev/null 2>&1 && continue
70875b29833Smrg      am__tar='tar chf - "$$tardir"'
70975b29833Smrg      am__tar_='tar chf - "$tardir"'
71075b29833Smrg      am__untar='tar xf -'
71175b29833Smrg      ;;
71275b29833Smrg    pax)
71375b29833Smrg      am__tar='pax -L -x $1 -w "$$tardir"'
71475b29833Smrg      am__tar_='pax -L -x $1 -w "$tardir"'
71575b29833Smrg      am__untar='pax -r'
71675b29833Smrg      ;;
71775b29833Smrg    cpio)
71875b29833Smrg      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
71975b29833Smrg      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
72075b29833Smrg      am__untar='cpio -i -H $1 -d'
72175b29833Smrg      ;;
72275b29833Smrg    none)
72375b29833Smrg      am__tar=false
72475b29833Smrg      am__tar_=false
72575b29833Smrg      am__untar=false
72675b29833Smrg      ;;
72775b29833Smrg    esac
72875b29833Smrg
72975b29833Smrg    # If the value was cached, stop now.  We just wanted to have am__tar
73075b29833Smrg    # and am__untar set.
73175b29833Smrg    test -n "${am_cv_prog_tar_$1}" && break
73275b29833Smrg
73375b29833Smrg    # tar/untar a dummy directory, and stop if the command works.
73475b29833Smrg    rm -rf conftest.dir
73575b29833Smrg    mkdir conftest.dir
73675b29833Smrg    echo GrepMe > conftest.dir/file
73775b29833Smrg    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
73875b29833Smrg    rm -rf conftest.dir
73975b29833Smrg    if test -s conftest.tar; then
74075b29833Smrg      AM_RUN_LOG([$am__untar <conftest.tar])
74175b29833Smrg      AM_RUN_LOG([cat conftest.dir/file])
74275b29833Smrg      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
74375b29833Smrg    fi
74475b29833Smrg  done
74575b29833Smrg  rm -rf conftest.dir
74675b29833Smrg
74775b29833Smrg  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
74875b29833Smrg  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
74975b29833Smrg
75075b29833SmrgAC_SUBST([am__tar])
75175b29833SmrgAC_SUBST([am__untar])
75275b29833Smrg]) # _AM_PROG_TAR
75375b29833Smrg
75475b29833Smrgdnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
75575b29833Smrgdnl serial 11 (pkg-config-0.29)
75675b29833Smrgdnl
75775b29833Smrgdnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
75875b29833Smrgdnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
75975b29833Smrgdnl
76075b29833Smrgdnl This program is free software; you can redistribute it and/or modify
76175b29833Smrgdnl it under the terms of the GNU General Public License as published by
76275b29833Smrgdnl the Free Software Foundation; either version 2 of the License, or
76375b29833Smrgdnl (at your option) any later version.
76475b29833Smrgdnl
76575b29833Smrgdnl This program is distributed in the hope that it will be useful, but
76675b29833Smrgdnl WITHOUT ANY WARRANTY; without even the implied warranty of
76775b29833Smrgdnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
76875b29833Smrgdnl General Public License for more details.
76975b29833Smrgdnl
77075b29833Smrgdnl You should have received a copy of the GNU General Public License
77175b29833Smrgdnl along with this program; if not, write to the Free Software
77275b29833Smrgdnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
77375b29833Smrgdnl 02111-1307, USA.
77475b29833Smrgdnl
77575b29833Smrgdnl As a special exception to the GNU General Public License, if you
77675b29833Smrgdnl distribute this file as part of a program that contains a
77775b29833Smrgdnl configuration script generated by Autoconf, you may include it under
77875b29833Smrgdnl the same distribution terms that you use for the rest of that
77975b29833Smrgdnl program.
78075b29833Smrg
78175b29833Smrgdnl PKG_PREREQ(MIN-VERSION)
78275b29833Smrgdnl -----------------------
78375b29833Smrgdnl Since: 0.29
78475b29833Smrgdnl
78575b29833Smrgdnl Verify that the version of the pkg-config macros are at least
78675b29833Smrgdnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
78775b29833Smrgdnl installed version of pkg-config, this checks the developer's version
78875b29833Smrgdnl of pkg.m4 when generating configure.
78975b29833Smrgdnl
79075b29833Smrgdnl To ensure that this macro is defined, also add:
79175b29833Smrgdnl m4_ifndef([PKG_PREREQ],
79275b29833Smrgdnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
79375b29833Smrgdnl
79475b29833Smrgdnl See the "Since" comment for each macro you use to see what version
79575b29833Smrgdnl of the macros you require.
79675b29833Smrgm4_defun([PKG_PREREQ],
79775b29833Smrg[m4_define([PKG_MACROS_VERSION], [0.29])
79875b29833Smrgm4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
79975b29833Smrg    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
80075b29833Smrg])dnl PKG_PREREQ
80175b29833Smrg
80275b29833Smrgdnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
80375b29833Smrgdnl ----------------------------------
80475b29833Smrgdnl Since: 0.16
80575b29833Smrgdnl
80675b29833Smrgdnl Search for the pkg-config tool and set the PKG_CONFIG variable to
80775b29833Smrgdnl first found in the path. Checks that the version of pkg-config found
80875b29833Smrgdnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
80975b29833Smrgdnl used since that's the first version where most current features of
81075b29833Smrgdnl pkg-config existed.
81175b29833SmrgAC_DEFUN([PKG_PROG_PKG_CONFIG],
81275b29833Smrg[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
81375b29833Smrgm4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
81475b29833Smrgm4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
81575b29833SmrgAC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
81675b29833SmrgAC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
81775b29833SmrgAC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
81875b29833Smrg
81975b29833Smrgif test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
82075b29833Smrg	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
82175b29833Smrgfi
82275b29833Smrgif test -n "$PKG_CONFIG"; then
82375b29833Smrg	_pkg_min_version=m4_default([$1], [0.9.0])
82475b29833Smrg	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
82575b29833Smrg	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
82675b29833Smrg		AC_MSG_RESULT([yes])
82775b29833Smrg	else
82875b29833Smrg		AC_MSG_RESULT([no])
82975b29833Smrg		PKG_CONFIG=""
83075b29833Smrg	fi
83175b29833Smrgfi[]dnl
83275b29833Smrg])dnl PKG_PROG_PKG_CONFIG
83375b29833Smrg
83475b29833Smrgdnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
83575b29833Smrgdnl -------------------------------------------------------------------
83675b29833Smrgdnl Since: 0.18
83775b29833Smrgdnl
83875b29833Smrgdnl Check to see whether a particular set of modules exists. Similar to
83975b29833Smrgdnl PKG_CHECK_MODULES(), but does not set variables or print errors.
84075b29833Smrgdnl
84175b29833Smrgdnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
84275b29833Smrgdnl only at the first occurence in configure.ac, so if the first place
84375b29833Smrgdnl it's called might be skipped (such as if it is within an "if", you
84475b29833Smrgdnl have to call PKG_CHECK_EXISTS manually
84575b29833SmrgAC_DEFUN([PKG_CHECK_EXISTS],
84675b29833Smrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
84775b29833Smrgif test -n "$PKG_CONFIG" && \
84875b29833Smrg    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
84975b29833Smrg  m4_default([$2], [:])
85075b29833Smrgm4_ifvaln([$3], [else
85175b29833Smrg  $3])dnl
85275b29833Smrgfi])
85375b29833Smrg
85475b29833Smrgdnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
85575b29833Smrgdnl ---------------------------------------------
85675b29833Smrgdnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
85775b29833Smrgdnl pkg_failed based on the result.
85875b29833Smrgm4_define([_PKG_CONFIG],
85975b29833Smrg[if test -n "$$1"; then
86075b29833Smrg    pkg_cv_[]$1="$$1"
86175b29833Smrg elif test -n "$PKG_CONFIG"; then
86275b29833Smrg    PKG_CHECK_EXISTS([$3],
86375b29833Smrg                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
86475b29833Smrg		      test "x$?" != "x0" && pkg_failed=yes ],
86575b29833Smrg		     [pkg_failed=yes])
86675b29833Smrg else
86775b29833Smrg    pkg_failed=untried
86875b29833Smrgfi[]dnl
86975b29833Smrg])dnl _PKG_CONFIG
87075b29833Smrg
87175b29833Smrgdnl _PKG_SHORT_ERRORS_SUPPORTED
87275b29833Smrgdnl ---------------------------
87375b29833Smrgdnl Internal check to see if pkg-config supports short errors.
87475b29833SmrgAC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
87575b29833Smrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
87675b29833Smrgif $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
87775b29833Smrg        _pkg_short_errors_supported=yes
87875b29833Smrgelse
87975b29833Smrg        _pkg_short_errors_supported=no
88075b29833Smrgfi[]dnl
88175b29833Smrg])dnl _PKG_SHORT_ERRORS_SUPPORTED
88275b29833Smrg
88375b29833Smrg
88475b29833Smrgdnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
88575b29833Smrgdnl   [ACTION-IF-NOT-FOUND])
88675b29833Smrgdnl --------------------------------------------------------------
88775b29833Smrgdnl Since: 0.4.0
88875b29833Smrgdnl
88975b29833Smrgdnl Note that if there is a possibility the first call to
89075b29833Smrgdnl PKG_CHECK_MODULES might not happen, you should be sure to include an
89175b29833Smrgdnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
89275b29833SmrgAC_DEFUN([PKG_CHECK_MODULES],
89375b29833Smrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
89475b29833SmrgAC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
89575b29833SmrgAC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
89675b29833Smrg
89775b29833Smrgpkg_failed=no
89875b29833SmrgAC_MSG_CHECKING([for $1])
89975b29833Smrg
90075b29833Smrg_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
90175b29833Smrg_PKG_CONFIG([$1][_LIBS], [libs], [$2])
90275b29833Smrg
90375b29833Smrgm4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
90475b29833Smrgand $1[]_LIBS to avoid the need to call pkg-config.
90575b29833SmrgSee the pkg-config man page for more details.])
90675b29833Smrg
90775b29833Smrgif test $pkg_failed = yes; then
90875b29833Smrg   	AC_MSG_RESULT([no])
90975b29833Smrg        _PKG_SHORT_ERRORS_SUPPORTED
91075b29833Smrg        if test $_pkg_short_errors_supported = yes; then
91175b29833Smrg	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
91275b29833Smrg        else 
91375b29833Smrg	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
91475b29833Smrg        fi
91575b29833Smrg	# Put the nasty error message in config.log where it belongs
91675b29833Smrg	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
91775b29833Smrg
91875b29833Smrg	m4_default([$4], [AC_MSG_ERROR(
91975b29833Smrg[Package requirements ($2) were not met:
92075b29833Smrg
92175b29833Smrg$$1_PKG_ERRORS
92275b29833Smrg
92375b29833SmrgConsider adjusting the PKG_CONFIG_PATH environment variable if you
92475b29833Smrginstalled software in a non-standard prefix.
92575b29833Smrg
92675b29833Smrg_PKG_TEXT])[]dnl
92775b29833Smrg        ])
92875b29833Smrgelif test $pkg_failed = untried; then
92975b29833Smrg     	AC_MSG_RESULT([no])
93075b29833Smrg	m4_default([$4], [AC_MSG_FAILURE(
93175b29833Smrg[The pkg-config script could not be found or is too old.  Make sure it
93275b29833Smrgis in your PATH or set the PKG_CONFIG environment variable to the full
93375b29833Smrgpath to pkg-config.
93475b29833Smrg
93575b29833Smrg_PKG_TEXT
93675b29833Smrg
93775b29833SmrgTo get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
93875b29833Smrg        ])
93975b29833Smrgelse
94075b29833Smrg	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
94175b29833Smrg	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
94275b29833Smrg        AC_MSG_RESULT([yes])
94375b29833Smrg	$3
94475b29833Smrgfi[]dnl
94575b29833Smrg])dnl PKG_CHECK_MODULES
94675b29833Smrg
94775b29833Smrg
94875b29833Smrgdnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
94975b29833Smrgdnl   [ACTION-IF-NOT-FOUND])
95075b29833Smrgdnl ---------------------------------------------------------------------
95175b29833Smrgdnl Since: 0.29
95275b29833Smrgdnl
95375b29833Smrgdnl Checks for existence of MODULES and gathers its build flags with
95475b29833Smrgdnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
95575b29833Smrgdnl and VARIABLE-PREFIX_LIBS from --libs.
95675b29833Smrgdnl
95775b29833Smrgdnl Note that if there is a possibility the first call to
95875b29833Smrgdnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
95975b29833Smrgdnl include an explicit call to PKG_PROG_PKG_CONFIG in your
96075b29833Smrgdnl configure.ac.
96175b29833SmrgAC_DEFUN([PKG_CHECK_MODULES_STATIC],
96275b29833Smrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
96375b29833Smrg_save_PKG_CONFIG=$PKG_CONFIG
96475b29833SmrgPKG_CONFIG="$PKG_CONFIG --static"
96575b29833SmrgPKG_CHECK_MODULES($@)
96675b29833SmrgPKG_CONFIG=$_save_PKG_CONFIG[]dnl
96775b29833Smrg])dnl PKG_CHECK_MODULES_STATIC
96875b29833Smrg
96975b29833Smrg
97075b29833Smrgdnl PKG_INSTALLDIR([DIRECTORY])
97175b29833Smrgdnl -------------------------
97275b29833Smrgdnl Since: 0.27
97375b29833Smrgdnl
97475b29833Smrgdnl Substitutes the variable pkgconfigdir as the location where a module
97575b29833Smrgdnl should install pkg-config .pc files. By default the directory is
97675b29833Smrgdnl $libdir/pkgconfig, but the default can be changed by passing
97775b29833Smrgdnl DIRECTORY. The user can override through the --with-pkgconfigdir
97875b29833Smrgdnl parameter.
97975b29833SmrgAC_DEFUN([PKG_INSTALLDIR],
98075b29833Smrg[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
98175b29833Smrgm4_pushdef([pkg_description],
98275b29833Smrg    [pkg-config installation directory @<:@]pkg_default[@:>@])
98375b29833SmrgAC_ARG_WITH([pkgconfigdir],
98475b29833Smrg    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
98575b29833Smrg    [with_pkgconfigdir=]pkg_default)
98675b29833SmrgAC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
98775b29833Smrgm4_popdef([pkg_default])
98875b29833Smrgm4_popdef([pkg_description])
98975b29833Smrg])dnl PKG_INSTALLDIR
99075b29833Smrg
99175b29833Smrg
99275b29833Smrgdnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
99375b29833Smrgdnl --------------------------------
99475b29833Smrgdnl Since: 0.27
99575b29833Smrgdnl
99675b29833Smrgdnl Substitutes the variable noarch_pkgconfigdir as the location where a
99775b29833Smrgdnl module should install arch-independent pkg-config .pc files. By
99875b29833Smrgdnl default the directory is $datadir/pkgconfig, but the default can be
99975b29833Smrgdnl changed by passing DIRECTORY. The user can override through the
100075b29833Smrgdnl --with-noarch-pkgconfigdir parameter.
100175b29833SmrgAC_DEFUN([PKG_NOARCH_INSTALLDIR],
100275b29833Smrg[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
100375b29833Smrgm4_pushdef([pkg_description],
100475b29833Smrg    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
100575b29833SmrgAC_ARG_WITH([noarch-pkgconfigdir],
100675b29833Smrg    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
100775b29833Smrg    [with_noarch_pkgconfigdir=]pkg_default)
100875b29833SmrgAC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
100975b29833Smrgm4_popdef([pkg_default])
101075b29833Smrgm4_popdef([pkg_description])
101175b29833Smrg])dnl PKG_NOARCH_INSTALLDIR
101275b29833Smrg
101375b29833Smrg
101475b29833Smrgdnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
101575b29833Smrgdnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
101675b29833Smrgdnl -------------------------------------------
101775b29833Smrgdnl Since: 0.28
101875b29833Smrgdnl
101975b29833Smrgdnl Retrieves the value of the pkg-config variable for the given module.
102075b29833SmrgAC_DEFUN([PKG_CHECK_VAR],
102175b29833Smrg[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
102275b29833SmrgAC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
102375b29833Smrg
102475b29833Smrg_PKG_CONFIG([$1], [variable="][$3]["], [$2])
102575b29833SmrgAS_VAR_COPY([$1], [pkg_cv_][$1])
102675b29833Smrg
102775b29833SmrgAS_VAR_IF([$1], [""], [$5], [$4])dnl
102875b29833Smrg])dnl PKG_CHECK_VAR
102975b29833Smrg
103075b29833Smrgdnl fontutil.m4.  Generated from fontutil.m4.in by configure.
103175b29833Smrgdnl
103275b29833Smrgdnl This file comes from X.Org's font-util 1.4.0
103375b29833Smrgdnl
103475b29833Smrgdnl Copyright (c) 2009, 2023, Oracle and/or its affiliates.
103575b29833Smrgdnl
103675b29833Smrgdnl Permission is hereby granted, free of charge, to any person obtaining a
103775b29833Smrgdnl copy of this software and associated documentation files (the "Software"),
103875b29833Smrgdnl to deal in the Software without restriction, including without limitation
103975b29833Smrgdnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
104075b29833Smrgdnl and/or sell copies of the Software, and to permit persons to whom the
104175b29833Smrgdnl Software is furnished to do so, subject to the following conditions:
104275b29833Smrgdnl
104375b29833Smrgdnl The above copyright notice and this permission notice (including the next
104475b29833Smrgdnl paragraph) shall be included in all copies or substantial portions of the
104575b29833Smrgdnl Software.
104675b29833Smrgdnl
104775b29833Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104875b29833Smrgdnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
104975b29833Smrgdnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
105075b29833Smrgdnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105175b29833Smrgdnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
105275b29833Smrgdnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
105375b29833Smrgdnl DEALINGS IN THE SOFTWARE.
105475b29833Smrgdnl
105575b29833Smrgdnl --------------------------------------------------------------------
105675b29833Smrgdnl
105775b29833Smrgdnl Copyright 2005 Red Hat, Inc
105875b29833Smrgdnl
105975b29833Smrgdnl Permission to use, copy, modify, distribute, and sell this software and its
106075b29833Smrgdnl documentation for any purpose is hereby granted without fee, provided that
106175b29833Smrgdnl the above copyright notice appear in all copies and that both that
106275b29833Smrgdnl copyright notice and this permission notice appear in supporting
106375b29833Smrgdnl documentation.
106475b29833Smrgdnl
106575b29833Smrgdnl The above copyright notice and this permission notice shall be included
106675b29833Smrgdnl in all copies or substantial portions of the Software.
106775b29833Smrgdnl
106875b29833Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
106975b29833Smrgdnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
107075b29833Smrgdnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
107175b29833Smrgdnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
107275b29833Smrgdnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
107375b29833Smrgdnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
107475b29833Smrgdnl OTHER DEALINGS IN THE SOFTWARE.
107575b29833Smrgdnl
107675b29833Smrgdnl Except as contained in this notice, the name of the copyright holders shall
107775b29833Smrgdnl not be used in advertising or otherwise to promote the sale, use or
107875b29833Smrgdnl other dealings in this Software without prior written authorization
107975b29833Smrgdnl from the copyright holders.
108075b29833Smrg
108175b29833Smrg# XORG_FONT_MACROS_VERSION(required-version)
108275b29833Smrg# ------------------------------------------
108375b29833Smrg# Minimum version: 1.1.0
108475b29833Smrg#
108575b29833Smrg# If you're using a macro added in Version 1.1 or newer, include this in
108675b29833Smrg# your configure.ac with the minimum required version, such as:
108775b29833Smrg# XORG_FONT_MACROS_VERSION(1.1)
108875b29833Smrg#
108975b29833Smrg# To ensure that this macro is defined, also add:
109075b29833Smrg# m4_ifndef([XORG_FONT_MACROS_VERSION],
109175b29833Smrg#     [m4_fatal([must install X.Org font-util 1.1 or later before running autoconf/autogen])])
109275b29833Smrg#
109375b29833Smrg#
109475b29833Smrg# See the "minimum version" comment for each macro you use to see what
109575b29833Smrg# version you require.
109675b29833Smrgm4_defun([XORG_FONT_MACROS_VERSION],[
109775b29833Smrgm4_define([vers_have], [1.4.0])
109875b29833Smrgm4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
109975b29833Smrgm4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
110075b29833Smrgm4_if(m4_cmp(maj_have, maj_needed), 0,,
110175b29833Smrg    [m4_fatal([font-util major version ]maj_needed[ is required but ]vers_have[ found])])
110275b29833Smrgm4_if(m4_version_compare(vers_have, [$1]), -1,
110375b29833Smrg    [m4_fatal([font-util version $1 or higher is required but ]vers_have[ found])])
110475b29833Smrgm4_undefine([vers_have])
110575b29833Smrgm4_undefine([maj_have])
110675b29833Smrgm4_undefine([maj_needed])
110775b29833Smrg]) # XORG_FONT_MACROS_VERSION
110875b29833Smrg
110975b29833Smrg# XORG_FONT_CHECK_{maps}()
111075b29833Smrg# ------------------------
111175b29833Smrg# Minimum version: 1.0.0
111275b29833Smrg# These macros add --enable/disable-{maps} where {maps} are ISO8859-*,
111375b29833Smrg# JISX0201 or KOI8_R.  By default, they are all enabled.
111475b29833Smrg
111575b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_1], [XORG_FONT_CHECK_ENCODING(ISO8859-1)])
111675b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_2], [XORG_FONT_CHECK_ENCODING(ISO8859-2)])
111775b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_3], [XORG_FONT_CHECK_ENCODING(ISO8859-3)])
111875b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_4], [XORG_FONT_CHECK_ENCODING(ISO8859-4)])
111975b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_5], [XORG_FONT_CHECK_ENCODING(ISO8859-5)])
112075b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_6], [XORG_FONT_CHECK_ENCODING(ISO8859-6)])
112175b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_7], [XORG_FONT_CHECK_ENCODING(ISO8859-7)])
112275b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_8], [XORG_FONT_CHECK_ENCODING(ISO8859-8)])
112375b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_9], [XORG_FONT_CHECK_ENCODING(ISO8859-9)])
112475b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_10],[XORG_FONT_CHECK_ENCODING(ISO8859-10)])
112575b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_11],[XORG_FONT_CHECK_ENCODING(ISO8859-11)])
112675b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_12],[XORG_FONT_CHECK_ENCODING(ISO8859-12)])
112775b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_13],[XORG_FONT_CHECK_ENCODING(ISO8859-13)])
112875b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_14],[XORG_FONT_CHECK_ENCODING(ISO8859-14)])
112975b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_15],[XORG_FONT_CHECK_ENCODING(ISO8859-15)])
113075b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ISO8859_16],[XORG_FONT_CHECK_ENCODING(ISO8859-16)])
113175b29833SmrgAC_DEFUN([XORG_FONT_CHECK_JISX0201],  [XORG_FONT_CHECK_ENCODING(JISX0201)])
113275b29833SmrgAC_DEFUN([XORG_FONT_CHECK_KOI8_R],    [XORG_FONT_CHECK_ENCODING(KOI8-R)])
113375b29833Smrg
113475b29833Smrg# XORG_FONT_CHECK_ENCODING(encoding)
113575b29833Smrg# ----------------------------------
113675b29833Smrg# Minimum version: 1.1.0
113775b29833Smrg# This macro adds --enable/disable-<encoding>, enabled by default.
113875b29833Smrg# It replaced individual copies of this code in the above macros in 1.1.
113975b29833Smrg# Currently assumes encoding names will be all upper-case - add m4_toupper
114075b29833Smrg# calls if this is not true in the future.
114175b29833Smrg
114275b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ENCODING],[
114375b29833Smrg	AC_ARG_ENABLE(m4_tolower($1),
114475b29833Smrg		AS_HELP_STRING(m4_join([-], [--disable], m4_tolower($1)),
114575b29833Smrg				[Build $1 fonts (default: yes)]),
114675b29833Smrg		[AS_TR_SH($1)=$enableval])
114775b29833Smrg	AC_MSG_CHECKING([whether to build $1 fonts])
114875b29833Smrg	AC_MSG_RESULT($[AS_TR_SH($1)])
114975b29833Smrg	AM_CONDITIONAL(AS_TR_SH($1), [test "x$AS_TR_SH($1)" = xyes])
115075b29833Smrg]) # XORG_FONT_CHECK_ENCODING
115175b29833Smrg
115275b29833Smrg# XORG_FONT_CHECK_ENCODING_LIST(encoding1 encoding2....)
115375b29833Smrg# -----------------------------------------------------
115475b29833Smrg# Minimum version: 1.1.0
115575b29833Smrg# Call XORG_FONT_CHECK_ENCODING for multiple encodings at once.
115675b29833Smrg# Add a shorthand --enable/disable-all-encodings option.
115775b29833Smrg
115875b29833SmrgAC_DEFUN([XORG_FONT_CHECK_ENCODING_LIST],[
115975b29833Smrg	AC_ARG_ENABLE([all-encodings],
116075b29833Smrg		AS_HELP_STRING([--disable-all-encodings],
116175b29833Smrg				[Disable building of all font encodings]),
116275b29833Smrg		[m4_foreach_w([enc], [$1], [
116375b29833Smrg			AS_TR_SH(enc)=$enableval
116475b29833Smrg		])],
116575b29833Smrg		[m4_foreach_w([enc], [$1], [
116675b29833Smrg			AS_TR_SH(enc)=yes
116775b29833Smrg		])])
116875b29833Smrg	m4_foreach_w([enc], [$1], [XORG_FONT_CHECK_ENCODING(enc)])
116975b29833Smrg]) # XORG_FONT_CHECK_ENCODING_LIST
117075b29833Smrg
117175b29833Smrg# XORG_FONT_REQUIRED_PROG(VARNAME, progname)
117275b29833Smrg# ------------------------------------------
117375b29833Smrg# Minimum version: 1.1.0
117475b29833Smrg#
117575b29833Smrg# Simple wrapper around AC_PATH_PROG that errors if not found
117675b29833Smrg#
117775b29833Smrg
117875b29833SmrgAC_DEFUN([XORG_FONT_REQUIRED_PROG],[
117975b29833Smrg	AC_PATH_PROG($1, $2)
118075b29833Smrg	if test x"$$1" = x; then
118175b29833Smrg		AC_MSG_ERROR([$2 is required to build $PACKAGE_NAME.])
118275b29833Smrg	fi
118375b29833Smrg])
118475b29833Smrg
118575b29833Smrg
118675b29833Smrg# XORG_FONT_FCCACHE()
118775b29833Smrg# -------------------
118875b29833Smrg# Minimum version: 1.1.0
118975b29833Smrg#
119075b29833Smrg# Set FCCACHE to path to fc-cache (fontconfig cache builder) if found
119175b29833Smrg# Set RUN_FCCACHE to a rule suitable for substituting into a makefile
119275b29833Smrg# to run fc-cache if found and not installing to $DESTDIR and not
119375b29833Smrg# cross-compiling
119475b29833Smrg#
119575b29833Smrg# fc-cache is optional, not required, and should be skipped when making
119675b29833Smrg# packages (installing to $DESTDIR) or cross-compiling
119775b29833Smrg#
119875b29833SmrgAC_DEFUN([XORG_FONT_FCCACHE],[
119975b29833Smrg	AC_PATH_PROG(FCCACHE, fc-cache)
120075b29833Smrg	FCCACHE_WARN='echo "** Warning: fonts.cache not built" ; echo "** Generate this file manually on host system using fc-cache"'
120175b29833Smrg	if test x"$FCCACHE" = x || test x"$cross_compiling" != x"no" ; then
120275b29833Smrg		RUN_FCCACHE="${FCCACHE_WARN}"
120375b29833Smrg	else
120475b29833Smrg		RUN_FCCACHE='@(if test -z "$(DESTDIR)"; then echo $(FCCACHE) $(fontdir); $(FCCACHE) $(fontdir); else'
120575b29833Smrg		RUN_FCCACHE="${RUN_FCCACHE} ${FCCACHE_WARN} ; fi)"
120675b29833Smrg	fi
120775b29833Smrg	AC_SUBST([RUN_FCCACHE])
120875b29833Smrg])
120975b29833Smrg
121075b29833Smrg# XORG_FONT_MKFONTDIR()
121175b29833Smrg# -------------------
121275b29833Smrg# Minimum version: 1.3.0
121375b29833Smrg#
121475b29833Smrg# Set MKFONTDIR to path to mkfontdir.
121575b29833Smrg#
121675b29833Smrg# If cross-compiling, and if mkdir is not found, use a shell command
121775b29833Smrg# which warns mkfontdir needs to be run on the target
121875b29833Smrg#
121975b29833Smrg# If not cross-compiling, mkfontdir must be found
122075b29833Smrg#
122175b29833SmrgAC_DEFUN([XORG_FONT_MKFONTDIR],[
122275b29833Smrg	if test x"$cross_compiling" != x"no" ; then
122375b29833Smrg		AC_PATH_PROG(MKFONTDIR, mkfontdir, "")
122475b29833Smrg		MKFONTDIR_WARN='echo "** Warning: mkfontdir not run" ; echo "** Run mkfontdir manually on host system"'
122575b29833Smrg
122675b29833Smrg		if test x"$MKFONTDIR" = x; then
122775b29833Smrg			MKFONTDIR="${MKFONTDIR_WARN} ; echo '** mkfontdir'"
122875b29833Smrg		fi
122975b29833Smrg	else
123075b29833Smrg		XORG_FONT_REQUIRED_PROG(MKFONTDIR, mkfontdir)
123175b29833Smrg	fi
123275b29833Smrg
123375b29833Smrg	AC_SUBST([MKFONTDIR])
123475b29833Smrg])
123575b29833Smrg
123675b29833Smrg# XORG_FONT_COMMON_UTILS()
123775b29833Smrg# ------------------------
123875b29833Smrg# Minimum version: 1.1.0
123975b29833Smrg#
124075b29833Smrg# Call XORG_FONT_REQUIRED_PROG for programs needed for all font types
124175b29833Smrg
124275b29833SmrgAC_DEFUN([XORG_FONT_COMMON_UTILS],[
124375b29833Smrg	XORG_FONT_FCCACHE
124475b29833Smrg	XORG_FONT_MKFONTDIR
124575b29833Smrg])
124675b29833Smrg
124775b29833Smrg# XORG_FONT_SCALED_UTILS()
124875b29833Smrg# ------------------------
124975b29833Smrg# Minimum version: 1.1.0
125075b29833Smrg#
125175b29833Smrg# Call XORG_FONT_REQUIRED_PROG for programs needed for scalable fonts
125275b29833Smrg# (TrueType, OpenType, Type1)
125375b29833Smrg
125475b29833SmrgAC_DEFUN([XORG_FONT_SCALED_UTILS],[
125575b29833Smrg	XORG_FONT_COMMON_UTILS
125675b29833Smrg	XORG_FONT_REQUIRED_PROG(MKFONTSCALE, mkfontscale)
125775b29833Smrg])
125875b29833Smrg
125975b29833Smrg# XORG_FONT_BDF_UTILS()
126075b29833Smrg# ---------------------
126175b29833Smrg# Minimum version: 1.1.0
126275b29833Smrg#
126375b29833Smrg# Call XORG_FONT_REQUIRED_PROG for programs needed for BDF format bitmap fonts
126475b29833Smrg# Also call XORG_FONT_CHECK_COMPRESSION to determine how to compress the
126575b29833Smrg# PCF output files created by bdftopcf
126675b29833Smrg
126775b29833SmrgAC_DEFUN([XORG_FONT_BDF_UTILS],[
126875b29833Smrg	XORG_FONT_COMMON_UTILS
126975b29833Smrg	XORG_FONT_REQUIRED_PROG(BDFTOPCF, bdftopcf)
127075b29833Smrg	XORG_FONT_CHECK_COMPRESSION
127175b29833Smrg])
127275b29833Smrg
127375b29833Smrg# XORG_FONT_CHECK_COMPRESSION()
127475b29833Smrg# -----------------------------
127575b29833Smrg# Minimum version: 1.1.0
127675b29833Smrg#
127775b29833Smrg# Offer a --with-compression flag to control what compression method is
127875b29833Smrg# used for pcf font files.   Offers all the methods currently supported
127975b29833Smrg# by libXfont, including no compression.
128075b29833Smrg#
128175b29833Smrg# If COMPRESS_FLAGS is not set, and the compression method has flags needed
128275b29833Smrg# for reproducible builds, such as gzip -n to not record timestamp, will
128375b29833Smrg# set COMPRESS_FLAGS to those options.
128475b29833Smrg
128575b29833SmrgAC_DEFUN([XORG_FONT_CHECK_COMPRESSION],[
128675b29833Smrg	AC_MSG_CHECKING([font compression method])
128775b29833Smrg	AC_ARG_WITH(compression,
128875b29833Smrg	 [AS_HELP_STRING([--with-compression=<no|compress|gzip|bzip2>],
128975b29833Smrg			 [compression method to use on pcf fonts])],
129075b29833Smrg         [compression="$withval"], [compression="yes"])
129175b29833Smrg	if test x"$compression" = "xyes" ; then
129275b29833Smrg		compression="gzip"
129375b29833Smrg	fi
129475b29833Smrg	AC_MSG_RESULT([${compression}])
129575b29833Smrg	case ${compression} in
129675b29833Smrg	 *compress)	COMPRESS_SUFFIX=".Z" ;;
129775b29833Smrg	 *gzip)		COMPRESS_SUFFIX=".gz" ;
129875b29833Smrg			COMPRESS_FLAGS="${COMPRESS_FLAGS--n}" ;;
129975b29833Smrg	 *bzip2)	COMPRESS_SUFFIX=".bz2" ;;
130075b29833Smrg	 no|none)	COMPRESS_SUFFIX="" ; COMPRESS="cat" ;;
130175b29833Smrg	 *) AC_MSG_ERROR([${compression} is not a supported compression method]) ;;
130275b29833Smrg	esac
130375b29833Smrg	if test x"$COMPRESS_SUFFIX" != "x" ; then
130475b29833Smrg	   XORG_FONT_REQUIRED_PROG(COMPRESS, ${compression})
130575b29833Smrg	fi
130675b29833Smrg	AC_MSG_CHECKING([options to font compression command])
130775b29833Smrg	AC_MSG_RESULT([${COMPRESS_FLAGS:-none}])
130875b29833Smrg	AC_SUBST([COMPRESS_FLAGS])
130975b29833Smrg	AC_SUBST([COMPRESS_SUFFIX])
131075b29833Smrg])
131175b29833Smrg
131275b29833Smrg# XORG_FONT_UCS2ANY()
131375b29833Smrg# -------------------
131475b29833Smrg# Minimum version: 1.1.0
131575b29833Smrg#
131675b29833Smrg# Call XORG_FONT_REQUIRED_PROG for ucs2any program needed for splitting
131775b29833Smrg# Unicode-encoded BDF format bitmap fonts into subsets for older encodings.
131875b29833Smrg# Also call pkg-config to find the directory with the encoding files needed
131975b29833Smrg# by ucs2any, and export it as MAPFILES_PATH to the Makefiles
132075b29833Smrg
132175b29833SmrgAC_DEFUN([XORG_FONT_UCS2ANY],[
132275b29833Smrg	AC_REQUIRE([PKG_PROG_PKG_CONFIG])
132375b29833Smrg	XORG_FONT_REQUIRED_PROG(UCS2ANY, ucs2any)
132475b29833Smrg	PKG_CHECK_MODULES(MAPS, [fontutil])
132575b29833Smrg	AC_MSG_CHECKING([for ucs2any encoding data files])
132675b29833Smrg	MAPFILES_PATH=`$PKG_CONFIG --variable=mapdir fontutil`
132775b29833Smrg	AC_SUBST(MAPFILES_PATH)
132875b29833Smrg	AC_MSG_RESULT([${MAPFILES_PATH}])
132975b29833Smrg])
133075b29833Smrg
133175b29833Smrg
133275b29833Smrg
133375b29833Smrg# XORG_FONT_FC_CONFDIR()
133475b29833Smrg# --------------------
133575b29833Smrg# Minimum version: 1.2.0
133675b29833Smrg#
133775b29833Smrg# Sets FC_CONFDIR to the fontconfig config directory
133875b29833Smrg# (which should be --with-confdir=... when building fontconfig)
133975b29833Smrg# found from:
134075b29833Smrg#	--with-fc-confdir=...
134175b29833Smrg#	pkg-config --variable=confdir fontconfig
134275b29833Smrg#	${sysconfdir}/fonts
134375b29833Smrg
134475b29833SmrgAC_DEFUN([XORG_FONT_FC_CONFDIR],[
134575b29833Smrg	dnl Ensure $PKG_CONFIG is set first
134675b29833Smrg	AC_REQUIRE([PKG_PROG_PKG_CONFIG])
134775b29833Smrg
134875b29833Smrg	AC_MSG_CHECKING([for fontconfig's configuration directory])
134975b29833Smrg	AC_ARG_WITH(fc-confdir,
135075b29833Smrg		    AS_HELP_STRING([--with-fc-confdir=DIR],
135175b29833Smrg			   [Path to fontconfig's configuration directory]),
135275b29833Smrg		    [FC_CONFDIR="$withval"])
135375b29833Smrg	# if --with-fc-confdir was not specified
135475b29833Smrg	if test "x${FC_CONFDIR}" = "x"; then
135575b29833Smrg		FC_CONFDIR=`$PKG_CONFIG --variable=confdir fontconfig`
135675b29833Smrg	fi
135775b29833Smrg	# ...and if pkg-config didn't find confdir in fontconfig.pc...
135875b29833Smrg	if test "x${FC_CONFDIR}" = "x"; then
135975b29833Smrg		FC_CONFDIR="${sysconfdir}/fonts"
136075b29833Smrg	fi
136175b29833Smrg	AC_SUBST(FC_CONFDIR)
136275b29833Smrg	AC_MSG_RESULT([${FC_CONFDIR}])
136375b29833Smrg])
136475b29833Smrg
136575b29833Smrg
136675b29833Smrg
136775b29833Smrg# XORG_FONTROOTDIR()
136875b29833Smrg# --------------------
136975b29833Smrg# Minimum version: 1.1.0
137075b29833Smrg#
137175b29833Smrg# Sets FONTROOTDIR to the root directory for font files.  Uses the first
137275b29833Smrg# found from:
137375b29833Smrg#	--with-fontrootdir
137475b29833Smrg#	pkg-config --variable=fontrootdir fontutil
137575b29833Smrg#	${datadir}/fonts/X11
137675b29833Smrg
137775b29833SmrgAC_DEFUN([XORG_FONTROOTDIR],[
137875b29833Smrg	dnl Ensure $PKG_CONFIG is set first
137975b29833Smrg	AC_REQUIRE([PKG_PROG_PKG_CONFIG])
138075b29833Smrg
138175b29833Smrg	AC_MSG_CHECKING([for root directory for font files])
138275b29833Smrg	AC_ARG_WITH(fontrootdir,
138375b29833Smrg		    AS_HELP_STRING([--with-fontrootdir=DIR],
138475b29833Smrg			   [Path to root directory for font files]),
138575b29833Smrg		    [FONTROOTDIR="$withval"])
138675b29833Smrg	# if --with-fontrootdir not specified...
138775b29833Smrg	if test "x${FONTROOTDIR}" = "x"; then
138875b29833Smrg		FONTROOTDIR=`$PKG_CONFIG --variable=fontrootdir fontutil`
138975b29833Smrg	fi
139075b29833Smrg	# ...and if pkg-config didn't find fontdir in fontutil.pc...
139175b29833Smrg	if test "x${FONTROOTDIR}" = "x"; then
139275b29833Smrg		FONTROOTDIR="${datadir}/fonts/X11"
139375b29833Smrg	fi
139475b29833Smrg	AC_SUBST(FONTROOTDIR)
139575b29833Smrg	AC_MSG_RESULT([${FONTROOTDIR}])
139675b29833Smrg])
139775b29833Smrg
139875b29833Smrg# XORG_FONTSUBDIR(variable, flag, subdir)
139975b29833Smrg# ---------------------------------------
140075b29833Smrg# Minimum version: 1.1.0
140175b29833Smrg#
140275b29833Smrg# Offer a --with-<flag> flag to control directory for font installation
140375b29833Smrg# Default is the specified <subdir> of the font root directory.
140475b29833Smrg# Sets <variable> to the selected directory
140575b29833Smrg
140675b29833SmrgAC_DEFUN([XORG_FONTSUBDIR],[
140775b29833Smrg	AC_REQUIRE([XORG_FONTROOTDIR])
140875b29833Smrg
140975b29833Smrg	AC_MSG_CHECKING([for directory for $3 files])
141075b29833Smrg	AC_ARG_WITH($2,
141175b29833Smrg		    [AS_HELP_STRING([--with-$2=DIR],
141275b29833Smrg				    [Path to $3 files [FONTROOTDIR/$3]])],
141375b29833Smrg		    [$1="${withval}"], [$1='${FONTROOTDIR}/$3'])
141475b29833Smrg	AC_SUBST($1)
141575b29833Smrg	AC_MSG_RESULT([${$1}])
141675b29833Smrg]) # XORG_FONTSUBDIR
141775b29833Smrg
141875b29833Smrg# XORG_FONTDIR(subdir)
141975b29833Smrg# --------------------
142075b29833Smrg# Minimum version: 1.1.0
142175b29833Smrg#
142275b29833Smrg# Offer a --with-fontdir flag to control directory for font installation
142375b29833Smrg# Default is the specified subdir of the font root directory.
142475b29833Smrg# Sets FONTDIR to the selected directory
142575b29833Smrg
142675b29833SmrgAC_DEFUN([XORG_FONTDIR],[XORG_FONTSUBDIR([FONTDIR], [fontdir], [$1])])
142775b29833Smrg
142875b29833Smrgdnl xorg-macros.m4.  Generated from xorg-macros.m4.in xorgversion.m4 by configure.
142975b29833Smrgdnl
143075b29833Smrgdnl Copyright (c) 2005, 2023, Oracle and/or its affiliates.
143175b29833Smrgdnl
143275b29833Smrgdnl Permission is hereby granted, free of charge, to any person obtaining a
143375b29833Smrgdnl copy of this software and associated documentation files (the "Software"),
143475b29833Smrgdnl to deal in the Software without restriction, including without limitation
143575b29833Smrgdnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
143675b29833Smrgdnl and/or sell copies of the Software, and to permit persons to whom the
143775b29833Smrgdnl Software is furnished to do so, subject to the following conditions:
143875b29833Smrgdnl
143975b29833Smrgdnl The above copyright notice and this permission notice (including the next
144075b29833Smrgdnl paragraph) shall be included in all copies or substantial portions of the
144175b29833Smrgdnl Software.
144275b29833Smrgdnl
144375b29833Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
144475b29833Smrgdnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
144575b29833Smrgdnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
144675b29833Smrgdnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
144775b29833Smrgdnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
144875b29833Smrgdnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
144975b29833Smrgdnl DEALINGS IN THE SOFTWARE.
145075b29833Smrg
145175b29833Smrg# XORG_MACROS_VERSION(required-version)
145275b29833Smrg# -------------------------------------
145375b29833Smrg# Minimum version: 1.1.0
145475b29833Smrg#
145575b29833Smrg# If you're using a macro added in Version 1.1 or newer, include this in
145675b29833Smrg# your configure.ac with the minimum required version, such as:
145775b29833Smrg# XORG_MACROS_VERSION(1.1)
145875b29833Smrg#
145975b29833Smrg# To ensure that this macro is defined, also add:
146075b29833Smrg# m4_ifndef([XORG_MACROS_VERSION],
146175b29833Smrg#     [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
146275b29833Smrg#
146375b29833Smrg#
146475b29833Smrg# See the "minimum version" comment for each macro you use to see what
146575b29833Smrg# version you require.
146675b29833Smrgm4_defun([XORG_MACROS_VERSION],[
146775b29833Smrgm4_define([vers_have], [1.20.0])
146875b29833Smrgm4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
146975b29833Smrgm4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
147075b29833Smrgm4_if(m4_cmp(maj_have, maj_needed), 0,,
147175b29833Smrg    [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
147275b29833Smrgm4_if(m4_version_compare(vers_have, [$1]), -1,
147375b29833Smrg    [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
147475b29833Smrgm4_undefine([vers_have])
147575b29833Smrgm4_undefine([maj_have])
147675b29833Smrgm4_undefine([maj_needed])
147775b29833Smrg]) # XORG_MACROS_VERSION
147875b29833Smrg
147975b29833Smrg# XORG_PROG_RAWCPP()
148075b29833Smrg# ------------------
148175b29833Smrg# Minimum version: 1.0.0
148275b29833Smrg#
148375b29833Smrg# Find cpp program and necessary flags for use in pre-processing text files
148475b29833Smrg# such as man pages and config files
148575b29833SmrgAC_DEFUN([XORG_PROG_RAWCPP],[
148675b29833SmrgAC_REQUIRE([AC_PROG_CPP])
148775b29833SmrgAC_PATH_TOOL(RAWCPP, [cpp], [${CPP}],
148875b29833Smrg   [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
148975b29833Smrg
149075b29833Smrg# Check for flag to avoid builtin definitions - assumes unix is predefined,
149175b29833Smrg# which is not the best choice for supporting other OS'es, but covers most
149275b29833Smrg# of the ones we need for now.
149375b29833SmrgAC_MSG_CHECKING([if $RAWCPP requires -undef])
149475b29833SmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
149575b29833Smrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
149675b29833Smrg	AC_MSG_RESULT([no])
149775b29833Smrgelse
149875b29833Smrg	if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
149975b29833Smrg		RAWCPPFLAGS=-undef
150075b29833Smrg		AC_MSG_RESULT([yes])
150175b29833Smrg	# under Cygwin unix is still defined even with -undef
150275b29833Smrg	elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
150375b29833Smrg		RAWCPPFLAGS="-undef -ansi"
150475b29833Smrg		AC_MSG_RESULT([yes, with -ansi])
150575b29833Smrg	else
150675b29833Smrg		AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef.  I don't know what to do.])
150775b29833Smrg	fi
150875b29833Smrgfi
150975b29833Smrgrm -f conftest.$ac_ext
151075b29833Smrg
151175b29833SmrgAC_MSG_CHECKING([if $RAWCPP requires -traditional])
151275b29833SmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
151375b29833Smrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
151475b29833Smrg	AC_MSG_RESULT([no])
151575b29833Smrgelse
151675b29833Smrg	if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
151775b29833Smrg		TRADITIONALCPPFLAGS="-traditional"
151875b29833Smrg		RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
151975b29833Smrg		AC_MSG_RESULT([yes])
152075b29833Smrg	else
152175b29833Smrg		AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
152275b29833Smrg	fi
152375b29833Smrgfi
152475b29833Smrgrm -f conftest.$ac_ext
152575b29833SmrgAC_SUBST(RAWCPPFLAGS)
152675b29833SmrgAC_SUBST(TRADITIONALCPPFLAGS)
152775b29833Smrg]) # XORG_PROG_RAWCPP
152875b29833Smrg
152975b29833Smrg# XORG_MANPAGE_SECTIONS()
153075b29833Smrg# -----------------------
153175b29833Smrg# Minimum version: 1.0.0
153275b29833Smrg#
153375b29833Smrg# Determine which sections man pages go in for the different man page types
153475b29833Smrg# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
153575b29833Smrg# Not sure if there's any better way than just hardcoding by OS name.
153675b29833Smrg# Override default settings by setting environment variables
153775b29833Smrg# Added MAN_SUBSTS in version 1.8
153875b29833Smrg# Added AC_PROG_SED in version 1.8
153975b29833Smrg
154075b29833SmrgAC_DEFUN([XORG_MANPAGE_SECTIONS],[
154175b29833SmrgAC_REQUIRE([AC_CANONICAL_HOST])
154275b29833SmrgAC_REQUIRE([AC_PROG_SED])
154375b29833Smrg
154475b29833Smrgcase $host_os in
154575b29833Smrg    solaris*)
154675b29833Smrg        # Solaris 2.0 - 11.3 use SysV man page section numbers, so we
154775b29833Smrg        # check for a man page file found in later versions that use
154875b29833Smrg        # traditional section numbers instead
154975b29833Smrg        AC_CHECK_FILE([/usr/share/man/man7/attributes.7],
155075b29833Smrg                [SYSV_MAN_SECTIONS=false], [SYSV_MAN_SECTIONS=true])
155175b29833Smrg        ;;
155275b29833Smrg    *) SYSV_MAN_SECTIONS=false ;;
155375b29833Smrgesac
155475b29833Smrg
155575b29833Smrgif test x$APP_MAN_SUFFIX = x    ; then
155675b29833Smrg    APP_MAN_SUFFIX=1
155775b29833Smrgfi
155875b29833Smrgif test x$APP_MAN_DIR = x    ; then
155975b29833Smrg    APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
156075b29833Smrgfi
156175b29833Smrg
156275b29833Smrgif test x$LIB_MAN_SUFFIX = x    ; then
156375b29833Smrg    LIB_MAN_SUFFIX=3
156475b29833Smrgfi
156575b29833Smrgif test x$LIB_MAN_DIR = x    ; then
156675b29833Smrg    LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
156775b29833Smrgfi
156875b29833Smrg
156975b29833Smrgif test x$FILE_MAN_SUFFIX = x    ; then
157075b29833Smrg    case $SYSV_MAN_SECTIONS in
157175b29833Smrg	true)				FILE_MAN_SUFFIX=4  ;;
157275b29833Smrg	*)				FILE_MAN_SUFFIX=5  ;;
157375b29833Smrg    esac
157475b29833Smrgfi
157575b29833Smrgif test x$FILE_MAN_DIR = x    ; then
157675b29833Smrg    FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
157775b29833Smrgfi
157875b29833Smrg
157975b29833Smrgif test x$MISC_MAN_SUFFIX = x    ; then
158075b29833Smrg    case $SYSV_MAN_SECTIONS in
158175b29833Smrg	true)				MISC_MAN_SUFFIX=5  ;;
158275b29833Smrg	*)				MISC_MAN_SUFFIX=7  ;;
158375b29833Smrg    esac
158475b29833Smrgfi
158575b29833Smrgif test x$MISC_MAN_DIR = x    ; then
158675b29833Smrg    MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
158775b29833Smrgfi
158875b29833Smrg
158975b29833Smrgif test x$DRIVER_MAN_SUFFIX = x    ; then
159075b29833Smrg    case $SYSV_MAN_SECTIONS in
159175b29833Smrg	true)				DRIVER_MAN_SUFFIX=7  ;;
159275b29833Smrg	*)				DRIVER_MAN_SUFFIX=4  ;;
159375b29833Smrg    esac
159475b29833Smrgfi
159575b29833Smrgif test x$DRIVER_MAN_DIR = x    ; then
159675b29833Smrg    DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
159775b29833Smrgfi
159875b29833Smrg
159975b29833Smrgif test x$ADMIN_MAN_SUFFIX = x    ; then
160075b29833Smrg    case $SYSV_MAN_SECTIONS in
160175b29833Smrg	true)				ADMIN_MAN_SUFFIX=1m ;;
160275b29833Smrg	*)				ADMIN_MAN_SUFFIX=8  ;;
160375b29833Smrg    esac
160475b29833Smrgfi
160575b29833Smrgif test x$ADMIN_MAN_DIR = x    ; then
160675b29833Smrg    ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
160775b29833Smrgfi
160875b29833Smrg
160975b29833Smrg
161075b29833SmrgAC_SUBST([APP_MAN_SUFFIX])
161175b29833SmrgAC_SUBST([LIB_MAN_SUFFIX])
161275b29833SmrgAC_SUBST([FILE_MAN_SUFFIX])
161375b29833SmrgAC_SUBST([MISC_MAN_SUFFIX])
161475b29833SmrgAC_SUBST([DRIVER_MAN_SUFFIX])
161575b29833SmrgAC_SUBST([ADMIN_MAN_SUFFIX])
161675b29833SmrgAC_SUBST([APP_MAN_DIR])
161775b29833SmrgAC_SUBST([LIB_MAN_DIR])
161875b29833SmrgAC_SUBST([FILE_MAN_DIR])
161975b29833SmrgAC_SUBST([MISC_MAN_DIR])
162075b29833SmrgAC_SUBST([DRIVER_MAN_DIR])
162175b29833SmrgAC_SUBST([ADMIN_MAN_DIR])
162275b29833Smrg
162375b29833SmrgXORG_MAN_PAGE="X Version 11"
162475b29833SmrgAC_SUBST([XORG_MAN_PAGE])
162575b29833SmrgMAN_SUBSTS="\
162675b29833Smrg	-e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
162775b29833Smrg	-e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
162875b29833Smrg	-e 's|__xservername__|Xorg|g' \
162975b29833Smrg	-e 's|__xconfigfile__|xorg.conf|g' \
163075b29833Smrg	-e 's|__projectroot__|\$(prefix)|g' \
163175b29833Smrg	-e 's|__apploaddir__|\$(appdefaultdir)|g' \
163275b29833Smrg	-e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
163375b29833Smrg	-e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
163475b29833Smrg	-e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
163575b29833Smrg	-e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
163675b29833Smrg	-e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
163775b29833Smrg	-e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
163875b29833SmrgAC_SUBST([MAN_SUBSTS])
163975b29833Smrg
164075b29833Smrg]) # XORG_MANPAGE_SECTIONS
164175b29833Smrg
164275b29833Smrg# XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
164375b29833Smrg# ------------------------
164475b29833Smrg# Minimum version: 1.7.0
164575b29833Smrg#
164675b29833Smrg# Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
164775b29833Smrg# provided by xorg-sgml-doctools, if installed.
164875b29833SmrgAC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
164975b29833SmrgAC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
165075b29833SmrgXORG_SGML_PATH=
165175b29833SmrgPKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
165275b29833Smrg    [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
165375b29833Smrg    [m4_ifval([$1],[:],
165475b29833Smrg        [if test x"$cross_compiling" != x"yes" ; then
165575b29833Smrg            AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
165675b29833Smrg                          [XORG_SGML_PATH=$prefix/share/sgml])
165775b29833Smrg         fi])
165875b29833Smrg    ])
165975b29833Smrg
166075b29833Smrg# Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
166175b29833Smrg# the path and the name of the doc stylesheet
166275b29833Smrgif test "x$XORG_SGML_PATH" != "x" ; then
166375b29833Smrg   AC_MSG_RESULT([$XORG_SGML_PATH])
166475b29833Smrg   STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
166575b29833Smrg   XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
166675b29833Smrgelse
166775b29833Smrg   AC_MSG_RESULT([no])
166875b29833Smrgfi
166975b29833Smrg
167075b29833SmrgAC_SUBST(XORG_SGML_PATH)
167175b29833SmrgAC_SUBST(STYLESHEET_SRCDIR)
167275b29833SmrgAC_SUBST(XSL_STYLESHEET)
167375b29833SmrgAM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
167475b29833Smrg]) # XORG_CHECK_SGML_DOCTOOLS
167575b29833Smrg
167675b29833Smrg# XORG_CHECK_LINUXDOC
167775b29833Smrg# -------------------
167875b29833Smrg# Minimum version: 1.0.0
167975b29833Smrg#
168075b29833Smrg# Defines the variable MAKE_TEXT if the necessary tools and
168175b29833Smrg# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
168275b29833Smrg# Whether or not the necessary tools and files are found can be checked
168375b29833Smrg# with the AM_CONDITIONAL "BUILD_LINUXDOC"
168475b29833SmrgAC_DEFUN([XORG_CHECK_LINUXDOC],[
168575b29833SmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
168675b29833SmrgAC_REQUIRE([XORG_WITH_PS2PDF])
168775b29833Smrg
168875b29833SmrgAC_PATH_PROG(LINUXDOC, linuxdoc)
168975b29833Smrg
169075b29833SmrgAC_MSG_CHECKING([whether to build documentation])
169175b29833Smrg
169275b29833Smrgif test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
169375b29833Smrg   BUILDDOC=yes
169475b29833Smrgelse
169575b29833Smrg   BUILDDOC=no
169675b29833Smrgfi
169775b29833Smrg
169875b29833SmrgAM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
169975b29833Smrg
170075b29833SmrgAC_MSG_RESULT([$BUILDDOC])
170175b29833Smrg
170275b29833SmrgAC_MSG_CHECKING([whether to build pdf documentation])
170375b29833Smrg
170475b29833Smrgif test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
170575b29833Smrg   BUILDPDFDOC=yes
170675b29833Smrgelse
170775b29833Smrg   BUILDPDFDOC=no
170875b29833Smrgfi
170975b29833Smrg
171075b29833SmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
171175b29833Smrg
171275b29833SmrgAC_MSG_RESULT([$BUILDPDFDOC])
171375b29833Smrg
171475b29833SmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
171575b29833SmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
171675b29833SmrgMAKE_PDF="$PS2PDF"
171775b29833SmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
171875b29833Smrg
171975b29833SmrgAC_SUBST(MAKE_TEXT)
172075b29833SmrgAC_SUBST(MAKE_PS)
172175b29833SmrgAC_SUBST(MAKE_PDF)
172275b29833SmrgAC_SUBST(MAKE_HTML)
172375b29833Smrg]) # XORG_CHECK_LINUXDOC
172475b29833Smrg
172575b29833Smrg# XORG_CHECK_DOCBOOK
172675b29833Smrg# -------------------
172775b29833Smrg# Minimum version: 1.0.0
172875b29833Smrg#
172975b29833Smrg# Checks for the ability to build output formats from SGML DocBook source.
173075b29833Smrg# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
173175b29833Smrg# indicates whether the necessary tools and files are found and, if set,
173275b29833Smrg# $(MAKE_XXX) blah.sgml will produce blah.xxx.
173375b29833SmrgAC_DEFUN([XORG_CHECK_DOCBOOK],[
173475b29833SmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
173575b29833Smrg
173675b29833SmrgBUILDTXTDOC=no
173775b29833SmrgBUILDPDFDOC=no
173875b29833SmrgBUILDPSDOC=no
173975b29833SmrgBUILDHTMLDOC=no
174075b29833Smrg
174175b29833SmrgAC_PATH_PROG(DOCBOOKPS, docbook2ps)
174275b29833SmrgAC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
174375b29833SmrgAC_PATH_PROG(DOCBOOKHTML, docbook2html)
174475b29833SmrgAC_PATH_PROG(DOCBOOKTXT, docbook2txt)
174575b29833Smrg
174675b29833SmrgAC_MSG_CHECKING([whether to build text documentation])
174775b29833Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
174875b29833Smrg   test x$BUILD_TXTDOC != xno; then
174975b29833Smrg	BUILDTXTDOC=yes
175075b29833Smrgfi
175175b29833SmrgAM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
175275b29833SmrgAC_MSG_RESULT([$BUILDTXTDOC])
175375b29833Smrg
175475b29833SmrgAC_MSG_CHECKING([whether to build PDF documentation])
175575b29833Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
175675b29833Smrg   test x$BUILD_PDFDOC != xno; then
175775b29833Smrg	BUILDPDFDOC=yes
175875b29833Smrgfi
175975b29833SmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
176075b29833SmrgAC_MSG_RESULT([$BUILDPDFDOC])
176175b29833Smrg
176275b29833SmrgAC_MSG_CHECKING([whether to build PostScript documentation])
176375b29833Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
176475b29833Smrg   test x$BUILD_PSDOC != xno; then
176575b29833Smrg	BUILDPSDOC=yes
176675b29833Smrgfi
176775b29833SmrgAM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
176875b29833SmrgAC_MSG_RESULT([$BUILDPSDOC])
176975b29833Smrg
177075b29833SmrgAC_MSG_CHECKING([whether to build HTML documentation])
177175b29833Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
177275b29833Smrg   test x$BUILD_HTMLDOC != xno; then
177375b29833Smrg	BUILDHTMLDOC=yes
177475b29833Smrgfi
177575b29833SmrgAM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
177675b29833SmrgAC_MSG_RESULT([$BUILDHTMLDOC])
177775b29833Smrg
177875b29833SmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
177975b29833SmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
178075b29833SmrgMAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
178175b29833SmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
178275b29833Smrg
178375b29833SmrgAC_SUBST(MAKE_TEXT)
178475b29833SmrgAC_SUBST(MAKE_PS)
178575b29833SmrgAC_SUBST(MAKE_PDF)
178675b29833SmrgAC_SUBST(MAKE_HTML)
178775b29833Smrg]) # XORG_CHECK_DOCBOOK
178875b29833Smrg
178975b29833Smrg# XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
179075b29833Smrg# ----------------
179175b29833Smrg# Minimum version: 1.5.0
179275b29833Smrg# Minimum version for optional DEFAULT argument: 1.11.0
179375b29833Smrg#
179475b29833Smrg# Documentation tools are not always available on all platforms and sometimes
179575b29833Smrg# not at the appropriate level. This macro enables a module to test for the
179675b29833Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
179775b29833Smrg# the --with-xmlto option, it allows maximum flexibility in making decisions
179875b29833Smrg# as whether or not to use the xmlto package. When DEFAULT is not specified,
179975b29833Smrg# --with-xmlto assumes 'auto'.
180075b29833Smrg#
180175b29833Smrg# Interface to module:
180275b29833Smrg# HAVE_XMLTO: 	used in makefiles to conditionally generate documentation
180375b29833Smrg# XMLTO:	returns the path of the xmlto program found
180475b29833Smrg#		returns the path set by the user in the environment
180575b29833Smrg# --with-xmlto:	'yes' user instructs the module to use xmlto
180675b29833Smrg#		'no' user instructs the module not to use xmlto
180775b29833Smrg#
180875b29833Smrg# Added in version 1.10.0
180975b29833Smrg# HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
181075b29833Smrg#                  xmlto for text output requires either lynx, links, or w3m browsers
181175b29833Smrg#
181275b29833Smrg# If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
181375b29833Smrg#
181475b29833SmrgAC_DEFUN([XORG_WITH_XMLTO],[
181575b29833SmrgAC_ARG_VAR([XMLTO], [Path to xmlto command])
181675b29833Smrgm4_define([_defopt], m4_default([$2], [auto]))
181775b29833SmrgAC_ARG_WITH(xmlto,
181875b29833Smrg	AS_HELP_STRING([--with-xmlto],
181975b29833Smrg	   [Use xmlto to regenerate documentation (default: ]_defopt[)]),
182075b29833Smrg	   [use_xmlto=$withval], [use_xmlto=]_defopt)
182175b29833Smrgm4_undefine([_defopt])
182275b29833Smrg
182375b29833Smrgif test "x$use_xmlto" = x"auto"; then
182475b29833Smrg   AC_PATH_PROG([XMLTO], [xmlto])
182575b29833Smrg   if test "x$XMLTO" = "x"; then
182675b29833Smrg        AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
182775b29833Smrg	have_xmlto=no
182875b29833Smrg   else
182975b29833Smrg        have_xmlto=yes
183075b29833Smrg   fi
183175b29833Smrgelif test "x$use_xmlto" = x"yes" ; then
183275b29833Smrg   AC_PATH_PROG([XMLTO], [xmlto])
183375b29833Smrg   if test "x$XMLTO" = "x"; then
183475b29833Smrg        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
183575b29833Smrg   fi
183675b29833Smrg   have_xmlto=yes
183775b29833Smrgelif test "x$use_xmlto" = x"no" ; then
183875b29833Smrg   if test "x$XMLTO" != "x"; then
183975b29833Smrg      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
184075b29833Smrg   fi
184175b29833Smrg   have_xmlto=no
184275b29833Smrgelse
184375b29833Smrg   AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
184475b29833Smrgfi
184575b29833Smrg
184675b29833Smrg# Test for a minimum version of xmlto, if provided.
184775b29833Smrgm4_ifval([$1],
184875b29833Smrg[if test "$have_xmlto" = yes; then
184975b29833Smrg    # scrape the xmlto version
185075b29833Smrg    AC_MSG_CHECKING([the xmlto version])
185175b29833Smrg    xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
185275b29833Smrg    AC_MSG_RESULT([$xmlto_version])
185375b29833Smrg    AS_VERSION_COMPARE([$xmlto_version], [$1],
185475b29833Smrg        [if test "x$use_xmlto" = xauto; then
185575b29833Smrg            AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
185675b29833Smrg            have_xmlto=no
185775b29833Smrg        else
185875b29833Smrg            AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
185975b29833Smrg        fi])
186075b29833Smrgfi])
186175b29833Smrg
186275b29833Smrg# Test for the ability of xmlto to generate a text target
186375b29833Smrg#
186475b29833Smrg# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
186575b29833Smrg# following test for empty XML docbook files.
186675b29833Smrg# For compatibility reasons use the following empty XML docbook file and if
186775b29833Smrg# it fails try it again with a non-empty XML file.
186875b29833Smrghave_xmlto_text=no
186975b29833Smrgcat > conftest.xml << "EOF"
187075b29833SmrgEOF
187175b29833SmrgAS_IF([test "$have_xmlto" = yes],
187275b29833Smrg      [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
187375b29833Smrg             [have_xmlto_text=yes],
187475b29833Smrg             [# Try it again with a non-empty XML file.
187575b29833Smrg              cat > conftest.xml << "EOF"
187675b29833Smrg<x></x>
187775b29833SmrgEOF
187875b29833Smrg              AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
187975b29833Smrg                    [have_xmlto_text=yes],
188075b29833Smrg                    [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])])
188175b29833Smrgrm -f conftest.xml
188275b29833SmrgAM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
188375b29833SmrgAM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
188475b29833Smrg]) # XORG_WITH_XMLTO
188575b29833Smrg
188675b29833Smrg# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
188775b29833Smrg# --------------------------------------------
188875b29833Smrg# Minimum version: 1.12.0
188975b29833Smrg# Minimum version for optional DEFAULT argument: 1.12.0
189075b29833Smrg#
189175b29833Smrg# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
189275b29833Smrg# XML-based language used for the transformation of XML documents.
189375b29833Smrg# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
189475b29833Smrg# It is used under the cover by xmlto to generate html files from DocBook/XML.
189575b29833Smrg# The XSLT processor is often used as a standalone tool for transformations.
189675b29833Smrg# It should not be assumed that this tool is used only to work with documnetation.
189775b29833Smrg# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
189875b29833Smrg#
189975b29833Smrg# Interface to module:
190075b29833Smrg# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
190175b29833Smrg# XSLTPROC:	 returns the path of the xsltproc program found
190275b29833Smrg#		 returns the path set by the user in the environment
190375b29833Smrg# --with-xsltproc: 'yes' user instructs the module to use xsltproc
190475b29833Smrg#		  'no' user instructs the module not to use xsltproc
190575b29833Smrg# have_xsltproc: returns yes if xsltproc found in PATH or no
190675b29833Smrg#
190775b29833Smrg# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
190875b29833Smrg#
190975b29833SmrgAC_DEFUN([XORG_WITH_XSLTPROC],[
191075b29833SmrgAC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
191175b29833Smrg# Preserves the interface, should it be implemented later
191275b29833Smrgm4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
191375b29833Smrgm4_define([_defopt], m4_default([$2], [auto]))
191475b29833SmrgAC_ARG_WITH(xsltproc,
191575b29833Smrg	AS_HELP_STRING([--with-xsltproc],
191675b29833Smrg	   [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
191775b29833Smrg	   [use_xsltproc=$withval], [use_xsltproc=]_defopt)
191875b29833Smrgm4_undefine([_defopt])
191975b29833Smrg
192075b29833Smrgif test "x$use_xsltproc" = x"auto"; then
192175b29833Smrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
192275b29833Smrg   if test "x$XSLTPROC" = "x"; then
192375b29833Smrg        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
192475b29833Smrg	have_xsltproc=no
192575b29833Smrg   else
192675b29833Smrg        have_xsltproc=yes
192775b29833Smrg   fi
192875b29833Smrgelif test "x$use_xsltproc" = x"yes" ; then
192975b29833Smrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
193075b29833Smrg   if test "x$XSLTPROC" = "x"; then
193175b29833Smrg        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
193275b29833Smrg   fi
193375b29833Smrg   have_xsltproc=yes
193475b29833Smrgelif test "x$use_xsltproc" = x"no" ; then
193575b29833Smrg   if test "x$XSLTPROC" != "x"; then
193675b29833Smrg      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
193775b29833Smrg   fi
193875b29833Smrg   have_xsltproc=no
193975b29833Smrgelse
194075b29833Smrg   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
194175b29833Smrgfi
194275b29833Smrg
194375b29833SmrgAM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
194475b29833Smrg]) # XORG_WITH_XSLTPROC
194575b29833Smrg
194675b29833Smrg# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
194775b29833Smrg# ----------------------------------------
194875b29833Smrg# Minimum version: 1.15.0
194975b29833Smrg#
195075b29833Smrg# PERL (Practical Extraction and Report Language) is a language optimized for
195175b29833Smrg# scanning arbitrary text files, extracting information from those text files,
195275b29833Smrg# and printing reports based on that information.
195375b29833Smrg#
195475b29833Smrg# When DEFAULT is not specified, --with-perl assumes 'auto'.
195575b29833Smrg#
195675b29833Smrg# Interface to module:
195775b29833Smrg# HAVE_PERL: used in makefiles to conditionally scan text files
195875b29833Smrg# PERL:	     returns the path of the perl program found
195975b29833Smrg#	     returns the path set by the user in the environment
196075b29833Smrg# --with-perl: 'yes' user instructs the module to use perl
196175b29833Smrg#	       'no' user instructs the module not to use perl
196275b29833Smrg# have_perl: returns yes if perl found in PATH or no
196375b29833Smrg#
196475b29833Smrg# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
196575b29833Smrg#
196675b29833SmrgAC_DEFUN([XORG_WITH_PERL],[
196775b29833SmrgAC_ARG_VAR([PERL], [Path to perl command])
196875b29833Smrg# Preserves the interface, should it be implemented later
196975b29833Smrgm4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
197075b29833Smrgm4_define([_defopt], m4_default([$2], [auto]))
197175b29833SmrgAC_ARG_WITH(perl,
197275b29833Smrg	AS_HELP_STRING([--with-perl],
197375b29833Smrg	   [Use perl for extracting information from files (default: ]_defopt[)]),
197475b29833Smrg	   [use_perl=$withval], [use_perl=]_defopt)
197575b29833Smrgm4_undefine([_defopt])
197675b29833Smrg
197775b29833Smrgif test "x$use_perl" = x"auto"; then
197875b29833Smrg   AC_PATH_PROG([PERL], [perl])
197975b29833Smrg   if test "x$PERL" = "x"; then
198075b29833Smrg        AC_MSG_WARN([perl not found - cannot extract information and report])
198175b29833Smrg	have_perl=no
198275b29833Smrg   else
198375b29833Smrg        have_perl=yes
198475b29833Smrg   fi
198575b29833Smrgelif test "x$use_perl" = x"yes" ; then
198675b29833Smrg   AC_PATH_PROG([PERL], [perl])
198775b29833Smrg   if test "x$PERL" = "x"; then
198875b29833Smrg        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
198975b29833Smrg   fi
199075b29833Smrg   have_perl=yes
199175b29833Smrgelif test "x$use_perl" = x"no" ; then
199275b29833Smrg   if test "x$PERL" != "x"; then
199375b29833Smrg      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
199475b29833Smrg   fi
199575b29833Smrg   have_perl=no
199675b29833Smrgelse
199775b29833Smrg   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
199875b29833Smrgfi
199975b29833Smrg
200075b29833SmrgAM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
200175b29833Smrg]) # XORG_WITH_PERL
200275b29833Smrg
200375b29833Smrg# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
200475b29833Smrg# ----------------
200575b29833Smrg# Minimum version: 1.5.0
200675b29833Smrg# Minimum version for optional DEFAULT argument: 1.11.0
200775b29833Smrg#
200875b29833Smrg# Documentation tools are not always available on all platforms and sometimes
200975b29833Smrg# not at the appropriate level. This macro enables a module to test for the
201075b29833Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
201175b29833Smrg# the --with-asciidoc option, it allows maximum flexibility in making decisions
201275b29833Smrg# as whether or not to use the asciidoc package. When DEFAULT is not specified,
201375b29833Smrg# --with-asciidoc assumes 'auto'.
201475b29833Smrg#
201575b29833Smrg# Interface to module:
201675b29833Smrg# HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
201775b29833Smrg# ASCIIDOC:	 returns the path of the asciidoc program found
201875b29833Smrg#		 returns the path set by the user in the environment
201975b29833Smrg# --with-asciidoc: 'yes' user instructs the module to use asciidoc
202075b29833Smrg#		  'no' user instructs the module not to use asciidoc
202175b29833Smrg#
202275b29833Smrg# If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
202375b29833Smrg#
202475b29833SmrgAC_DEFUN([XORG_WITH_ASCIIDOC],[
202575b29833SmrgAC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
202675b29833Smrgm4_define([_defopt], m4_default([$2], [auto]))
202775b29833SmrgAC_ARG_WITH(asciidoc,
202875b29833Smrg	AS_HELP_STRING([--with-asciidoc],
202975b29833Smrg	   [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
203075b29833Smrg	   [use_asciidoc=$withval], [use_asciidoc=]_defopt)
203175b29833Smrgm4_undefine([_defopt])
203275b29833Smrg
203375b29833Smrgif test "x$use_asciidoc" = x"auto"; then
203475b29833Smrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
203575b29833Smrg   if test "x$ASCIIDOC" = "x"; then
203675b29833Smrg        AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
203775b29833Smrg	have_asciidoc=no
203875b29833Smrg   else
203975b29833Smrg        have_asciidoc=yes
204075b29833Smrg   fi
204175b29833Smrgelif test "x$use_asciidoc" = x"yes" ; then
204275b29833Smrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
204375b29833Smrg   if test "x$ASCIIDOC" = "x"; then
204475b29833Smrg        AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
204575b29833Smrg   fi
204675b29833Smrg   have_asciidoc=yes
204775b29833Smrgelif test "x$use_asciidoc" = x"no" ; then
204875b29833Smrg   if test "x$ASCIIDOC" != "x"; then
204975b29833Smrg      AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
205075b29833Smrg   fi
205175b29833Smrg   have_asciidoc=no
205275b29833Smrgelse
205375b29833Smrg   AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
205475b29833Smrgfi
205575b29833Smrgm4_ifval([$1],
205675b29833Smrg[if test "$have_asciidoc" = yes; then
205775b29833Smrg    # scrape the asciidoc version
205875b29833Smrg    AC_MSG_CHECKING([the asciidoc version])
205975b29833Smrg    asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
206075b29833Smrg    AC_MSG_RESULT([$asciidoc_version])
206175b29833Smrg    AS_VERSION_COMPARE([$asciidoc_version], [$1],
206275b29833Smrg        [if test "x$use_asciidoc" = xauto; then
206375b29833Smrg            AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
206475b29833Smrg            have_asciidoc=no
206575b29833Smrg        else
206675b29833Smrg            AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
206775b29833Smrg        fi])
206875b29833Smrgfi])
206975b29833SmrgAM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
207075b29833Smrg]) # XORG_WITH_ASCIIDOC
207175b29833Smrg
207275b29833Smrg# XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
207375b29833Smrg# -------------------------------------------
207475b29833Smrg# Minimum version: 1.5.0
207575b29833Smrg# Minimum version for optional DEFAULT argument: 1.11.0
207675b29833Smrg# Minimum version for optional DOT checking: 1.18.0
207775b29833Smrg#
207875b29833Smrg# Documentation tools are not always available on all platforms and sometimes
207975b29833Smrg# not at the appropriate level. This macro enables a module to test for the
208075b29833Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
208175b29833Smrg# the --with-doxygen option, it allows maximum flexibility in making decisions
208275b29833Smrg# as whether or not to use the doxygen package. When DEFAULT is not specified,
208375b29833Smrg# --with-doxygen assumes 'auto'.
208475b29833Smrg#
208575b29833Smrg# Interface to module:
208675b29833Smrg# HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
208775b29833Smrg# DOXYGEN:	 returns the path of the doxygen program found
208875b29833Smrg#		 returns the path set by the user in the environment
208975b29833Smrg# --with-doxygen: 'yes' user instructs the module to use doxygen
209075b29833Smrg#		  'no' user instructs the module not to use doxygen
209175b29833Smrg#
209275b29833Smrg# If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
209375b29833Smrg#
209475b29833SmrgAC_DEFUN([XORG_WITH_DOXYGEN],[
209575b29833SmrgAC_ARG_VAR([DOXYGEN], [Path to doxygen command])
209675b29833SmrgAC_ARG_VAR([DOT], [Path to the dot graphics utility])
209775b29833Smrgm4_define([_defopt], m4_default([$2], [auto]))
209875b29833SmrgAC_ARG_WITH(doxygen,
209975b29833Smrg	AS_HELP_STRING([--with-doxygen],
210075b29833Smrg	   [Use doxygen to regenerate documentation (default: ]_defopt[)]),
210175b29833Smrg	   [use_doxygen=$withval], [use_doxygen=]_defopt)
210275b29833Smrgm4_undefine([_defopt])
210375b29833Smrg
210475b29833Smrgif test "x$use_doxygen" = x"auto"; then
210575b29833Smrg   AC_PATH_PROG([DOXYGEN], [doxygen])
210675b29833Smrg   if test "x$DOXYGEN" = "x"; then
210775b29833Smrg        AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
210875b29833Smrg	have_doxygen=no
210975b29833Smrg   else
211075b29833Smrg        have_doxygen=yes
211175b29833Smrg   fi
211275b29833Smrgelif test "x$use_doxygen" = x"yes" ; then
211375b29833Smrg   AC_PATH_PROG([DOXYGEN], [doxygen])
211475b29833Smrg   if test "x$DOXYGEN" = "x"; then
211575b29833Smrg        AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
211675b29833Smrg   fi
211775b29833Smrg   have_doxygen=yes
211875b29833Smrgelif test "x$use_doxygen" = x"no" ; then
211975b29833Smrg   if test "x$DOXYGEN" != "x"; then
212075b29833Smrg      AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
212175b29833Smrg   fi
212275b29833Smrg   have_doxygen=no
212375b29833Smrgelse
212475b29833Smrg   AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
212575b29833Smrgfi
212675b29833Smrgm4_ifval([$1],
212775b29833Smrg[if test "$have_doxygen" = yes; then
212875b29833Smrg    # scrape the doxygen version
212975b29833Smrg    AC_MSG_CHECKING([the doxygen version])
213075b29833Smrg    doxygen_version=`$DOXYGEN --version 2>/dev/null`
213175b29833Smrg    AC_MSG_RESULT([$doxygen_version])
213275b29833Smrg    AS_VERSION_COMPARE([$doxygen_version], [$1],
213375b29833Smrg        [if test "x$use_doxygen" = xauto; then
213475b29833Smrg            AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
213575b29833Smrg            have_doxygen=no
213675b29833Smrg        else
213775b29833Smrg            AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
213875b29833Smrg        fi])
213975b29833Smrgfi])
214075b29833Smrg
214175b29833Smrgdnl Check for DOT if we have doxygen. The caller decides if it is mandatory
214275b29833Smrgdnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
214375b29833Smrgdnl 	HAVE_DOT = @HAVE_DOT@
214475b29833SmrgHAVE_DOT=no
214575b29833Smrgif test "x$have_doxygen" = "xyes"; then
214675b29833Smrg  AC_PATH_PROG([DOT], [dot])
214775b29833Smrg    if test "x$DOT" != "x"; then
214875b29833Smrg      HAVE_DOT=yes
214975b29833Smrg    fi
215075b29833Smrgfi
215175b29833Smrg
215275b29833SmrgAC_SUBST([HAVE_DOT])
215375b29833SmrgAM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
215475b29833SmrgAM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
215575b29833Smrg]) # XORG_WITH_DOXYGEN
215675b29833Smrg
215775b29833Smrg# XORG_WITH_GROFF([DEFAULT])
215875b29833Smrg# ----------------
215975b29833Smrg# Minimum version: 1.6.0
216075b29833Smrg# Minimum version for optional DEFAULT argument: 1.11.0
216175b29833Smrg#
216275b29833Smrg# Documentation tools are not always available on all platforms and sometimes
216375b29833Smrg# not at the appropriate level. This macro enables a module to test for the
216475b29833Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
216575b29833Smrg# the --with-groff option, it allows maximum flexibility in making decisions
216675b29833Smrg# as whether or not to use the groff package. When DEFAULT is not specified,
216775b29833Smrg# --with-groff assumes 'auto'.
216875b29833Smrg#
216975b29833Smrg# Interface to module:
217075b29833Smrg# HAVE_GROFF:	 used in makefiles to conditionally generate documentation
217175b29833Smrg# HAVE_GROFF_MM: the memorandum macros (-mm) package
217275b29833Smrg# HAVE_GROFF_MS: the -ms macros package
217375b29833Smrg# GROFF:	 returns the path of the groff program found
217475b29833Smrg#		 returns the path set by the user in the environment
217575b29833Smrg# --with-groff:	 'yes' user instructs the module to use groff
217675b29833Smrg#		 'no' user instructs the module not to use groff
217775b29833Smrg#
217875b29833Smrg# Added in version 1.9.0:
217975b29833Smrg# HAVE_GROFF_HTML: groff has dependencies to output HTML format:
218075b29833Smrg#		   pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
218175b29833Smrg#		   psselect from the psutils package.
218275b29833Smrg#		   the ghostcript package. Refer to the grohtml man pages
218375b29833Smrg#
218475b29833Smrg# If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
218575b29833Smrg#
218675b29833Smrg# OS and distros often splits groff in a basic and full package, the former
218775b29833Smrg# having the groff program and the later having devices, fonts and macros
218875b29833Smrg# Checking for the groff executable is not enough.
218975b29833Smrg#
219075b29833Smrg# If macros are missing, we cannot assume that groff is useless, so we don't
219175b29833Smrg# unset HAVE_GROFF or GROFF env variables.
219275b29833Smrg# HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
219375b29833Smrg#
219475b29833SmrgAC_DEFUN([XORG_WITH_GROFF],[
219575b29833SmrgAC_ARG_VAR([GROFF], [Path to groff command])
219675b29833Smrgm4_define([_defopt], m4_default([$1], [auto]))
219775b29833SmrgAC_ARG_WITH(groff,
219875b29833Smrg	AS_HELP_STRING([--with-groff],
219975b29833Smrg	   [Use groff to regenerate documentation (default: ]_defopt[)]),
220075b29833Smrg	   [use_groff=$withval], [use_groff=]_defopt)
220175b29833Smrgm4_undefine([_defopt])
220275b29833Smrg
220375b29833Smrgif test "x$use_groff" = x"auto"; then
220475b29833Smrg   AC_PATH_PROG([GROFF], [groff])
220575b29833Smrg   if test "x$GROFF" = "x"; then
220675b29833Smrg        AC_MSG_WARN([groff not found - documentation targets will be skipped])
220775b29833Smrg	have_groff=no
220875b29833Smrg   else
220975b29833Smrg        have_groff=yes
221075b29833Smrg   fi
221175b29833Smrgelif test "x$use_groff" = x"yes" ; then
221275b29833Smrg   AC_PATH_PROG([GROFF], [groff])
221375b29833Smrg   if test "x$GROFF" = "x"; then
221475b29833Smrg        AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
221575b29833Smrg   fi
221675b29833Smrg   have_groff=yes
221775b29833Smrgelif test "x$use_groff" = x"no" ; then
221875b29833Smrg   if test "x$GROFF" != "x"; then
221975b29833Smrg      AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
222075b29833Smrg   fi
222175b29833Smrg   have_groff=no
222275b29833Smrgelse
222375b29833Smrg   AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
222475b29833Smrgfi
222575b29833Smrg
222675b29833Smrg# We have groff, test for the presence of the macro packages
222775b29833Smrgif test "x$have_groff" = x"yes"; then
222875b29833Smrg    AC_MSG_CHECKING([for ${GROFF} -ms macros])
222975b29833Smrg    if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
223075b29833Smrg        groff_ms_works=yes
223175b29833Smrg    else
223275b29833Smrg        groff_ms_works=no
223375b29833Smrg    fi
223475b29833Smrg    AC_MSG_RESULT([$groff_ms_works])
223575b29833Smrg    AC_MSG_CHECKING([for ${GROFF} -mm macros])
223675b29833Smrg    if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
223775b29833Smrg        groff_mm_works=yes
223875b29833Smrg    else
223975b29833Smrg        groff_mm_works=no
224075b29833Smrg    fi
224175b29833Smrg    AC_MSG_RESULT([$groff_mm_works])
224275b29833Smrgfi
224375b29833Smrg
224475b29833Smrg# We have groff, test for HTML dependencies, one command per package
224575b29833Smrgif test "x$have_groff" = x"yes"; then
224675b29833Smrg   AC_PATH_PROGS(GS_PATH, [gs gswin32c])
224775b29833Smrg   AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
224875b29833Smrg   AC_PATH_PROG(PSSELECT_PATH, [psselect])
224975b29833Smrg   if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
225075b29833Smrg      have_groff_html=yes
225175b29833Smrg   else
225275b29833Smrg      have_groff_html=no
225375b29833Smrg      AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
225475b29833Smrg   fi
225575b29833Smrgfi
225675b29833Smrg
225775b29833Smrg# Set Automake conditionals for Makefiles
225875b29833SmrgAM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
225975b29833SmrgAM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
226075b29833SmrgAM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
226175b29833SmrgAM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
226275b29833Smrg]) # XORG_WITH_GROFF
226375b29833Smrg
226475b29833Smrg# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
226575b29833Smrg# ---------------------------------------
226675b29833Smrg# Minimum version: 1.6.0
226775b29833Smrg# Minimum version for optional DEFAULT argument: 1.11.0
226875b29833Smrg# Minimum version for optional MIN-VERSION argument: 1.15.0
226975b29833Smrg#
227075b29833Smrg# Documentation tools are not always available on all platforms and sometimes
227175b29833Smrg# not at the appropriate level. This macro enables a module to test for the
227275b29833Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
227375b29833Smrg# the --with-fop option, it allows maximum flexibility in making decisions
227475b29833Smrg# as whether or not to use the fop package. When DEFAULT is not specified,
227575b29833Smrg# --with-fop assumes 'auto'.
227675b29833Smrg#
227775b29833Smrg# Interface to module:
227875b29833Smrg# HAVE_FOP: 	used in makefiles to conditionally generate documentation
227975b29833Smrg# FOP:	 	returns the path of the fop program found
228075b29833Smrg#		returns the path set by the user in the environment
228175b29833Smrg# --with-fop: 	'yes' user instructs the module to use fop
228275b29833Smrg#		'no' user instructs the module not to use fop
228375b29833Smrg#
228475b29833Smrg# If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
228575b29833Smrg#
228675b29833SmrgAC_DEFUN([XORG_WITH_FOP],[
228775b29833SmrgAC_ARG_VAR([FOP], [Path to fop command])
228875b29833Smrgm4_define([_defopt], m4_default([$2], [auto]))
228975b29833SmrgAC_ARG_WITH(fop,
229075b29833Smrg	AS_HELP_STRING([--with-fop],
229175b29833Smrg	   [Use fop to regenerate documentation (default: ]_defopt[)]),
229275b29833Smrg	   [use_fop=$withval], [use_fop=]_defopt)
229375b29833Smrgm4_undefine([_defopt])
229475b29833Smrg
229575b29833Smrgif test "x$use_fop" = x"auto"; then
229675b29833Smrg   AC_PATH_PROG([FOP], [fop])
229775b29833Smrg   if test "x$FOP" = "x"; then
229875b29833Smrg        AC_MSG_WARN([fop not found - documentation targets will be skipped])
229975b29833Smrg	have_fop=no
230075b29833Smrg   else
230175b29833Smrg        have_fop=yes
230275b29833Smrg   fi
230375b29833Smrgelif test "x$use_fop" = x"yes" ; then
230475b29833Smrg   AC_PATH_PROG([FOP], [fop])
230575b29833Smrg   if test "x$FOP" = "x"; then
230675b29833Smrg        AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
230775b29833Smrg   fi
230875b29833Smrg   have_fop=yes
230975b29833Smrgelif test "x$use_fop" = x"no" ; then
231075b29833Smrg   if test "x$FOP" != "x"; then
231175b29833Smrg      AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
231275b29833Smrg   fi
231375b29833Smrg   have_fop=no
231475b29833Smrgelse
231575b29833Smrg   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
231675b29833Smrgfi
231775b29833Smrg
231875b29833Smrg# Test for a minimum version of fop, if provided.
231975b29833Smrgm4_ifval([$1],
232075b29833Smrg[if test "$have_fop" = yes; then
232175b29833Smrg    # scrape the fop version
232275b29833Smrg    AC_MSG_CHECKING([for fop minimum version])
232375b29833Smrg    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
232475b29833Smrg    AC_MSG_RESULT([$fop_version])
232575b29833Smrg    AS_VERSION_COMPARE([$fop_version], [$1],
232675b29833Smrg        [if test "x$use_fop" = xauto; then
232775b29833Smrg            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
232875b29833Smrg            have_fop=no
232975b29833Smrg        else
233075b29833Smrg            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
233175b29833Smrg        fi])
233275b29833Smrgfi])
233375b29833SmrgAM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
233475b29833Smrg]) # XORG_WITH_FOP
233575b29833Smrg
233675b29833Smrg# XORG_WITH_M4([MIN-VERSION])
233775b29833Smrg# ---------------------------
233875b29833Smrg# Minimum version: 1.19.0
233975b29833Smrg#
234075b29833Smrg# This macro attempts to locate an m4 macro processor which supports
234175b29833Smrg# -I option and is only useful for modules relying on M4 in order to
234275b29833Smrg# expand macros in source code files.
234375b29833Smrg#
234475b29833Smrg# Interface to module:
234575b29833Smrg# M4:	 	returns the path of the m4 program found
234675b29833Smrg#		returns the path set by the user in the environment
234775b29833Smrg#
234875b29833SmrgAC_DEFUN([XORG_WITH_M4], [
234975b29833SmrgAC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
235075b29833Smrg   [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
235175b29833Smrg       [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
235275b29833Smrg         ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
235375b29833Smrg   [AC_MSG_ERROR([could not find m4 that supports -I option])],
235475b29833Smrg   [$PATH:/usr/gnu/bin])])
235575b29833Smrg
235675b29833SmrgAC_SUBST([M4], [$ac_cv_path_M4])
235775b29833Smrg]) # XORG_WITH_M4
235875b29833Smrg
235975b29833Smrg# XORG_WITH_PS2PDF([DEFAULT])
236075b29833Smrg# ----------------
236175b29833Smrg# Minimum version: 1.6.0
236275b29833Smrg# Minimum version for optional DEFAULT argument: 1.11.0
236375b29833Smrg#
236475b29833Smrg# Documentation tools are not always available on all platforms and sometimes
236575b29833Smrg# not at the appropriate level. This macro enables a module to test for the
236675b29833Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
236775b29833Smrg# the --with-ps2pdf option, it allows maximum flexibility in making decisions
236875b29833Smrg# as whether or not to use the ps2pdf package. When DEFAULT is not specified,
236975b29833Smrg# --with-ps2pdf assumes 'auto'.
237075b29833Smrg#
237175b29833Smrg# Interface to module:
237275b29833Smrg# HAVE_PS2PDF: 	used in makefiles to conditionally generate documentation
237375b29833Smrg# PS2PDF:	returns the path of the ps2pdf program found
237475b29833Smrg#		returns the path set by the user in the environment
237575b29833Smrg# --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
237675b29833Smrg#		 'no' user instructs the module not to use ps2pdf
237775b29833Smrg#
237875b29833Smrg# If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
237975b29833Smrg#
238075b29833SmrgAC_DEFUN([XORG_WITH_PS2PDF],[
238175b29833SmrgAC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
238275b29833Smrgm4_define([_defopt], m4_default([$1], [auto]))
238375b29833SmrgAC_ARG_WITH(ps2pdf,
238475b29833Smrg	AS_HELP_STRING([--with-ps2pdf],
238575b29833Smrg	   [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
238675b29833Smrg	   [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
238775b29833Smrgm4_undefine([_defopt])
238875b29833Smrg
238975b29833Smrgif test "x$use_ps2pdf" = x"auto"; then
239075b29833Smrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
239175b29833Smrg   if test "x$PS2PDF" = "x"; then
239275b29833Smrg        AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
239375b29833Smrg	have_ps2pdf=no
239475b29833Smrg   else
239575b29833Smrg        have_ps2pdf=yes
239675b29833Smrg   fi
239775b29833Smrgelif test "x$use_ps2pdf" = x"yes" ; then
239875b29833Smrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
239975b29833Smrg   if test "x$PS2PDF" = "x"; then
240075b29833Smrg        AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
240175b29833Smrg   fi
240275b29833Smrg   have_ps2pdf=yes
240375b29833Smrgelif test "x$use_ps2pdf" = x"no" ; then
240475b29833Smrg   if test "x$PS2PDF" != "x"; then
240575b29833Smrg      AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
240675b29833Smrg   fi
240775b29833Smrg   have_ps2pdf=no
240875b29833Smrgelse
240975b29833Smrg   AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
241075b29833Smrgfi
241175b29833SmrgAM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
241275b29833Smrg]) # XORG_WITH_PS2PDF
241375b29833Smrg
241475b29833Smrg# XORG_ENABLE_DOCS (enable_docs=yes)
241575b29833Smrg# ----------------
241675b29833Smrg# Minimum version: 1.6.0
241775b29833Smrg#
241875b29833Smrg# Documentation tools are not always available on all platforms and sometimes
241975b29833Smrg# not at the appropriate level. This macro enables a builder to skip all
242075b29833Smrg# documentation targets except traditional man pages.
242175b29833Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
242275b29833Smrg# maximum flexibility in controlling documentation building.
242375b29833Smrg# Refer to:
242475b29833Smrg# XORG_WITH_XMLTO         --with-xmlto
242575b29833Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
242675b29833Smrg# XORG_WITH_DOXYGEN       --with-doxygen
242775b29833Smrg# XORG_WITH_FOP           --with-fop
242875b29833Smrg# XORG_WITH_GROFF         --with-groff
242975b29833Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
243075b29833Smrg#
243175b29833Smrg# Interface to module:
243275b29833Smrg# ENABLE_DOCS: 	  used in makefiles to conditionally generate documentation
243375b29833Smrg# --enable-docs: 'yes' user instructs the module to generate docs
243475b29833Smrg#		 'no' user instructs the module not to generate docs
243575b29833Smrg# parm1:	specify the default value, yes or no.
243675b29833Smrg#
243775b29833SmrgAC_DEFUN([XORG_ENABLE_DOCS],[
243875b29833Smrgm4_define([docs_default], m4_default([$1], [yes]))
243975b29833SmrgAC_ARG_ENABLE(docs,
244075b29833Smrg	AS_HELP_STRING([--enable-docs],
244175b29833Smrg	   [Enable building the documentation (default: ]docs_default[)]),
244275b29833Smrg	   [build_docs=$enableval], [build_docs=]docs_default)
244375b29833Smrgm4_undefine([docs_default])
244475b29833SmrgAM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
244575b29833SmrgAC_MSG_CHECKING([whether to build documentation])
244675b29833SmrgAC_MSG_RESULT([$build_docs])
244775b29833Smrg]) # XORG_ENABLE_DOCS
244875b29833Smrg
244975b29833Smrg# XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
245075b29833Smrg# ----------------
245175b29833Smrg# Minimum version: 1.6.0
245275b29833Smrg#
245375b29833Smrg# This macro enables a builder to skip all developer documentation.
245475b29833Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
245575b29833Smrg# maximum flexibility in controlling documentation building.
245675b29833Smrg# Refer to:
245775b29833Smrg# XORG_WITH_XMLTO         --with-xmlto
245875b29833Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
245975b29833Smrg# XORG_WITH_DOXYGEN       --with-doxygen
246075b29833Smrg# XORG_WITH_FOP           --with-fop
246175b29833Smrg# XORG_WITH_GROFF         --with-groff
246275b29833Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
246375b29833Smrg#
246475b29833Smrg# Interface to module:
246575b29833Smrg# ENABLE_DEVEL_DOCS:	used in makefiles to conditionally generate developer docs
246675b29833Smrg# --enable-devel-docs:	'yes' user instructs the module to generate developer docs
246775b29833Smrg#			'no' user instructs the module not to generate developer docs
246875b29833Smrg# parm1:		specify the default value, yes or no.
246975b29833Smrg#
247075b29833SmrgAC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
247175b29833Smrgm4_define([devel_default], m4_default([$1], [yes]))
247275b29833SmrgAC_ARG_ENABLE(devel-docs,
247375b29833Smrg	AS_HELP_STRING([--enable-devel-docs],
247475b29833Smrg	   [Enable building the developer documentation (default: ]devel_default[)]),
247575b29833Smrg	   [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
247675b29833Smrgm4_undefine([devel_default])
247775b29833SmrgAM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
247875b29833SmrgAC_MSG_CHECKING([whether to build developer documentation])
247975b29833SmrgAC_MSG_RESULT([$build_devel_docs])
248075b29833Smrg]) # XORG_ENABLE_DEVEL_DOCS
248175b29833Smrg
248275b29833Smrg# XORG_ENABLE_SPECS (enable_specs=yes)
248375b29833Smrg# ----------------
248475b29833Smrg# Minimum version: 1.6.0
248575b29833Smrg#
248675b29833Smrg# This macro enables a builder to skip all functional specification targets.
248775b29833Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
248875b29833Smrg# maximum flexibility in controlling documentation building.
248975b29833Smrg# Refer to:
249075b29833Smrg# XORG_WITH_XMLTO         --with-xmlto
249175b29833Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
249275b29833Smrg# XORG_WITH_DOXYGEN       --with-doxygen
249375b29833Smrg# XORG_WITH_FOP           --with-fop
249475b29833Smrg# XORG_WITH_GROFF         --with-groff
249575b29833Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
249675b29833Smrg#
249775b29833Smrg# Interface to module:
249875b29833Smrg# ENABLE_SPECS:		used in makefiles to conditionally generate specs
249975b29833Smrg# --enable-specs:	'yes' user instructs the module to generate specs
250075b29833Smrg#			'no' user instructs the module not to generate specs
250175b29833Smrg# parm1:		specify the default value, yes or no.
250275b29833Smrg#
250375b29833SmrgAC_DEFUN([XORG_ENABLE_SPECS],[
250475b29833Smrgm4_define([spec_default], m4_default([$1], [yes]))
250575b29833SmrgAC_ARG_ENABLE(specs,
250675b29833Smrg	AS_HELP_STRING([--enable-specs],
250775b29833Smrg	   [Enable building the specs (default: ]spec_default[)]),
250875b29833Smrg	   [build_specs=$enableval], [build_specs=]spec_default)
250975b29833Smrgm4_undefine([spec_default])
251075b29833SmrgAM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
251175b29833SmrgAC_MSG_CHECKING([whether to build functional specifications])
251275b29833SmrgAC_MSG_RESULT([$build_specs])
251375b29833Smrg]) # XORG_ENABLE_SPECS
251475b29833Smrg
251575b29833Smrg# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
251675b29833Smrg# ----------------------------------------------
251775b29833Smrg# Minimum version: 1.13.0
251875b29833Smrg#
251975b29833Smrg# This macro enables a builder to enable/disable unit testing
252075b29833Smrg# It makes no assumption about the test cases implementation
252175b29833Smrg# Test cases may or may not use Automake "Support for test suites"
252275b29833Smrg# They may or may not use the software utility library GLib
252375b29833Smrg#
252475b29833Smrg# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
252575b29833Smrg# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
252675b29833Smrg# The variable enable_unit_tests is used by other macros in this file.
252775b29833Smrg#
252875b29833Smrg# Interface to module:
252975b29833Smrg# ENABLE_UNIT_TESTS:	used in makefiles to conditionally build tests
253075b29833Smrg# enable_unit_tests:    used in configure.ac for additional configuration
253175b29833Smrg# --enable-unit-tests:	'yes' user instructs the module to build tests
253275b29833Smrg#			'no' user instructs the module not to build tests
253375b29833Smrg# parm1:		specify the default value, yes or no.
253475b29833Smrg#
253575b29833SmrgAC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
253675b29833SmrgAC_BEFORE([$0], [XORG_WITH_GLIB])
253775b29833SmrgAC_BEFORE([$0], [XORG_LD_WRAP])
253875b29833SmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
253975b29833Smrgm4_define([_defopt], m4_default([$1], [auto]))
254075b29833SmrgAC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
254175b29833Smrg	[Enable building unit test cases (default: ]_defopt[)]),
254275b29833Smrg	[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
254375b29833Smrgm4_undefine([_defopt])
254475b29833SmrgAM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
254575b29833SmrgAC_MSG_CHECKING([whether to build unit test cases])
254675b29833SmrgAC_MSG_RESULT([$enable_unit_tests])
254775b29833Smrg]) # XORG_ENABLE_UNIT_TESTS
254875b29833Smrg
254975b29833Smrg# XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
255075b29833Smrg# ------------------------------------------------------
255175b29833Smrg# Minimum version: 1.17.0
255275b29833Smrg#
255375b29833Smrg# This macro enables a builder to enable/disable integration testing
255475b29833Smrg# It makes no assumption about the test cases' implementation
255575b29833Smrg# Test cases may or may not use Automake "Support for test suites"
255675b29833Smrg#
255775b29833Smrg# Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
255875b29833Smrg# usually requires less dependencies and may be built and run under less
255975b29833Smrg# stringent environments than integration tests.
256075b29833Smrg#
256175b29833Smrg# Interface to module:
256275b29833Smrg# ENABLE_INTEGRATION_TESTS:   used in makefiles to conditionally build tests
256375b29833Smrg# enable_integration_tests:   used in configure.ac for additional configuration
256475b29833Smrg# --enable-integration-tests: 'yes' user instructs the module to build tests
256575b29833Smrg#                             'no' user instructs the module not to build tests
256675b29833Smrg# parm1:                      specify the default value, yes or no.
256775b29833Smrg#
256875b29833SmrgAC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
256975b29833SmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
257075b29833Smrgm4_define([_defopt], m4_default([$1], [auto]))
257175b29833SmrgAC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
257275b29833Smrg	[Enable building integration test cases (default: ]_defopt[)]),
257375b29833Smrg	[enable_integration_tests=$enableval],
257475b29833Smrg	[enable_integration_tests=]_defopt)
257575b29833Smrgm4_undefine([_defopt])
257675b29833SmrgAM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
257775b29833Smrg	[test "x$enable_integration_tests" != xno])
257875b29833SmrgAC_MSG_CHECKING([whether to build unit test cases])
257975b29833SmrgAC_MSG_RESULT([$enable_integration_tests])
258075b29833Smrg]) # XORG_ENABLE_INTEGRATION_TESTS
258175b29833Smrg
258275b29833Smrg# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
258375b29833Smrg# ----------------------------------------
258475b29833Smrg# Minimum version: 1.13.0
258575b29833Smrg#
258675b29833Smrg# GLib is a library which provides advanced data structures and functions.
258775b29833Smrg# This macro enables a module to test for the presence of Glib.
258875b29833Smrg#
258975b29833Smrg# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
259075b29833Smrg# Otherwise the value of $enable_unit_tests is blank.
259175b29833Smrg#
259275b29833Smrg# Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
259375b29833Smrg# test support usually requires less dependencies and may be built and run under
259475b29833Smrg# less stringent environments than integration tests.
259575b29833Smrg#
259675b29833Smrg# Interface to module:
259775b29833Smrg# HAVE_GLIB: used in makefiles to conditionally build targets
259875b29833Smrg# with_glib: used in configure.ac to know if GLib has been found
259975b29833Smrg# --with-glib:	'yes' user instructs the module to use glib
260075b29833Smrg#		'no' user instructs the module not to use glib
260175b29833Smrg#
260275b29833SmrgAC_DEFUN([XORG_WITH_GLIB],[
260375b29833SmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
260475b29833Smrgm4_define([_defopt], m4_default([$2], [auto]))
260575b29833SmrgAC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
260675b29833Smrg	[Use GLib library for unit testing (default: ]_defopt[)]),
260775b29833Smrg	[with_glib=$withval], [with_glib=]_defopt)
260875b29833Smrgm4_undefine([_defopt])
260975b29833Smrg
261075b29833Smrghave_glib=no
261175b29833Smrg# Do not probe GLib if user explicitly disabled unit testing
261275b29833Smrgif test "x$enable_unit_tests" != x"no"; then
261375b29833Smrg  # Do not probe GLib if user explicitly disabled it
261475b29833Smrg  if test "x$with_glib" != x"no"; then
261575b29833Smrg    m4_ifval(
261675b29833Smrg      [$1],
261775b29833Smrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
261875b29833Smrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
261975b29833Smrg    )
262075b29833Smrg  fi
262175b29833Smrgfi
262275b29833Smrg
262375b29833Smrg# Not having GLib when unit testing has been explicitly requested is an error
262475b29833Smrgif test "x$enable_unit_tests" = x"yes"; then
262575b29833Smrg  if test "x$have_glib" = x"no"; then
262675b29833Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
262775b29833Smrg  fi
262875b29833Smrgfi
262975b29833Smrg
263075b29833Smrg# Having unit testing disabled when GLib has been explicitly requested is an error
263175b29833Smrgif test "x$enable_unit_tests" = x"no"; then
263275b29833Smrg  if test "x$with_glib" = x"yes"; then
263375b29833Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
263475b29833Smrg  fi
263575b29833Smrgfi
263675b29833Smrg
263775b29833Smrg# Not having GLib when it has been explicitly requested is an error
263875b29833Smrgif test "x$with_glib" = x"yes"; then
263975b29833Smrg  if test "x$have_glib" = x"no"; then
264075b29833Smrg    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
264175b29833Smrg  fi
264275b29833Smrgfi
264375b29833Smrg
264475b29833SmrgAM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
264575b29833Smrg]) # XORG_WITH_GLIB
264675b29833Smrg
264775b29833Smrg# XORG_LD_WRAP([required|optional])
264875b29833Smrg# ---------------------------------
264975b29833Smrg# Minimum version: 1.13.0
265075b29833Smrg#
265175b29833Smrg# Check if linker supports -wrap, passed via compiler flags
265275b29833Smrg#
265375b29833Smrg# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
265475b29833Smrg# Otherwise the value of $enable_unit_tests is blank.
265575b29833Smrg#
265675b29833Smrg# Argument added in 1.16.0 - default is "required", to match existing behavior
265775b29833Smrg# of returning an error if enable_unit_tests is yes, and ld -wrap is not
265875b29833Smrg# available, an argument of "optional" allows use when some unit tests require
265975b29833Smrg# ld -wrap and others do not.
266075b29833Smrg#
266175b29833SmrgAC_DEFUN([XORG_LD_WRAP],[
266275b29833SmrgXORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
266375b29833Smrg    [AC_LANG_PROGRAM([#include <stdlib.h>
266475b29833Smrg                      void __wrap_exit(int status) { return; }],
266575b29833Smrg                     [exit(0);])])
266675b29833Smrg# Not having ld wrap when unit testing has been explicitly requested is an error
266775b29833Smrgif test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
266875b29833Smrg  if test "x$have_ld_wrap" = x"no"; then
266975b29833Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
267075b29833Smrg  fi
267175b29833Smrgfi
267275b29833SmrgAM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
267375b29833Smrg#
267475b29833Smrg]) # XORG_LD_WRAP
267575b29833Smrg
267675b29833Smrg# XORG_CHECK_LINKER_FLAGS
267775b29833Smrg# -----------------------
267875b29833Smrg# SYNOPSIS
267975b29833Smrg#
268075b29833Smrg#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
268175b29833Smrg#
268275b29833Smrg# DESCRIPTION
268375b29833Smrg#
268475b29833Smrg#   Check whether the given linker FLAGS work with the current language's
268575b29833Smrg#   linker, or whether they give an error.
268675b29833Smrg#
268775b29833Smrg#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
268875b29833Smrg#   success/failure.
268975b29833Smrg#
269075b29833Smrg#   PROGRAM-SOURCE is the program source to link with, if needed
269175b29833Smrg#
269275b29833Smrg#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
269375b29833Smrg#
269475b29833Smrg# LICENSE
269575b29833Smrg#
269675b29833Smrg#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
269775b29833Smrg#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
269875b29833Smrg#   Copyright (c) 2009 Matteo Frigo
269975b29833Smrg#
270075b29833Smrg#   This program is free software: you can redistribute it and/or modify it
270175b29833Smrg#   under the terms of the GNU General Public License as published by the
270275b29833Smrg#   Free Software Foundation, either version 3 of the License, or (at your
270375b29833Smrg#   option) any later version.
270475b29833Smrg#
270575b29833Smrg#   This program is distributed in the hope that it will be useful, but
270675b29833Smrg#   WITHOUT ANY WARRANTY; without even the implied warranty of
270775b29833Smrg#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
270875b29833Smrg#   Public License for more details.
270975b29833Smrg#
271075b29833Smrg#   You should have received a copy of the GNU General Public License along
271175b29833Smrg#   with this program. If not, see <http://www.gnu.org/licenses/>.
271275b29833Smrg#
271375b29833Smrg#   As a special exception, the respective Autoconf Macro's copyright owner
271475b29833Smrg#   gives unlimited permission to copy, distribute and modify the configure
271575b29833Smrg#   scripts that are the output of Autoconf when processing the Macro. You
271675b29833Smrg#   need not follow the terms of the GNU General Public License when using
271775b29833Smrg#   or distributing such scripts, even though portions of the text of the
271875b29833Smrg#   Macro appear in them. The GNU General Public License (GPL) does govern
271975b29833Smrg#   all other use of the material that constitutes the Autoconf Macro.
272075b29833Smrg#
272175b29833Smrg#   This special exception to the GPL applies to versions of the Autoconf
272275b29833Smrg#   Macro released by the Autoconf Archive. When you make and distribute a
272375b29833Smrg#   modified version of the Autoconf Macro, you may extend this special
272475b29833Smrg#   exception to the GPL to apply to your modified version as well.#
272575b29833SmrgAC_DEFUN([XORG_CHECK_LINKER_FLAGS],
272675b29833Smrg[AC_MSG_CHECKING([whether the linker accepts $1])
272775b29833Smrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
272875b29833SmrgAS_LITERAL_IF([$1],
272975b29833Smrg  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
273075b29833Smrg      ax_save_FLAGS=$LDFLAGS
273175b29833Smrg      LDFLAGS="$1"
273275b29833Smrg      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
273375b29833Smrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
273475b29833Smrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
273575b29833Smrg      LDFLAGS=$ax_save_FLAGS])],
273675b29833Smrg  [ax_save_FLAGS=$LDFLAGS
273775b29833Smrg   LDFLAGS="$1"
273875b29833Smrg   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
273975b29833Smrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
274075b29833Smrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
274175b29833Smrg   LDFLAGS=$ax_save_FLAGS])
274275b29833Smrgeval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
274375b29833SmrgAC_MSG_RESULT($xorg_check_linker_flags)
274475b29833Smrgif test "x$xorg_check_linker_flags" = xyes; then
274575b29833Smrg	m4_default([$2], :)
274675b29833Smrgelse
274775b29833Smrg	m4_default([$3], :)
274875b29833Smrgfi
274975b29833Smrg]) # XORG_CHECK_LINKER_FLAGS
275075b29833Smrg
275175b29833Smrg# XORG_MEMORY_CHECK_FLAGS
275275b29833Smrg# -----------------------
275375b29833Smrg# Minimum version: 1.16.0
275475b29833Smrg#
275575b29833Smrg# This macro attempts to find appropriate memory checking functionality
275675b29833Smrg# for various platforms which unit testing code may use to catch various
275775b29833Smrg# forms of memory allocation and access errors in testing.
275875b29833Smrg#
275975b29833Smrg# Interface to module:
276075b29833Smrg# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
276175b29833Smrg#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
276275b29833Smrg#
276375b29833Smrg# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
276475b29833Smrg#
276575b29833SmrgAC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
276675b29833Smrg
276775b29833SmrgAC_REQUIRE([AC_CANONICAL_HOST])
276875b29833SmrgAC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
276975b29833Smrg           [Environment variables to enable memory checking in tests])
277075b29833Smrg
277175b29833Smrg# Check for different types of support on different platforms
277275b29833Smrgcase $host_os in
277375b29833Smrg    solaris*)
277475b29833Smrg        AC_CHECK_LIB([umem], [umem_alloc],
277575b29833Smrg            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
277675b29833Smrg        ;;
277775b29833Smrg    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
277875b29833Smrg        # both directly and inverted, so should not be 0 or 255.
277975b29833Smrg        malloc_debug_env='MALLOC_PERTURB_=15'
278075b29833Smrg        ;;
278175b29833Smrg    darwin*)
278275b29833Smrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
278375b29833Smrg        ;;
278475b29833Smrg    *bsd*)
278575b29833Smrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
278675b29833Smrg        ;;
278775b29833Smrgesac
278875b29833Smrg
278975b29833Smrg# User supplied flags override default flags
279075b29833Smrgif test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
279175b29833Smrg    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
279275b29833Smrgfi
279375b29833Smrg
279475b29833SmrgAC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
279575b29833Smrg]) # XORG_WITH_LINT
279675b29833Smrg
279775b29833Smrg# XORG_CHECK_MALLOC_ZERO
279875b29833Smrg# ----------------------
279975b29833Smrg# Minimum version: 1.0.0
280075b29833Smrg#
280175b29833Smrg# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
280275b29833Smrg# malloc(0) returns NULL.  Packages should add one of these cflags to
280375b29833Smrg# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
280475b29833SmrgAC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
280575b29833SmrgAC_ARG_ENABLE(malloc0returnsnull,
280675b29833Smrg	AS_HELP_STRING([--enable-malloc0returnsnull],
280775b29833Smrg		       [malloc(0) returns NULL (default: auto)]),
280875b29833Smrg	[MALLOC_ZERO_RETURNS_NULL=$enableval],
280975b29833Smrg	[MALLOC_ZERO_RETURNS_NULL=auto])
281075b29833Smrg
281175b29833SmrgAC_MSG_CHECKING([whether malloc(0) returns NULL])
281275b29833Smrgif test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
281375b29833SmrgAC_CACHE_VAL([xorg_cv_malloc0_returns_null],
281475b29833Smrg	[AC_RUN_IFELSE([AC_LANG_PROGRAM([
281575b29833Smrg#include <stdlib.h>
281675b29833Smrg],[
281775b29833Smrg    char *m0, *r0, *c0, *p;
281875b29833Smrg    m0 = malloc(0);
281975b29833Smrg    p = malloc(10);
282075b29833Smrg    r0 = realloc(p,0);
282175b29833Smrg    c0 = calloc(0,10);
282275b29833Smrg    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
282375b29833Smrg])],
282475b29833Smrg		[xorg_cv_malloc0_returns_null=yes],
282575b29833Smrg		[xorg_cv_malloc0_returns_null=no])])
282675b29833SmrgMALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null
282775b29833Smrgfi
282875b29833SmrgAC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
282975b29833Smrg
283075b29833Smrgif test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
283175b29833Smrg	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
283275b29833Smrg	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
283375b29833Smrg	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
283475b29833Smrgelse
283575b29833Smrg	MALLOC_ZERO_CFLAGS=""
283675b29833Smrg	XMALLOC_ZERO_CFLAGS=""
283775b29833Smrg	XTMALLOC_ZERO_CFLAGS=""
283875b29833Smrgfi
283975b29833Smrg
284075b29833SmrgAC_SUBST([MALLOC_ZERO_CFLAGS])
284175b29833SmrgAC_SUBST([XMALLOC_ZERO_CFLAGS])
284275b29833SmrgAC_SUBST([XTMALLOC_ZERO_CFLAGS])
284375b29833Smrg]) # XORG_CHECK_MALLOC_ZERO
284475b29833Smrg
284575b29833Smrg# XORG_WITH_LINT()
284675b29833Smrg# ----------------
284775b29833Smrg# Minimum version: 1.1.0
284875b29833Smrg#
284975b29833Smrg# This macro enables the use of a tool that flags some suspicious and
285075b29833Smrg# non-portable constructs (likely to be bugs) in C language source code.
285175b29833Smrg# It will attempt to locate the tool and use appropriate options.
285275b29833Smrg# There are various lint type tools on different platforms.
285375b29833Smrg#
285475b29833Smrg# Interface to module:
285575b29833Smrg# LINT:		returns the path to the tool found on the platform
285675b29833Smrg#		or the value set to LINT on the configure cmd line
285775b29833Smrg#		also an Automake conditional
285875b29833Smrg# LINT_FLAGS:	an Automake variable with appropriate flags
285975b29833Smrg#
286075b29833Smrg# --with-lint:	'yes' user instructs the module to use lint
286175b29833Smrg#		'no' user instructs the module not to use lint (default)
286275b29833Smrg#
286375b29833Smrg# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
286475b29833Smrg# If the user sets the value of LINT_FLAGS, they are used verbatim.
286575b29833Smrg#
286675b29833SmrgAC_DEFUN([XORG_WITH_LINT],[
286775b29833Smrg
286875b29833SmrgAC_ARG_VAR([LINT], [Path to a lint-style command])
286975b29833SmrgAC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
287075b29833SmrgAC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
287175b29833Smrg		[Use a lint-style source code checker (default: disabled)])],
287275b29833Smrg		[use_lint=$withval], [use_lint=no])
287375b29833Smrg
287475b29833Smrg# Obtain platform specific info like program name and options
287575b29833Smrg# The lint program on FreeBSD and NetBSD is different from the one on Solaris
287675b29833Smrgcase $host_os in
287775b29833Smrg  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
287875b29833Smrg	lint_name=splint
287975b29833Smrg	lint_options="-badflag"
288075b29833Smrg	;;
288175b29833Smrg  *freebsd* | *netbsd*)
288275b29833Smrg	lint_name=lint
288375b29833Smrg	lint_options="-u -b"
288475b29833Smrg	;;
288575b29833Smrg  *solaris*)
288675b29833Smrg	lint_name=lint
288775b29833Smrg	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
288875b29833Smrg	;;
288975b29833Smrgesac
289075b29833Smrg
289175b29833Smrg# Test for the presence of the program (either guessed by the code or spelled out by the user)
289275b29833Smrgif test "x$use_lint" = x"yes" ; then
289375b29833Smrg   AC_PATH_PROG([LINT], [$lint_name])
289475b29833Smrg   if test "x$LINT" = "x"; then
289575b29833Smrg        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
289675b29833Smrg   fi
289775b29833Smrgelif test "x$use_lint" = x"no" ; then
289875b29833Smrg   if test "x$LINT" != "x"; then
289975b29833Smrg      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
290075b29833Smrg   fi
290175b29833Smrgelse
290275b29833Smrg   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
290375b29833Smrgfi
290475b29833Smrg
290575b29833Smrg# User supplied flags override default flags
290675b29833Smrgif test "x$LINT_FLAGS" != "x"; then
290775b29833Smrg   lint_options=$LINT_FLAGS
290875b29833Smrgfi
290975b29833Smrg
291075b29833SmrgAC_SUBST([LINT_FLAGS],[$lint_options])
291175b29833SmrgAM_CONDITIONAL(LINT, [test "x$LINT" != x])
291275b29833Smrg
291375b29833Smrg]) # XORG_WITH_LINT
291475b29833Smrg
291575b29833Smrg# XORG_LINT_LIBRARY(LIBNAME)
291675b29833Smrg# --------------------------
291775b29833Smrg# Minimum version: 1.1.0
291875b29833Smrg#
291975b29833Smrg# Sets up flags for building lint libraries for checking programs that call
292075b29833Smrg# functions in the library.
292175b29833Smrg#
292275b29833Smrg# Interface to module:
292375b29833Smrg# LINTLIB		- Automake variable with the name of lint library file to make
292475b29833Smrg# MAKE_LINT_LIB		- Automake conditional
292575b29833Smrg#
292675b29833Smrg# --enable-lint-library:  - 'yes' user instructs the module to created a lint library
292775b29833Smrg#			  - 'no' user instructs the module not to create a lint library (default)
292875b29833Smrg
292975b29833SmrgAC_DEFUN([XORG_LINT_LIBRARY],[
293075b29833SmrgAC_REQUIRE([XORG_WITH_LINT])
293175b29833SmrgAC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
293275b29833Smrg	[Create lint library (default: disabled)])],
293375b29833Smrg	[make_lint_lib=$enableval], [make_lint_lib=no])
293475b29833Smrg
293575b29833Smrgif test "x$make_lint_lib" = x"yes" ; then
293675b29833Smrg   LINTLIB=llib-l$1.ln
293775b29833Smrg   if test "x$LINT" = "x"; then
293875b29833Smrg        AC_MSG_ERROR([Cannot make lint library without --with-lint])
293975b29833Smrg   fi
294075b29833Smrgelif test "x$make_lint_lib" != x"no" ; then
294175b29833Smrg   AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
294275b29833Smrgfi
294375b29833Smrg
294475b29833SmrgAC_SUBST(LINTLIB)
294575b29833SmrgAM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
294675b29833Smrg
294775b29833Smrg]) # XORG_LINT_LIBRARY
294875b29833Smrg
294975b29833Smrg# XORG_COMPILER_BRAND
295075b29833Smrg# -------------------
295175b29833Smrg# Minimum version: 1.14.0
295275b29833Smrg#
295375b29833Smrg# Checks for various brands of compilers and sets flags as appropriate:
295475b29833Smrg#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
295575b29833Smrg#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
295675b29833Smrg#   clang compiler - sets CLANGCC to "yes"
295775b29833Smrg#   Intel compiler - sets INTELCC to "yes"
295875b29833Smrg#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
295975b29833Smrg#
296075b29833SmrgAC_DEFUN([XORG_COMPILER_BRAND], [
296175b29833SmrgAC_LANG_CASE(
296275b29833Smrg	[C], [
296375b29833Smrg		dnl autoconf-2.70 folded AC_PROG_CC_C99 into AC_PROG_CC
296475b29833Smrg		dnl and complains that AC_PROG_CC_C99 is obsolete
296575b29833Smrg		m4_version_prereq([2.70],
296675b29833Smrg			[AC_REQUIRE([AC_PROG_CC])],
296775b29833Smrg			[AC_REQUIRE([AC_PROG_CC_C99])])
296875b29833Smrg	],
296975b29833Smrg	[C++], [
297075b29833Smrg		AC_REQUIRE([AC_PROG_CXX])
297175b29833Smrg	]
297275b29833Smrg)
297375b29833SmrgAC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
297475b29833SmrgAC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
297575b29833SmrgAC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
297675b29833Smrg]) # XORG_COMPILER_BRAND
297775b29833Smrg
297875b29833Smrg# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
297975b29833Smrg# ---------------
298075b29833Smrg# Minimum version: 1.16.0
298175b29833Smrg#
298275b29833Smrg# Test if the compiler works when passed the given flag as a command line argument.
298375b29833Smrg# If it succeeds, the flag is appended to the given variable.  If not, it tries the
298475b29833Smrg# next flag in the list until there are no more options.
298575b29833Smrg#
298675b29833Smrg# Note that this does not guarantee that the compiler supports the flag as some
298775b29833Smrg# compilers will simply ignore arguments that they do not understand, but we do
298875b29833Smrg# attempt to weed out false positives by using -Werror=unknown-warning-option and
298975b29833Smrg# -Werror=unused-command-line-argument
299075b29833Smrg#
299175b29833SmrgAC_DEFUN([XORG_TESTSET_CFLAG], [
299275b29833Smrgm4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
299375b29833Smrgm4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
299475b29833Smrg
299575b29833SmrgAC_LANG_COMPILER_REQUIRE
299675b29833Smrg
299775b29833SmrgAC_LANG_CASE(
299875b29833Smrg	[C], [
299975b29833Smrg		dnl autoconf-2.70 folded AC_PROG_CC_C99 into AC_PROG_CC
300075b29833Smrg		dnl and complains that AC_PROG_CC_C99 is obsolete
300175b29833Smrg		m4_version_prereq([2.70],
300275b29833Smrg			[AC_REQUIRE([AC_PROG_CC])],
300375b29833Smrg			[AC_REQUIRE([AC_PROG_CC_C99])])
300475b29833Smrg		define([PREFIX], [C])
300575b29833Smrg		define([CACHE_PREFIX], [cc])
300675b29833Smrg		define([COMPILER], [$CC])
300775b29833Smrg	],
300875b29833Smrg	[C++], [
300975b29833Smrg		define([PREFIX], [CXX])
301075b29833Smrg		define([CACHE_PREFIX], [cxx])
301175b29833Smrg		define([COMPILER], [$CXX])
301275b29833Smrg	]
301375b29833Smrg)
301475b29833Smrg
301575b29833Smrg[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
301675b29833Smrg
301775b29833Smrgif test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
301875b29833Smrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
301975b29833Smrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
302075b29833Smrg			[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
302175b29833Smrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
302275b29833Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
302375b29833Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
302475b29833Smrg	[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
302575b29833Smrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
302675b29833Smrgfi
302775b29833Smrg
302875b29833Smrgif test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
302975b29833Smrg	if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
303075b29833Smrg		PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
303175b29833Smrg	fi
303275b29833Smrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
303375b29833Smrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
303475b29833Smrg			[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
303575b29833Smrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
303675b29833Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
303775b29833Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
303875b29833Smrg	[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
303975b29833Smrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
304075b29833Smrgfi
304175b29833Smrg
304275b29833Smrgfound="no"
304375b29833Smrgm4_foreach([flag], m4_cdr($@), [
304475b29833Smrg	if test $found = "no" ; then
304575b29833Smrg		if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
304675b29833Smrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
304775b29833Smrg		fi
304875b29833Smrg
304975b29833Smrg		if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
305075b29833Smrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
305175b29833Smrg		fi
305275b29833Smrg
305375b29833Smrg		PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
305475b29833Smrg
305575b29833Smrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
305675b29833Smrg		AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
305775b29833Smrg		cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
305875b29833Smrg		AC_CACHE_VAL($cacheid,
305975b29833Smrg			     [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
306075b29833Smrg					     [eval $cacheid=yes],
306175b29833Smrg					     [eval $cacheid=no])])
306275b29833Smrg
306375b29833Smrg		PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
306475b29833Smrg
306575b29833Smrg		eval supported=\$$cacheid
306675b29833Smrg		AC_MSG_RESULT([$supported])
306775b29833Smrg		if test "$supported" = "yes" ; then
306875b29833Smrg			$1="$$1 ]flag["
306975b29833Smrg			found="yes"
307075b29833Smrg		fi
307175b29833Smrg	fi
307275b29833Smrg])
307375b29833Smrg]) # XORG_TESTSET_CFLAG
307475b29833Smrg
307575b29833Smrg# XORG_COMPILER_FLAGS
307675b29833Smrg# ---------------
307775b29833Smrg# Minimum version: 1.16.0
307875b29833Smrg#
307975b29833Smrg# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
308075b29833Smrg# arguments supported by the selected compiler which do NOT alter the generated
308175b29833Smrg# code.  These arguments will cause the compiler to print various warnings
308275b29833Smrg# during compilation AND turn a conservative set of warnings into errors.
308375b29833Smrg#
308475b29833Smrg# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
308575b29833Smrg# future versions of util-macros as options are added to new compilers.
308675b29833Smrg#
308775b29833SmrgAC_DEFUN([XORG_COMPILER_FLAGS], [
308875b29833SmrgAC_REQUIRE([XORG_COMPILER_BRAND])
308975b29833Smrg
309075b29833SmrgAC_ARG_ENABLE(selective-werror,
309175b29833Smrg              AS_HELP_STRING([--disable-selective-werror],
309275b29833Smrg                             [Turn off selective compiler errors. (default: enabled)]),
309375b29833Smrg              [SELECTIVE_WERROR=$enableval],
309475b29833Smrg              [SELECTIVE_WERROR=yes])
309575b29833Smrg
309675b29833SmrgAC_LANG_CASE(
309775b29833Smrg        [C], [
309875b29833Smrg                define([PREFIX], [C])
309975b29833Smrg        ],
310075b29833Smrg        [C++], [
310175b29833Smrg                define([PREFIX], [CXX])
310275b29833Smrg        ]
310375b29833Smrg)
310475b29833Smrg# -v is too short to test reliably with XORG_TESTSET_CFLAG
310575b29833Smrgif test "x$SUNCC" = "xyes"; then
310675b29833Smrg    [BASE_]PREFIX[FLAGS]="-v"
310775b29833Smrgelse
310875b29833Smrg    [BASE_]PREFIX[FLAGS]=""
310975b29833Smrgfi
311075b29833Smrg
311175b29833Smrg# This chunk of warnings were those that existed in the legacy CWARNFLAGS
311275b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
311375b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
311475b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
311575b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
311675b29833Smrg
311775b29833SmrgAC_LANG_CASE(
311875b29833Smrg	[C], [
311975b29833Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
312075b29833Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
312175b29833Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
312275b29833Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
312375b29833Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
312475b29833Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
312575b29833Smrg	]
312675b29833Smrg)
312775b29833Smrg
312875b29833Smrg# This chunk adds additional warnings that could catch undesired effects.
312975b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
313075b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
313175b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
313275b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
313375b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
313475b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
313575b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
313675b29833Smrg
313775b29833Smrg# These are currently disabled because they are noisy.  They will be enabled
313875b29833Smrg# in the future once the codebase is sufficiently modernized to silence
313975b29833Smrg# them.  For now, I don't want them to drown out the other warnings.
314075b29833Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
314175b29833Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
314275b29833Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
314375b29833Smrg
314475b29833Smrg# Turn some warnings into errors, so we don't accidentally get successful builds
314575b29833Smrg# when there are problems that should be fixed.
314675b29833Smrg
314775b29833Smrgif test "x$SELECTIVE_WERROR" = "xyes" ; then
314875b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
314975b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
315075b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
315175b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
315275b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
315375b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
315475b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
315575b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
315675b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
315775b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
315875b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
315975b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
316075b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
316175b29833Smrgelse
316275b29833SmrgAC_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])
316375b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
316475b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
316575b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
316675b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
316775b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
316875b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
316975b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
317075b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
317175b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
317275b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
317375b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
317475b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
317575b29833SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
317675b29833Smrgfi
317775b29833Smrg
317875b29833SmrgAC_SUBST([BASE_]PREFIX[FLAGS])
317975b29833Smrg]) # XORG_COMPILER_FLAGS
318075b29833Smrg
318175b29833Smrg# XORG_CWARNFLAGS
318275b29833Smrg# ---------------
318375b29833Smrg# Minimum version: 1.2.0
318475b29833Smrg# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
318575b29833Smrg#
318675b29833Smrg# Defines CWARNFLAGS to enable C compiler warnings.
318775b29833Smrg#
318875b29833Smrg# This function is deprecated because it defines -fno-strict-aliasing
318975b29833Smrg# which alters the code generated by the compiler.  If -fno-strict-aliasing
319075b29833Smrg# is needed, then it should be added explicitly in the module when
319175b29833Smrg# it is updated to use BASE_CFLAGS.
319275b29833Smrg#
319375b29833SmrgAC_DEFUN([XORG_CWARNFLAGS], [
319475b29833SmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
319575b29833SmrgAC_REQUIRE([XORG_COMPILER_BRAND])
319675b29833SmrgAC_LANG_CASE(
319775b29833Smrg	[C], [
319875b29833Smrg		CWARNFLAGS="$BASE_CFLAGS"
319975b29833Smrg		if  test "x$GCC" = xyes ; then
320075b29833Smrg		    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
320175b29833Smrg		fi
320275b29833Smrg		AC_SUBST(CWARNFLAGS)
320375b29833Smrg	]
320475b29833Smrg)
320575b29833Smrg]) # XORG_CWARNFLAGS
320675b29833Smrg
320775b29833Smrg# XORG_STRICT_OPTION
320875b29833Smrg# -----------------------
320975b29833Smrg# Minimum version: 1.3.0
321075b29833Smrg#
321175b29833Smrg# Add configure option to enable strict compilation flags, such as treating
321275b29833Smrg# warnings as fatal errors.
321375b29833Smrg# If --enable-strict-compilation is passed to configure, adds strict flags to
321475b29833Smrg# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
321575b29833Smrg#
321675b29833Smrg# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
321775b29833Smrg# when strict compilation is unconditionally desired.
321875b29833SmrgAC_DEFUN([XORG_STRICT_OPTION], [
321975b29833SmrgAC_REQUIRE([XORG_CWARNFLAGS])
322075b29833SmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
322175b29833Smrg
322275b29833SmrgAC_ARG_ENABLE(strict-compilation,
322375b29833Smrg			  AS_HELP_STRING([--enable-strict-compilation],
322475b29833Smrg			  [Enable all warnings from compiler and make them errors (default: disabled)]),
322575b29833Smrg			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
322675b29833Smrg
322775b29833SmrgAC_LANG_CASE(
322875b29833Smrg        [C], [
322975b29833Smrg                define([PREFIX], [C])
323075b29833Smrg        ],
323175b29833Smrg        [C++], [
323275b29833Smrg                define([PREFIX], [CXX])
323375b29833Smrg        ]
323475b29833Smrg)
323575b29833Smrg
323675b29833Smrg[STRICT_]PREFIX[FLAGS]=""
323775b29833SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
323875b29833SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
323975b29833Smrg
324075b29833Smrg# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
324175b29833Smrg# activate it with -Werror, so we add it here explicitly.
324275b29833SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
324375b29833Smrg
324475b29833Smrgif test "x$STRICT_COMPILE" = "xyes"; then
324575b29833Smrg    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
324675b29833Smrg    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
324775b29833Smrgfi
324875b29833SmrgAC_SUBST([STRICT_]PREFIX[FLAGS])
324975b29833SmrgAC_SUBST([BASE_]PREFIX[FLAGS])
325075b29833SmrgAC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
325175b29833Smrg]) # XORG_STRICT_OPTION
325275b29833Smrg
325375b29833Smrg# XORG_DEFAULT_NOCODE_OPTIONS
325475b29833Smrg# ---------------------------
325575b29833Smrg# Minimum version: 1.20.0
325675b29833Smrg#
325775b29833Smrg# Defines default options for X.Org modules which don't compile code,
325875b29833Smrg# such as fonts, bitmaps, cursors, and docs.
325975b29833Smrg#
326075b29833SmrgAC_DEFUN([XORG_DEFAULT_NOCODE_OPTIONS], [
326175b29833SmrgAC_REQUIRE([AC_PROG_INSTALL])
326275b29833SmrgXORG_RELEASE_VERSION
326375b29833SmrgXORG_CHANGELOG
326475b29833SmrgXORG_INSTALL
326575b29833SmrgXORG_MANPAGE_SECTIONS
326675b29833Smrgm4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
326775b29833Smrg    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
326875b29833Smrg]) # XORG_DEFAULT_NOCODE_OPTIONS
326975b29833Smrg
327075b29833Smrg# XORG_DEFAULT_OPTIONS
327175b29833Smrg# --------------------
327275b29833Smrg# Minimum version: 1.3.0
327375b29833Smrg#
327475b29833Smrg# Defines default options for X.Org modules which compile code.
327575b29833Smrg#
327675b29833SmrgAC_DEFUN([XORG_DEFAULT_OPTIONS], [
327775b29833SmrgAC_REQUIRE([AC_PROG_INSTALL])
327875b29833SmrgXORG_COMPILER_FLAGS
327975b29833SmrgXORG_CWARNFLAGS
328075b29833SmrgXORG_STRICT_OPTION
328175b29833SmrgXORG_DEFAULT_NOCODE_OPTIONS
328275b29833Smrg]) # XORG_DEFAULT_OPTIONS
328375b29833Smrg
328475b29833Smrg# XORG_INSTALL()
328575b29833Smrg# ----------------
328675b29833Smrg# Minimum version: 1.4.0
328775b29833Smrg#
328875b29833Smrg# Defines the variable INSTALL_CMD as the command to copy
328975b29833Smrg# INSTALL from $prefix/share/util-macros.
329075b29833Smrg#
329175b29833SmrgAC_DEFUN([XORG_INSTALL], [
329275b29833SmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
329375b29833Smrgmacros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
329475b29833SmrgINSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
329575b29833Smrgmv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
329675b29833Smrg|| (rm -f \$(top_srcdir)/.INSTALL.tmp; test -e \$(top_srcdir)/INSTALL || ( \
329775b29833Smrgtouch \$(top_srcdir)/INSTALL; \
329875b29833Smrgecho 'failed to copy INSTALL from util-macros: installing empty INSTALL.' >&2))"
329975b29833SmrgAC_SUBST([INSTALL_CMD])
330075b29833Smrg]) # XORG_INSTALL
330175b29833Smrgdnl Copyright 2005 Red Hat, Inc
330275b29833Smrgdnl
330375b29833Smrgdnl Permission to use, copy, modify, distribute, and sell this software and its
330475b29833Smrgdnl documentation for any purpose is hereby granted without fee, provided that
330575b29833Smrgdnl the above copyright notice appear in all copies and that both that
330675b29833Smrgdnl copyright notice and this permission notice appear in supporting
330775b29833Smrgdnl documentation.
330875b29833Smrgdnl
330975b29833Smrgdnl The above copyright notice and this permission notice shall be included
331075b29833Smrgdnl in all copies or substantial portions of the Software.
331175b29833Smrgdnl
331275b29833Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
331375b29833Smrgdnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
331475b29833Smrgdnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
331575b29833Smrgdnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
331675b29833Smrgdnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
331775b29833Smrgdnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
331875b29833Smrgdnl OTHER DEALINGS IN THE SOFTWARE.
331975b29833Smrgdnl
332075b29833Smrgdnl Except as contained in this notice, the name of the copyright holders shall
332175b29833Smrgdnl not be used in advertising or otherwise to promote the sale, use or
332275b29833Smrgdnl other dealings in this Software without prior written authorization
332375b29833Smrgdnl from the copyright holders.
332475b29833Smrgdnl
332575b29833Smrg
332675b29833Smrg# XORG_RELEASE_VERSION
332775b29833Smrg# --------------------
332875b29833Smrg# Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use.
332975b29833Smrg
333075b29833SmrgAC_DEFUN([XORG_RELEASE_VERSION],[
333175b29833Smrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
333275b29833Smrg		[`echo $PACKAGE_VERSION | cut -d . -f 1`],
333375b29833Smrg		[Major version of this package])
333475b29833Smrg	PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1`
333575b29833Smrg	if test "x$PVM" = "x"; then
333675b29833Smrg		PVM="0"
333775b29833Smrg	fi
333875b29833Smrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
333975b29833Smrg		[$PVM],
334075b29833Smrg		[Minor version of this package])
334175b29833Smrg	PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1`
334275b29833Smrg	if test "x$PVP" = "x"; then
334375b29833Smrg		PVP="0"
334475b29833Smrg	fi
334575b29833Smrg	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
334675b29833Smrg		[$PVP],
334775b29833Smrg		[Patch version of this package])
334875b29833Smrg])
334975b29833Smrg
335075b29833Smrg# XORG_CHANGELOG()
335175b29833Smrg# ----------------
335275b29833Smrg# Minimum version: 1.2.0
335375b29833Smrg#
335475b29833Smrg# Defines the variable CHANGELOG_CMD as the command to generate
335575b29833Smrg# ChangeLog from git.
335675b29833Smrg#
335775b29833Smrg#
335875b29833SmrgAC_DEFUN([XORG_CHANGELOG], [
335975b29833SmrgCHANGELOG_CMD="((GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp) 2>/dev/null && \
336075b29833Smrgmv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
336175b29833Smrg|| (rm -f \$(top_srcdir)/.changelog.tmp; test -e \$(top_srcdir)/ChangeLog || ( \
336275b29833Smrgtouch \$(top_srcdir)/ChangeLog; \
336375b29833Smrgecho 'git failed to create ChangeLog: installing empty ChangeLog.' >&2))"
336475b29833SmrgAC_SUBST([CHANGELOG_CMD])
336575b29833Smrg]) # XORG_CHANGELOG
336675b29833Smrg
3367