aclocal.m4 revision 688b3aec
1# generated automatically by aclocal 1.15 -*- Autoconf -*-
2
3# Copyright (C) 1996-2014 Free Software Foundation, Inc.
4
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12# PARTICULAR PURPOSE.
13
14m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
15m4_ifndef([AC_AUTOCONF_VERSION],
16  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
17m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
18[m4_warning([this file was generated for autoconf 2.69.
19You have another version of autoconf.  It may work, but is not guaranteed to.
20If you have problems, you may need to regenerate the build system entirely.
21To do so, use the procedure documented by the package, typically 'autoreconf'.])])
22
23# iconv.m4 serial 19 (gettext-0.18.2)
24dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc.
25dnl This file is free software; the Free Software Foundation
26dnl gives unlimited permission to copy and/or distribute it,
27dnl with or without modifications, as long as this notice is preserved.
28
29dnl From Bruno Haible.
30
31AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
32[
33  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
34  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
35  AC_REQUIRE([AC_LIB_RPATH])
36
37  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
38  dnl accordingly.
39  AC_LIB_LINKFLAGS_BODY([iconv])
40])
41
42AC_DEFUN([AM_ICONV_LINK],
43[
44  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
45  dnl those with the standalone portable GNU libiconv installed).
46  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
47
48  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
49  dnl accordingly.
50  AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
51
52  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
53  dnl because if the user has installed libiconv and not disabled its use
54  dnl via --without-libiconv-prefix, he wants to use it. The first
55  dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
56  am_save_CPPFLAGS="$CPPFLAGS"
57  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
58
59  AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
60    am_cv_func_iconv="no, consider installing GNU libiconv"
61    am_cv_lib_iconv=no
62    AC_LINK_IFELSE(
63      [AC_LANG_PROGRAM(
64         [[
65#include <stdlib.h>
66#include <iconv.h>
67         ]],
68         [[iconv_t cd = iconv_open("","");
69           iconv(cd,NULL,NULL,NULL,NULL);
70           iconv_close(cd);]])],
71      [am_cv_func_iconv=yes])
72    if test "$am_cv_func_iconv" != yes; then
73      am_save_LIBS="$LIBS"
74      LIBS="$LIBS $LIBICONV"
75      AC_LINK_IFELSE(
76        [AC_LANG_PROGRAM(
77           [[
78#include <stdlib.h>
79#include <iconv.h>
80           ]],
81           [[iconv_t cd = iconv_open("","");
82             iconv(cd,NULL,NULL,NULL,NULL);
83             iconv_close(cd);]])],
84        [am_cv_lib_iconv=yes]
85        [am_cv_func_iconv=yes])
86      LIBS="$am_save_LIBS"
87    fi
88  ])
89  if test "$am_cv_func_iconv" = yes; then
90    AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
91      dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
92      dnl Solaris 10.
93      am_save_LIBS="$LIBS"
94      if test $am_cv_lib_iconv = yes; then
95        LIBS="$LIBS $LIBICONV"
96      fi
97      am_cv_func_iconv_works=no
98      for ac_iconv_const in '' 'const'; do
99        AC_RUN_IFELSE(
100          [AC_LANG_PROGRAM(
101             [[
102#include <iconv.h>
103#include <string.h>
104
105#ifndef ICONV_CONST
106# define ICONV_CONST $ac_iconv_const
107#endif
108             ]],
109             [[int result = 0;
110  /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
111     returns.  */
112  {
113    iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
114    if (cd_utf8_to_88591 != (iconv_t)(-1))
115      {
116        static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
117        char buf[10];
118        ICONV_CONST char *inptr = input;
119        size_t inbytesleft = strlen (input);
120        char *outptr = buf;
121        size_t outbytesleft = sizeof (buf);
122        size_t res = iconv (cd_utf8_to_88591,
123                            &inptr, &inbytesleft,
124                            &outptr, &outbytesleft);
125        if (res == 0)
126          result |= 1;
127        iconv_close (cd_utf8_to_88591);
128      }
129  }
130  /* Test against Solaris 10 bug: Failures are not distinguishable from
131     successful returns.  */
132  {
133    iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
134    if (cd_ascii_to_88591 != (iconv_t)(-1))
135      {
136        static ICONV_CONST char input[] = "\263";
137        char buf[10];
138        ICONV_CONST char *inptr = input;
139        size_t inbytesleft = strlen (input);
140        char *outptr = buf;
141        size_t outbytesleft = sizeof (buf);
142        size_t res = iconv (cd_ascii_to_88591,
143                            &inptr, &inbytesleft,
144                            &outptr, &outbytesleft);
145        if (res == 0)
146          result |= 2;
147        iconv_close (cd_ascii_to_88591);
148      }
149  }
150  /* Test against AIX 6.1..7.1 bug: Buffer overrun.  */
151  {
152    iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
153    if (cd_88591_to_utf8 != (iconv_t)(-1))
154      {
155        static ICONV_CONST char input[] = "\304";
156        static char buf[2] = { (char)0xDE, (char)0xAD };
157        ICONV_CONST char *inptr = input;
158        size_t inbytesleft = 1;
159        char *outptr = buf;
160        size_t outbytesleft = 1;
161        size_t res = iconv (cd_88591_to_utf8,
162                            &inptr, &inbytesleft,
163                            &outptr, &outbytesleft);
164        if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
165          result |= 4;
166        iconv_close (cd_88591_to_utf8);
167      }
168  }
169#if 0 /* This bug could be worked around by the caller.  */
170  /* Test against HP-UX 11.11 bug: Positive return value instead of 0.  */
171  {
172    iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
173    if (cd_88591_to_utf8 != (iconv_t)(-1))
174      {
175        static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
176        char buf[50];
177        ICONV_CONST char *inptr = input;
178        size_t inbytesleft = strlen (input);
179        char *outptr = buf;
180        size_t outbytesleft = sizeof (buf);
181        size_t res = iconv (cd_88591_to_utf8,
182                            &inptr, &inbytesleft,
183                            &outptr, &outbytesleft);
184        if ((int)res > 0)
185          result |= 8;
186        iconv_close (cd_88591_to_utf8);
187      }
188  }
189#endif
190  /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
191     provided.  */
192  if (/* Try standardized names.  */
193      iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
194      /* Try IRIX, OSF/1 names.  */
195      && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
196      /* Try AIX names.  */
197      && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
198      /* Try HP-UX names.  */
199      && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
200    result |= 16;
201  return result;
202]])],
203          [am_cv_func_iconv_works=yes], ,
204          [case "$host_os" in
205             aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
206             *)            am_cv_func_iconv_works="guessing yes" ;;
207           esac])
208        test "$am_cv_func_iconv_works" = no || break
209      done
210      LIBS="$am_save_LIBS"
211    ])
212    case "$am_cv_func_iconv_works" in
213      *no) am_func_iconv=no am_cv_lib_iconv=no ;;
214      *)   am_func_iconv=yes ;;
215    esac
216  else
217    am_func_iconv=no am_cv_lib_iconv=no
218  fi
219  if test "$am_func_iconv" = yes; then
220    AC_DEFINE([HAVE_ICONV], [1],
221      [Define if you have the iconv() function and it works.])
222  fi
223  if test "$am_cv_lib_iconv" = yes; then
224    AC_MSG_CHECKING([how to link with libiconv])
225    AC_MSG_RESULT([$LIBICONV])
226  else
227    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
228    dnl either.
229    CPPFLAGS="$am_save_CPPFLAGS"
230    LIBICONV=
231    LTLIBICONV=
232  fi
233  AC_SUBST([LIBICONV])
234  AC_SUBST([LTLIBICONV])
235])
236
237dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
238dnl avoid warnings like
239dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
240dnl This is tricky because of the way 'aclocal' is implemented:
241dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
242dnl   Otherwise aclocal's initial scan pass would miss the macro definition.
243dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
244dnl   Otherwise aclocal would emit many "Use of uninitialized value $1"
245dnl   warnings.
246m4_define([gl_iconv_AC_DEFUN],
247  m4_version_prereq([2.64],
248    [[AC_DEFUN_ONCE(
249        [$1], [$2])]],
250    [m4_ifdef([gl_00GNULIB],
251       [[AC_DEFUN_ONCE(
252           [$1], [$2])]],
253       [[AC_DEFUN(
254           [$1], [$2])]])]))
255gl_iconv_AC_DEFUN([AM_ICONV],
256[
257  AM_ICONV_LINK
258  if test "$am_cv_func_iconv" = yes; then
259    AC_MSG_CHECKING([for iconv declaration])
260    AC_CACHE_VAL([am_cv_proto_iconv], [
261      AC_COMPILE_IFELSE(
262        [AC_LANG_PROGRAM(
263           [[
264#include <stdlib.h>
265#include <iconv.h>
266extern
267#ifdef __cplusplus
268"C"
269#endif
270#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
271size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
272#else
273size_t iconv();
274#endif
275           ]],
276           [[]])],
277        [am_cv_proto_iconv_arg1=""],
278        [am_cv_proto_iconv_arg1="const"])
279      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
280    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
281    AC_MSG_RESULT([
282         $am_cv_proto_iconv])
283    AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
284      [Define as const if the declaration of iconv() needs const.])
285    dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
286    m4_ifdef([gl_ICONV_H_DEFAULTS],
287      [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
288       if test -n "$am_cv_proto_iconv_arg1"; then
289         ICONV_CONST="const"
290       fi
291      ])
292  fi
293])
294
295# lib-ld.m4 serial 6
296dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc.
297dnl This file is free software; the Free Software Foundation
298dnl gives unlimited permission to copy and/or distribute it,
299dnl with or without modifications, as long as this notice is preserved.
300
301dnl Subroutines of libtool.m4,
302dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
303dnl collision with libtool.m4.
304
305dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
306AC_DEFUN([AC_LIB_PROG_LD_GNU],
307[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
308[# I'd rather use --version here, but apparently some GNU lds only accept -v.
309case `$LD -v 2>&1 </dev/null` in
310*GNU* | *'with BFD'*)
311  acl_cv_prog_gnu_ld=yes
312  ;;
313*)
314  acl_cv_prog_gnu_ld=no
315  ;;
316esac])
317with_gnu_ld=$acl_cv_prog_gnu_ld
318])
319
320dnl From libtool-2.4. Sets the variable LD.
321AC_DEFUN([AC_LIB_PROG_LD],
322[AC_REQUIRE([AC_PROG_CC])dnl
323AC_REQUIRE([AC_CANONICAL_HOST])dnl
324
325AC_ARG_WITH([gnu-ld],
326    [AS_HELP_STRING([--with-gnu-ld],
327        [assume the C compiler uses GNU ld [default=no]])],
328    [test "$withval" = no || with_gnu_ld=yes],
329    [with_gnu_ld=no])dnl
330
331# Prepare PATH_SEPARATOR.
332# The user is always right.
333if test "${PATH_SEPARATOR+set}" != set; then
334  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
335  # contains only /bin. Note that ksh looks also at the FPATH variable,
336  # so we have to set that as well for the test.
337  PATH_SEPARATOR=:
338  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
339    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
340           || PATH_SEPARATOR=';'
341       }
342fi
343
344ac_prog=ld
345if test "$GCC" = yes; then
346  # Check if gcc -print-prog-name=ld gives a path.
347  AC_MSG_CHECKING([for ld used by $CC])
348  case $host in
349  *-*-mingw*)
350    # gcc leaves a trailing carriage return which upsets mingw
351    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
352  *)
353    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
354  esac
355  case $ac_prog in
356    # Accept absolute paths.
357    [[\\/]]* | ?:[[\\/]]*)
358      re_direlt='/[[^/]][[^/]]*/\.\./'
359      # Canonicalize the pathname of ld
360      ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
361      while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
362        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
363      done
364      test -z "$LD" && LD="$ac_prog"
365      ;;
366  "")
367    # If it fails, then pretend we aren't using GCC.
368    ac_prog=ld
369    ;;
370  *)
371    # If it is relative, then search for the first ld in PATH.
372    with_gnu_ld=unknown
373    ;;
374  esac
375elif test "$with_gnu_ld" = yes; then
376  AC_MSG_CHECKING([for GNU ld])
377else
378  AC_MSG_CHECKING([for non-GNU ld])
379fi
380AC_CACHE_VAL([acl_cv_path_LD],
381[if test -z "$LD"; then
382  acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
383  for ac_dir in $PATH; do
384    IFS="$acl_save_ifs"
385    test -z "$ac_dir" && ac_dir=.
386    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
387      acl_cv_path_LD="$ac_dir/$ac_prog"
388      # Check to see if the program is GNU ld.  I'd rather use --version,
389      # but apparently some variants of GNU ld only accept -v.
390      # Break only if it was the GNU/non-GNU ld that we prefer.
391      case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
392      *GNU* | *'with BFD'*)
393        test "$with_gnu_ld" != no && break
394        ;;
395      *)
396        test "$with_gnu_ld" != yes && break
397        ;;
398      esac
399    fi
400  done
401  IFS="$acl_save_ifs"
402else
403  acl_cv_path_LD="$LD" # Let the user override the test with a path.
404fi])
405LD="$acl_cv_path_LD"
406if test -n "$LD"; then
407  AC_MSG_RESULT([$LD])
408else
409  AC_MSG_RESULT([no])
410fi
411test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
412AC_LIB_PROG_LD_GNU
413])
414
415# lib-link.m4 serial 26 (gettext-0.18.2)
416dnl Copyright (C) 2001-2016 Free Software Foundation, Inc.
417dnl This file is free software; the Free Software Foundation
418dnl gives unlimited permission to copy and/or distribute it,
419dnl with or without modifications, as long as this notice is preserved.
420
421dnl From Bruno Haible.
422
423AC_PREREQ([2.54])
424
425dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
426dnl the libraries corresponding to explicit and implicit dependencies.
427dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
428dnl augments the CPPFLAGS variable.
429dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
430dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
431AC_DEFUN([AC_LIB_LINKFLAGS],
432[
433  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
434  AC_REQUIRE([AC_LIB_RPATH])
435  pushdef([Name],[m4_translit([$1],[./+-], [____])])
436  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
437                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
438  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
439    AC_LIB_LINKFLAGS_BODY([$1], [$2])
440    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
441    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
442    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
443    ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
444  ])
445  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
446  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
447  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
448  LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
449  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
450  AC_SUBST([LIB]NAME)
451  AC_SUBST([LTLIB]NAME)
452  AC_SUBST([LIB]NAME[_PREFIX])
453  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
454  dnl results of this search when this library appears as a dependency.
455  HAVE_LIB[]NAME=yes
456  popdef([NAME])
457  popdef([Name])
458])
459
460dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
461dnl searches for libname and the libraries corresponding to explicit and
462dnl implicit dependencies, together with the specified include files and
463dnl the ability to compile and link the specified testcode. The missing-message
464dnl defaults to 'no' and may contain additional hints for the user.
465dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
466dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
467dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
468dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
469dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
470dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
471AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
472[
473  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
474  AC_REQUIRE([AC_LIB_RPATH])
475  pushdef([Name],[m4_translit([$1],[./+-], [____])])
476  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
477                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
478
479  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
480  dnl accordingly.
481  AC_LIB_LINKFLAGS_BODY([$1], [$2])
482
483  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
484  dnl because if the user has installed lib[]Name and not disabled its use
485  dnl via --without-lib[]Name-prefix, he wants to use it.
486  ac_save_CPPFLAGS="$CPPFLAGS"
487  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
488
489  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
490    ac_save_LIBS="$LIBS"
491    dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
492    dnl because these -l options might require -L options that are present in
493    dnl LIBS. -l options benefit only from the -L options listed before it.
494    dnl Otherwise, add it to the front of LIBS, because it may be a static
495    dnl library that depends on another static library that is present in LIBS.
496    dnl Static libraries benefit only from the static libraries listed after
497    dnl it.
498    case " $LIB[]NAME" in
499      *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
500      *)       LIBS="$LIB[]NAME $LIBS" ;;
501    esac
502    AC_LINK_IFELSE(
503      [AC_LANG_PROGRAM([[$3]], [[$4]])],
504      [ac_cv_lib[]Name=yes],
505      [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
506    LIBS="$ac_save_LIBS"
507  ])
508  if test "$ac_cv_lib[]Name" = yes; then
509    HAVE_LIB[]NAME=yes
510    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
511    AC_MSG_CHECKING([how to link with lib[]$1])
512    AC_MSG_RESULT([$LIB[]NAME])
513  else
514    HAVE_LIB[]NAME=no
515    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
516    dnl $INC[]NAME either.
517    CPPFLAGS="$ac_save_CPPFLAGS"
518    LIB[]NAME=
519    LTLIB[]NAME=
520    LIB[]NAME[]_PREFIX=
521  fi
522  AC_SUBST([HAVE_LIB]NAME)
523  AC_SUBST([LIB]NAME)
524  AC_SUBST([LTLIB]NAME)
525  AC_SUBST([LIB]NAME[_PREFIX])
526  popdef([NAME])
527  popdef([Name])
528])
529
530dnl Determine the platform dependent parameters needed to use rpath:
531dnl   acl_libext,
532dnl   acl_shlibext,
533dnl   acl_libname_spec,
534dnl   acl_library_names_spec,
535dnl   acl_hardcode_libdir_flag_spec,
536dnl   acl_hardcode_libdir_separator,
537dnl   acl_hardcode_direct,
538dnl   acl_hardcode_minus_L.
539AC_DEFUN([AC_LIB_RPATH],
540[
541  dnl Tell automake >= 1.10 to complain if config.rpath is missing.
542  m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
543  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
544  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
545  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
546  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
547  AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
548    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
549    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
550    . ./conftest.sh
551    rm -f ./conftest.sh
552    acl_cv_rpath=done
553  ])
554  wl="$acl_cv_wl"
555  acl_libext="$acl_cv_libext"
556  acl_shlibext="$acl_cv_shlibext"
557  acl_libname_spec="$acl_cv_libname_spec"
558  acl_library_names_spec="$acl_cv_library_names_spec"
559  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
560  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
561  acl_hardcode_direct="$acl_cv_hardcode_direct"
562  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
563  dnl Determine whether the user wants rpath handling at all.
564  AC_ARG_ENABLE([rpath],
565    [  --disable-rpath         do not hardcode runtime library paths],
566    :, enable_rpath=yes)
567])
568
569dnl AC_LIB_FROMPACKAGE(name, package)
570dnl declares that libname comes from the given package. The configure file
571dnl will then not have a --with-libname-prefix option but a
572dnl --with-package-prefix option. Several libraries can come from the same
573dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
574dnl macro call that searches for libname.
575AC_DEFUN([AC_LIB_FROMPACKAGE],
576[
577  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
578                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
579  define([acl_frompackage_]NAME, [$2])
580  popdef([NAME])
581  pushdef([PACK],[$2])
582  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
583                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
584  define([acl_libsinpackage_]PACKUP,
585    m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
586  popdef([PACKUP])
587  popdef([PACK])
588])
589
590dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
591dnl the libraries corresponding to explicit and implicit dependencies.
592dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
593dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
594dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
595AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
596[
597  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
598  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
599                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
600  pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
601  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
602                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
603  pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
604  dnl Autoconf >= 2.61 supports dots in --with options.
605  pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
606  dnl By default, look in $includedir and $libdir.
607  use_additional=yes
608  AC_LIB_WITH_FINAL_PREFIX([
609    eval additional_includedir=\"$includedir\"
610    eval additional_libdir=\"$libdir\"
611  ])
612  AC_ARG_WITH(P_A_C_K[-prefix],
613[[  --with-]]P_A_C_K[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
614  --without-]]P_A_C_K[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
615[
616    if test "X$withval" = "Xno"; then
617      use_additional=no
618    else
619      if test "X$withval" = "X"; then
620        AC_LIB_WITH_FINAL_PREFIX([
621          eval additional_includedir=\"$includedir\"
622          eval additional_libdir=\"$libdir\"
623        ])
624      else
625        additional_includedir="$withval/include"
626        additional_libdir="$withval/$acl_libdirstem"
627        if test "$acl_libdirstem2" != "$acl_libdirstem" \
628           && ! test -d "$withval/$acl_libdirstem"; then
629          additional_libdir="$withval/$acl_libdirstem2"
630        fi
631      fi
632    fi
633])
634  dnl Search the library and its dependencies in $additional_libdir and
635  dnl $LDFLAGS. Using breadth-first-seach.
636  LIB[]NAME=
637  LTLIB[]NAME=
638  INC[]NAME=
639  LIB[]NAME[]_PREFIX=
640  dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
641  dnl computed. So it has to be reset here.
642  HAVE_LIB[]NAME=
643  rpathdirs=
644  ltrpathdirs=
645  names_already_handled=
646  names_next_round='$1 $2'
647  while test -n "$names_next_round"; do
648    names_this_round="$names_next_round"
649    names_next_round=
650    for name in $names_this_round; do
651      already_handled=
652      for n in $names_already_handled; do
653        if test "$n" = "$name"; then
654          already_handled=yes
655          break
656        fi
657      done
658      if test -z "$already_handled"; then
659        names_already_handled="$names_already_handled $name"
660        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
661        dnl or AC_LIB_HAVE_LINKFLAGS call.
662        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
663        eval value=\"\$HAVE_LIB$uppername\"
664        if test -n "$value"; then
665          if test "$value" = yes; then
666            eval value=\"\$LIB$uppername\"
667            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
668            eval value=\"\$LTLIB$uppername\"
669            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
670          else
671            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
672            dnl that this library doesn't exist. So just drop it.
673            :
674          fi
675        else
676          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
677          dnl and the already constructed $LIBNAME/$LTLIBNAME.
678          found_dir=
679          found_la=
680          found_so=
681          found_a=
682          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
683          if test -n "$acl_shlibext"; then
684            shrext=".$acl_shlibext"             # typically: shrext=.so
685          else
686            shrext=
687          fi
688          if test $use_additional = yes; then
689            dir="$additional_libdir"
690            dnl The same code as in the loop below:
691            dnl First look for a shared library.
692            if test -n "$acl_shlibext"; then
693              if test -f "$dir/$libname$shrext"; then
694                found_dir="$dir"
695                found_so="$dir/$libname$shrext"
696              else
697                if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
698                  ver=`(cd "$dir" && \
699                        for f in "$libname$shrext".*; do echo "$f"; done \
700                        | sed -e "s,^$libname$shrext\\\\.,," \
701                        | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
702                        | sed 1q ) 2>/dev/null`
703                  if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
704                    found_dir="$dir"
705                    found_so="$dir/$libname$shrext.$ver"
706                  fi
707                else
708                  eval library_names=\"$acl_library_names_spec\"
709                  for f in $library_names; do
710                    if test -f "$dir/$f"; then
711                      found_dir="$dir"
712                      found_so="$dir/$f"
713                      break
714                    fi
715                  done
716                fi
717              fi
718            fi
719            dnl Then look for a static library.
720            if test "X$found_dir" = "X"; then
721              if test -f "$dir/$libname.$acl_libext"; then
722                found_dir="$dir"
723                found_a="$dir/$libname.$acl_libext"
724              fi
725            fi
726            if test "X$found_dir" != "X"; then
727              if test -f "$dir/$libname.la"; then
728                found_la="$dir/$libname.la"
729              fi
730            fi
731          fi
732          if test "X$found_dir" = "X"; then
733            for x in $LDFLAGS $LTLIB[]NAME; do
734              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
735              case "$x" in
736                -L*)
737                  dir=`echo "X$x" | sed -e 's/^X-L//'`
738                  dnl First look for a shared library.
739                  if test -n "$acl_shlibext"; then
740                    if test -f "$dir/$libname$shrext"; then
741                      found_dir="$dir"
742                      found_so="$dir/$libname$shrext"
743                    else
744                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
745                        ver=`(cd "$dir" && \
746                              for f in "$libname$shrext".*; do echo "$f"; done \
747                              | sed -e "s,^$libname$shrext\\\\.,," \
748                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
749                              | sed 1q ) 2>/dev/null`
750                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
751                          found_dir="$dir"
752                          found_so="$dir/$libname$shrext.$ver"
753                        fi
754                      else
755                        eval library_names=\"$acl_library_names_spec\"
756                        for f in $library_names; do
757                          if test -f "$dir/$f"; then
758                            found_dir="$dir"
759                            found_so="$dir/$f"
760                            break
761                          fi
762                        done
763                      fi
764                    fi
765                  fi
766                  dnl Then look for a static library.
767                  if test "X$found_dir" = "X"; then
768                    if test -f "$dir/$libname.$acl_libext"; then
769                      found_dir="$dir"
770                      found_a="$dir/$libname.$acl_libext"
771                    fi
772                  fi
773                  if test "X$found_dir" != "X"; then
774                    if test -f "$dir/$libname.la"; then
775                      found_la="$dir/$libname.la"
776                    fi
777                  fi
778                  ;;
779              esac
780              if test "X$found_dir" != "X"; then
781                break
782              fi
783            done
784          fi
785          if test "X$found_dir" != "X"; then
786            dnl Found the library.
787            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
788            if test "X$found_so" != "X"; then
789              dnl Linking with a shared library. We attempt to hardcode its
790              dnl directory into the executable's runpath, unless it's the
791              dnl standard /usr/lib.
792              if test "$enable_rpath" = no \
793                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
794                 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
795                dnl No hardcoding is needed.
796                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
797              else
798                dnl Use an explicit option to hardcode DIR into the resulting
799                dnl binary.
800                dnl Potentially add DIR to ltrpathdirs.
801                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
802                haveit=
803                for x in $ltrpathdirs; do
804                  if test "X$x" = "X$found_dir"; then
805                    haveit=yes
806                    break
807                  fi
808                done
809                if test -z "$haveit"; then
810                  ltrpathdirs="$ltrpathdirs $found_dir"
811                fi
812                dnl The hardcoding into $LIBNAME is system dependent.
813                if test "$acl_hardcode_direct" = yes; then
814                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
815                  dnl resulting binary.
816                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
817                else
818                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
819                    dnl Use an explicit option to hardcode DIR into the resulting
820                    dnl binary.
821                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
822                    dnl Potentially add DIR to rpathdirs.
823                    dnl The rpathdirs will be appended to $LIBNAME at the end.
824                    haveit=
825                    for x in $rpathdirs; do
826                      if test "X$x" = "X$found_dir"; then
827                        haveit=yes
828                        break
829                      fi
830                    done
831                    if test -z "$haveit"; then
832                      rpathdirs="$rpathdirs $found_dir"
833                    fi
834                  else
835                    dnl Rely on "-L$found_dir".
836                    dnl But don't add it if it's already contained in the LDFLAGS
837                    dnl or the already constructed $LIBNAME
838                    haveit=
839                    for x in $LDFLAGS $LIB[]NAME; do
840                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
841                      if test "X$x" = "X-L$found_dir"; then
842                        haveit=yes
843                        break
844                      fi
845                    done
846                    if test -z "$haveit"; then
847                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
848                    fi
849                    if test "$acl_hardcode_minus_L" != no; then
850                      dnl FIXME: Not sure whether we should use
851                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
852                      dnl here.
853                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
854                    else
855                      dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
856                      dnl here, because this doesn't fit in flags passed to the
857                      dnl compiler. So give up. No hardcoding. This affects only
858                      dnl very old systems.
859                      dnl FIXME: Not sure whether we should use
860                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
861                      dnl here.
862                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
863                    fi
864                  fi
865                fi
866              fi
867            else
868              if test "X$found_a" != "X"; then
869                dnl Linking with a static library.
870                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
871              else
872                dnl We shouldn't come here, but anyway it's good to have a
873                dnl fallback.
874                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
875              fi
876            fi
877            dnl Assume the include files are nearby.
878            additional_includedir=
879            case "$found_dir" in
880              */$acl_libdirstem | */$acl_libdirstem/)
881                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
882                if test "$name" = '$1'; then
883                  LIB[]NAME[]_PREFIX="$basedir"
884                fi
885                additional_includedir="$basedir/include"
886                ;;
887              */$acl_libdirstem2 | */$acl_libdirstem2/)
888                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
889                if test "$name" = '$1'; then
890                  LIB[]NAME[]_PREFIX="$basedir"
891                fi
892                additional_includedir="$basedir/include"
893                ;;
894            esac
895            if test "X$additional_includedir" != "X"; then
896              dnl Potentially add $additional_includedir to $INCNAME.
897              dnl But don't add it
898              dnl   1. if it's the standard /usr/include,
899              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
900              dnl   3. if it's already present in $CPPFLAGS or the already
901              dnl      constructed $INCNAME,
902              dnl   4. if it doesn't exist as a directory.
903              if test "X$additional_includedir" != "X/usr/include"; then
904                haveit=
905                if test "X$additional_includedir" = "X/usr/local/include"; then
906                  if test -n "$GCC"; then
907                    case $host_os in
908                      linux* | gnu* | k*bsd*-gnu) haveit=yes;;
909                    esac
910                  fi
911                fi
912                if test -z "$haveit"; then
913                  for x in $CPPFLAGS $INC[]NAME; do
914                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
915                    if test "X$x" = "X-I$additional_includedir"; then
916                      haveit=yes
917                      break
918                    fi
919                  done
920                  if test -z "$haveit"; then
921                    if test -d "$additional_includedir"; then
922                      dnl Really add $additional_includedir to $INCNAME.
923                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
924                    fi
925                  fi
926                fi
927              fi
928            fi
929            dnl Look for dependencies.
930            if test -n "$found_la"; then
931              dnl Read the .la file. It defines the variables
932              dnl dlname, library_names, old_library, dependency_libs, current,
933              dnl age, revision, installed, dlopen, dlpreopen, libdir.
934              save_libdir="$libdir"
935              case "$found_la" in
936                */* | *\\*) . "$found_la" ;;
937                *) . "./$found_la" ;;
938              esac
939              libdir="$save_libdir"
940              dnl We use only dependency_libs.
941              for dep in $dependency_libs; do
942                case "$dep" in
943                  -L*)
944                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
945                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
946                    dnl But don't add it
947                    dnl   1. if it's the standard /usr/lib,
948                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
949                    dnl   3. if it's already present in $LDFLAGS or the already
950                    dnl      constructed $LIBNAME,
951                    dnl   4. if it doesn't exist as a directory.
952                    if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
953                       && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
954                      haveit=
955                      if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
956                         || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
957                        if test -n "$GCC"; then
958                          case $host_os in
959                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
960                          esac
961                        fi
962                      fi
963                      if test -z "$haveit"; then
964                        haveit=
965                        for x in $LDFLAGS $LIB[]NAME; do
966                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
967                          if test "X$x" = "X-L$additional_libdir"; then
968                            haveit=yes
969                            break
970                          fi
971                        done
972                        if test -z "$haveit"; then
973                          if test -d "$additional_libdir"; then
974                            dnl Really add $additional_libdir to $LIBNAME.
975                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
976                          fi
977                        fi
978                        haveit=
979                        for x in $LDFLAGS $LTLIB[]NAME; do
980                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
981                          if test "X$x" = "X-L$additional_libdir"; then
982                            haveit=yes
983                            break
984                          fi
985                        done
986                        if test -z "$haveit"; then
987                          if test -d "$additional_libdir"; then
988                            dnl Really add $additional_libdir to $LTLIBNAME.
989                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
990                          fi
991                        fi
992                      fi
993                    fi
994                    ;;
995                  -R*)
996                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
997                    if test "$enable_rpath" != no; then
998                      dnl Potentially add DIR to rpathdirs.
999                      dnl The rpathdirs will be appended to $LIBNAME at the end.
1000                      haveit=
1001                      for x in $rpathdirs; do
1002                        if test "X$x" = "X$dir"; then
1003                          haveit=yes
1004                          break
1005                        fi
1006                      done
1007                      if test -z "$haveit"; then
1008                        rpathdirs="$rpathdirs $dir"
1009                      fi
1010                      dnl Potentially add DIR to ltrpathdirs.
1011                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
1012                      haveit=
1013                      for x in $ltrpathdirs; do
1014                        if test "X$x" = "X$dir"; then
1015                          haveit=yes
1016                          break
1017                        fi
1018                      done
1019                      if test -z "$haveit"; then
1020                        ltrpathdirs="$ltrpathdirs $dir"
1021                      fi
1022                    fi
1023                    ;;
1024                  -l*)
1025                    dnl Handle this in the next round.
1026                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
1027                    ;;
1028                  *.la)
1029                    dnl Handle this in the next round. Throw away the .la's
1030                    dnl directory; it is already contained in a preceding -L
1031                    dnl option.
1032                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
1033                    ;;
1034                  *)
1035                    dnl Most likely an immediate library name.
1036                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
1037                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
1038                    ;;
1039                esac
1040              done
1041            fi
1042          else
1043            dnl Didn't find the library; assume it is in the system directories
1044            dnl known to the linker and runtime loader. (All the system
1045            dnl directories known to the linker should also be known to the
1046            dnl runtime loader, otherwise the system is severely misconfigured.)
1047            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
1048            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
1049          fi
1050        fi
1051      fi
1052    done
1053  done
1054  if test "X$rpathdirs" != "X"; then
1055    if test -n "$acl_hardcode_libdir_separator"; then
1056      dnl Weird platform: only the last -rpath option counts, the user must
1057      dnl pass all path elements in one option. We can arrange that for a
1058      dnl single library, but not when more than one $LIBNAMEs are used.
1059      alldirs=
1060      for found_dir in $rpathdirs; do
1061        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
1062      done
1063      dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
1064      acl_save_libdir="$libdir"
1065      libdir="$alldirs"
1066      eval flag=\"$acl_hardcode_libdir_flag_spec\"
1067      libdir="$acl_save_libdir"
1068      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
1069    else
1070      dnl The -rpath options are cumulative.
1071      for found_dir in $rpathdirs; do
1072        acl_save_libdir="$libdir"
1073        libdir="$found_dir"
1074        eval flag=\"$acl_hardcode_libdir_flag_spec\"
1075        libdir="$acl_save_libdir"
1076        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
1077      done
1078    fi
1079  fi
1080  if test "X$ltrpathdirs" != "X"; then
1081    dnl When using libtool, the option that works for both libraries and
1082    dnl executables is -R. The -R options are cumulative.
1083    for found_dir in $ltrpathdirs; do
1084      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
1085    done
1086  fi
1087  popdef([P_A_C_K])
1088  popdef([PACKLIBS])
1089  popdef([PACKUP])
1090  popdef([PACK])
1091  popdef([NAME])
1092])
1093
1094dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
1095dnl unless already present in VAR.
1096dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
1097dnl contains two or three consecutive elements that belong together.
1098AC_DEFUN([AC_LIB_APPENDTOVAR],
1099[
1100  for element in [$2]; do
1101    haveit=
1102    for x in $[$1]; do
1103      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1104      if test "X$x" = "X$element"; then
1105        haveit=yes
1106        break
1107      fi
1108    done
1109    if test -z "$haveit"; then
1110      [$1]="${[$1]}${[$1]:+ }$element"
1111    fi
1112  done
1113])
1114
1115dnl For those cases where a variable contains several -L and -l options
1116dnl referring to unknown libraries and directories, this macro determines the
1117dnl necessary additional linker options for the runtime path.
1118dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
1119dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
1120dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
1121dnl otherwise linking without libtool is assumed.
1122AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
1123[
1124  AC_REQUIRE([AC_LIB_RPATH])
1125  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
1126  $1=
1127  if test "$enable_rpath" != no; then
1128    if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
1129      dnl Use an explicit option to hardcode directories into the resulting
1130      dnl binary.
1131      rpathdirs=
1132      next=
1133      for opt in $2; do
1134        if test -n "$next"; then
1135          dir="$next"
1136          dnl No need to hardcode the standard /usr/lib.
1137          if test "X$dir" != "X/usr/$acl_libdirstem" \
1138             && test "X$dir" != "X/usr/$acl_libdirstem2"; then
1139            rpathdirs="$rpathdirs $dir"
1140          fi
1141          next=
1142        else
1143          case $opt in
1144            -L) next=yes ;;
1145            -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
1146                 dnl No need to hardcode the standard /usr/lib.
1147                 if test "X$dir" != "X/usr/$acl_libdirstem" \
1148                    && test "X$dir" != "X/usr/$acl_libdirstem2"; then
1149                   rpathdirs="$rpathdirs $dir"
1150                 fi
1151                 next= ;;
1152            *) next= ;;
1153          esac
1154        fi
1155      done
1156      if test "X$rpathdirs" != "X"; then
1157        if test -n ""$3""; then
1158          dnl libtool is used for linking. Use -R options.
1159          for dir in $rpathdirs; do
1160            $1="${$1}${$1:+ }-R$dir"
1161          done
1162        else
1163          dnl The linker is used for linking directly.
1164          if test -n "$acl_hardcode_libdir_separator"; then
1165            dnl Weird platform: only the last -rpath option counts, the user
1166            dnl must pass all path elements in one option.
1167            alldirs=
1168            for dir in $rpathdirs; do
1169              alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
1170            done
1171            acl_save_libdir="$libdir"
1172            libdir="$alldirs"
1173            eval flag=\"$acl_hardcode_libdir_flag_spec\"
1174            libdir="$acl_save_libdir"
1175            $1="$flag"
1176          else
1177            dnl The -rpath options are cumulative.
1178            for dir in $rpathdirs; do
1179              acl_save_libdir="$libdir"
1180              libdir="$dir"
1181              eval flag=\"$acl_hardcode_libdir_flag_spec\"
1182              libdir="$acl_save_libdir"
1183              $1="${$1}${$1:+ }$flag"
1184            done
1185          fi
1186        fi
1187      fi
1188    fi
1189  fi
1190  AC_SUBST([$1])
1191])
1192
1193# lib-prefix.m4 serial 7 (gettext-0.18)
1194dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc.
1195dnl This file is free software; the Free Software Foundation
1196dnl gives unlimited permission to copy and/or distribute it,
1197dnl with or without modifications, as long as this notice is preserved.
1198
1199dnl From Bruno Haible.
1200
1201dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
1202dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
1203dnl require excessive bracketing.
1204ifdef([AC_HELP_STRING],
1205[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
1206[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
1207
1208dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
1209dnl to access previously installed libraries. The basic assumption is that
1210dnl a user will want packages to use other packages he previously installed
1211dnl with the same --prefix option.
1212dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
1213dnl libraries, but is otherwise very convenient.
1214AC_DEFUN([AC_LIB_PREFIX],
1215[
1216  AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
1217  AC_REQUIRE([AC_PROG_CC])
1218  AC_REQUIRE([AC_CANONICAL_HOST])
1219  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
1220  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
1221  dnl By default, look in $includedir and $libdir.
1222  use_additional=yes
1223  AC_LIB_WITH_FINAL_PREFIX([
1224    eval additional_includedir=\"$includedir\"
1225    eval additional_libdir=\"$libdir\"
1226  ])
1227  AC_LIB_ARG_WITH([lib-prefix],
1228[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
1229  --without-lib-prefix    don't search for libraries in includedir and libdir],
1230[
1231    if test "X$withval" = "Xno"; then
1232      use_additional=no
1233    else
1234      if test "X$withval" = "X"; then
1235        AC_LIB_WITH_FINAL_PREFIX([
1236          eval additional_includedir=\"$includedir\"
1237          eval additional_libdir=\"$libdir\"
1238        ])
1239      else
1240        additional_includedir="$withval/include"
1241        additional_libdir="$withval/$acl_libdirstem"
1242      fi
1243    fi
1244])
1245  if test $use_additional = yes; then
1246    dnl Potentially add $additional_includedir to $CPPFLAGS.
1247    dnl But don't add it
1248    dnl   1. if it's the standard /usr/include,
1249    dnl   2. if it's already present in $CPPFLAGS,
1250    dnl   3. if it's /usr/local/include and we are using GCC on Linux,
1251    dnl   4. if it doesn't exist as a directory.
1252    if test "X$additional_includedir" != "X/usr/include"; then
1253      haveit=
1254      for x in $CPPFLAGS; do
1255        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1256        if test "X$x" = "X-I$additional_includedir"; then
1257          haveit=yes
1258          break
1259        fi
1260      done
1261      if test -z "$haveit"; then
1262        if test "X$additional_includedir" = "X/usr/local/include"; then
1263          if test -n "$GCC"; then
1264            case $host_os in
1265              linux* | gnu* | k*bsd*-gnu) haveit=yes;;
1266            esac
1267          fi
1268        fi
1269        if test -z "$haveit"; then
1270          if test -d "$additional_includedir"; then
1271            dnl Really add $additional_includedir to $CPPFLAGS.
1272            CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
1273          fi
1274        fi
1275      fi
1276    fi
1277    dnl Potentially add $additional_libdir to $LDFLAGS.
1278    dnl But don't add it
1279    dnl   1. if it's the standard /usr/lib,
1280    dnl   2. if it's already present in $LDFLAGS,
1281    dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
1282    dnl   4. if it doesn't exist as a directory.
1283    if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
1284      haveit=
1285      for x in $LDFLAGS; do
1286        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1287        if test "X$x" = "X-L$additional_libdir"; then
1288          haveit=yes
1289          break
1290        fi
1291      done
1292      if test -z "$haveit"; then
1293        if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
1294          if test -n "$GCC"; then
1295            case $host_os in
1296              linux*) haveit=yes;;
1297            esac
1298          fi
1299        fi
1300        if test -z "$haveit"; then
1301          if test -d "$additional_libdir"; then
1302            dnl Really add $additional_libdir to $LDFLAGS.
1303            LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
1304          fi
1305        fi
1306      fi
1307    fi
1308  fi
1309])
1310
1311dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
1312dnl acl_final_exec_prefix, containing the values to which $prefix and
1313dnl $exec_prefix will expand at the end of the configure script.
1314AC_DEFUN([AC_LIB_PREPARE_PREFIX],
1315[
1316  dnl Unfortunately, prefix and exec_prefix get only finally determined
1317  dnl at the end of configure.
1318  if test "X$prefix" = "XNONE"; then
1319    acl_final_prefix="$ac_default_prefix"
1320  else
1321    acl_final_prefix="$prefix"
1322  fi
1323  if test "X$exec_prefix" = "XNONE"; then
1324    acl_final_exec_prefix='${prefix}'
1325  else
1326    acl_final_exec_prefix="$exec_prefix"
1327  fi
1328  acl_save_prefix="$prefix"
1329  prefix="$acl_final_prefix"
1330  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
1331  prefix="$acl_save_prefix"
1332])
1333
1334dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
1335dnl variables prefix and exec_prefix bound to the values they will have
1336dnl at the end of the configure script.
1337AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
1338[
1339  acl_save_prefix="$prefix"
1340  prefix="$acl_final_prefix"
1341  acl_save_exec_prefix="$exec_prefix"
1342  exec_prefix="$acl_final_exec_prefix"
1343  $1
1344  exec_prefix="$acl_save_exec_prefix"
1345  prefix="$acl_save_prefix"
1346])
1347
1348dnl AC_LIB_PREPARE_MULTILIB creates
1349dnl - a variable acl_libdirstem, containing the basename of the libdir, either
1350dnl   "lib" or "lib64" or "lib/64",
1351dnl - a variable acl_libdirstem2, as a secondary possible value for
1352dnl   acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
1353dnl   "lib/amd64".
1354AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
1355[
1356  dnl There is no formal standard regarding lib and lib64.
1357  dnl On glibc systems, the current practice is that on a system supporting
1358  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
1359  dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
1360  dnl the compiler's default mode by looking at the compiler's library search
1361  dnl path. If at least one of its elements ends in /lib64 or points to a
1362  dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
1363  dnl Otherwise we use the default, namely "lib".
1364  dnl On Solaris systems, the current practice is that on a system supporting
1365  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
1366  dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
1367  dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
1368  AC_REQUIRE([AC_CANONICAL_HOST])
1369  acl_libdirstem=lib
1370  acl_libdirstem2=
1371  case "$host_os" in
1372    solaris*)
1373      dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
1374      dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
1375      dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
1376      dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
1377      dnl symlink is missing, so we set acl_libdirstem2 too.
1378      AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
1379        [AC_EGREP_CPP([sixtyfour bits], [
1380#ifdef _LP64
1381sixtyfour bits
1382#endif
1383           ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
1384        ])
1385      if test $gl_cv_solaris_64bit = yes; then
1386        acl_libdirstem=lib/64
1387        case "$host_cpu" in
1388          sparc*)        acl_libdirstem2=lib/sparcv9 ;;
1389          i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
1390        esac
1391      fi
1392      ;;
1393    *)
1394      searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
1395      if test -n "$searchpath"; then
1396        acl_save_IFS="${IFS= 	}"; IFS=":"
1397        for searchdir in $searchpath; do
1398          if test -d "$searchdir"; then
1399            case "$searchdir" in
1400              */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
1401              */../ | */.. )
1402                # Better ignore directories of this form. They are misleading.
1403                ;;
1404              *) searchdir=`cd "$searchdir" && pwd`
1405                 case "$searchdir" in
1406                   */lib64 ) acl_libdirstem=lib64 ;;
1407                 esac ;;
1408            esac
1409          fi
1410        done
1411        IFS="$acl_save_IFS"
1412      fi
1413      ;;
1414  esac
1415  test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
1416])
1417
1418dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
1419dnl serial 11 (pkg-config-0.29)
1420dnl
1421dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1422dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
1423dnl
1424dnl This program is free software; you can redistribute it and/or modify
1425dnl it under the terms of the GNU General Public License as published by
1426dnl the Free Software Foundation; either version 2 of the License, or
1427dnl (at your option) any later version.
1428dnl
1429dnl This program is distributed in the hope that it will be useful, but
1430dnl WITHOUT ANY WARRANTY; without even the implied warranty of
1431dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1432dnl General Public License for more details.
1433dnl
1434dnl You should have received a copy of the GNU General Public License
1435dnl along with this program; if not, write to the Free Software
1436dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1437dnl 02111-1307, USA.
1438dnl
1439dnl As a special exception to the GNU General Public License, if you
1440dnl distribute this file as part of a program that contains a
1441dnl configuration script generated by Autoconf, you may include it under
1442dnl the same distribution terms that you use for the rest of that
1443dnl program.
1444
1445dnl PKG_PREREQ(MIN-VERSION)
1446dnl -----------------------
1447dnl Since: 0.29
1448dnl
1449dnl Verify that the version of the pkg-config macros are at least
1450dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
1451dnl installed version of pkg-config, this checks the developer's version
1452dnl of pkg.m4 when generating configure.
1453dnl
1454dnl To ensure that this macro is defined, also add:
1455dnl m4_ifndef([PKG_PREREQ],
1456dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
1457dnl
1458dnl See the "Since" comment for each macro you use to see what version
1459dnl of the macros you require.
1460m4_defun([PKG_PREREQ],
1461[m4_define([PKG_MACROS_VERSION], [0.29])
1462m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
1463    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
1464])dnl PKG_PREREQ
1465
1466dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
1467dnl ----------------------------------
1468dnl Since: 0.16
1469dnl
1470dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
1471dnl first found in the path. Checks that the version of pkg-config found
1472dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
1473dnl used since that's the first version where most current features of
1474dnl pkg-config existed.
1475AC_DEFUN([PKG_PROG_PKG_CONFIG],
1476[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
1477m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
1478m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
1479AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
1480AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
1481AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
1482
1483if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1484	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1485fi
1486if test -n "$PKG_CONFIG"; then
1487	_pkg_min_version=m4_default([$1], [0.9.0])
1488	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1489	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1490		AC_MSG_RESULT([yes])
1491	else
1492		AC_MSG_RESULT([no])
1493		PKG_CONFIG=""
1494	fi
1495fi[]dnl
1496])dnl PKG_PROG_PKG_CONFIG
1497
1498dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1499dnl -------------------------------------------------------------------
1500dnl Since: 0.18
1501dnl
1502dnl Check to see whether a particular set of modules exists. Similar to
1503dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
1504dnl
1505dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1506dnl only at the first occurence in configure.ac, so if the first place
1507dnl it's called might be skipped (such as if it is within an "if", you
1508dnl have to call PKG_CHECK_EXISTS manually
1509AC_DEFUN([PKG_CHECK_EXISTS],
1510[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1511if test -n "$PKG_CONFIG" && \
1512    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
1513  m4_default([$2], [:])
1514m4_ifvaln([$3], [else
1515  $3])dnl
1516fi])
1517
1518dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
1519dnl ---------------------------------------------
1520dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
1521dnl pkg_failed based on the result.
1522m4_define([_PKG_CONFIG],
1523[if test -n "$$1"; then
1524    pkg_cv_[]$1="$$1"
1525 elif test -n "$PKG_CONFIG"; then
1526    PKG_CHECK_EXISTS([$3],
1527                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
1528		      test "x$?" != "x0" && pkg_failed=yes ],
1529		     [pkg_failed=yes])
1530 else
1531    pkg_failed=untried
1532fi[]dnl
1533])dnl _PKG_CONFIG
1534
1535dnl _PKG_SHORT_ERRORS_SUPPORTED
1536dnl ---------------------------
1537dnl Internal check to see if pkg-config supports short errors.
1538AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
1539[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1540if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1541        _pkg_short_errors_supported=yes
1542else
1543        _pkg_short_errors_supported=no
1544fi[]dnl
1545])dnl _PKG_SHORT_ERRORS_SUPPORTED
1546
1547
1548dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1549dnl   [ACTION-IF-NOT-FOUND])
1550dnl --------------------------------------------------------------
1551dnl Since: 0.4.0
1552dnl
1553dnl Note that if there is a possibility the first call to
1554dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
1555dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
1556AC_DEFUN([PKG_CHECK_MODULES],
1557[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1558AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
1559AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
1560
1561pkg_failed=no
1562AC_MSG_CHECKING([for $1])
1563
1564_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
1565_PKG_CONFIG([$1][_LIBS], [libs], [$2])
1566
1567m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
1568and $1[]_LIBS to avoid the need to call pkg-config.
1569See the pkg-config man page for more details.])
1570
1571if test $pkg_failed = yes; then
1572   	AC_MSG_RESULT([no])
1573        _PKG_SHORT_ERRORS_SUPPORTED
1574        if test $_pkg_short_errors_supported = yes; then
1575	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
1576        else 
1577	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
1578        fi
1579	# Put the nasty error message in config.log where it belongs
1580	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
1581
1582	m4_default([$4], [AC_MSG_ERROR(
1583[Package requirements ($2) were not met:
1584
1585$$1_PKG_ERRORS
1586
1587Consider adjusting the PKG_CONFIG_PATH environment variable if you
1588installed software in a non-standard prefix.
1589
1590_PKG_TEXT])[]dnl
1591        ])
1592elif test $pkg_failed = untried; then
1593     	AC_MSG_RESULT([no])
1594	m4_default([$4], [AC_MSG_FAILURE(
1595[The pkg-config script could not be found or is too old.  Make sure it
1596is in your PATH or set the PKG_CONFIG environment variable to the full
1597path to pkg-config.
1598
1599_PKG_TEXT
1600
1601To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
1602        ])
1603else
1604	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
1605	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
1606        AC_MSG_RESULT([yes])
1607	$3
1608fi[]dnl
1609])dnl PKG_CHECK_MODULES
1610
1611
1612dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1613dnl   [ACTION-IF-NOT-FOUND])
1614dnl ---------------------------------------------------------------------
1615dnl Since: 0.29
1616dnl
1617dnl Checks for existence of MODULES and gathers its build flags with
1618dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
1619dnl and VARIABLE-PREFIX_LIBS from --libs.
1620dnl
1621dnl Note that if there is a possibility the first call to
1622dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
1623dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
1624dnl configure.ac.
1625AC_DEFUN([PKG_CHECK_MODULES_STATIC],
1626[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1627_save_PKG_CONFIG=$PKG_CONFIG
1628PKG_CONFIG="$PKG_CONFIG --static"
1629PKG_CHECK_MODULES($@)
1630PKG_CONFIG=$_save_PKG_CONFIG[]dnl
1631])dnl PKG_CHECK_MODULES_STATIC
1632
1633
1634dnl PKG_INSTALLDIR([DIRECTORY])
1635dnl -------------------------
1636dnl Since: 0.27
1637dnl
1638dnl Substitutes the variable pkgconfigdir as the location where a module
1639dnl should install pkg-config .pc files. By default the directory is
1640dnl $libdir/pkgconfig, but the default can be changed by passing
1641dnl DIRECTORY. The user can override through the --with-pkgconfigdir
1642dnl parameter.
1643AC_DEFUN([PKG_INSTALLDIR],
1644[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
1645m4_pushdef([pkg_description],
1646    [pkg-config installation directory @<:@]pkg_default[@:>@])
1647AC_ARG_WITH([pkgconfigdir],
1648    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
1649    [with_pkgconfigdir=]pkg_default)
1650AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
1651m4_popdef([pkg_default])
1652m4_popdef([pkg_description])
1653])dnl PKG_INSTALLDIR
1654
1655
1656dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
1657dnl --------------------------------
1658dnl Since: 0.27
1659dnl
1660dnl Substitutes the variable noarch_pkgconfigdir as the location where a
1661dnl module should install arch-independent pkg-config .pc files. By
1662dnl default the directory is $datadir/pkgconfig, but the default can be
1663dnl changed by passing DIRECTORY. The user can override through the
1664dnl --with-noarch-pkgconfigdir parameter.
1665AC_DEFUN([PKG_NOARCH_INSTALLDIR],
1666[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
1667m4_pushdef([pkg_description],
1668    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
1669AC_ARG_WITH([noarch-pkgconfigdir],
1670    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
1671    [with_noarch_pkgconfigdir=]pkg_default)
1672AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
1673m4_popdef([pkg_default])
1674m4_popdef([pkg_description])
1675])dnl PKG_NOARCH_INSTALLDIR
1676
1677
1678dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
1679dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1680dnl -------------------------------------------
1681dnl Since: 0.28
1682dnl
1683dnl Retrieves the value of the pkg-config variable for the given module.
1684AC_DEFUN([PKG_CHECK_VAR],
1685[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1686AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
1687
1688_PKG_CONFIG([$1], [variable="][$3]["], [$2])
1689AS_VAR_COPY([$1], [pkg_cv_][$1])
1690
1691AS_VAR_IF([$1], [""], [$5], [$4])dnl
1692])dnl PKG_CHECK_VAR
1693
1694dnl xorg-macros.m4.  Generated from xorg-macros.m4.in xorgversion.m4 by configure.
1695dnl
1696dnl Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
1697dnl
1698dnl Permission is hereby granted, free of charge, to any person obtaining a
1699dnl copy of this software and associated documentation files (the "Software"),
1700dnl to deal in the Software without restriction, including without limitation
1701dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
1702dnl and/or sell copies of the Software, and to permit persons to whom the
1703dnl Software is furnished to do so, subject to the following conditions:
1704dnl
1705dnl The above copyright notice and this permission notice (including the next
1706dnl paragraph) shall be included in all copies or substantial portions of the
1707dnl Software.
1708dnl
1709dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1710dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1711dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1712dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1713dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1714dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1715dnl DEALINGS IN THE SOFTWARE.
1716
1717# XORG_MACROS_VERSION(required-version)
1718# -------------------------------------
1719# Minimum version: 1.1.0
1720#
1721# If you're using a macro added in Version 1.1 or newer, include this in
1722# your configure.ac with the minimum required version, such as:
1723# XORG_MACROS_VERSION(1.1)
1724#
1725# To ensure that this macro is defined, also add:
1726# m4_ifndef([XORG_MACROS_VERSION],
1727#     [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
1728#
1729#
1730# See the "minimum version" comment for each macro you use to see what
1731# version you require.
1732m4_defun([XORG_MACROS_VERSION],[
1733m4_define([vers_have], [1.19.0])
1734m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
1735m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
1736m4_if(m4_cmp(maj_have, maj_needed), 0,,
1737    [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
1738m4_if(m4_version_compare(vers_have, [$1]), -1,
1739    [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
1740m4_undefine([vers_have])
1741m4_undefine([maj_have])
1742m4_undefine([maj_needed])
1743]) # XORG_MACROS_VERSION
1744
1745# XORG_PROG_RAWCPP()
1746# ------------------
1747# Minimum version: 1.0.0
1748#
1749# Find cpp program and necessary flags for use in pre-processing text files
1750# such as man pages and config files
1751AC_DEFUN([XORG_PROG_RAWCPP],[
1752AC_REQUIRE([AC_PROG_CPP])
1753AC_PATH_PROGS(RAWCPP, [cpp], [${CPP}],
1754   [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
1755
1756# Check for flag to avoid builtin definitions - assumes unix is predefined,
1757# which is not the best choice for supporting other OS'es, but covers most
1758# of the ones we need for now.
1759AC_MSG_CHECKING([if $RAWCPP requires -undef])
1760AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
1761if test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
1762	AC_MSG_RESULT([no])
1763else
1764	if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
1765		RAWCPPFLAGS=-undef
1766		AC_MSG_RESULT([yes])
1767	# under Cygwin unix is still defined even with -undef
1768	elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
1769		RAWCPPFLAGS="-undef -ansi"
1770		AC_MSG_RESULT([yes, with -ansi])
1771	else
1772		AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef.  I don't know what to do.])
1773	fi
1774fi
1775rm -f conftest.$ac_ext
1776
1777AC_MSG_CHECKING([if $RAWCPP requires -traditional])
1778AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
1779if test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
1780	AC_MSG_RESULT([no])
1781else
1782	if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve   \"'` -eq 1 ; then
1783		TRADITIONALCPPFLAGS="-traditional"
1784		RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
1785		AC_MSG_RESULT([yes])
1786	else
1787		AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
1788	fi
1789fi
1790rm -f conftest.$ac_ext
1791AC_SUBST(RAWCPPFLAGS)
1792AC_SUBST(TRADITIONALCPPFLAGS)
1793]) # XORG_PROG_RAWCPP
1794
1795# XORG_MANPAGE_SECTIONS()
1796# -----------------------
1797# Minimum version: 1.0.0
1798#
1799# Determine which sections man pages go in for the different man page types
1800# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
1801# Not sure if there's any better way than just hardcoding by OS name.
1802# Override default settings by setting environment variables
1803# Added MAN_SUBSTS in version 1.8
1804# Added AC_PROG_SED in version 1.8
1805
1806AC_DEFUN([XORG_MANPAGE_SECTIONS],[
1807AC_REQUIRE([AC_CANONICAL_HOST])
1808AC_REQUIRE([AC_PROG_SED])
1809
1810if test x$APP_MAN_SUFFIX = x    ; then
1811    APP_MAN_SUFFIX=1
1812fi
1813if test x$APP_MAN_DIR = x    ; then
1814    APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
1815fi
1816
1817if test x$LIB_MAN_SUFFIX = x    ; then
1818    LIB_MAN_SUFFIX=3
1819fi
1820if test x$LIB_MAN_DIR = x    ; then
1821    LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
1822fi
1823
1824if test x$FILE_MAN_SUFFIX = x    ; then
1825    case $host_os in
1826	# Solaris 2.0 - 11 use SysV man page sections
1827	solaris2.?|solaris2.1[[01]])	FILE_MAN_SUFFIX=4  ;;
1828	*)				FILE_MAN_SUFFIX=5  ;;
1829    esac
1830fi
1831if test x$FILE_MAN_DIR = x    ; then
1832    FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
1833fi
1834
1835if test x$MISC_MAN_SUFFIX = x    ; then
1836    case $host_os in
1837	# Solaris 2.0 - 11 use SysV man page sections
1838	solaris2.?|solaris2.1[[01]])	MISC_MAN_SUFFIX=5  ;;
1839	*)				MISC_MAN_SUFFIX=7  ;;
1840    esac
1841fi
1842if test x$MISC_MAN_DIR = x    ; then
1843    MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
1844fi
1845
1846if test x$DRIVER_MAN_SUFFIX = x    ; then
1847    case $host_os in
1848	# Solaris 2.0 - 11 use SysV man page sections
1849	solaris2.?|solaris2.1[[01]])	DRIVER_MAN_SUFFIX=7  ;;
1850	*)				DRIVER_MAN_SUFFIX=4  ;;
1851    esac
1852fi
1853if test x$DRIVER_MAN_DIR = x    ; then
1854    DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
1855fi
1856
1857if test x$ADMIN_MAN_SUFFIX = x    ; then
1858    case $host_os in
1859	# Solaris 2.0 - 11 use SysV man page sections
1860	solaris2.?|solaris2.1[[01]])	ADMIN_MAN_SUFFIX=1m ;;
1861	*)				ADMIN_MAN_SUFFIX=8  ;;
1862    esac
1863fi
1864if test x$ADMIN_MAN_DIR = x    ; then
1865    ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
1866fi
1867
1868
1869AC_SUBST([APP_MAN_SUFFIX])
1870AC_SUBST([LIB_MAN_SUFFIX])
1871AC_SUBST([FILE_MAN_SUFFIX])
1872AC_SUBST([MISC_MAN_SUFFIX])
1873AC_SUBST([DRIVER_MAN_SUFFIX])
1874AC_SUBST([ADMIN_MAN_SUFFIX])
1875AC_SUBST([APP_MAN_DIR])
1876AC_SUBST([LIB_MAN_DIR])
1877AC_SUBST([FILE_MAN_DIR])
1878AC_SUBST([MISC_MAN_DIR])
1879AC_SUBST([DRIVER_MAN_DIR])
1880AC_SUBST([ADMIN_MAN_DIR])
1881
1882XORG_MAN_PAGE="X Version 11"
1883AC_SUBST([XORG_MAN_PAGE])
1884MAN_SUBSTS="\
1885	-e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
1886	-e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
1887	-e 's|__xservername__|Xorg|g' \
1888	-e 's|__xconfigfile__|xorg.conf|g' \
1889	-e 's|__projectroot__|\$(prefix)|g' \
1890	-e 's|__apploaddir__|\$(appdefaultdir)|g' \
1891	-e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
1892	-e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
1893	-e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
1894	-e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
1895	-e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
1896	-e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
1897AC_SUBST([MAN_SUBSTS])
1898
1899]) # XORG_MANPAGE_SECTIONS
1900
1901# XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
1902# ------------------------
1903# Minimum version: 1.7.0
1904#
1905# Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
1906# provided by xorg-sgml-doctools, if installed.
1907AC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
1908AC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
1909XORG_SGML_PATH=
1910PKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
1911    [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
1912    [m4_ifval([$1],[:],
1913        [if test x"$cross_compiling" != x"yes" ; then
1914            AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
1915                          [XORG_SGML_PATH=$prefix/share/sgml])
1916         fi])
1917    ])
1918
1919# Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
1920# the path and the name of the doc stylesheet
1921if test "x$XORG_SGML_PATH" != "x" ; then
1922   AC_MSG_RESULT([$XORG_SGML_PATH])
1923   STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
1924   XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
1925else
1926   AC_MSG_RESULT([no])
1927fi
1928
1929AC_SUBST(XORG_SGML_PATH)
1930AC_SUBST(STYLESHEET_SRCDIR)
1931AC_SUBST(XSL_STYLESHEET)
1932AM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
1933]) # XORG_CHECK_SGML_DOCTOOLS
1934
1935# XORG_CHECK_LINUXDOC
1936# -------------------
1937# Minimum version: 1.0.0
1938#
1939# Defines the variable MAKE_TEXT if the necessary tools and
1940# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
1941# Whether or not the necessary tools and files are found can be checked
1942# with the AM_CONDITIONAL "BUILD_LINUXDOC"
1943AC_DEFUN([XORG_CHECK_LINUXDOC],[
1944AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
1945AC_REQUIRE([XORG_WITH_PS2PDF])
1946
1947AC_PATH_PROG(LINUXDOC, linuxdoc)
1948
1949AC_MSG_CHECKING([whether to build documentation])
1950
1951if test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
1952   BUILDDOC=yes
1953else
1954   BUILDDOC=no
1955fi
1956
1957AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
1958
1959AC_MSG_RESULT([$BUILDDOC])
1960
1961AC_MSG_CHECKING([whether to build pdf documentation])
1962
1963if test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
1964   BUILDPDFDOC=yes
1965else
1966   BUILDPDFDOC=no
1967fi
1968
1969AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
1970
1971AC_MSG_RESULT([$BUILDPDFDOC])
1972
1973MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
1974MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
1975MAKE_PDF="$PS2PDF"
1976MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
1977
1978AC_SUBST(MAKE_TEXT)
1979AC_SUBST(MAKE_PS)
1980AC_SUBST(MAKE_PDF)
1981AC_SUBST(MAKE_HTML)
1982]) # XORG_CHECK_LINUXDOC
1983
1984# XORG_CHECK_DOCBOOK
1985# -------------------
1986# Minimum version: 1.0.0
1987#
1988# Checks for the ability to build output formats from SGML DocBook source.
1989# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
1990# indicates whether the necessary tools and files are found and, if set,
1991# $(MAKE_XXX) blah.sgml will produce blah.xxx.
1992AC_DEFUN([XORG_CHECK_DOCBOOK],[
1993AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
1994
1995BUILDTXTDOC=no
1996BUILDPDFDOC=no
1997BUILDPSDOC=no
1998BUILDHTMLDOC=no
1999
2000AC_PATH_PROG(DOCBOOKPS, docbook2ps)
2001AC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
2002AC_PATH_PROG(DOCBOOKHTML, docbook2html)
2003AC_PATH_PROG(DOCBOOKTXT, docbook2txt)
2004
2005AC_MSG_CHECKING([whether to build text documentation])
2006if test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
2007   test x$BUILD_TXTDOC != xno; then
2008	BUILDTXTDOC=yes
2009fi
2010AM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
2011AC_MSG_RESULT([$BUILDTXTDOC])
2012
2013AC_MSG_CHECKING([whether to build PDF documentation])
2014if test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
2015   test x$BUILD_PDFDOC != xno; then
2016	BUILDPDFDOC=yes
2017fi
2018AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
2019AC_MSG_RESULT([$BUILDPDFDOC])
2020
2021AC_MSG_CHECKING([whether to build PostScript documentation])
2022if test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
2023   test x$BUILD_PSDOC != xno; then
2024	BUILDPSDOC=yes
2025fi
2026AM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
2027AC_MSG_RESULT([$BUILDPSDOC])
2028
2029AC_MSG_CHECKING([whether to build HTML documentation])
2030if test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
2031   test x$BUILD_HTMLDOC != xno; then
2032	BUILDHTMLDOC=yes
2033fi
2034AM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
2035AC_MSG_RESULT([$BUILDHTMLDOC])
2036
2037MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
2038MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
2039MAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
2040MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
2041
2042AC_SUBST(MAKE_TEXT)
2043AC_SUBST(MAKE_PS)
2044AC_SUBST(MAKE_PDF)
2045AC_SUBST(MAKE_HTML)
2046]) # XORG_CHECK_DOCBOOK
2047
2048# XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
2049# ----------------
2050# Minimum version: 1.5.0
2051# Minimum version for optional DEFAULT argument: 1.11.0
2052#
2053# Documentation tools are not always available on all platforms and sometimes
2054# not at the appropriate level. This macro enables a module to test for the
2055# presence of the tool and obtain it's path in separate variables. Coupled with
2056# the --with-xmlto option, it allows maximum flexibilty in making decisions
2057# as whether or not to use the xmlto package. When DEFAULT is not specified,
2058# --with-xmlto assumes 'auto'.
2059#
2060# Interface to module:
2061# HAVE_XMLTO: 	used in makefiles to conditionally generate documentation
2062# XMLTO:	returns the path of the xmlto program found
2063#		returns the path set by the user in the environment
2064# --with-xmlto:	'yes' user instructs the module to use xmlto
2065#		'no' user instructs the module not to use xmlto
2066#
2067# Added in version 1.10.0
2068# HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
2069#                  xmlto for text output requires either lynx, links, or w3m browsers
2070#
2071# If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
2072#
2073AC_DEFUN([XORG_WITH_XMLTO],[
2074AC_ARG_VAR([XMLTO], [Path to xmlto command])
2075m4_define([_defopt], m4_default([$2], [auto]))
2076AC_ARG_WITH(xmlto,
2077	AS_HELP_STRING([--with-xmlto],
2078	   [Use xmlto to regenerate documentation (default: ]_defopt[)]),
2079	   [use_xmlto=$withval], [use_xmlto=]_defopt)
2080m4_undefine([_defopt])
2081
2082if test "x$use_xmlto" = x"auto"; then
2083   AC_PATH_PROG([XMLTO], [xmlto])
2084   if test "x$XMLTO" = "x"; then
2085        AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
2086	have_xmlto=no
2087   else
2088        have_xmlto=yes
2089   fi
2090elif test "x$use_xmlto" = x"yes" ; then
2091   AC_PATH_PROG([XMLTO], [xmlto])
2092   if test "x$XMLTO" = "x"; then
2093        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
2094   fi
2095   have_xmlto=yes
2096elif test "x$use_xmlto" = x"no" ; then
2097   if test "x$XMLTO" != "x"; then
2098      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
2099   fi
2100   have_xmlto=no
2101else
2102   AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
2103fi
2104
2105# Test for a minimum version of xmlto, if provided.
2106m4_ifval([$1],
2107[if test "$have_xmlto" = yes; then
2108    # scrape the xmlto version
2109    AC_MSG_CHECKING([the xmlto version])
2110    xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
2111    AC_MSG_RESULT([$xmlto_version])
2112    AS_VERSION_COMPARE([$xmlto_version], [$1],
2113        [if test "x$use_xmlto" = xauto; then
2114            AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
2115            have_xmlto=no
2116        else
2117            AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
2118        fi])
2119fi])
2120
2121# Test for the ability of xmlto to generate a text target
2122#
2123# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
2124# following test for empty XML docbook files.
2125# For compatibility reasons use the following empty XML docbook file and if
2126# it fails try it again with a non-empty XML file.
2127have_xmlto_text=no
2128cat > conftest.xml << "EOF"
2129EOF
2130AS_IF([test "$have_xmlto" = yes],
2131      [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
2132             [have_xmlto_text=yes],
2133             [# Try it again with a non-empty XML file.
2134              cat > conftest.xml << "EOF"
2135<x></x>
2136EOF
2137              AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
2138                    [have_xmlto_text=yes],
2139                    [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])])
2140rm -f conftest.xml
2141AM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
2142AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
2143]) # XORG_WITH_XMLTO
2144
2145# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
2146# --------------------------------------------
2147# Minimum version: 1.12.0
2148# Minimum version for optional DEFAULT argument: 1.12.0
2149#
2150# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
2151# XML-based language used for the transformation of XML documents.
2152# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
2153# It is used under the cover by xmlto to generate html files from DocBook/XML.
2154# The XSLT processor is often used as a standalone tool for transformations.
2155# It should not be assumed that this tool is used only to work with documnetation.
2156# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
2157#
2158# Interface to module:
2159# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
2160# XSLTPROC:	 returns the path of the xsltproc program found
2161#		 returns the path set by the user in the environment
2162# --with-xsltproc: 'yes' user instructs the module to use xsltproc
2163#		  'no' user instructs the module not to use xsltproc
2164# have_xsltproc: returns yes if xsltproc found in PATH or no
2165#
2166# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
2167#
2168AC_DEFUN([XORG_WITH_XSLTPROC],[
2169AC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
2170# Preserves the interface, should it be implemented later
2171m4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
2172m4_define([_defopt], m4_default([$2], [auto]))
2173AC_ARG_WITH(xsltproc,
2174	AS_HELP_STRING([--with-xsltproc],
2175	   [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
2176	   [use_xsltproc=$withval], [use_xsltproc=]_defopt)
2177m4_undefine([_defopt])
2178
2179if test "x$use_xsltproc" = x"auto"; then
2180   AC_PATH_PROG([XSLTPROC], [xsltproc])
2181   if test "x$XSLTPROC" = "x"; then
2182        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
2183	have_xsltproc=no
2184   else
2185        have_xsltproc=yes
2186   fi
2187elif test "x$use_xsltproc" = x"yes" ; then
2188   AC_PATH_PROG([XSLTPROC], [xsltproc])
2189   if test "x$XSLTPROC" = "x"; then
2190        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
2191   fi
2192   have_xsltproc=yes
2193elif test "x$use_xsltproc" = x"no" ; then
2194   if test "x$XSLTPROC" != "x"; then
2195      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
2196   fi
2197   have_xsltproc=no
2198else
2199   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
2200fi
2201
2202AM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
2203]) # XORG_WITH_XSLTPROC
2204
2205# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
2206# ----------------------------------------
2207# Minimum version: 1.15.0
2208#
2209# PERL (Practical Extraction and Report Language) is a language optimized for
2210# scanning arbitrary text files, extracting information from those text files,
2211# and printing reports based on that information.
2212#
2213# When DEFAULT is not specified, --with-perl assumes 'auto'.
2214#
2215# Interface to module:
2216# HAVE_PERL: used in makefiles to conditionally scan text files
2217# PERL:	     returns the path of the perl program found
2218#	     returns the path set by the user in the environment
2219# --with-perl: 'yes' user instructs the module to use perl
2220#	       'no' user instructs the module not to use perl
2221# have_perl: returns yes if perl found in PATH or no
2222#
2223# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
2224#
2225AC_DEFUN([XORG_WITH_PERL],[
2226AC_ARG_VAR([PERL], [Path to perl command])
2227# Preserves the interface, should it be implemented later
2228m4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
2229m4_define([_defopt], m4_default([$2], [auto]))
2230AC_ARG_WITH(perl,
2231	AS_HELP_STRING([--with-perl],
2232	   [Use perl for extracting information from files (default: ]_defopt[)]),
2233	   [use_perl=$withval], [use_perl=]_defopt)
2234m4_undefine([_defopt])
2235
2236if test "x$use_perl" = x"auto"; then
2237   AC_PATH_PROG([PERL], [perl])
2238   if test "x$PERL" = "x"; then
2239        AC_MSG_WARN([perl not found - cannot extract information and report])
2240	have_perl=no
2241   else
2242        have_perl=yes
2243   fi
2244elif test "x$use_perl" = x"yes" ; then
2245   AC_PATH_PROG([PERL], [perl])
2246   if test "x$PERL" = "x"; then
2247        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
2248   fi
2249   have_perl=yes
2250elif test "x$use_perl" = x"no" ; then
2251   if test "x$PERL" != "x"; then
2252      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
2253   fi
2254   have_perl=no
2255else
2256   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
2257fi
2258
2259AM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
2260]) # XORG_WITH_PERL
2261
2262# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
2263# ----------------
2264# Minimum version: 1.5.0
2265# Minimum version for optional DEFAULT argument: 1.11.0
2266#
2267# Documentation tools are not always available on all platforms and sometimes
2268# not at the appropriate level. This macro enables a module to test for the
2269# presence of the tool and obtain it's path in separate variables. Coupled with
2270# the --with-asciidoc option, it allows maximum flexibilty in making decisions
2271# as whether or not to use the asciidoc package. When DEFAULT is not specified,
2272# --with-asciidoc assumes 'auto'.
2273#
2274# Interface to module:
2275# HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
2276# ASCIIDOC:	 returns the path of the asciidoc program found
2277#		 returns the path set by the user in the environment
2278# --with-asciidoc: 'yes' user instructs the module to use asciidoc
2279#		  'no' user instructs the module not to use asciidoc
2280#
2281# If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
2282#
2283AC_DEFUN([XORG_WITH_ASCIIDOC],[
2284AC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
2285m4_define([_defopt], m4_default([$2], [auto]))
2286AC_ARG_WITH(asciidoc,
2287	AS_HELP_STRING([--with-asciidoc],
2288	   [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
2289	   [use_asciidoc=$withval], [use_asciidoc=]_defopt)
2290m4_undefine([_defopt])
2291
2292if test "x$use_asciidoc" = x"auto"; then
2293   AC_PATH_PROG([ASCIIDOC], [asciidoc])
2294   if test "x$ASCIIDOC" = "x"; then
2295        AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
2296	have_asciidoc=no
2297   else
2298        have_asciidoc=yes
2299   fi
2300elif test "x$use_asciidoc" = x"yes" ; then
2301   AC_PATH_PROG([ASCIIDOC], [asciidoc])
2302   if test "x$ASCIIDOC" = "x"; then
2303        AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
2304   fi
2305   have_asciidoc=yes
2306elif test "x$use_asciidoc" = x"no" ; then
2307   if test "x$ASCIIDOC" != "x"; then
2308      AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
2309   fi
2310   have_asciidoc=no
2311else
2312   AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
2313fi
2314m4_ifval([$1],
2315[if test "$have_asciidoc" = yes; then
2316    # scrape the asciidoc version
2317    AC_MSG_CHECKING([the asciidoc version])
2318    asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
2319    AC_MSG_RESULT([$asciidoc_version])
2320    AS_VERSION_COMPARE([$asciidoc_version], [$1],
2321        [if test "x$use_asciidoc" = xauto; then
2322            AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
2323            have_asciidoc=no
2324        else
2325            AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
2326        fi])
2327fi])
2328AM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
2329]) # XORG_WITH_ASCIIDOC
2330
2331# XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
2332# -------------------------------------------
2333# Minimum version: 1.5.0
2334# Minimum version for optional DEFAULT argument: 1.11.0
2335# Minimum version for optional DOT checking: 1.18.0
2336#
2337# Documentation tools are not always available on all platforms and sometimes
2338# not at the appropriate level. This macro enables a module to test for the
2339# presence of the tool and obtain it's path in separate variables. Coupled with
2340# the --with-doxygen option, it allows maximum flexibilty in making decisions
2341# as whether or not to use the doxygen package. When DEFAULT is not specified,
2342# --with-doxygen assumes 'auto'.
2343#
2344# Interface to module:
2345# HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
2346# DOXYGEN:	 returns the path of the doxygen program found
2347#		 returns the path set by the user in the environment
2348# --with-doxygen: 'yes' user instructs the module to use doxygen
2349#		  'no' user instructs the module not to use doxygen
2350#
2351# If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
2352#
2353AC_DEFUN([XORG_WITH_DOXYGEN],[
2354AC_ARG_VAR([DOXYGEN], [Path to doxygen command])
2355AC_ARG_VAR([DOT], [Path to the dot graphics utility])
2356m4_define([_defopt], m4_default([$2], [auto]))
2357AC_ARG_WITH(doxygen,
2358	AS_HELP_STRING([--with-doxygen],
2359	   [Use doxygen to regenerate documentation (default: ]_defopt[)]),
2360	   [use_doxygen=$withval], [use_doxygen=]_defopt)
2361m4_undefine([_defopt])
2362
2363if test "x$use_doxygen" = x"auto"; then
2364   AC_PATH_PROG([DOXYGEN], [doxygen])
2365   if test "x$DOXYGEN" = "x"; then
2366        AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
2367	have_doxygen=no
2368   else
2369        have_doxygen=yes
2370   fi
2371elif test "x$use_doxygen" = x"yes" ; then
2372   AC_PATH_PROG([DOXYGEN], [doxygen])
2373   if test "x$DOXYGEN" = "x"; then
2374        AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
2375   fi
2376   have_doxygen=yes
2377elif test "x$use_doxygen" = x"no" ; then
2378   if test "x$DOXYGEN" != "x"; then
2379      AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
2380   fi
2381   have_doxygen=no
2382else
2383   AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
2384fi
2385m4_ifval([$1],
2386[if test "$have_doxygen" = yes; then
2387    # scrape the doxygen version
2388    AC_MSG_CHECKING([the doxygen version])
2389    doxygen_version=`$DOXYGEN --version 2>/dev/null`
2390    AC_MSG_RESULT([$doxygen_version])
2391    AS_VERSION_COMPARE([$doxygen_version], [$1],
2392        [if test "x$use_doxygen" = xauto; then
2393            AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
2394            have_doxygen=no
2395        else
2396            AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
2397        fi])
2398fi])
2399
2400dnl Check for DOT if we have doxygen. The caller decides if it is mandatory
2401dnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
2402dnl 	HAVE_DOT = @HAVE_DOT@
2403HAVE_DOT=no
2404if test "x$have_doxygen" = "xyes"; then
2405  AC_PATH_PROG([DOT], [dot])
2406    if test "x$DOT" != "x"; then
2407      HAVE_DOT=yes
2408    fi
2409fi
2410
2411AC_SUBST([HAVE_DOT])
2412AM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
2413AM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
2414]) # XORG_WITH_DOXYGEN
2415
2416# XORG_WITH_GROFF([DEFAULT])
2417# ----------------
2418# Minimum version: 1.6.0
2419# Minimum version for optional DEFAULT argument: 1.11.0
2420#
2421# Documentation tools are not always available on all platforms and sometimes
2422# not at the appropriate level. This macro enables a module to test for the
2423# presence of the tool and obtain it's path in separate variables. Coupled with
2424# the --with-groff option, it allows maximum flexibilty in making decisions
2425# as whether or not to use the groff package. When DEFAULT is not specified,
2426# --with-groff assumes 'auto'.
2427#
2428# Interface to module:
2429# HAVE_GROFF:	 used in makefiles to conditionally generate documentation
2430# HAVE_GROFF_MM: the memorandum macros (-mm) package
2431# HAVE_GROFF_MS: the -ms macros package
2432# GROFF:	 returns the path of the groff program found
2433#		 returns the path set by the user in the environment
2434# --with-groff:	 'yes' user instructs the module to use groff
2435#		 'no' user instructs the module not to use groff
2436#
2437# Added in version 1.9.0:
2438# HAVE_GROFF_HTML: groff has dependencies to output HTML format:
2439#		   pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
2440#		   psselect from the psutils package.
2441#		   the ghostcript package. Refer to the grohtml man pages
2442#
2443# If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
2444#
2445# OS and distros often splits groff in a basic and full package, the former
2446# having the groff program and the later having devices, fonts and macros
2447# Checking for the groff executable is not enough.
2448#
2449# If macros are missing, we cannot assume that groff is useless, so we don't
2450# unset HAVE_GROFF or GROFF env variables.
2451# HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
2452#
2453AC_DEFUN([XORG_WITH_GROFF],[
2454AC_ARG_VAR([GROFF], [Path to groff command])
2455m4_define([_defopt], m4_default([$1], [auto]))
2456AC_ARG_WITH(groff,
2457	AS_HELP_STRING([--with-groff],
2458	   [Use groff to regenerate documentation (default: ]_defopt[)]),
2459	   [use_groff=$withval], [use_groff=]_defopt)
2460m4_undefine([_defopt])
2461
2462if test "x$use_groff" = x"auto"; then
2463   AC_PATH_PROG([GROFF], [groff])
2464   if test "x$GROFF" = "x"; then
2465        AC_MSG_WARN([groff not found - documentation targets will be skipped])
2466	have_groff=no
2467   else
2468        have_groff=yes
2469   fi
2470elif test "x$use_groff" = x"yes" ; then
2471   AC_PATH_PROG([GROFF], [groff])
2472   if test "x$GROFF" = "x"; then
2473        AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
2474   fi
2475   have_groff=yes
2476elif test "x$use_groff" = x"no" ; then
2477   if test "x$GROFF" != "x"; then
2478      AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
2479   fi
2480   have_groff=no
2481else
2482   AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
2483fi
2484
2485# We have groff, test for the presence of the macro packages
2486if test "x$have_groff" = x"yes"; then
2487    AC_MSG_CHECKING([for ${GROFF} -ms macros])
2488    if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
2489        groff_ms_works=yes
2490    else
2491        groff_ms_works=no
2492    fi
2493    AC_MSG_RESULT([$groff_ms_works])
2494    AC_MSG_CHECKING([for ${GROFF} -mm macros])
2495    if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
2496        groff_mm_works=yes
2497    else
2498        groff_mm_works=no
2499    fi
2500    AC_MSG_RESULT([$groff_mm_works])
2501fi
2502
2503# We have groff, test for HTML dependencies, one command per package
2504if test "x$have_groff" = x"yes"; then
2505   AC_PATH_PROGS(GS_PATH, [gs gswin32c])
2506   AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
2507   AC_PATH_PROG(PSSELECT_PATH, [psselect])
2508   if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
2509      have_groff_html=yes
2510   else
2511      have_groff_html=no
2512      AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
2513   fi
2514fi
2515
2516# Set Automake conditionals for Makefiles
2517AM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
2518AM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
2519AM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
2520AM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
2521]) # XORG_WITH_GROFF
2522
2523# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
2524# ---------------------------------------
2525# Minimum version: 1.6.0
2526# Minimum version for optional DEFAULT argument: 1.11.0
2527# Minimum version for optional MIN-VERSION argument: 1.15.0
2528#
2529# Documentation tools are not always available on all platforms and sometimes
2530# not at the appropriate level. This macro enables a module to test for the
2531# presence of the tool and obtain it's path in separate variables. Coupled with
2532# the --with-fop option, it allows maximum flexibilty in making decisions
2533# as whether or not to use the fop package. When DEFAULT is not specified,
2534# --with-fop assumes 'auto'.
2535#
2536# Interface to module:
2537# HAVE_FOP: 	used in makefiles to conditionally generate documentation
2538# FOP:	 	returns the path of the fop program found
2539#		returns the path set by the user in the environment
2540# --with-fop: 	'yes' user instructs the module to use fop
2541#		'no' user instructs the module not to use fop
2542#
2543# If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
2544#
2545AC_DEFUN([XORG_WITH_FOP],[
2546AC_ARG_VAR([FOP], [Path to fop command])
2547m4_define([_defopt], m4_default([$2], [auto]))
2548AC_ARG_WITH(fop,
2549	AS_HELP_STRING([--with-fop],
2550	   [Use fop to regenerate documentation (default: ]_defopt[)]),
2551	   [use_fop=$withval], [use_fop=]_defopt)
2552m4_undefine([_defopt])
2553
2554if test "x$use_fop" = x"auto"; then
2555   AC_PATH_PROG([FOP], [fop])
2556   if test "x$FOP" = "x"; then
2557        AC_MSG_WARN([fop not found - documentation targets will be skipped])
2558	have_fop=no
2559   else
2560        have_fop=yes
2561   fi
2562elif test "x$use_fop" = x"yes" ; then
2563   AC_PATH_PROG([FOP], [fop])
2564   if test "x$FOP" = "x"; then
2565        AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
2566   fi
2567   have_fop=yes
2568elif test "x$use_fop" = x"no" ; then
2569   if test "x$FOP" != "x"; then
2570      AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
2571   fi
2572   have_fop=no
2573else
2574   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
2575fi
2576
2577# Test for a minimum version of fop, if provided.
2578m4_ifval([$1],
2579[if test "$have_fop" = yes; then
2580    # scrape the fop version
2581    AC_MSG_CHECKING([for fop minimum version])
2582    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
2583    AC_MSG_RESULT([$fop_version])
2584    AS_VERSION_COMPARE([$fop_version], [$1],
2585        [if test "x$use_fop" = xauto; then
2586            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
2587            have_fop=no
2588        else
2589            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
2590        fi])
2591fi])
2592AM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
2593]) # XORG_WITH_FOP
2594
2595# XORG_WITH_M4([MIN-VERSION])
2596# ---------------------------
2597# Minimum version: 1.19.0
2598#
2599# This macro attempts to locate an m4 macro processor which supports
2600# -I option and is only useful for modules relying on M4 in order to
2601# expand macros in source code files.
2602#
2603# Interface to module:
2604# M4:	 	returns the path of the m4 program found
2605#		returns the path set by the user in the environment
2606#
2607AC_DEFUN([XORG_WITH_M4], [
2608AC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
2609   [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
2610       [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
2611         ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
2612   [AC_MSG_ERROR([could not find m4 that supports -I option])],
2613   [$PATH:/usr/gnu/bin])])
2614
2615AC_SUBST([M4], [$ac_cv_path_M4])
2616]) # XORG_WITH_M4
2617
2618# XORG_WITH_PS2PDF([DEFAULT])
2619# ----------------
2620# Minimum version: 1.6.0
2621# Minimum version for optional DEFAULT argument: 1.11.0
2622#
2623# Documentation tools are not always available on all platforms and sometimes
2624# not at the appropriate level. This macro enables a module to test for the
2625# presence of the tool and obtain it's path in separate variables. Coupled with
2626# the --with-ps2pdf option, it allows maximum flexibilty in making decisions
2627# as whether or not to use the ps2pdf package. When DEFAULT is not specified,
2628# --with-ps2pdf assumes 'auto'.
2629#
2630# Interface to module:
2631# HAVE_PS2PDF: 	used in makefiles to conditionally generate documentation
2632# PS2PDF:	returns the path of the ps2pdf program found
2633#		returns the path set by the user in the environment
2634# --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
2635#		 'no' user instructs the module not to use ps2pdf
2636#
2637# If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
2638#
2639AC_DEFUN([XORG_WITH_PS2PDF],[
2640AC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
2641m4_define([_defopt], m4_default([$1], [auto]))
2642AC_ARG_WITH(ps2pdf,
2643	AS_HELP_STRING([--with-ps2pdf],
2644	   [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
2645	   [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
2646m4_undefine([_defopt])
2647
2648if test "x$use_ps2pdf" = x"auto"; then
2649   AC_PATH_PROG([PS2PDF], [ps2pdf])
2650   if test "x$PS2PDF" = "x"; then
2651        AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
2652	have_ps2pdf=no
2653   else
2654        have_ps2pdf=yes
2655   fi
2656elif test "x$use_ps2pdf" = x"yes" ; then
2657   AC_PATH_PROG([PS2PDF], [ps2pdf])
2658   if test "x$PS2PDF" = "x"; then
2659        AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
2660   fi
2661   have_ps2pdf=yes
2662elif test "x$use_ps2pdf" = x"no" ; then
2663   if test "x$PS2PDF" != "x"; then
2664      AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
2665   fi
2666   have_ps2pdf=no
2667else
2668   AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
2669fi
2670AM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
2671]) # XORG_WITH_PS2PDF
2672
2673# XORG_ENABLE_DOCS (enable_docs=yes)
2674# ----------------
2675# Minimum version: 1.6.0
2676#
2677# Documentation tools are not always available on all platforms and sometimes
2678# not at the appropriate level. This macro enables a builder to skip all
2679# documentation targets except traditional man pages.
2680# Combined with the specific tool checking macros XORG_WITH_*, it provides
2681# maximum flexibilty in controlling documentation building.
2682# Refer to:
2683# XORG_WITH_XMLTO         --with-xmlto
2684# XORG_WITH_ASCIIDOC      --with-asciidoc
2685# XORG_WITH_DOXYGEN       --with-doxygen
2686# XORG_WITH_FOP           --with-fop
2687# XORG_WITH_GROFF         --with-groff
2688# XORG_WITH_PS2PDF        --with-ps2pdf
2689#
2690# Interface to module:
2691# ENABLE_DOCS: 	  used in makefiles to conditionally generate documentation
2692# --enable-docs: 'yes' user instructs the module to generate docs
2693#		 'no' user instructs the module not to generate docs
2694# parm1:	specify the default value, yes or no.
2695#
2696AC_DEFUN([XORG_ENABLE_DOCS],[
2697m4_define([docs_default], m4_default([$1], [yes]))
2698AC_ARG_ENABLE(docs,
2699	AS_HELP_STRING([--enable-docs],
2700	   [Enable building the documentation (default: ]docs_default[)]),
2701	   [build_docs=$enableval], [build_docs=]docs_default)
2702m4_undefine([docs_default])
2703AM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
2704AC_MSG_CHECKING([whether to build documentation])
2705AC_MSG_RESULT([$build_docs])
2706]) # XORG_ENABLE_DOCS
2707
2708# XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
2709# ----------------
2710# Minimum version: 1.6.0
2711#
2712# This macro enables a builder to skip all developer documentation.
2713# Combined with the specific tool checking macros XORG_WITH_*, it provides
2714# maximum flexibilty in controlling documentation building.
2715# Refer to:
2716# XORG_WITH_XMLTO         --with-xmlto
2717# XORG_WITH_ASCIIDOC      --with-asciidoc
2718# XORG_WITH_DOXYGEN       --with-doxygen
2719# XORG_WITH_FOP           --with-fop
2720# XORG_WITH_GROFF         --with-groff
2721# XORG_WITH_PS2PDF        --with-ps2pdf
2722#
2723# Interface to module:
2724# ENABLE_DEVEL_DOCS:	used in makefiles to conditionally generate developer docs
2725# --enable-devel-docs:	'yes' user instructs the module to generate developer docs
2726#			'no' user instructs the module not to generate developer docs
2727# parm1:		specify the default value, yes or no.
2728#
2729AC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
2730m4_define([devel_default], m4_default([$1], [yes]))
2731AC_ARG_ENABLE(devel-docs,
2732	AS_HELP_STRING([--enable-devel-docs],
2733	   [Enable building the developer documentation (default: ]devel_default[)]),
2734	   [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
2735m4_undefine([devel_default])
2736AM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
2737AC_MSG_CHECKING([whether to build developer documentation])
2738AC_MSG_RESULT([$build_devel_docs])
2739]) # XORG_ENABLE_DEVEL_DOCS
2740
2741# XORG_ENABLE_SPECS (enable_specs=yes)
2742# ----------------
2743# Minimum version: 1.6.0
2744#
2745# This macro enables a builder to skip all functional specification targets.
2746# Combined with the specific tool checking macros XORG_WITH_*, it provides
2747# maximum flexibilty in controlling documentation building.
2748# Refer to:
2749# XORG_WITH_XMLTO         --with-xmlto
2750# XORG_WITH_ASCIIDOC      --with-asciidoc
2751# XORG_WITH_DOXYGEN       --with-doxygen
2752# XORG_WITH_FOP           --with-fop
2753# XORG_WITH_GROFF         --with-groff
2754# XORG_WITH_PS2PDF        --with-ps2pdf
2755#
2756# Interface to module:
2757# ENABLE_SPECS:		used in makefiles to conditionally generate specs
2758# --enable-specs:	'yes' user instructs the module to generate specs
2759#			'no' user instructs the module not to generate specs
2760# parm1:		specify the default value, yes or no.
2761#
2762AC_DEFUN([XORG_ENABLE_SPECS],[
2763m4_define([spec_default], m4_default([$1], [yes]))
2764AC_ARG_ENABLE(specs,
2765	AS_HELP_STRING([--enable-specs],
2766	   [Enable building the specs (default: ]spec_default[)]),
2767	   [build_specs=$enableval], [build_specs=]spec_default)
2768m4_undefine([spec_default])
2769AM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
2770AC_MSG_CHECKING([whether to build functional specifications])
2771AC_MSG_RESULT([$build_specs])
2772]) # XORG_ENABLE_SPECS
2773
2774# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
2775# ----------------------------------------------
2776# Minimum version: 1.13.0
2777#
2778# This macro enables a builder to enable/disable unit testing
2779# It makes no assumption about the test cases implementation
2780# Test cases may or may not use Automake "Support for test suites"
2781# They may or may not use the software utility library GLib
2782#
2783# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
2784# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
2785# The variable enable_unit_tests is used by other macros in this file.
2786#
2787# Interface to module:
2788# ENABLE_UNIT_TESTS:	used in makefiles to conditionally build tests
2789# enable_unit_tests:    used in configure.ac for additional configuration
2790# --enable-unit-tests:	'yes' user instructs the module to build tests
2791#			'no' user instructs the module not to build tests
2792# parm1:		specify the default value, yes or no.
2793#
2794AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
2795AC_BEFORE([$0], [XORG_WITH_GLIB])
2796AC_BEFORE([$0], [XORG_LD_WRAP])
2797AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
2798m4_define([_defopt], m4_default([$1], [auto]))
2799AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
2800	[Enable building unit test cases (default: ]_defopt[)]),
2801	[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
2802m4_undefine([_defopt])
2803AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
2804AC_MSG_CHECKING([whether to build unit test cases])
2805AC_MSG_RESULT([$enable_unit_tests])
2806]) # XORG_ENABLE_UNIT_TESTS
2807
2808# XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
2809# ------------------------------------------------------
2810# Minimum version: 1.17.0
2811#
2812# This macro enables a builder to enable/disable integration testing
2813# It makes no assumption about the test cases' implementation
2814# Test cases may or may not use Automake "Support for test suites"
2815#
2816# Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
2817# usually requires less dependencies and may be built and run under less
2818# stringent environments than integration tests.
2819#
2820# Interface to module:
2821# ENABLE_INTEGRATION_TESTS:   used in makefiles to conditionally build tests
2822# enable_integration_tests:   used in configure.ac for additional configuration
2823# --enable-integration-tests: 'yes' user instructs the module to build tests
2824#                             'no' user instructs the module not to build tests
2825# parm1:                      specify the default value, yes or no.
2826#
2827AC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
2828AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
2829m4_define([_defopt], m4_default([$1], [auto]))
2830AC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
2831	[Enable building integration test cases (default: ]_defopt[)]),
2832	[enable_integration_tests=$enableval],
2833	[enable_integration_tests=]_defopt)
2834m4_undefine([_defopt])
2835AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
2836	[test "x$enable_integration_tests" != xno])
2837AC_MSG_CHECKING([whether to build unit test cases])
2838AC_MSG_RESULT([$enable_integration_tests])
2839]) # XORG_ENABLE_INTEGRATION_TESTS
2840
2841# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
2842# ----------------------------------------
2843# Minimum version: 1.13.0
2844#
2845# GLib is a library which provides advanced data structures and functions.
2846# This macro enables a module to test for the presence of Glib.
2847#
2848# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
2849# Otherwise the value of $enable_unit_tests is blank.
2850#
2851# Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
2852# test support usually requires less dependencies and may be built and run under
2853# less stringent environments than integration tests.
2854#
2855# Interface to module:
2856# HAVE_GLIB: used in makefiles to conditionally build targets
2857# with_glib: used in configure.ac to know if GLib has been found
2858# --with-glib:	'yes' user instructs the module to use glib
2859#		'no' user instructs the module not to use glib
2860#
2861AC_DEFUN([XORG_WITH_GLIB],[
2862AC_REQUIRE([PKG_PROG_PKG_CONFIG])
2863m4_define([_defopt], m4_default([$2], [auto]))
2864AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
2865	[Use GLib library for unit testing (default: ]_defopt[)]),
2866	[with_glib=$withval], [with_glib=]_defopt)
2867m4_undefine([_defopt])
2868
2869have_glib=no
2870# Do not probe GLib if user explicitly disabled unit testing
2871if test "x$enable_unit_tests" != x"no"; then
2872  # Do not probe GLib if user explicitly disabled it
2873  if test "x$with_glib" != x"no"; then
2874    m4_ifval(
2875      [$1],
2876      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
2877      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
2878    )
2879  fi
2880fi
2881
2882# Not having GLib when unit testing has been explicitly requested is an error
2883if test "x$enable_unit_tests" = x"yes"; then
2884  if test "x$have_glib" = x"no"; then
2885    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
2886  fi
2887fi
2888
2889# Having unit testing disabled when GLib has been explicitly requested is an error
2890if test "x$enable_unit_tests" = x"no"; then
2891  if test "x$with_glib" = x"yes"; then
2892    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
2893  fi
2894fi
2895
2896# Not having GLib when it has been explicitly requested is an error
2897if test "x$with_glib" = x"yes"; then
2898  if test "x$have_glib" = x"no"; then
2899    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
2900  fi
2901fi
2902
2903AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
2904]) # XORG_WITH_GLIB
2905
2906# XORG_LD_WRAP([required|optional])
2907# ---------------------------------
2908# Minimum version: 1.13.0
2909#
2910# Check if linker supports -wrap, passed via compiler flags
2911#
2912# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
2913# Otherwise the value of $enable_unit_tests is blank.
2914#
2915# Argument added in 1.16.0 - default is "required", to match existing behavior
2916# of returning an error if enable_unit_tests is yes, and ld -wrap is not
2917# available, an argument of "optional" allows use when some unit tests require
2918# ld -wrap and others do not.
2919#
2920AC_DEFUN([XORG_LD_WRAP],[
2921XORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
2922    [AC_LANG_PROGRAM([#include <stdlib.h>
2923                      void __wrap_exit(int status) { return; }],
2924                     [exit(0);])])
2925# Not having ld wrap when unit testing has been explicitly requested is an error
2926if test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
2927  if test "x$have_ld_wrap" = x"no"; then
2928    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
2929  fi
2930fi
2931AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
2932#
2933]) # XORG_LD_WRAP
2934
2935# XORG_CHECK_LINKER_FLAGS
2936# -----------------------
2937# SYNOPSIS
2938#
2939#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
2940#
2941# DESCRIPTION
2942#
2943#   Check whether the given linker FLAGS work with the current language's
2944#   linker, or whether they give an error.
2945#
2946#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
2947#   success/failure.
2948#
2949#   PROGRAM-SOURCE is the program source to link with, if needed
2950#
2951#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
2952#
2953# LICENSE
2954#
2955#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
2956#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
2957#   Copyright (c) 2009 Matteo Frigo
2958#
2959#   This program is free software: you can redistribute it and/or modify it
2960#   under the terms of the GNU General Public License as published by the
2961#   Free Software Foundation, either version 3 of the License, or (at your
2962#   option) any later version.
2963#
2964#   This program is distributed in the hope that it will be useful, but
2965#   WITHOUT ANY WARRANTY; without even the implied warranty of
2966#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
2967#   Public License for more details.
2968#
2969#   You should have received a copy of the GNU General Public License along
2970#   with this program. If not, see <http://www.gnu.org/licenses/>.
2971#
2972#   As a special exception, the respective Autoconf Macro's copyright owner
2973#   gives unlimited permission to copy, distribute and modify the configure
2974#   scripts that are the output of Autoconf when processing the Macro. You
2975#   need not follow the terms of the GNU General Public License when using
2976#   or distributing such scripts, even though portions of the text of the
2977#   Macro appear in them. The GNU General Public License (GPL) does govern
2978#   all other use of the material that constitutes the Autoconf Macro.
2979#
2980#   This special exception to the GPL applies to versions of the Autoconf
2981#   Macro released by the Autoconf Archive. When you make and distribute a
2982#   modified version of the Autoconf Macro, you may extend this special
2983#   exception to the GPL to apply to your modified version as well.#
2984AC_DEFUN([XORG_CHECK_LINKER_FLAGS],
2985[AC_MSG_CHECKING([whether the linker accepts $1])
2986dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
2987AS_LITERAL_IF([$1],
2988  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
2989      ax_save_FLAGS=$LDFLAGS
2990      LDFLAGS="$1"
2991      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
2992        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
2993        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
2994      LDFLAGS=$ax_save_FLAGS])],
2995  [ax_save_FLAGS=$LDFLAGS
2996   LDFLAGS="$1"
2997   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
2998     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
2999     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
3000   LDFLAGS=$ax_save_FLAGS])
3001eval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
3002AC_MSG_RESULT($xorg_check_linker_flags)
3003if test "x$xorg_check_linker_flags" = xyes; then
3004	m4_default([$2], :)
3005else
3006	m4_default([$3], :)
3007fi
3008]) # XORG_CHECK_LINKER_FLAGS
3009
3010# XORG_MEMORY_CHECK_FLAGS
3011# -----------------------
3012# Minimum version: 1.16.0
3013#
3014# This macro attempts to find appropriate memory checking functionality
3015# for various platforms which unit testing code may use to catch various
3016# forms of memory allocation and access errors in testing.
3017#
3018# Interface to module:
3019# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
3020#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
3021#
3022# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
3023#
3024AC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
3025
3026AC_REQUIRE([AC_CANONICAL_HOST])
3027AC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
3028           [Environment variables to enable memory checking in tests])
3029
3030# Check for different types of support on different platforms
3031case $host_os in
3032    solaris*)
3033        AC_CHECK_LIB([umem], [umem_alloc],
3034            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
3035        ;;
3036    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
3037        # both directly and inverted, so should not be 0 or 255.
3038        malloc_debug_env='MALLOC_PERTURB_=15'
3039        ;;
3040    darwin*)
3041        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
3042        ;;
3043    *bsd*)
3044        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
3045        ;;
3046esac
3047
3048# User supplied flags override default flags
3049if test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
3050    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
3051fi
3052
3053AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
3054]) # XORG_WITH_LINT
3055
3056# XORG_CHECK_MALLOC_ZERO
3057# ----------------------
3058# Minimum version: 1.0.0
3059#
3060# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
3061# malloc(0) returns NULL.  Packages should add one of these cflags to
3062# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
3063AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
3064AC_ARG_ENABLE(malloc0returnsnull,
3065	AS_HELP_STRING([--enable-malloc0returnsnull],
3066		       [malloc(0) returns NULL (default: auto)]),
3067	[MALLOC_ZERO_RETURNS_NULL=$enableval],
3068	[MALLOC_ZERO_RETURNS_NULL=auto])
3069
3070AC_MSG_CHECKING([whether malloc(0) returns NULL])
3071if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
3072AC_CACHE_VAL([xorg_cv_malloc0_returns_null],
3073	[AC_RUN_IFELSE([AC_LANG_PROGRAM([
3074#include <stdlib.h>
3075],[
3076    char *m0, *r0, *c0, *p;
3077    m0 = malloc(0);
3078    p = malloc(10);
3079    r0 = realloc(p,0);
3080    c0 = calloc(0,10);
3081    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
3082])],
3083		[xorg_cv_malloc0_returns_null=yes],
3084		[xorg_cv_malloc0_returns_null=no])])
3085MALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null
3086fi
3087AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
3088
3089if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
3090	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
3091	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
3092	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
3093else
3094	MALLOC_ZERO_CFLAGS=""
3095	XMALLOC_ZERO_CFLAGS=""
3096	XTMALLOC_ZERO_CFLAGS=""
3097fi
3098
3099AC_SUBST([MALLOC_ZERO_CFLAGS])
3100AC_SUBST([XMALLOC_ZERO_CFLAGS])
3101AC_SUBST([XTMALLOC_ZERO_CFLAGS])
3102]) # XORG_CHECK_MALLOC_ZERO
3103
3104# XORG_WITH_LINT()
3105# ----------------
3106# Minimum version: 1.1.0
3107#
3108# This macro enables the use of a tool that flags some suspicious and
3109# non-portable constructs (likely to be bugs) in C language source code.
3110# It will attempt to locate the tool and use appropriate options.
3111# There are various lint type tools on different platforms.
3112#
3113# Interface to module:
3114# LINT:		returns the path to the tool found on the platform
3115#		or the value set to LINT on the configure cmd line
3116#		also an Automake conditional
3117# LINT_FLAGS:	an Automake variable with appropriate flags
3118#
3119# --with-lint:	'yes' user instructs the module to use lint
3120#		'no' user instructs the module not to use lint (default)
3121#
3122# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
3123# If the user sets the value of LINT_FLAGS, they are used verbatim.
3124#
3125AC_DEFUN([XORG_WITH_LINT],[
3126
3127AC_ARG_VAR([LINT], [Path to a lint-style command])
3128AC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
3129AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
3130		[Use a lint-style source code checker (default: disabled)])],
3131		[use_lint=$withval], [use_lint=no])
3132
3133# Obtain platform specific info like program name and options
3134# The lint program on FreeBSD and NetBSD is different from the one on Solaris
3135case $host_os in
3136  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
3137	lint_name=splint
3138	lint_options="-badflag"
3139	;;
3140  *freebsd* | *netbsd*)
3141	lint_name=lint
3142	lint_options="-u -b"
3143	;;
3144  *solaris*)
3145	lint_name=lint
3146	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
3147	;;
3148esac
3149
3150# Test for the presence of the program (either guessed by the code or spelled out by the user)
3151if test "x$use_lint" = x"yes" ; then
3152   AC_PATH_PROG([LINT], [$lint_name])
3153   if test "x$LINT" = "x"; then
3154        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
3155   fi
3156elif test "x$use_lint" = x"no" ; then
3157   if test "x$LINT" != "x"; then
3158      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
3159   fi
3160else
3161   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
3162fi
3163
3164# User supplied flags override default flags
3165if test "x$LINT_FLAGS" != "x"; then
3166   lint_options=$LINT_FLAGS
3167fi
3168
3169AC_SUBST([LINT_FLAGS],[$lint_options])
3170AM_CONDITIONAL(LINT, [test "x$LINT" != x])
3171
3172]) # XORG_WITH_LINT
3173
3174# XORG_LINT_LIBRARY(LIBNAME)
3175# --------------------------
3176# Minimum version: 1.1.0
3177#
3178# Sets up flags for building lint libraries for checking programs that call
3179# functions in the library.
3180#
3181# Interface to module:
3182# LINTLIB		- Automake variable with the name of lint library file to make
3183# MAKE_LINT_LIB		- Automake conditional
3184#
3185# --enable-lint-library:  - 'yes' user instructs the module to created a lint library
3186#			  - 'no' user instructs the module not to create a lint library (default)
3187
3188AC_DEFUN([XORG_LINT_LIBRARY],[
3189AC_REQUIRE([XORG_WITH_LINT])
3190AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
3191	[Create lint library (default: disabled)])],
3192	[make_lint_lib=$enableval], [make_lint_lib=no])
3193
3194if test "x$make_lint_lib" = x"yes" ; then
3195   LINTLIB=llib-l$1.ln
3196   if test "x$LINT" = "x"; then
3197        AC_MSG_ERROR([Cannot make lint library without --with-lint])
3198   fi
3199elif test "x$make_lint_lib" != x"no" ; then
3200   AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
3201fi
3202
3203AC_SUBST(LINTLIB)
3204AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
3205
3206]) # XORG_LINT_LIBRARY
3207
3208# XORG_COMPILER_BRAND
3209# -------------------
3210# Minimum version: 1.14.0
3211#
3212# Checks for various brands of compilers and sets flags as appropriate:
3213#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
3214#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
3215#   clang compiler - sets CLANGCC to "yes"
3216#   Intel compiler - sets INTELCC to "yes"
3217#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
3218#
3219AC_DEFUN([XORG_COMPILER_BRAND], [
3220AC_LANG_CASE(
3221	[C], [
3222		AC_REQUIRE([AC_PROG_CC_C99])
3223	],
3224	[C++], [
3225		AC_REQUIRE([AC_PROG_CXX])
3226	]
3227)
3228AC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
3229AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
3230AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
3231]) # XORG_COMPILER_BRAND
3232
3233# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
3234# ---------------
3235# Minimum version: 1.16.0
3236#
3237# Test if the compiler works when passed the given flag as a command line argument.
3238# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
3239# next flag in the list until there are no more options.
3240#
3241# Note that this does not guarantee that the compiler supports the flag as some
3242# compilers will simply ignore arguments that they do not understand, but we do
3243# attempt to weed out false positives by using -Werror=unknown-warning-option and
3244# -Werror=unused-command-line-argument
3245#
3246AC_DEFUN([XORG_TESTSET_CFLAG], [
3247m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
3248m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
3249
3250AC_LANG_COMPILER_REQUIRE
3251
3252AC_LANG_CASE(
3253	[C], [
3254		AC_REQUIRE([AC_PROG_CC_C99])
3255		define([PREFIX], [C])
3256		define([CACHE_PREFIX], [cc])
3257		define([COMPILER], [$CC])
3258	],
3259	[C++], [
3260		define([PREFIX], [CXX])
3261		define([CACHE_PREFIX], [cxx])
3262		define([COMPILER], [$CXX])
3263	]
3264)
3265
3266[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
3267
3268if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
3269	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
3270	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
3271			[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
3272			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
3273					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
3274					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
3275	[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
3276	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
3277fi
3278
3279if test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
3280	if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
3281		PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
3282	fi
3283	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
3284	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
3285			[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
3286			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
3287					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
3288					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
3289	[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
3290	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
3291fi
3292
3293found="no"
3294m4_foreach([flag], m4_cdr($@), [
3295	if test $found = "no" ; then
3296		if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
3297			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
3298		fi
3299
3300		if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
3301			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
3302		fi
3303
3304		PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
3305
3306dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
3307		AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
3308		cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
3309		AC_CACHE_VAL($cacheid,
3310			     [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
3311					     [eval $cacheid=yes],
3312					     [eval $cacheid=no])])
3313
3314		PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
3315
3316		eval supported=\$$cacheid
3317		AC_MSG_RESULT([$supported])
3318		if test "$supported" = "yes" ; then
3319			$1="$$1 ]flag["
3320			found="yes"
3321		fi
3322	fi
3323])
3324]) # XORG_TESTSET_CFLAG
3325
3326# XORG_COMPILER_FLAGS
3327# ---------------
3328# Minimum version: 1.16.0
3329#
3330# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
3331# arguments supported by the selected compiler which do NOT alter the generated
3332# code.  These arguments will cause the compiler to print various warnings
3333# during compilation AND turn a conservative set of warnings into errors.
3334#
3335# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
3336# future versions of util-macros as options are added to new compilers.
3337#
3338AC_DEFUN([XORG_COMPILER_FLAGS], [
3339AC_REQUIRE([XORG_COMPILER_BRAND])
3340
3341AC_ARG_ENABLE(selective-werror,
3342              AS_HELP_STRING([--disable-selective-werror],
3343                             [Turn off selective compiler errors. (default: enabled)]),
3344              [SELECTIVE_WERROR=$enableval],
3345              [SELECTIVE_WERROR=yes])
3346
3347AC_LANG_CASE(
3348        [C], [
3349                define([PREFIX], [C])
3350        ],
3351        [C++], [
3352                define([PREFIX], [CXX])
3353        ]
3354)
3355# -v is too short to test reliably with XORG_TESTSET_CFLAG
3356if test "x$SUNCC" = "xyes"; then
3357    [BASE_]PREFIX[FLAGS]="-v"
3358else
3359    [BASE_]PREFIX[FLAGS]=""
3360fi
3361
3362# This chunk of warnings were those that existed in the legacy CWARNFLAGS
3363XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
3364XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
3365XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
3366XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
3367
3368AC_LANG_CASE(
3369	[C], [
3370		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
3371		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
3372		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
3373		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
3374		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
3375		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
3376	]
3377)
3378
3379# This chunk adds additional warnings that could catch undesired effects.
3380XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
3381XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
3382XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
3383XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
3384XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
3385XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
3386XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
3387
3388# These are currently disabled because they are noisy.  They will be enabled
3389# in the future once the codebase is sufficiently modernized to silence
3390# them.  For now, I don't want them to drown out the other warnings.
3391# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
3392# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
3393# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
3394
3395# Turn some warnings into errors, so we don't accidently get successful builds
3396# when there are problems that should be fixed.
3397
3398if test "x$SELECTIVE_WERROR" = "xyes" ; then
3399XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
3400XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
3401XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
3402XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
3403XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
3404XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
3405XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
3406XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
3407XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
3408XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
3409XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
3410XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
3411XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
3412else
3413AC_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])
3414XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
3415XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
3416XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
3417XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
3418XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
3419XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
3420XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
3421XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
3422XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
3423XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
3424XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
3425XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
3426XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
3427fi
3428
3429AC_SUBST([BASE_]PREFIX[FLAGS])
3430]) # XORG_COMPILER_FLAGS
3431
3432# XORG_CWARNFLAGS
3433# ---------------
3434# Minimum version: 1.2.0
3435# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
3436#
3437# Defines CWARNFLAGS to enable C compiler warnings.
3438#
3439# This function is deprecated because it defines -fno-strict-aliasing
3440# which alters the code generated by the compiler.  If -fno-strict-aliasing
3441# is needed, then it should be added explicitly in the module when
3442# it is updated to use BASE_CFLAGS.
3443#
3444AC_DEFUN([XORG_CWARNFLAGS], [
3445AC_REQUIRE([XORG_COMPILER_FLAGS])
3446AC_REQUIRE([XORG_COMPILER_BRAND])
3447AC_LANG_CASE(
3448	[C], [
3449		CWARNFLAGS="$BASE_CFLAGS"
3450		if  test "x$GCC" = xyes ; then
3451		    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
3452		fi
3453		AC_SUBST(CWARNFLAGS)
3454	]
3455)
3456]) # XORG_CWARNFLAGS
3457
3458# XORG_STRICT_OPTION
3459# -----------------------
3460# Minimum version: 1.3.0
3461#
3462# Add configure option to enable strict compilation flags, such as treating
3463# warnings as fatal errors.
3464# If --enable-strict-compilation is passed to configure, adds strict flags to
3465# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
3466#
3467# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
3468# when strict compilation is unconditionally desired.
3469AC_DEFUN([XORG_STRICT_OPTION], [
3470AC_REQUIRE([XORG_CWARNFLAGS])
3471AC_REQUIRE([XORG_COMPILER_FLAGS])
3472
3473AC_ARG_ENABLE(strict-compilation,
3474			  AS_HELP_STRING([--enable-strict-compilation],
3475			  [Enable all warnings from compiler and make them errors (default: disabled)]),
3476			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
3477
3478AC_LANG_CASE(
3479        [C], [
3480                define([PREFIX], [C])
3481        ],
3482        [C++], [
3483                define([PREFIX], [CXX])
3484        ]
3485)
3486
3487[STRICT_]PREFIX[FLAGS]=""
3488XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
3489XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
3490
3491# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
3492# activate it with -Werror, so we add it here explicitly.
3493XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
3494
3495if test "x$STRICT_COMPILE" = "xyes"; then
3496    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
3497    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
3498fi
3499AC_SUBST([STRICT_]PREFIX[FLAGS])
3500AC_SUBST([BASE_]PREFIX[FLAGS])
3501AC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
3502]) # XORG_STRICT_OPTION
3503
3504# XORG_DEFAULT_OPTIONS
3505# --------------------
3506# Minimum version: 1.3.0
3507#
3508# Defines default options for X.Org modules.
3509#
3510AC_DEFUN([XORG_DEFAULT_OPTIONS], [
3511AC_REQUIRE([AC_PROG_INSTALL])
3512XORG_COMPILER_FLAGS
3513XORG_CWARNFLAGS
3514XORG_STRICT_OPTION
3515XORG_RELEASE_VERSION
3516XORG_CHANGELOG
3517XORG_INSTALL
3518XORG_MANPAGE_SECTIONS
3519m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
3520    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
3521]) # XORG_DEFAULT_OPTIONS
3522
3523# XORG_INSTALL()
3524# ----------------
3525# Minimum version: 1.4.0
3526#
3527# Defines the variable INSTALL_CMD as the command to copy
3528# INSTALL from $prefix/share/util-macros.
3529#
3530AC_DEFUN([XORG_INSTALL], [
3531AC_REQUIRE([PKG_PROG_PKG_CONFIG])
3532macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
3533INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
3534mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
3535|| (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \
3536echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
3537AC_SUBST([INSTALL_CMD])
3538]) # XORG_INSTALL
3539dnl Copyright 2005 Red Hat, Inc
3540dnl
3541dnl Permission to use, copy, modify, distribute, and sell this software and its
3542dnl documentation for any purpose is hereby granted without fee, provided that
3543dnl the above copyright notice appear in all copies and that both that
3544dnl copyright notice and this permission notice appear in supporting
3545dnl documentation.
3546dnl
3547dnl The above copyright notice and this permission notice shall be included
3548dnl in all copies or substantial portions of the Software.
3549dnl
3550dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3551dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3552dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
3553dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
3554dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
3555dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3556dnl OTHER DEALINGS IN THE SOFTWARE.
3557dnl
3558dnl Except as contained in this notice, the name of the copyright holders shall
3559dnl not be used in advertising or otherwise to promote the sale, use or
3560dnl other dealings in this Software without prior written authorization
3561dnl from the copyright holders.
3562dnl
3563
3564# XORG_RELEASE_VERSION
3565# --------------------
3566# Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use.
3567
3568AC_DEFUN([XORG_RELEASE_VERSION],[
3569	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
3570		[`echo $PACKAGE_VERSION | cut -d . -f 1`],
3571		[Major version of this package])
3572	PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1`
3573	if test "x$PVM" = "x"; then
3574		PVM="0"
3575	fi
3576	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
3577		[$PVM],
3578		[Minor version of this package])
3579	PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1`
3580	if test "x$PVP" = "x"; then
3581		PVP="0"
3582	fi
3583	AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
3584		[$PVP],
3585		[Patch version of this package])
3586])
3587
3588# XORG_CHANGELOG()
3589# ----------------
3590# Minimum version: 1.2.0
3591#
3592# Defines the variable CHANGELOG_CMD as the command to generate
3593# ChangeLog from git.
3594#
3595#
3596AC_DEFUN([XORG_CHANGELOG], [
3597CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp && \
3598mv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
3599|| (rm -f \$(top_srcdir)/.changelog.tmp; touch \$(top_srcdir)/ChangeLog; \
3600echo 'git directory not found: installing possibly empty changelog.' >&2)"
3601AC_SUBST([CHANGELOG_CMD])
3602]) # XORG_CHANGELOG
3603
3604# Copyright (C) 2002-2014 Free Software Foundation, Inc.
3605#
3606# This file is free software; the Free Software Foundation
3607# gives unlimited permission to copy and/or distribute it,
3608# with or without modifications, as long as this notice is preserved.
3609
3610# AM_AUTOMAKE_VERSION(VERSION)
3611# ----------------------------
3612# Automake X.Y traces this macro to ensure aclocal.m4 has been
3613# generated from the m4 files accompanying Automake X.Y.
3614# (This private macro should not be called outside this file.)
3615AC_DEFUN([AM_AUTOMAKE_VERSION],
3616[am__api_version='1.15'
3617dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3618dnl require some minimum version.  Point them to the right macro.
3619m4_if([$1], [1.15], [],
3620      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
3621])
3622
3623# _AM_AUTOCONF_VERSION(VERSION)
3624# -----------------------------
3625# aclocal traces this macro to find the Autoconf version.
3626# This is a private macro too.  Using m4_define simplifies
3627# the logic in aclocal, which can simply ignore this definition.
3628m4_define([_AM_AUTOCONF_VERSION], [])
3629
3630# AM_SET_CURRENT_AUTOMAKE_VERSION
3631# -------------------------------
3632# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
3633# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
3634AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
3635[AM_AUTOMAKE_VERSION([1.15])dnl
3636m4_ifndef([AC_AUTOCONF_VERSION],
3637  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
3638_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
3639
3640# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
3641
3642# Copyright (C) 2001-2014 Free Software Foundation, Inc.
3643#
3644# This file is free software; the Free Software Foundation
3645# gives unlimited permission to copy and/or distribute it,
3646# with or without modifications, as long as this notice is preserved.
3647
3648# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
3649# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
3650# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
3651#
3652# Of course, Automake must honor this variable whenever it calls a
3653# tool from the auxiliary directory.  The problem is that $srcdir (and
3654# therefore $ac_aux_dir as well) can be either absolute or relative,
3655# depending on how configure is run.  This is pretty annoying, since
3656# it makes $ac_aux_dir quite unusable in subdirectories: in the top
3657# source directory, any form will work fine, but in subdirectories a
3658# relative path needs to be adjusted first.
3659#
3660# $ac_aux_dir/missing
3661#    fails when called from a subdirectory if $ac_aux_dir is relative
3662# $top_srcdir/$ac_aux_dir/missing
3663#    fails if $ac_aux_dir is absolute,
3664#    fails when called from a subdirectory in a VPATH build with
3665#          a relative $ac_aux_dir
3666#
3667# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
3668# are both prefixed by $srcdir.  In an in-source build this is usually
3669# harmless because $srcdir is '.', but things will broke when you
3670# start a VPATH build or use an absolute $srcdir.
3671#
3672# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
3673# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
3674#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
3675# and then we would define $MISSING as
3676#   MISSING="\${SHELL} $am_aux_dir/missing"
3677# This will work as long as MISSING is not called from configure, because
3678# unfortunately $(top_srcdir) has no meaning in configure.
3679# However there are other variables, like CC, which are often used in
3680# configure, and could therefore not use this "fixed" $ac_aux_dir.
3681#
3682# Another solution, used here, is to always expand $ac_aux_dir to an
3683# absolute PATH.  The drawback is that using absolute paths prevent a
3684# configured tree to be moved without reconfiguration.
3685
3686AC_DEFUN([AM_AUX_DIR_EXPAND],
3687[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
3688# Expand $ac_aux_dir to an absolute path.
3689am_aux_dir=`cd "$ac_aux_dir" && pwd`
3690])
3691
3692# AM_CONDITIONAL                                            -*- Autoconf -*-
3693
3694# Copyright (C) 1997-2014 Free Software Foundation, Inc.
3695#
3696# This file is free software; the Free Software Foundation
3697# gives unlimited permission to copy and/or distribute it,
3698# with or without modifications, as long as this notice is preserved.
3699
3700# AM_CONDITIONAL(NAME, SHELL-CONDITION)
3701# -------------------------------------
3702# Define a conditional.
3703AC_DEFUN([AM_CONDITIONAL],
3704[AC_PREREQ([2.52])dnl
3705 m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
3706       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
3707AC_SUBST([$1_TRUE])dnl
3708AC_SUBST([$1_FALSE])dnl
3709_AM_SUBST_NOTMAKE([$1_TRUE])dnl
3710_AM_SUBST_NOTMAKE([$1_FALSE])dnl
3711m4_define([_AM_COND_VALUE_$1], [$2])dnl
3712if $2; then
3713  $1_TRUE=
3714  $1_FALSE='#'
3715else
3716  $1_TRUE='#'
3717  $1_FALSE=
3718fi
3719AC_CONFIG_COMMANDS_PRE(
3720[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
3721  AC_MSG_ERROR([[conditional "$1" was never defined.
3722Usually this means the macro was only invoked conditionally.]])
3723fi])])
3724
3725# Copyright (C) 1999-2014 Free Software Foundation, Inc.
3726#
3727# This file is free software; the Free Software Foundation
3728# gives unlimited permission to copy and/or distribute it,
3729# with or without modifications, as long as this notice is preserved.
3730
3731
3732# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
3733# written in clear, in which case automake, when reading aclocal.m4,
3734# will think it sees a *use*, and therefore will trigger all it's
3735# C support machinery.  Also note that it means that autoscan, seeing
3736# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
3737
3738
3739# _AM_DEPENDENCIES(NAME)
3740# ----------------------
3741# See how the compiler implements dependency checking.
3742# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
3743# We try a few techniques and use that to set a single cache variable.
3744#
3745# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
3746# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
3747# dependency, and given that the user is not expected to run this macro,
3748# just rely on AC_PROG_CC.
3749AC_DEFUN([_AM_DEPENDENCIES],
3750[AC_REQUIRE([AM_SET_DEPDIR])dnl
3751AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
3752AC_REQUIRE([AM_MAKE_INCLUDE])dnl
3753AC_REQUIRE([AM_DEP_TRACK])dnl
3754
3755m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
3756      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
3757      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
3758      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
3759      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
3760      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
3761                    [depcc="$$1"   am_compiler_list=])
3762
3763AC_CACHE_CHECK([dependency style of $depcc],
3764               [am_cv_$1_dependencies_compiler_type],
3765[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
3766  # We make a subdir and do the tests there.  Otherwise we can end up
3767  # making bogus files that we don't know about and never remove.  For
3768  # instance it was reported that on HP-UX the gcc test will end up
3769  # making a dummy file named 'D' -- because '-MD' means "put the output
3770  # in D".
3771  rm -rf conftest.dir
3772  mkdir conftest.dir
3773  # Copy depcomp to subdir because otherwise we won't find it if we're
3774  # using a relative directory.
3775  cp "$am_depcomp" conftest.dir
3776  cd conftest.dir
3777  # We will build objects and dependencies in a subdirectory because
3778  # it helps to detect inapplicable dependency modes.  For instance
3779  # both Tru64's cc and ICC support -MD to output dependencies as a
3780  # side effect of compilation, but ICC will put the dependencies in
3781  # the current directory while Tru64 will put them in the object
3782  # directory.
3783  mkdir sub
3784
3785  am_cv_$1_dependencies_compiler_type=none
3786  if test "$am_compiler_list" = ""; then
3787     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
3788  fi
3789  am__universal=false
3790  m4_case([$1], [CC],
3791    [case " $depcc " in #(
3792     *\ -arch\ *\ -arch\ *) am__universal=true ;;
3793     esac],
3794    [CXX],
3795    [case " $depcc " in #(
3796     *\ -arch\ *\ -arch\ *) am__universal=true ;;
3797     esac])
3798
3799  for depmode in $am_compiler_list; do
3800    # Setup a source with many dependencies, because some compilers
3801    # like to wrap large dependency lists on column 80 (with \), and
3802    # we should not choose a depcomp mode which is confused by this.
3803    #
3804    # We need to recreate these files for each test, as the compiler may
3805    # overwrite some of them when testing with obscure command lines.
3806    # This happens at least with the AIX C compiler.
3807    : > sub/conftest.c
3808    for i in 1 2 3 4 5 6; do
3809      echo '#include "conftst'$i'.h"' >> sub/conftest.c
3810      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
3811      # Solaris 10 /bin/sh.
3812      echo '/* dummy */' > sub/conftst$i.h
3813    done
3814    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
3815
3816    # We check with '-c' and '-o' for the sake of the "dashmstdout"
3817    # mode.  It turns out that the SunPro C++ compiler does not properly
3818    # handle '-M -o', and we need to detect this.  Also, some Intel
3819    # versions had trouble with output in subdirs.
3820    am__obj=sub/conftest.${OBJEXT-o}
3821    am__minus_obj="-o $am__obj"
3822    case $depmode in
3823    gcc)
3824      # This depmode causes a compiler race in universal mode.
3825      test "$am__universal" = false || continue
3826      ;;
3827    nosideeffect)
3828      # After this tag, mechanisms are not by side-effect, so they'll
3829      # only be used when explicitly requested.
3830      if test "x$enable_dependency_tracking" = xyes; then
3831	continue
3832      else
3833	break
3834      fi
3835      ;;
3836    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
3837      # This compiler won't grok '-c -o', but also, the minuso test has
3838      # not run yet.  These depmodes are late enough in the game, and
3839      # so weak that their functioning should not be impacted.
3840      am__obj=conftest.${OBJEXT-o}
3841      am__minus_obj=
3842      ;;
3843    none) break ;;
3844    esac
3845    if depmode=$depmode \
3846       source=sub/conftest.c object=$am__obj \
3847       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
3848       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
3849         >/dev/null 2>conftest.err &&
3850       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
3851       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
3852       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
3853       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
3854      # icc doesn't choke on unknown options, it will just issue warnings
3855      # or remarks (even with -Werror).  So we grep stderr for any message
3856      # that says an option was ignored or not supported.
3857      # When given -MP, icc 7.0 and 7.1 complain thusly:
3858      #   icc: Command line warning: ignoring option '-M'; no argument required
3859      # The diagnosis changed in icc 8.0:
3860      #   icc: Command line remark: option '-MP' not supported
3861      if (grep 'ignoring option' conftest.err ||
3862          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
3863        am_cv_$1_dependencies_compiler_type=$depmode
3864        break
3865      fi
3866    fi
3867  done
3868
3869  cd ..
3870  rm -rf conftest.dir
3871else
3872  am_cv_$1_dependencies_compiler_type=none
3873fi
3874])
3875AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
3876AM_CONDITIONAL([am__fastdep$1], [
3877  test "x$enable_dependency_tracking" != xno \
3878  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
3879])
3880
3881
3882# AM_SET_DEPDIR
3883# -------------
3884# Choose a directory name for dependency files.
3885# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
3886AC_DEFUN([AM_SET_DEPDIR],
3887[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
3888AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
3889])
3890
3891
3892# AM_DEP_TRACK
3893# ------------
3894AC_DEFUN([AM_DEP_TRACK],
3895[AC_ARG_ENABLE([dependency-tracking], [dnl
3896AS_HELP_STRING(
3897  [--enable-dependency-tracking],
3898  [do not reject slow dependency extractors])
3899AS_HELP_STRING(
3900  [--disable-dependency-tracking],
3901  [speeds up one-time build])])
3902if test "x$enable_dependency_tracking" != xno; then
3903  am_depcomp="$ac_aux_dir/depcomp"
3904  AMDEPBACKSLASH='\'
3905  am__nodep='_no'
3906fi
3907AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
3908AC_SUBST([AMDEPBACKSLASH])dnl
3909_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
3910AC_SUBST([am__nodep])dnl
3911_AM_SUBST_NOTMAKE([am__nodep])dnl
3912])
3913
3914# Generate code to set up dependency tracking.              -*- Autoconf -*-
3915
3916# Copyright (C) 1999-2014 Free Software Foundation, Inc.
3917#
3918# This file is free software; the Free Software Foundation
3919# gives unlimited permission to copy and/or distribute it,
3920# with or without modifications, as long as this notice is preserved.
3921
3922
3923# _AM_OUTPUT_DEPENDENCY_COMMANDS
3924# ------------------------------
3925AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
3926[{
3927  # Older Autoconf quotes --file arguments for eval, but not when files
3928  # are listed without --file.  Let's play safe and only enable the eval
3929  # if we detect the quoting.
3930  case $CONFIG_FILES in
3931  *\'*) eval set x "$CONFIG_FILES" ;;
3932  *)   set x $CONFIG_FILES ;;
3933  esac
3934  shift
3935  for mf
3936  do
3937    # Strip MF so we end up with the name of the file.
3938    mf=`echo "$mf" | sed -e 's/:.*$//'`
3939    # Check whether this is an Automake generated Makefile or not.
3940    # We used to match only the files named 'Makefile.in', but
3941    # some people rename them; so instead we look at the file content.
3942    # Grep'ing the first line is not enough: some people post-process
3943    # each Makefile.in and add a new line on top of each file to say so.
3944    # Grep'ing the whole file is not good either: AIX grep has a line
3945    # limit of 2048, but all sed's we know have understand at least 4000.
3946    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
3947      dirpart=`AS_DIRNAME("$mf")`
3948    else
3949      continue
3950    fi
3951    # Extract the definition of DEPDIR, am__include, and am__quote
3952    # from the Makefile without running 'make'.
3953    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
3954    test -z "$DEPDIR" && continue
3955    am__include=`sed -n 's/^am__include = //p' < "$mf"`
3956    test -z "$am__include" && continue
3957    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
3958    # Find all dependency output files, they are included files with
3959    # $(DEPDIR) in their names.  We invoke sed twice because it is the
3960    # simplest approach to changing $(DEPDIR) to its actual value in the
3961    # expansion.
3962    for file in `sed -n "
3963      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
3964	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
3965      # Make sure the directory exists.
3966      test -f "$dirpart/$file" && continue
3967      fdir=`AS_DIRNAME(["$file"])`
3968      AS_MKDIR_P([$dirpart/$fdir])
3969      # echo "creating $dirpart/$file"
3970      echo '# dummy' > "$dirpart/$file"
3971    done
3972  done
3973}
3974])# _AM_OUTPUT_DEPENDENCY_COMMANDS
3975
3976
3977# AM_OUTPUT_DEPENDENCY_COMMANDS
3978# -----------------------------
3979# This macro should only be invoked once -- use via AC_REQUIRE.
3980#
3981# This code is only required when automatic dependency tracking
3982# is enabled.  FIXME.  This creates each '.P' file that we will
3983# need in order to bootstrap the dependency handling code.
3984AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
3985[AC_CONFIG_COMMANDS([depfiles],
3986     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
3987     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
3988])
3989
3990# Do all the work for Automake.                             -*- Autoconf -*-
3991
3992# Copyright (C) 1996-2014 Free Software Foundation, Inc.
3993#
3994# This file is free software; the Free Software Foundation
3995# gives unlimited permission to copy and/or distribute it,
3996# with or without modifications, as long as this notice is preserved.
3997
3998# This macro actually does too much.  Some checks are only needed if
3999# your package does certain things.  But this isn't really a big deal.
4000
4001dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
4002m4_define([AC_PROG_CC],
4003m4_defn([AC_PROG_CC])
4004[_AM_PROG_CC_C_O
4005])
4006
4007# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
4008# AM_INIT_AUTOMAKE([OPTIONS])
4009# -----------------------------------------------
4010# The call with PACKAGE and VERSION arguments is the old style
4011# call (pre autoconf-2.50), which is being phased out.  PACKAGE
4012# and VERSION should now be passed to AC_INIT and removed from
4013# the call to AM_INIT_AUTOMAKE.
4014# We support both call styles for the transition.  After
4015# the next Automake release, Autoconf can make the AC_INIT
4016# arguments mandatory, and then we can depend on a new Autoconf
4017# release and drop the old call support.
4018AC_DEFUN([AM_INIT_AUTOMAKE],
4019[AC_PREREQ([2.65])dnl
4020dnl Autoconf wants to disallow AM_ names.  We explicitly allow
4021dnl the ones we care about.
4022m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
4023AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
4024AC_REQUIRE([AC_PROG_INSTALL])dnl
4025if test "`cd $srcdir && pwd`" != "`pwd`"; then
4026  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
4027  # is not polluted with repeated "-I."
4028  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
4029  # test to see if srcdir already configured
4030  if test -f $srcdir/config.status; then
4031    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
4032  fi
4033fi
4034
4035# test whether we have cygpath
4036if test -z "$CYGPATH_W"; then
4037  if (cygpath --version) >/dev/null 2>/dev/null; then
4038    CYGPATH_W='cygpath -w'
4039  else
4040    CYGPATH_W=echo
4041  fi
4042fi
4043AC_SUBST([CYGPATH_W])
4044
4045# Define the identity of the package.
4046dnl Distinguish between old-style and new-style calls.
4047m4_ifval([$2],
4048[AC_DIAGNOSE([obsolete],
4049             [$0: two- and three-arguments forms are deprecated.])
4050m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
4051 AC_SUBST([PACKAGE], [$1])dnl
4052 AC_SUBST([VERSION], [$2])],
4053[_AM_SET_OPTIONS([$1])dnl
4054dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
4055m4_if(
4056  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
4057  [ok:ok],,
4058  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
4059 AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
4060 AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
4061
4062_AM_IF_OPTION([no-define],,
4063[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
4064 AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
4065
4066# Some tools Automake needs.
4067AC_REQUIRE([AM_SANITY_CHECK])dnl
4068AC_REQUIRE([AC_ARG_PROGRAM])dnl
4069AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
4070AM_MISSING_PROG([AUTOCONF], [autoconf])
4071AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
4072AM_MISSING_PROG([AUTOHEADER], [autoheader])
4073AM_MISSING_PROG([MAKEINFO], [makeinfo])
4074AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
4075AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
4076AC_REQUIRE([AC_PROG_MKDIR_P])dnl
4077# For better backward compatibility.  To be removed once Automake 1.9.x
4078# dies out for good.  For more background, see:
4079# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
4080# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
4081AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
4082# We need awk for the "check" target (and possibly the TAP driver).  The
4083# system "awk" is bad on some platforms.
4084AC_REQUIRE([AC_PROG_AWK])dnl
4085AC_REQUIRE([AC_PROG_MAKE_SET])dnl
4086AC_REQUIRE([AM_SET_LEADING_DOT])dnl
4087_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
4088	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
4089			     [_AM_PROG_TAR([v7])])])
4090_AM_IF_OPTION([no-dependencies],,
4091[AC_PROVIDE_IFELSE([AC_PROG_CC],
4092		  [_AM_DEPENDENCIES([CC])],
4093		  [m4_define([AC_PROG_CC],
4094			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
4095AC_PROVIDE_IFELSE([AC_PROG_CXX],
4096		  [_AM_DEPENDENCIES([CXX])],
4097		  [m4_define([AC_PROG_CXX],
4098			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
4099AC_PROVIDE_IFELSE([AC_PROG_OBJC],
4100		  [_AM_DEPENDENCIES([OBJC])],
4101		  [m4_define([AC_PROG_OBJC],
4102			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
4103AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
4104		  [_AM_DEPENDENCIES([OBJCXX])],
4105		  [m4_define([AC_PROG_OBJCXX],
4106			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
4107])
4108AC_REQUIRE([AM_SILENT_RULES])dnl
4109dnl The testsuite driver may need to know about EXEEXT, so add the
4110dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
4111dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
4112AC_CONFIG_COMMANDS_PRE(dnl
4113[m4_provide_if([_AM_COMPILER_EXEEXT],
4114  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
4115
4116# POSIX will say in a future version that running "rm -f" with no argument
4117# is OK; and we want to be able to make that assumption in our Makefile
4118# recipes.  So use an aggressive probe to check that the usage we want is
4119# actually supported "in the wild" to an acceptable degree.
4120# See automake bug#10828.
4121# To make any issue more visible, cause the running configure to be aborted
4122# by default if the 'rm' program in use doesn't match our expectations; the
4123# user can still override this though.
4124if rm -f && rm -fr && rm -rf; then : OK; else
4125  cat >&2 <<'END'
4126Oops!
4127
4128Your 'rm' program seems unable to run without file operands specified
4129on the command line, even when the '-f' option is present.  This is contrary
4130to the behaviour of most rm programs out there, and not conforming with
4131the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
4132
4133Please tell bug-automake@gnu.org about your system, including the value
4134of your $PATH and any error possibly output before this message.  This
4135can help us improve future automake versions.
4136
4137END
4138  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
4139    echo 'Configuration will proceed anyway, since you have set the' >&2
4140    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
4141    echo >&2
4142  else
4143    cat >&2 <<'END'
4144Aborting the configuration process, to ensure you take notice of the issue.
4145
4146You can download and install GNU coreutils to get an 'rm' implementation
4147that behaves properly: <http://www.gnu.org/software/coreutils/>.
4148
4149If you want to complete the configuration process using your problematic
4150'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
4151to "yes", and re-run configure.
4152
4153END
4154    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
4155  fi
4156fi
4157dnl The trailing newline in this macro's definition is deliberate, for
4158dnl backward compatibility and to allow trailing 'dnl'-style comments
4159dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
4160])
4161
4162dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
4163dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
4164dnl mangled by Autoconf and run in a shell conditional statement.
4165m4_define([_AC_COMPILER_EXEEXT],
4166m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
4167
4168# When config.status generates a header, we must update the stamp-h file.
4169# This file resides in the same directory as the config header
4170# that is generated.  The stamp files are numbered to have different names.
4171
4172# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
4173# loop where config.status creates the headers, so we can generate
4174# our stamp files there.
4175AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
4176[# Compute $1's index in $config_headers.
4177_am_arg=$1
4178_am_stamp_count=1
4179for _am_header in $config_headers :; do
4180  case $_am_header in
4181    $_am_arg | $_am_arg:* )
4182      break ;;
4183    * )
4184      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
4185  esac
4186done
4187echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
4188
4189# Copyright (C) 2001-2014 Free Software Foundation, Inc.
4190#
4191# This file is free software; the Free Software Foundation
4192# gives unlimited permission to copy and/or distribute it,
4193# with or without modifications, as long as this notice is preserved.
4194
4195# AM_PROG_INSTALL_SH
4196# ------------------
4197# Define $install_sh.
4198AC_DEFUN([AM_PROG_INSTALL_SH],
4199[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
4200if test x"${install_sh+set}" != xset; then
4201  case $am_aux_dir in
4202  *\ * | *\	*)
4203    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
4204  *)
4205    install_sh="\${SHELL} $am_aux_dir/install-sh"
4206  esac
4207fi
4208AC_SUBST([install_sh])])
4209
4210# Copyright (C) 2003-2014 Free Software Foundation, Inc.
4211#
4212# This file is free software; the Free Software Foundation
4213# gives unlimited permission to copy and/or distribute it,
4214# with or without modifications, as long as this notice is preserved.
4215
4216# Check whether the underlying file-system supports filenames
4217# with a leading dot.  For instance MS-DOS doesn't.
4218AC_DEFUN([AM_SET_LEADING_DOT],
4219[rm -rf .tst 2>/dev/null
4220mkdir .tst 2>/dev/null
4221if test -d .tst; then
4222  am__leading_dot=.
4223else
4224  am__leading_dot=_
4225fi
4226rmdir .tst 2>/dev/null
4227AC_SUBST([am__leading_dot])])
4228
4229# Check to see how 'make' treats includes.	            -*- Autoconf -*-
4230
4231# Copyright (C) 2001-2014 Free Software Foundation, Inc.
4232#
4233# This file is free software; the Free Software Foundation
4234# gives unlimited permission to copy and/or distribute it,
4235# with or without modifications, as long as this notice is preserved.
4236
4237# AM_MAKE_INCLUDE()
4238# -----------------
4239# Check to see how make treats includes.
4240AC_DEFUN([AM_MAKE_INCLUDE],
4241[am_make=${MAKE-make}
4242cat > confinc << 'END'
4243am__doit:
4244	@echo this is the am__doit target
4245.PHONY: am__doit
4246END
4247# If we don't find an include directive, just comment out the code.
4248AC_MSG_CHECKING([for style of include used by $am_make])
4249am__include="#"
4250am__quote=
4251_am_result=none
4252# First try GNU make style include.
4253echo "include confinc" > confmf
4254# Ignore all kinds of additional output from 'make'.
4255case `$am_make -s -f confmf 2> /dev/null` in #(
4256*the\ am__doit\ target*)
4257  am__include=include
4258  am__quote=
4259  _am_result=GNU
4260  ;;
4261esac
4262# Now try BSD make style include.
4263if test "$am__include" = "#"; then
4264   echo '.include "confinc"' > confmf
4265   case `$am_make -s -f confmf 2> /dev/null` in #(
4266   *the\ am__doit\ target*)
4267     am__include=.include
4268     am__quote="\""
4269     _am_result=BSD
4270     ;;
4271   esac
4272fi
4273AC_SUBST([am__include])
4274AC_SUBST([am__quote])
4275AC_MSG_RESULT([$_am_result])
4276rm -f confinc confmf
4277])
4278
4279# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
4280
4281# Copyright (C) 1997-2014 Free Software Foundation, Inc.
4282#
4283# This file is free software; the Free Software Foundation
4284# gives unlimited permission to copy and/or distribute it,
4285# with or without modifications, as long as this notice is preserved.
4286
4287# AM_MISSING_PROG(NAME, PROGRAM)
4288# ------------------------------
4289AC_DEFUN([AM_MISSING_PROG],
4290[AC_REQUIRE([AM_MISSING_HAS_RUN])
4291$1=${$1-"${am_missing_run}$2"}
4292AC_SUBST($1)])
4293
4294# AM_MISSING_HAS_RUN
4295# ------------------
4296# Define MISSING if not defined so far and test if it is modern enough.
4297# If it is, set am_missing_run to use it, otherwise, to nothing.
4298AC_DEFUN([AM_MISSING_HAS_RUN],
4299[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
4300AC_REQUIRE_AUX_FILE([missing])dnl
4301if test x"${MISSING+set}" != xset; then
4302  case $am_aux_dir in
4303  *\ * | *\	*)
4304    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
4305  *)
4306    MISSING="\${SHELL} $am_aux_dir/missing" ;;
4307  esac
4308fi
4309# Use eval to expand $SHELL
4310if eval "$MISSING --is-lightweight"; then
4311  am_missing_run="$MISSING "
4312else
4313  am_missing_run=
4314  AC_MSG_WARN(['missing' script is too old or missing])
4315fi
4316])
4317
4318# Helper functions for option handling.                     -*- Autoconf -*-
4319
4320# Copyright (C) 2001-2014 Free Software Foundation, Inc.
4321#
4322# This file is free software; the Free Software Foundation
4323# gives unlimited permission to copy and/or distribute it,
4324# with or without modifications, as long as this notice is preserved.
4325
4326# _AM_MANGLE_OPTION(NAME)
4327# -----------------------
4328AC_DEFUN([_AM_MANGLE_OPTION],
4329[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
4330
4331# _AM_SET_OPTION(NAME)
4332# --------------------
4333# Set option NAME.  Presently that only means defining a flag for this option.
4334AC_DEFUN([_AM_SET_OPTION],
4335[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
4336
4337# _AM_SET_OPTIONS(OPTIONS)
4338# ------------------------
4339# OPTIONS is a space-separated list of Automake options.
4340AC_DEFUN([_AM_SET_OPTIONS],
4341[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
4342
4343# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
4344# -------------------------------------------
4345# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
4346AC_DEFUN([_AM_IF_OPTION],
4347[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
4348
4349# Copyright (C) 1999-2014 Free Software Foundation, Inc.
4350#
4351# This file is free software; the Free Software Foundation
4352# gives unlimited permission to copy and/or distribute it,
4353# with or without modifications, as long as this notice is preserved.
4354
4355# _AM_PROG_CC_C_O
4356# ---------------
4357# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
4358# to automatically call this.
4359AC_DEFUN([_AM_PROG_CC_C_O],
4360[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
4361AC_REQUIRE_AUX_FILE([compile])dnl
4362AC_LANG_PUSH([C])dnl
4363AC_CACHE_CHECK(
4364  [whether $CC understands -c and -o together],
4365  [am_cv_prog_cc_c_o],
4366  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
4367  # Make sure it works both with $CC and with simple cc.
4368  # Following AC_PROG_CC_C_O, we do the test twice because some
4369  # compilers refuse to overwrite an existing .o file with -o,
4370  # though they will create one.
4371  am_cv_prog_cc_c_o=yes
4372  for am_i in 1 2; do
4373    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
4374         && test -f conftest2.$ac_objext; then
4375      : OK
4376    else
4377      am_cv_prog_cc_c_o=no
4378      break
4379    fi
4380  done
4381  rm -f core conftest*
4382  unset am_i])
4383if test "$am_cv_prog_cc_c_o" != yes; then
4384   # Losing compiler, so override with the script.
4385   # FIXME: It is wrong to rewrite CC.
4386   # But if we don't then we get into trouble of one sort or another.
4387   # A longer-term fix would be to have automake use am__CC in this case,
4388   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
4389   CC="$am_aux_dir/compile $CC"
4390fi
4391AC_LANG_POP([C])])
4392
4393# For backward compatibility.
4394AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
4395
4396# Copyright (C) 2001-2014 Free Software Foundation, Inc.
4397#
4398# This file is free software; the Free Software Foundation
4399# gives unlimited permission to copy and/or distribute it,
4400# with or without modifications, as long as this notice is preserved.
4401
4402# AM_RUN_LOG(COMMAND)
4403# -------------------
4404# Run COMMAND, save the exit status in ac_status, and log it.
4405# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
4406AC_DEFUN([AM_RUN_LOG],
4407[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
4408   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
4409   ac_status=$?
4410   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
4411   (exit $ac_status); }])
4412
4413# Check to make sure that the build environment is sane.    -*- Autoconf -*-
4414
4415# Copyright (C) 1996-2014 Free Software Foundation, Inc.
4416#
4417# This file is free software; the Free Software Foundation
4418# gives unlimited permission to copy and/or distribute it,
4419# with or without modifications, as long as this notice is preserved.
4420
4421# AM_SANITY_CHECK
4422# ---------------
4423AC_DEFUN([AM_SANITY_CHECK],
4424[AC_MSG_CHECKING([whether build environment is sane])
4425# Reject unsafe characters in $srcdir or the absolute working directory
4426# name.  Accept space and tab only in the latter.
4427am_lf='
4428'
4429case `pwd` in
4430  *[[\\\"\#\$\&\'\`$am_lf]]*)
4431    AC_MSG_ERROR([unsafe absolute working directory name]);;
4432esac
4433case $srcdir in
4434  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
4435    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
4436esac
4437
4438# Do 'set' in a subshell so we don't clobber the current shell's
4439# arguments.  Must try -L first in case configure is actually a
4440# symlink; some systems play weird games with the mod time of symlinks
4441# (eg FreeBSD returns the mod time of the symlink's containing
4442# directory).
4443if (
4444   am_has_slept=no
4445   for am_try in 1 2; do
4446     echo "timestamp, slept: $am_has_slept" > conftest.file
4447     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
4448     if test "$[*]" = "X"; then
4449	# -L didn't work.
4450	set X `ls -t "$srcdir/configure" conftest.file`
4451     fi
4452     if test "$[*]" != "X $srcdir/configure conftest.file" \
4453	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
4454
4455	# If neither matched, then we have a broken ls.  This can happen
4456	# if, for instance, CONFIG_SHELL is bash and it inherits a
4457	# broken ls alias from the environment.  This has actually
4458	# happened.  Such a system could not be considered "sane".
4459	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
4460  alias in your environment])
4461     fi
4462     if test "$[2]" = conftest.file || test $am_try -eq 2; then
4463       break
4464     fi
4465     # Just in case.
4466     sleep 1
4467     am_has_slept=yes
4468   done
4469   test "$[2]" = conftest.file
4470   )
4471then
4472   # Ok.
4473   :
4474else
4475   AC_MSG_ERROR([newly created file is older than distributed files!
4476Check your system clock])
4477fi
4478AC_MSG_RESULT([yes])
4479# If we didn't sleep, we still need to ensure time stamps of config.status and
4480# generated files are strictly newer.
4481am_sleep_pid=
4482if grep 'slept: no' conftest.file >/dev/null 2>&1; then
4483  ( sleep 1 ) &
4484  am_sleep_pid=$!
4485fi
4486AC_CONFIG_COMMANDS_PRE(
4487  [AC_MSG_CHECKING([that generated files are newer than configure])
4488   if test -n "$am_sleep_pid"; then
4489     # Hide warnings about reused PIDs.
4490     wait $am_sleep_pid 2>/dev/null
4491   fi
4492   AC_MSG_RESULT([done])])
4493rm -f conftest.file
4494])
4495
4496# Copyright (C) 2009-2014 Free Software Foundation, Inc.
4497#
4498# This file is free software; the Free Software Foundation
4499# gives unlimited permission to copy and/or distribute it,
4500# with or without modifications, as long as this notice is preserved.
4501
4502# AM_SILENT_RULES([DEFAULT])
4503# --------------------------
4504# Enable less verbose build rules; with the default set to DEFAULT
4505# ("yes" being less verbose, "no" or empty being verbose).
4506AC_DEFUN([AM_SILENT_RULES],
4507[AC_ARG_ENABLE([silent-rules], [dnl
4508AS_HELP_STRING(
4509  [--enable-silent-rules],
4510  [less verbose build output (undo: "make V=1")])
4511AS_HELP_STRING(
4512  [--disable-silent-rules],
4513  [verbose build output (undo: "make V=0")])dnl
4514])
4515case $enable_silent_rules in @%:@ (((
4516  yes) AM_DEFAULT_VERBOSITY=0;;
4517   no) AM_DEFAULT_VERBOSITY=1;;
4518    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
4519esac
4520dnl
4521dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
4522dnl do not support nested variable expansions.
4523dnl See automake bug#9928 and bug#10237.
4524am_make=${MAKE-make}
4525AC_CACHE_CHECK([whether $am_make supports nested variables],
4526   [am_cv_make_support_nested_variables],
4527   [if AS_ECHO([['TRUE=$(BAR$(V))
4528BAR0=false
4529BAR1=true
4530V=1
4531am__doit:
4532	@$(TRUE)
4533.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
4534  am_cv_make_support_nested_variables=yes
4535else
4536  am_cv_make_support_nested_variables=no
4537fi])
4538if test $am_cv_make_support_nested_variables = yes; then
4539  dnl Using '$V' instead of '$(V)' breaks IRIX make.
4540  AM_V='$(V)'
4541  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
4542else
4543  AM_V=$AM_DEFAULT_VERBOSITY
4544  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
4545fi
4546AC_SUBST([AM_V])dnl
4547AM_SUBST_NOTMAKE([AM_V])dnl
4548AC_SUBST([AM_DEFAULT_V])dnl
4549AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
4550AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
4551AM_BACKSLASH='\'
4552AC_SUBST([AM_BACKSLASH])dnl
4553_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
4554])
4555
4556# Copyright (C) 2001-2014 Free Software Foundation, Inc.
4557#
4558# This file is free software; the Free Software Foundation
4559# gives unlimited permission to copy and/or distribute it,
4560# with or without modifications, as long as this notice is preserved.
4561
4562# AM_PROG_INSTALL_STRIP
4563# ---------------------
4564# One issue with vendor 'install' (even GNU) is that you can't
4565# specify the program used to strip binaries.  This is especially
4566# annoying in cross-compiling environments, where the build's strip
4567# is unlikely to handle the host's binaries.
4568# Fortunately install-sh will honor a STRIPPROG variable, so we
4569# always use install-sh in "make install-strip", and initialize
4570# STRIPPROG with the value of the STRIP variable (set by the user).
4571AC_DEFUN([AM_PROG_INSTALL_STRIP],
4572[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
4573# Installed binaries are usually stripped using 'strip' when the user
4574# run "make install-strip".  However 'strip' might not be the right
4575# tool to use in cross-compilation environments, therefore Automake
4576# will honor the 'STRIP' environment variable to overrule this program.
4577dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
4578if test "$cross_compiling" != no; then
4579  AC_CHECK_TOOL([STRIP], [strip], :)
4580fi
4581INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
4582AC_SUBST([INSTALL_STRIP_PROGRAM])])
4583
4584# Copyright (C) 2006-2014 Free Software Foundation, Inc.
4585#
4586# This file is free software; the Free Software Foundation
4587# gives unlimited permission to copy and/or distribute it,
4588# with or without modifications, as long as this notice is preserved.
4589
4590# _AM_SUBST_NOTMAKE(VARIABLE)
4591# ---------------------------
4592# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
4593# This macro is traced by Automake.
4594AC_DEFUN([_AM_SUBST_NOTMAKE])
4595
4596# AM_SUBST_NOTMAKE(VARIABLE)
4597# --------------------------
4598# Public sister of _AM_SUBST_NOTMAKE.
4599AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
4600
4601# Check how to create a tarball.                            -*- Autoconf -*-
4602
4603# Copyright (C) 2004-2014 Free Software Foundation, Inc.
4604#
4605# This file is free software; the Free Software Foundation
4606# gives unlimited permission to copy and/or distribute it,
4607# with or without modifications, as long as this notice is preserved.
4608
4609# _AM_PROG_TAR(FORMAT)
4610# --------------------
4611# Check how to create a tarball in format FORMAT.
4612# FORMAT should be one of 'v7', 'ustar', or 'pax'.
4613#
4614# Substitute a variable $(am__tar) that is a command
4615# writing to stdout a FORMAT-tarball containing the directory
4616# $tardir.
4617#     tardir=directory && $(am__tar) > result.tar
4618#
4619# Substitute a variable $(am__untar) that extract such
4620# a tarball read from stdin.
4621#     $(am__untar) < result.tar
4622#
4623AC_DEFUN([_AM_PROG_TAR],
4624[# Always define AMTAR for backward compatibility.  Yes, it's still used
4625# in the wild :-(  We should find a proper way to deprecate it ...
4626AC_SUBST([AMTAR], ['$${TAR-tar}'])
4627
4628# We'll loop over all known methods to create a tar archive until one works.
4629_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
4630
4631m4_if([$1], [v7],
4632  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
4633
4634  [m4_case([$1],
4635    [ustar],
4636     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
4637      # There is notably a 21 bits limit for the UID and the GID.  In fact,
4638      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
4639      # and bug#13588).
4640      am_max_uid=2097151 # 2^21 - 1
4641      am_max_gid=$am_max_uid
4642      # The $UID and $GID variables are not portable, so we need to resort
4643      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
4644      # below are definitely unexpected, so allow the users to see them
4645      # (that is, avoid stderr redirection).
4646      am_uid=`id -u || echo unknown`
4647      am_gid=`id -g || echo unknown`
4648      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
4649      if test $am_uid -le $am_max_uid; then
4650         AC_MSG_RESULT([yes])
4651      else
4652         AC_MSG_RESULT([no])
4653         _am_tools=none
4654      fi
4655      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
4656      if test $am_gid -le $am_max_gid; then
4657         AC_MSG_RESULT([yes])
4658      else
4659        AC_MSG_RESULT([no])
4660        _am_tools=none
4661      fi],
4662
4663  [pax],
4664    [],
4665
4666  [m4_fatal([Unknown tar format])])
4667
4668  AC_MSG_CHECKING([how to create a $1 tar archive])
4669
4670  # Go ahead even if we have the value already cached.  We do so because we
4671  # need to set the values for the 'am__tar' and 'am__untar' variables.
4672  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
4673
4674  for _am_tool in $_am_tools; do
4675    case $_am_tool in
4676    gnutar)
4677      for _am_tar in tar gnutar gtar; do
4678        AM_RUN_LOG([$_am_tar --version]) && break
4679      done
4680      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
4681      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
4682      am__untar="$_am_tar -xf -"
4683      ;;
4684    plaintar)
4685      # Must skip GNU tar: if it does not support --format= it doesn't create
4686      # ustar tarball either.
4687      (tar --version) >/dev/null 2>&1 && continue
4688      am__tar='tar chf - "$$tardir"'
4689      am__tar_='tar chf - "$tardir"'
4690      am__untar='tar xf -'
4691      ;;
4692    pax)
4693      am__tar='pax -L -x $1 -w "$$tardir"'
4694      am__tar_='pax -L -x $1 -w "$tardir"'
4695      am__untar='pax -r'
4696      ;;
4697    cpio)
4698      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
4699      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
4700      am__untar='cpio -i -H $1 -d'
4701      ;;
4702    none)
4703      am__tar=false
4704      am__tar_=false
4705      am__untar=false
4706      ;;
4707    esac
4708
4709    # If the value was cached, stop now.  We just wanted to have am__tar
4710    # and am__untar set.
4711    test -n "${am_cv_prog_tar_$1}" && break
4712
4713    # tar/untar a dummy directory, and stop if the command works.
4714    rm -rf conftest.dir
4715    mkdir conftest.dir
4716    echo GrepMe > conftest.dir/file
4717    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
4718    rm -rf conftest.dir
4719    if test -s conftest.tar; then
4720      AM_RUN_LOG([$am__untar <conftest.tar])
4721      AM_RUN_LOG([cat conftest.dir/file])
4722      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
4723    fi
4724  done
4725  rm -rf conftest.dir
4726
4727  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
4728  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
4729
4730AC_SUBST([am__tar])
4731AC_SUBST([am__untar])
4732]) # _AM_PROG_TAR
4733
4734