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