diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:44:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:44:05 +0000 |
commit | d318611dd6f23fcfedd50e9b9e24620b102ba96a (patch) | |
tree | 8b9eef82ca40fdd5a8deeabf07572074c236095d /m4 | |
parent | Initial commit. (diff) | |
download | groff-d318611dd6f23fcfedd50e9b9e24620b102ba96a.tar.xz groff-d318611dd6f23fcfedd50e9b9e24620b102ba96a.zip |
Adding upstream version 1.23.0.upstream/1.23.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | m4/ax_compare_version.m4 | 177 | ||||
-rw-r--r-- | m4/ax_prog_perl_version.m4 | 70 | ||||
-rw-r--r-- | m4/codeset.m4 | 23 | ||||
-rw-r--r-- | m4/fcntl-o.m4 | 134 | ||||
-rw-r--r-- | m4/glibc21.m4 | 33 | ||||
-rw-r--r-- | m4/groff.m4 | 1886 | ||||
-rw-r--r-- | m4/iconv.m4 | 271 | ||||
-rw-r--r-- | m4/lib-ld.m4 | 119 | ||||
-rw-r--r-- | m4/lib-link.m4 | 777 | ||||
-rw-r--r-- | m4/lib-prefix.m4 | 224 | ||||
-rw-r--r-- | m4/localcharset.m4 | 17 |
11 files changed, 3731 insertions, 0 deletions
diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4 new file mode 100644 index 0000000..74dc0fd --- /dev/null +++ b/m4/ax_compare_version.m4 @@ -0,0 +1,177 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# +# DESCRIPTION +# +# This macro compares two version strings. Due to the various number of +# minor-version numbers that can exist, and the fact that string +# comparisons are not compatible with numeric comparisons, this is not +# necessarily trivial to do in a autoconf script. This macro makes doing +# these comparisons easy. +# +# The six basic comparisons are available, as well as checking equality +# limited to a certain number of minor-version levels. +# +# The operator OP determines what type of comparison to do, and can be one +# of: +# +# eq - equal (test A == B) +# ne - not equal (test A != B) +# le - less than or equal (test A <= B) +# ge - greater than or equal (test A >= B) +# lt - less than (test A < B) +# gt - greater than (test A > B) +# +# Additionally, the eq and ne operator can have a number after it to limit +# the test to that number of minor versions. +# +# eq0 - equal up to the length of the shorter version +# ne0 - not equal up to the length of the shorter version +# eqN - equal up to N sub-version levels +# neN - not equal up to N sub-version levels +# +# When the condition is true, shell commands ACTION-IF-TRUE are run, +# otherwise shell commands ACTION-IF-FALSE are run. The environment +# variable 'ax_compare_version' is always set to either 'true' or 'false' +# as well. +# +# Examples: +# +# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) +# AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) +# +# would both be true. +# +# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) +# AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) +# +# would both be false. +# +# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) +# +# would be true because it is only comparing two minor versions. +# +# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) +# +# would be true because it is only comparing the lesser number of minor +# versions of the two values. +# +# Note: The characters that separate the version numbers do not matter. An +# empty string is the same as version 0. OP is evaluated by autoconf, not +# configure, so must be a string, not a variable. +# +# The author would like to acknowledge Guido Draheim whose advice about +# the m4_case and m4_ifvaln functions make this macro only include the +# portions necessary to perform the specific comparison specified by the +# OP argument in the final configure script. +# +# LICENSE +# +# Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 11 + +dnl ######################################################################### +AC_DEFUN([AX_COMPARE_VERSION], [ + AC_REQUIRE([AC_PROG_AWK]) + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + AS_VAR_PUSHDEF([A],[ax_compare_version_A]) + A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ + -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/[[^0-9]]//g'` + + AS_VAR_PUSHDEF([B],[ax_compare_version_B]) + B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ + -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/[[^0-9]]//g'` + + dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary + dnl # then the first line is used to determine if the condition is true. + dnl # The sed right after the echo is to remove any indented white space. + m4_case(m4_tolower($2), + [lt],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` + ], + [gt],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` + ], + [le],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` + ], + [ge],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` + ],[ + dnl Split the operator from the subversion count if present. + m4_bmatch(m4_substr($2,2), + [0],[ + # A count of zero means use the length of the shorter version. + # Determine the number of characters in A and B. + ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` + ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` + + # Set A to no more than B's length and B to no more than A's length. + A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` + B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` + ], + [[0-9]+],[ + # A count greater than zero means use only that many subversions + A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` + B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` + ], + [.+],[ + AC_WARNING( + [illegal OP numeric parameter: $2]) + ],[]) + + # Pad zeros at end of numbers to make same length. + ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" + B="$B`echo $A | sed 's/./0/g'`" + A="$ax_compare_version_tmp_A" + + # Check for equality or inequality as necessary. + m4_case(m4_tolower(m4_substr($2,0,2)), + [eq],[ + test "x$A" = "x$B" && ax_compare_version=true + ], + [ne],[ + test "x$A" != "x$B" && ax_compare_version=true + ],[ + AC_WARNING([illegal OP parameter: $2]) + ]) + ]) + + AS_VAR_POPDEF([A])dnl + AS_VAR_POPDEF([B])dnl + + dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. + if test "$ax_compare_version" = "true" ; then + m4_ifvaln([$4],[$4],[:])dnl + m4_ifvaln([$5],[else $5])dnl + fi +]) dnl AX_COMPARE_VERSION diff --git a/m4/ax_prog_perl_version.m4 b/m4/ax_prog_perl_version.m4 new file mode 100644 index 0000000..d794c1a --- /dev/null +++ b/m4/ax_prog_perl_version.m4 @@ -0,0 +1,70 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_perl_version.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_PERL_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE]) +# +# DESCRIPTION +# +# Makes sure that perl supports the version indicated. If true the shell +# commands in ACTION-IF-TRUE are executed. If not the shell commands in +# ACTION-IF-FALSE are run. Note if $PERL is not set (for example by +# running AC_CHECK_PROG or AC_PATH_PROG) the macro will fail. +# +# Example: +# +# AC_PATH_PROG([PERL],[perl]) +# AX_PROG_PERL_VERSION([5.8.0],[ ... ],[ ... ]) +# +# This will check to make sure that the perl you have supports at least +# version 5.8.0. +# +# NOTE: This macro uses the $PERL variable to perform the check. +# AX_WITH_PERL can be used to set that variable prior to running this +# macro. The $PERL_VERSION variable will be valorized with the detected +# version. +# +# LICENSE +# +# Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 12 + +AC_DEFUN([AX_PROG_PERL_VERSION],[ + AC_REQUIRE([AC_PROG_SED]) + AC_REQUIRE([AC_PROG_GREP]) + + AS_IF([test -n "$PERL"],[ + ax_perl_version="$1" + + AC_MSG_CHECKING([for perl version]) + changequote(<<,>>) + perl_version=`$PERL --version 2>&1 \ + | $SED -n -e '/This is perl/b inspect +b +: inspect +s/.* (\{0,1\}v\([0-9]*\.[0-9]*\.[0-9]*\))\{0,1\} .*/\1/;p'` + changequote([,]) + AC_MSG_RESULT($perl_version) + + AC_SUBST([PERL_VERSION],[$perl_version]) + + AX_COMPARE_VERSION([$ax_perl_version],[le],[$perl_version],[ + : + $2 + ],[ + : + $3 + ]) + ],[ + AC_MSG_WARN([could not find the perl interpreter]) + $3 + ]) +]) diff --git a/m4/codeset.m4 b/m4/codeset.m4 new file mode 100644 index 0000000..4f09722 --- /dev/null +++ b/m4/codeset.m4 @@ -0,0 +1,23 @@ +# codeset.m4 serial 5 (gettext-0.18.2) +dnl Copyright (C) 2000-2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <langinfo.h>]], + [[char* cs = nl_langinfo(CODESET); return !cs;]])], + [am_cv_langinfo_codeset=yes], + [am_cv_langinfo_codeset=no]) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE([HAVE_LANGINFO_CODESET], [1], + [Define if you have <langinfo.h> and nl_langinfo(CODESET).]) + fi +]) diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4 new file mode 100644 index 0000000..b0605e4 --- /dev/null +++ b/m4/fcntl-o.m4 @@ -0,0 +1,134 @@ +# fcntl-o.m4 serial 4 +dnl Copyright (C) 2006-2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. +# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. +# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. +AC_DEFUN([gl_FCNTL_O_FLAGS], +[ + dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW. + dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes + dnl AC_GNU_SOURCE. + m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], + [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], + [AC_REQUIRE([AC_GNU_SOURCE])]) + + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_FUNCS_ONCE([symlink]) + AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/types.h> + #include <sys/stat.h> + #if HAVE_UNISTD_H + # include <unistd.h> + #else /* on Windows with MSVC */ + # include <io.h> + # include <stdlib.h> + # defined sleep(n) _sleep ((n) * 1000) + #endif + #include <fcntl.h> + #ifndef O_NOATIME + #define O_NOATIME 0 + #endif + #ifndef O_NOFOLLOW + #define O_NOFOLLOW 0 + #endif + static int const constants[] = + { + O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, + O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY + }; + ]], + [[ + int result = !constants; + #if HAVE_SYMLINK + { + static char const sym[] = "conftest.sym"; + if (symlink ("/dev/null", sym) != 0) + result |= 2; + else + { + int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0); + if (fd >= 0) + { + close (fd); + result |= 4; + } + } + if (unlink (sym) != 0 || symlink (".", sym) != 0) + result |= 2; + else + { + int fd = open (sym, O_RDONLY | O_NOFOLLOW); + if (fd >= 0) + { + close (fd); + result |= 4; + } + } + unlink (sym); + } + #endif + { + static char const file[] = "confdefs.h"; + int fd = open (file, O_RDONLY | O_NOATIME); + if (fd < 0) + result |= 8; + else + { + struct stat st0; + if (fstat (fd, &st0) != 0) + result |= 16; + else + { + char c; + sleep (1); + if (read (fd, &c, 1) != 1) + result |= 24; + else + { + if (close (fd) != 0) + result |= 32; + else + { + struct stat st1; + if (stat (file, &st1) != 0) + result |= 40; + else + if (st0.st_atime != st1.st_atime) + result |= 64; + } + } + } + } + } + return result;]])], + [gl_cv_header_working_fcntl_h=yes], + [case $? in #( + 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( + 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( + 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( + *) gl_cv_header_working_fcntl_h='no';; + esac], + [gl_cv_header_working_fcntl_h=cross-compiling])]) + + case $gl_cv_header_working_fcntl_h in #( + *O_NOATIME* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val], + [Define to 1 if O_NOATIME works.]) + + case $gl_cv_header_working_fcntl_h in #( + *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val], + [Define to 1 if O_NOFOLLOW works.]) +]) diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 new file mode 100644 index 0000000..818b49f --- /dev/null +++ b/m4/glibc21.m4 @@ -0,0 +1,33 @@ +# glibc21.m4 serial 5 +dnl Copyright (C) 2000-2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Test for the GNU C Library, version 2.1 or newer, or uClibc. +# From Bruno Haible. + +AC_DEFUN([gl_GLIBC21], + [ + AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc], + [ac_cv_gnu_library_2_1], + [AC_EGREP_CPP([Lucky], + [ +#include <features.h> +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif +#ifdef __UCLIBC__ + Lucky user +#endif + ], + [ac_cv_gnu_library_2_1=yes], + [ac_cv_gnu_library_2_1=no]) + ] + ) + AC_SUBST([GLIBC21]) + GLIBC21="$ac_cv_gnu_library_2_1" + ] +) diff --git a/m4/groff.m4 b/m4/groff.m4 new file mode 100644 index 0000000..19bf7f9 --- /dev/null +++ b/m4/groff.m4 @@ -0,0 +1,1886 @@ +# Autoconf macros for groff. +# Copyright (C) 1989-2023 Free Software Foundation, Inc. +# +# This file is part of groff. +# +# groff is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# groff is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Locate a print spooler for certain output formats. + +AC_DEFUN([GROFF_PRINT], [ + groff_have_spooler=no + if test -z "$PSPRINT" + then + AC_CHECK_PROGS([LPR], [lpr]) + AC_CHECK_PROGS([LP], [lp]) + if test -n "$LPR" && test -n "$LP" + then + # HP-UX provides an lpr command that emulates lpr using lp, + # but it doesn't have lpq; in this case we want to use lp + # rather than lpr. + AC_CHECK_PROGS([LPQ], [lpq]) + test -n "$LPQ" || LPR= + fi + if test -n "$LPR" + then + PSPRINT="$LPR" + elif test -n "$LP" + then + PSPRINT="$LP" + fi + fi + + if test -n "$PSPRINT" + then + groff_have_spooler="$PSPRINT" + AC_SUBST([PSPRINT]) + # Figure out DVIPRINT from PSPRINT. + AC_MSG_CHECKING([option to use when spooling DVI files]) + spooler_option=none + if test -n "$PSPRINT" && test -z "$DVIPRINT" + then + if test "$PSPRINT" = lpr + then + spooler_option=-d + DVIPRINT="$PSPRINT $spooler_option" + else + DVIPRINT="$PSPRINT" + fi + fi + AC_SUBST([DVIPRINT]) + AC_MSG_RESULT([$spooler_option]) + fi +]) + +# Bison-generated parsers have problems with C++ compilers other than +# g++. Thus, byacc is preferred over bison. If no yacc program is +# available, we issue an error only if not building from a distribution +# archive, because files generated by a yacc are already present there. + +AC_DEFUN([GROFF_PROG_YACC], [ + AC_CHECK_PROGS([YACC], [byacc 'bison -y' yacc], [missing]) + if ! test -f "$srcdir"/.tarball-version + then + if test "$YACC" = missing + then + AC_MSG_ERROR([could not find 'byacc', 'bison', or 'yacc'], 1) + fi + fi +]) + +# We need Perl 5.6.1 or newer. + +AC_DEFUN([GROFF_PERL], [ + PERLVERSION=v5.6.1 + AC_PATH_PROG([PERL], [perl], [no]) + if test "$PERL" = no + then + AC_MSG_ERROR([perl binary not found], 1) + fi + AX_PROG_PERL_VERSION([$PERLVERSION], true, + AC_MSG_ERROR([perl version is too old], 1)) +]) + +# We need m4 to generate some man pages. + +AC_DEFUN([GROFF_PROG_M4], [ + AC_CHECK_PROGS([M4], [m4], [missing]) + if test "$M4" = missing + then + AC_MSG_ERROR([could not find 'm4'], 1) + fi +]) + +# We need makeinfo from Texinfo 5.0 or newer, for @codequoteundirected. +# The minor version checking logic is present for future needs. + +AC_DEFUN([GROFF_PROG_MAKEINFO], [ + # By default automake will set MAKEINFO to MAKEINFO = ${SHELL} <top + # src dir>/build-aux/missing makeinfo. As we need a more precise + # check of makeinfo version, we don't use it. + MAKEINFO= + missing= + AC_CHECK_PROG([MAKEINFO], [makeinfo], [makeinfo]) + if test -z "$MAKEINFO" + then + missing="missing 'makeinfo'" + else + AC_MSG_CHECKING([for makeinfo version]) + # We need an additional level of quoting to make sed's regexps + # work. + [makeinfo_version=`$MAKEINFO --version 2>&1 \ + | sed -e 's/^.* \([^ ][^ ]*\)$/\1/' -e '1q'`] + AC_MSG_RESULT([$makeinfo_version]) + # Consider only the first two numbers in version number string. + makeinfo_version_major=`IFS=.; set x $makeinfo_version; echo ${2}` + makeinfo_version_minor=`IFS=.; set x $makeinfo_version; echo ${3}` + makeinfo_version_numeric=` + expr ${makeinfo_version_major}000 + $makeinfo_version_minor` + if test $makeinfo_version_numeric -lt 5000 + then + missing="'makeinfo' is too old." + MAKEINFO= + fi + fi + + if test -n "$missing" + then + infofile=doc/groff.info + test -f $infofile || infofile="$srcdir"/$infofile + if test ! -f $infofile \ + || test "$srcdir"/doc/groff.texi -nt $infofile + then + AC_MSG_ERROR($missing +[Get the 'texinfo' package version 5.0 or newer.]) + fi + fi + AC_SUBST([MAKEINFO]) +]) + +# 'makeinfo' and 'texi2dvi' are distributed together, so if the former +# is too old, the latter is too. + +AC_DEFUN([GROFF_PROG_TEXI2DVI], [ + AC_REQUIRE([GROFF_PROG_MAKEINFO]) + AC_CHECK_PROG([PROG_TEXI2DVI], [texi2dvi], [texi2dvi], [missing]) + groff_have_texi2dvi=no + if test "$PROG_TEXI2DVI" != missing && test -n "$MAKEINFO" + then + groff_have_texi2dvi=yes + fi +]) + +# 'texi2dvi' can be installed without TeX itself, so check for a 'tex' +# executable independently. + +AC_DEFUN([GROFF_USE_TEX_CHECK], [ + AC_REQUIRE([GROFF_PROG_TEXI2DVI]) + AC_CHECK_PROG([PROG_TEX], [tex], [found], [missing]) + groff_use_tex=no + test "$PROG_TEX" = found && groff_use_tex=yes +]) + +# grohtml needs the following programs to produce images from tbl(1) +# tables and eqn(1) equations. + +dnl Any macro that tests $make_htmldoc should AC_REQUIRE this. + +AC_DEFUN([GROFF_CHECK_GROHTML_PROGRAMS], [ + AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH]) + + make_htmldoc=no + missing= + m4_foreach([groff_prog], +dnl Keep this list of programs in sync with grohtml test scripts. + [[pnmcrop], [pnmcut], [pnmtopng], [pnmtops], [psselect]], [ + AC_CHECK_PROG(groff_prog, groff_prog, [found], [missing]) + if test $[]groff_prog = missing + then + missing="$missing 'groff_prog'" + fi + ]) + + test "$GHOSTSCRIPT" = "missing" && missing="'gs' $missing" + + if test -z "$missing" + then + make_htmldoc=yes + else + plural=`set $missing; test $[#] -gt 1 && echo s` + oxford=`set $missing; test $[#] -gt 2 && echo ,` + missing=`set $missing + missing= + while test $[#] -gt 0 + do + case $[#] in + 1) missing="$missing$[1]" ;; + 2) missing="$missing$[1]$oxford and " ;; + *) missing="$missing$[1], " ;; + esac + shift + done + echo $missing` + verb=`set $missing + if test $[#] -gt 1 + then + echo were + else + echo was + fi` + + grohtml_notice="The program$plural $missing $verb not found in \ +\$PATH. + + Consequently, groff's HTML output driver, 'grohtml', will not work + properly. It will not be possible to prepare or install + groff-generated documentation in HTML format. +" + fi + AC_SUBST([make_htmldoc]) +]) + + +AC_DEFUN([GROFF_GROHTML_PROGRAM_NOTICE], [ + AC_REQUIRE([GROFF_CHECK_GROHTML_PROGRAMS]) + + if test "$make_htmldoc" = no + then + AC_MSG_NOTICE([$grohtml_notice]) + fi +]) + +dnl pdfroff uses awk, and we use it in GROFF_URW_FONTS_CHECK. + +AC_DEFUN([GROFF_AWK_NOTICE], [ + AC_REQUIRE([GROFF_AWK_PATH]) + + awk_names=awk + if test -n "$ALT_AWK_PROGS" + then + awk_names="$ALT_AWK_PROGS" + fi + + if test "$AWK" = missing + then + AC_MSG_NOTICE([No awk program was found in \$PATH. + + It was sought under the name(s) "$awk_names". + ]) + fi +]) + +AC_DEFUN([GROFF_PDFROFF_DEPENDENCIES_CHECK], [ + AC_REQUIRE([GROFF_AWK_PATH]) + AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH]) + + use_pdfroff=no + pdfroff_missing_deps= + + test "$AWK" = missing && pdfroff_missing_deps="awk" + + if test "$GHOSTSCRIPT" = missing + then + verb=is + + if test -n "$pdfroff_missing_deps" + then + pdfroff_missing_deps="$pdfroff_missing_deps and " + verb=are + fi + pdfroff_missing_deps="${pdfroff_missing_deps}Ghostscript $verb" + fi + + if test -z "$pdfroff_missing_deps" + then + use_pdfroff=yes + fi + + AC_SUBST([use_pdfroff]) +]) + +AC_DEFUN([GROFF_GROPDF_DEPENDENCIES_CHECK], [ + AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH]) + AC_REQUIRE([GROFF_URW_FONTS_CHECK]) + + use_gropdf=no + gropdf_missing_deps= + + if test "$GHOSTSCRIPT" != missing \ + || test "$groff_have_urw_fonts" = yes + then + use_gropdf=yes + fi + + AC_SUBST([use_gropdf]) +]) + +AC_DEFUN([GROFF_PDFROFF_PROGRAM_NOTICE], [ + AC_REQUIRE([GROFF_PDFROFF_DEPENDENCIES_CHECK]) + + if test "$use_pdfroff" = no + then + AC_MSG_NOTICE(['pdfroff' will not be functional. + + Because $pdfroff_missing_deps missing, 'pdfroff' will not operate + and the 'pdfmark.pdf' document will not be available. +]) + fi +]) + +AC_DEFUN([GROFF_GROPDF_PROGRAM_NOTICE], [ + AC_REQUIRE([GROFF_GROPDF_DEPENDENCIES_CHECK]) + + if test "$use_gropdf" = no + then + AC_MSG_NOTICE(['gropdf' will have reduced function. + + Neither Ghostscript nor URW fonts are available; groff documentation + thus will not be available in PDF. + + 'gropdf' will be able to handle only documents using the standard PDF + base 14 fonts, plus the 'EURO' font groff supplies, and font embedding + with its '-e' option (accessed via the 'groff' command with the option + '-P -e') will not be possible. +]) + fi +]) + +# Make URW font directory configurable. + +AC_DEFUN([GROFF_URW_FONTS_PATH], [ + AC_ARG_WITH([urw-fonts-dir], + [AS_HELP_STRING([--with-urw-fonts-dir=DIR], + [search for URW PostScript Type 1 fonts in DIR])], + [urwfontsdir="$withval"]) +]) + +# Check for availability of URW fonts in the directory specified by the +# user (see GROFF_URW_FONTS_PATH above). We do NOT search the path of +# directories built into Ghostscript because those fonts lack the +# corresponding AFM files we need to generate groff font description +# files; see afmtodit(1). Ghostscript's own fonts are treated as the +# "default foundry" and we already provide descriptions of them in +# font/devpdf (along with groff's EURO font). + +AC_DEFUN([GROFF_URW_FONTS_CHECK], [ + AC_REQUIRE([GROFF_URW_FONTS_PATH]) + AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH]) + groff_have_urw_fonts=no + AC_MSG_CHECKING([for URW fonts in Type 1/PFB format]) + +dnl Keep this list in sync with font/devpdf/Foundry.in. + _list_paths="\ + /usr/share/fonts/type1/gsfonts/ \ + /usr/share/fonts/default/Type1/ \ + /usr/share/fonts/default/Type1/adobestd35/ \ + /usr/share/fonts/type1/urw-base35/ \ + /opt/local/share/fonts/urw-fonts/ \ + /usr/local/share/fonts/ghostscript/" + + if test -n "$urwfontsdir" + then + _list_paths="$urwfontsdir" + fi + +dnl Keep this list of font file names in sync with the corresponding +dnl entry in font/devpdf/util/BuildFoundries.pl. + for k in $_list_paths + do + for _font_file in \ + URWGothic-Book \ + URWGothic-Book.t1 \ + URWGothic-Book.pfb \ + URWGothicL-Book.pfb \ + a010013l.pfb + do + if test -f $k/$_font_file + then + AC_MSG_RESULT([found in $k]) + groff_have_urw_fonts=yes + urwfontsdir=$k + break 2 + fi + done + done + + if test $groff_have_urw_fonts = no + then + AC_MSG_RESULT([none found]) + urwfontsdir= + fi + + AC_SUBST([groff_have_urw_fonts]) + AC_SUBST(urwfontsdir) +]) + +AC_DEFUN([GROFF_URW_FONTS_NOTICE], [ + if test "$groff_have_urw_fonts" = no + then + gs_verbiage= + if test "$GHOSTSCRIPT" != missing + then + gs_verbiage=' as well as the search path shown by the + "'"$GHOSTSCRIPT"' -h" command (if available)' + fi + AC_MSG_NOTICE([URW fonts in Type 1/PFB format were not found. + + groff font description files for the URW fonts, used by the 'gropdf' + output driver, will not be available. Use and embedding of fonts from + the 'U' foundry in PDF documents generated by groff will not be + possible. + + You can obtain the URW base 35 fonts from their GitHub project. As of + this writing (2023-02-15), you can find them in the 'fonts' directory + of the following archives (choose one). + + https://github.com/ArtifexSoftware/urw-base35-fonts/archive/refs/ + tags/20200910.zip + https://github.com/ArtifexSoftware/urw-base35-fonts/archive/refs/ + tags/20200910.tar.gz + + You may wish to check for a newer release. + + https://github.com/ArtifexSoftware/urw-base35-fonts/releases + + 'gropdf' looks for these fonts in several directories specified in + font/devpdf/Foundry.in$gs_verbiage. + + You will need to "make distclean" and re-run the 'configure' script + after installing the URW fonts. + + Alternatively, you can pass the option '--with-urw-fonts-dir=DIR' + to 'configure' to look for them in the directory DIR you specify. + If found, the 'U' foundry will be available via the '-y' option to + 'gropdf' (accessed via the 'groff' command with the option '-P -y'). + ]) + fi +]) + + +# Check whether the pnm tools accept the -quiet option. + +dnl Any macro that tests $pnmtools_quiet should AC_REQUIRE this. + +AC_DEFUN([GROFF_PNMTOOLS_CAN_BE_QUIET], [ + AC_REQUIRE([GROFF_CHECK_GROHTML_PROGRAMS]) + + pnmtools_quiet= + + if test "$make_htmldoc" = yes + then + AC_MSG_CHECKING([whether PNM tools accept the '-quiet' option]) + if echo P2 2 2 255 0 1 2 0 | pnmtops -quiet > /dev/null 2>&1 + then + AC_MSG_RESULT([yes]) + pnmtools_quiet=-quiet + else + AC_MSG_RESULT([no]) + fi + fi + AC_SUBST([pnmtools_quiet]) +]) + + +# Check whether pnmtops can handle the -nosetpage option. +# +# We require this both for grohtml operation and generation of +# doc/gnu.eps from repository builds. + +AC_DEFUN([GROFF_PNMTOPS_NOSETPAGE], [ + AC_REQUIRE([GROFF_PNMTOOLS_CAN_BE_QUIET]) + + pnmtops_nosetpage="pnmtops $pnmtools_quiet" + AC_MSG_CHECKING([whether pnmtops accepts the '-nosetpage' option]) + if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 + then + AC_MSG_RESULT([yes]) + pnmtops_nosetpage="pnmtops $pnmtools_quiet -nosetpage" + else + AC_MSG_RESULT([no]) + fi + AC_SUBST([pnmtops_nosetpage]) +]) + + +# Check location of 'gs'; allow '--with-gs=PROG' option to override. + +dnl Any macro that tests $GHOSTSCRIPT should AC_REQUIRE this. + +AC_DEFUN([GROFF_GHOSTSCRIPT_PATH], + [AC_REQUIRE([GROFF_GHOSTSCRIPT_PREFS]) + AC_ARG_WITH([gs], + [AS_HELP_STRING([--with-gs=PROG], + [actual [/path/]name of ghostscript executable])], + [GHOSTSCRIPT=$withval], + [AC_CHECK_TOOLS(GHOSTSCRIPT, [$ALT_GHOSTSCRIPT_PROGS], [missing])]) + test "$GHOSTSCRIPT" = no && GHOSTSCRIPT=missing]) + +# Preferences for choice of 'gs' program... +# (allow --with-alt-gs="LIST" to override). + +AC_DEFUN([GROFF_GHOSTSCRIPT_PREFS], + [AC_ARG_WITH([alt-gs], + [AS_HELP_STRING([--with-alt-gs=LIST], + [alternative names for ghostscript executable])], + [ALT_GHOSTSCRIPT_PROGS="$withval"], + [ALT_GHOSTSCRIPT_PROGS="gs gswin32c gsos2"]) + AC_SUBST([ALT_GHOSTSCRIPT_PROGS])]) + +AC_DEFUN([GROFF_GHOSTSCRIPT_AVAILABILITY_NOTICE], [ + AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH]) + + gs_names=gs + if test -n "$ALT_GHOSTSCRIPT_PROGS" + then + gs_names="$ALT_GHOSTSCRIPT_PROGS" + fi + + if test "$GHOSTSCRIPT" = missing + then + AC_MSG_NOTICE([No Ghostscript program was found in \$PATH. + + It was sought under the name(s) "$gs_names". + + groff documentation will not be available in HTML. + + 'grohtml' will have reduced function, being unable to produce + documents using the 'tbl' preprocessor. + ]) + fi +]) + +# Ghostscript version check. Versions 9.00 <= x < 9.54 suffer from a +# rendering glitch that affects the AT&T troff (and groff) special +# character \(lh; see +# <https://bugs.ghostscript.com/show_bug.cgi?id=703187>. + +AC_DEFUN([GROFF_GHOSTSCRIPT_VERSION_CHECK], [ + AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH]) + + if test "$GHOSTSCRIPT" != missing + then + AC_MSG_CHECKING([for gs version with good left sidebearing handling]) + ghostscript_notice= + ghostscript_version_good= + ghostscript_v_string=`"$GHOSTSCRIPT" -v | sed 1q` + # Get first word. + ghostscript_words=`echo "$ghostscript_v_string" | cut -d\ -f1-` + + # If the first word is "GPL", discard it. + if expr "$ghostscript_words" : "GPL" > /dev/null + then + ghostscript_words=`echo "$ghostscript_words" | cut -d\ -f2-` + fi + + # Only do a version check if the program calls itself Ghostscript. + if expr "$ghostscript_words" : "Ghostscript" > /dev/null + then + ghostscript_version_good=no + ghostscript_version=`echo "$ghostscript_words" | cut -d\ -f2` + ghostscript_major=`echo "$ghostscript_version" | cut -d. -f1` + ghostscript_minor=`echo "$ghostscript_version" | cut -d. -f2` + + if test "$ghostscript_major" -lt 9 + then + ghostscript_version_good=yes + elif test "$ghostscript_major" -ge 10 + then + ghostscript_version_good=yes + elif test "$ghostscript_minor" -ge 54 + then + ghostscript_version_good=yes + fi + fi + + if test "$ghostscript_version_good" = yes + then + ghostscript_version="$ghostscript_version (good)" + elif test "$ghostscript_version_good" = no + then + ghostscript_version="$ghostscript_version (buggy)" + ghostscript_notice="Buggy version of Ghostscript detected." + else + ghostscript_notice="Unable to determine version of Ghostscript." + fi + + if test -n "$ghostscript_version" + then + AC_MSG_RESULT([got $ghostscript_version]) + else + AC_MSG_RESULT([unable to determine]) + fi + fi +]) + +AC_DEFUN([GROFF_GHOSTSCRIPT_VERSION_NOTICE], [ + if test -n "$ghostscript_notice" + then + AC_MSG_NOTICE([$ghostscript_notice + + Ghostscript versions 9.00 <= x < 9.54 suffer from a rendering glitch + that affects the AT&T troff (and groff) special character '\(lh'; see + <https://bugs.ghostscript.com/show_bug.cgi?id=703187>. If your + version of Ghostscript has not been patched to fix this problem, you + may need to work around it in groff documents you render for the + PostScript (and, for tbl(1) tables, HTML) output devices. + ]) + fi +]) + +# Check location of 'awk'; allow '--with-awk=PROG' option to override. + +AC_DEFUN([GROFF_AWK_PATH], + [AC_REQUIRE([GROFF_AWK_PREFS]) + AC_ARG_WITH([awk], + [AS_HELP_STRING([--with-awk=PROG], + [actual [/path/]name of awk executable])], + [AWK=$withval], + [AC_CHECK_TOOLS(AWK, [$ALT_AWK_PROGS], [missing])]) + test "$AWK" = no && AWK=missing]) + + +# Preferences for choice of 'awk' program; allow --with-alt-awk="LIST" +# to override. + +AC_DEFUN([GROFF_AWK_PREFS], + [AC_ARG_WITH([alt-awk], + [AS_HELP_STRING([--with-alt-awk=LIST], + [alternative names for awk executable])], + [ALT_AWK_PROGS="$withval"], + [ALT_AWK_PROGS="gawk mawk nawk awk"]) + AC_SUBST([ALT_AWK_PROGS])]) + + +# GROFF_CSH_HACK(if hack present, if not present) + +AC_DEFUN([GROFF_CSH_HACK], + [AC_MSG_CHECKING([for csh hash hack]) + +cat <<EOF >conftest.sh +#! /bin/sh +true || exit 0 +export PATH || exit 0 +exit 1 +EOF + + chmod +x conftest.sh + if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then + AC_MSG_RESULT([yes]) + $1 + else + AC_MSG_RESULT([no]) + $2 + fi + rm -f conftest.sh]) + + +# From udodo!hans@relay.NL.net (Hans Zuidam) + +AC_DEFUN([GROFF_ISC_SYSV3], + [AC_MSG_CHECKING([for ISC 3.x or 4.x]) + if grep ['[34]\.'] /usr/options/cb.name >/dev/null 2>&1 + then + AC_MSG_RESULT([yes]) + AC_DEFINE([_SYSV3], [1], [Define if you have ISC 3.x or 4.x.]) + else + AC_MSG_RESULT([no]) + fi]) + +AC_DEFUN([GROFF_POSIX], + [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary]) + AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <stdio.h> +extern "C" { void fileno(int); } + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE([_POSIX_SOURCE], [1], + [Define if -D_POSIX_SOURCE is necessary.])], + [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++])]) + + +# srand() of SunOS 4.1.3 has return type int instead of void + +AC_DEFUN([GROFF_SRAND], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([for return type of srand]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <stdlib.h> +extern "C" { void srand(unsigned int); } + + ]]) + ], + [AC_MSG_RESULT([void]) + AC_DEFINE([RET_TYPE_SRAND_IS_VOID], [1], + [Define if srand() returns void not int.])], + [AC_MSG_RESULT([int])]) + AC_LANG_POP([C++])]) + + +# In April 2005, autoconf's AC_TYPE_SIGNAL is still broken. + +AC_DEFUN([GROFF_TYPE_SIGNAL], + [AC_MSG_CHECKING([for return type of signal handlers]) + for groff_declaration in \ + 'extern "C" void (*signal (int, void (*)(int)))(int);' \ + 'extern "C" void (*signal (int, void (*)(int)) throw ())(int);' \ + 'void (*signal ()) ();' + do + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <sys/types.h> +#include <signal.h> +#ifdef signal +# undef signal +#endif +$groff_declaration + + ]], + [[ + +int i; + + ]]) + ], + [break], + [continue]) + done + + if test -n "$groff_declaration"; then + AC_MSG_RESULT([void]) + AC_DEFINE([RETSIGTYPE], [void], + [Define as the return type of signal handlers + ('int' or 'void').]) + else + AC_MSG_RESULT([int]) + AC_DEFINE([RETSIGTYPE], [int], + [Define as the return type of signal handlers + ('int' or 'void').]) + fi]) + + +AC_DEFUN([GROFF_SYS_NERR], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([for sys_nerr in <errno.h>, <stdio.h>, or <stdlib.h>]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> + + ]], + [[ + +int k; +k = sys_nerr; + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_SYS_NERR], [1], + [Define if you have sys_nerr in <errno.h>, <stdio.h>, or <stdio.h>.])], + [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++])]) + +AC_DEFUN([GROFF_SYS_ERRLIST], + [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> + + ]], + [[ + +int k; +k = (int)sys_errlist[0]; + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_SYS_ERRLIST], [1], + [Define if you have sys_errlist in <errno.h>, <stdio.h>, or <stdlib.h>.])], + [AC_MSG_RESULT([no])])]) + +AC_DEFUN([GROFF_OSFCN_H], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([C++ <osfcn.h>]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <osfcn.h> + + ]], + [[ + +read(0, 0, 0); +open(0, 0); + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_CC_OSFCN_H], [1], + [Define if you have a C++ <osfcn.h>.])], + [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++])]) + + +AC_DEFUN([GROFF_LIMITS_H], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([C++ <limits.h>]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <limits.h> + + ]], + [[ + +int x = INT_MIN; +int y = INT_MAX; +int z = UCHAR_MAX; + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_CC_LIMITS_H], [1], + [Define if you have a C++ <limits.h>.])], + [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++])]) + +AC_DEFUN([GROFF_TIME_T], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([for declaration of time_t]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <time.h> + + ]], + [[ + +time_t t = time(0); +struct tm *p = localtime(&t); + + ]]) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_DEFINE([LONG_FOR_TIME_T], [1], + [Define if localtime() takes a long * not a time_t *.])]) + AC_LANG_POP([C++])]) + +AC_DEFUN([GROFF_STRUCT_EXCEPTION], + [AC_MSG_CHECKING([struct exception]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <math.h> + + ]], + [[ + +struct exception e; + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_STRUCT_EXCEPTION], [1], + [Define if <math.h> defines struct exception.])], + [AC_MSG_RESULT([no])])]) + +AC_DEFUN([GROFF_ARRAY_DELETE], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([whether ISO C++98 array deletion syntax is supported]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM(, [[ + +char *p = new char[5]; +delete [] p; + + ]]) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([an ISO C++98-conformant compiler is required])]) + AC_LANG_POP([C++])]) + +AC_DEFUN([GROFF_TRADITIONAL_CPP], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([whether C preprocessor uses pre-ISO C90 syntax]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#define name2(a, b) a/**/b + + ]], + [[ + +int name2(foo, bar); + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_MSG_ERROR([an ISO C90-conformant C preprocessor is required])], + [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++])]) + +AC_DEFUN([GROFF_WCOREFLAG], + [AC_MSG_CHECKING([w_coredump]) + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <sys/types.h> +#include <sys/wait.h> + + ]], + [[ + +main() +{ +#ifdef WCOREFLAG + exit(1); +#else + int i = 0; + ((union wait *)&i)->w_coredump = 1; + exit(i != 0200); +#endif +} + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE(WCOREFLAG, 0200, + [Define if the 0200 bit of the status returned by wait() indicates + whether a core image was produced for a process that was terminated + by a signal.])], + [AC_MSG_RESULT([no])], + [AC_MSG_RESULT([no])])]) + + +AC_DEFUN([GROFF_BROKEN_SPOOLER_FLAGS], + [AC_MSG_CHECKING([default value for grops -b option]) + test -n "$BROKEN_SPOOLER_FLAGS" || BROKEN_SPOOLER_FLAGS=0 + AC_MSG_RESULT([$BROKEN_SPOOLER_FLAGS]) + AC_SUBST([BROKEN_SPOOLER_FLAGS])]) + + +AC_DEFUN([GROFF_PAGE], [ + AC_MSG_CHECKING([default paper format]) + groff_prefix=$prefix + test "$prefix" = NONE && groff_prefix=$ac_default_prefix + if test -z "$PAGE" && test -r /etc/papersize + then + sedexpr='s/#.*//;s/[ \t]\+/ /;s/ \+$//;s/^ \+//;/^$/d;p' + PAGE=`sed -n "$sedexpr" /etc/papersize` + fi + if test -z "$PAGE" + then + descfile= + if test -r "$groff_prefix"/share/groff/font/devps/DESC + then + descfile=$groff_prefix/share/groff/font/devps/DESC + elif test -r "$groff_prefix"/lib/groff/font/devps/DESC + then + descfile=$groff_prefix/lib/groff/font/devps/DESC + else + for f in "$groff_prefix"/share/groff/*/font/devps/DESC + do + if test -r "$f" + then + descfile=$f + break + fi + done + fi + + if test -n "$descfile" + then + if grep -q ['^paperlength[ ]\+841890'] "$descfile" + then + PAGE=A4 + elif grep -q ['^papersize[ ]\+[aA]4'] "$descfile" + then + PAGE=A4 + fi + fi + fi + + if test -z "$PAGE" + then + domains= + if test -r /etc/resolv.conf + then + sedexpr='s/#.*//;s/[ \t]\+/ /;s/ \+$//;s/^ \+//;/^$/d; +/^\(domain\|search\)/!d;s/\(domain\|search\) //;p' + domains=`sed -n "$sedexpr" /etc/resolv.conf` + fi + if test -z "$domains" + then + domains=`(domainname) 2>/dev/null | tr -d '+'` + if test -z "$domains" || test "$domains" = '(none)' + then + domains=`(hostname) 2>/dev/null | grep '\.'` + fi + fi + # resolv.conf's "search" directive might return multiple domains. + # If any top-level domain is two letters and it's not 'us' or 'ca', + # assume the system uses A4 paper. + for d in $domains + do + case "$d" in + [*.[Uu][Ss]|*.[Cc][Aa])] + ;; + [*.[A-Za-z][A-Za-z])] + PAGE=A4 ;; + esac + done + fi + + test -n "$PAGE" || PAGE=letter + AC_MSG_RESULT([$PAGE]) + AC_SUBST([PAGE]) +]) + + +AC_DEFUN([GROFF_CXX_CHECK], + [AC_REQUIRE([AC_PROG_CXX]) + AC_LANG_PUSH([C++]) + if test "$cross_compiling" = no; then + AC_MSG_CHECKING([that C++ compiler can compile simple program]) + fi + AC_RUN_IFELSE([ + AC_LANG_SOURCE([[ + +int main() { + return 0; +} + + ]]) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([a working C++ compiler is required])], + [:]) + + if test "$cross_compiling" = no; then + AC_MSG_CHECKING([that C++ static constructors and destructors are called]) + fi + AC_RUN_IFELSE([ + AC_LANG_SOURCE([[ + +extern "C" { + void _exit(int); +} + +int i; +struct A { + char dummy; + A() { i = 1; } + ~A() { if (i == 1) _exit(0); } +}; + +A a; + +int main() +{ + return 1; +} + + ]]) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([a working C++ compiler is required])], + [:]) + + AC_MSG_CHECKING([that header files support C++]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <stdio.h> + + ]], + [[ + +fopen(0, 0); + + ]]) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([header files do not support C++ + (if you are using a version of gcc/g++ earlier than 2.5, + you should install libg++)])]) + AC_LANG_POP([C++])]) + + +AC_DEFUN([GROFF_TMAC], + [AC_MSG_CHECKING([for prefix of system macro packages]) + sys_tmac_prefix= + sys_tmac_file_prefix= + for d in /usr/share/lib/tmac /usr/lib/tmac; do + for t in "" tmac.; do + for m in an s m; do + f=$d/$t$m + if test -z "$sys_tmac_prefix" \ + && test -f $f \ + && grep '^\.if' $f >/dev/null 2>&1; then + sys_tmac_prefix=$d/$t + sys_tmac_file_prefix=$t + fi + done + done + done + sys_tmac_prefix_result=none + test -z "$sys_tmac_prefix" \ + || sys_tmac_prefix_result="$sys_tmac_prefix" + AC_MSG_RESULT([$sys_tmac_prefix_result]) + AC_SUBST([sys_tmac_prefix]) + + AC_MSG_CHECKING([which system macro packages should be made available]) + tmac_wrap= + if test "$sys_tmac_file_prefix" = tmac.; then + for f in $sys_tmac_prefix*; do + suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` + case "$suff" in + e) + ;; + *) + grep "Copyright.*Free Software Foundation" $f >/dev/null \ + || tmac_wrap="$tmac_wrap $suff" ;; + esac + done + elif test -n "$sys_tmac_prefix"; then + files=`echo $sys_tmac_prefix*` + grep "\\.so" $files >conftest.sol + for f in $files; do + case "$f" in + ${sys_tmac_prefix}e) + ;; + *.me) + ;; + */ms.*) + ;; + *) + b=`basename $f` + if grep "\\.so.*/$b\$" conftest.sol >/dev/null \ + || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then + : + else + suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` + case "$suff" in + tmac.*) + ;; + *) + tmac_wrap="$tmac_wrap $suff" ;; + esac + fi + esac + done + rm -f conftest.sol + fi + tmac_wrap_result="none found" + test -z "$tmac_wrap" || tmac_wrap_result="$tmac_wrap" + AC_MSG_RESULT([$tmac_wrap_result]) + AC_SUBST([tmac_wrap])]) + + +# Searching if a non-GNU Troff is installed. The built-in register +# \n[.g] is always 1 in GNU Troff. +AC_DEFUN([GROFF_G], [ + g= + AC_MSG_CHECKING([for existing troff installation]) + if test "`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) \ + 2>/dev/null`" = 0 + then + AC_MSG_RESULT([yes]) + g=g + else + AC_MSG_RESULT([no]) + fi + AC_SUBST([g]) +]) + + +# Controllable groff compatibility wrappers for vendor-provided macro sets +# +# Background +# +# groff's configure script checks for a non-GNU system troff implementation +# in GROFF_G above, and uses this to rename programs that would conflict +# with the system *roff implementation. On such systems, groff's version of +# troff is installed as gtroff, groff's version of nroff is installed as +# gnroff, and so forth. See the ENVIRONMENT section of groff(1)'s manual +# page for the entry on GROFF_COMMAND_PREFIX, and the SEE ALSO section for +# details. The implementation of this can be found in "We use Automake's +# Uniform Naming Scheme" in Makefile.am, and its use of NAMEPREFIX. +# +# groff's configure script also checks for vendor-provided macro sets in +# GROFF_TMAC above, which sets 'sys_tmac_prefix' to the location of any +# vendor-provided macro sets. The script then determines if any of these +# vendor-provided macro sets are non-GNU implementations. A space-separated +# list of macro sets requiring compatibility wrappers is stored in +# 'tmac_wrap'. +# +# If 'tmac_wrap' is a non-empty list, the make infrastructure will build +# groff compatibility wrappers in the 'tmac' directory for each mentioned +# macro set. These wrappers enable compatibility mode (.cp 1) and include +# (.so <filepath>) the vendor implementation of that macro set. The 'an' +# wrapper gets special treatment, by including the 'andoc.tmac' macro set, +# before loading the vendor implementation. +# +# In groff version 1.22.3 and prior, if 'tmac_wrap' is a non-empty list at +# installation time (make install), the groff compatibility wrappers are +# installed in '<prefix>/lib/groff/site-tmac' directory (technically +# 'systemtmacdir' in Makefile.am) as the base macro set name (example: +# an.tmac), and the groff implementation of these macro sets are installed +# with a 'g' prefix in the '<prefix>/share/groff/<version>/tmac' directory +# (example: gan.tmac). +# +# If your system has these compatibility wrappers installed, then the +# command 'groff -man ...' (as an example) uses your vendor's 'an' macro +# set in compatibility mode, while the command 'groff -mgan ...' uses the +# groff implementation of the 'an' macro set. +# +# With groff being the principal (but not the only) full-featured *roff +# implementation in use today, and most FLOSS Unix-like Operating Systems +# using groff as their *roff implementation, the automatic implementation +# of compatibility wrappers on systems having their own macro sets needs to +# be revisited. Most FLOSS software is now developed on systems having no +# other *roff implementation, so manual pages (for example) are developed +# and proofread on systems using groff's implementation of the 'an' macro +# set. +# +# On systems with their own macro sets (especially 'an'), documents can be +# rendered incorrectly from the document author's point of view, when +# these compatibility mode wrappers are used. groff's own manual pages are +# the perfect case in point, with most not showing the principal usage line +# of a command, due to the use of .SY/.OP/.YS macros to display such lines. +# +# Updating groff's use of compatibility mode wrappers +# +# Given the above, on systems with their own (non-GNU) macro sets, groff's +# AUTOMATIC installation of these generated vendor compatibility wrappers +# as the principal implementation of a macro set for groff(1) users may not +# be desirable, especially if the users are principally using groff(1) to +# format FLOSS manual pages. +# +# The '--with-compatibility-wrappers=<value>' option to 'configure' gives +# these systems control over the default macro set implementation in use +# when using the groff family of tools. +# +# The supported values of the '--with-compatibility-wrappers=<value>' +# option are: +# 'check' [default] Check if system has vendor-provided non-GNU +# implementation of any *roff macro set. Based on that use the +# 'yes' or 'no' value for '--with-compatibility-wrappers'. This +# effectively emulates prior groff releases' implementation. +# 'yes' Install the vendor compatibility wrappers as groff's default +# implementation of these macro sets. This is compatible with +# groff implementations up to and including version 1.22.3. +# Direct use of the 'yes' option is discouraged, as it will +# abort the configure process if no vendor-provided non-GNU +# macro set implementations exists. +# 'no' Do not install any vendor compatibility wrappers. Use the +# groff implementation of all macro sets as the default. +# 'manual' Install the vendor compatibility wrappers as '<macro>-os.tmac' +# in the same directory as 'yes' option ('systemtmacdir'). +# groff users can access the vendor-provided macro set via the +# '-m<macro>-os' option on the command line of a tool from the +# groff family. The naming of the option value reflects that now +# a manual step must be taken to use the vendor-provided +# implementation of the macro set. This option can safely be +# used on systems without vendor-provided non-GNU macro set +# implementations to allow for cross-platform build +# instructions. +# + +AC_DEFUN([GROFF_WITH_COMPATIBILITY_WRAPPERS], + [AC_ARG_WITH([compatibility-wrappers], + [AS_HELP_STRING([--with-compatibility-wrappers[={check|manual|no|yes}]], + [choose whether and how groff compatibility wrappers for \ + vendor-provided non-GNU macro packages are installed. \ + 'check' searches for such packages, and behaves as if 'yes' or \ + 'no' were given, accordingly. \ + 'yes' generates compatibility wrappers for the vendor-provided \ + packages to allow their use with groff and related tools. \ + The compatibility wrappers are installed using the + vendor-provided names, while their groff implementations are \ + installed with a 'g' prefix. \ + Use of the latter thus requires options of the form + '-mg<package>' (example: -mgan). \ + 'no' installs only the groff implementations. + 'manual' generates compatibility wrappers for the \ + vendor-provided packages as '<macro>-os'. \ + Use of the latter thus requires options of the form + '-m<macro>-os' option (example: -man-os).])], + [compatibility_wrappers="$withval"], + [compatibility_wrappers="check"]) + + if test "$compatibility_wrappers" != check \ + && test "$compatibility_wrappers" != yes \ + && test "$compatibility_wrappers" != no \ + && test "$compatibility_wrappers" != manual + then + AC_MSG_WARN([Invalid '--with-compatibility-wrappers' argument: '$compatibility_wrappers' - assuming 'check' requested.]) + compatibility_wrappers="check" + fi + + if test -z "$tmac_wrap" + then + # No Operating System Macro Sets Present + if test "$compatibility_wrappers" = check + then + compatibility_wrappers="no" + elif test "$compatibility_wrappers" = yes + then + AC_MSG_ERROR([No non-GNU macro sets found - cannot create and install compatibility wrappers]) + elif test "$compatibility_wrappers" = no + then + : # No action required + elif test "$compatibility_wrappers" = manual + then + # 'manual' allows quiet conversion to 'no' to support + # cross-platform build instructions + compatibility_wrappers="no" + fi + else + # One or more Operating System Macro Sets Present + if test "$compatibility_wrappers" = check + then + compatibility_wrappers="yes" + fi + fi + + # Now compatibility_wrappers can only be yes, no or manual + AC_SUBST([compatibility_wrappers]) + ]) + +# We need the path to install-sh to be absolute. + +AC_DEFUN([GROFF_INSTALL_SH], + [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) + ac_dir=`cd $ac_aux_dir; pwd` + ac_install_sh="$ac_dir/install-sh -c"]) + + +# Test whether install-info is available. + +AC_DEFUN([GROFF_INSTALL_INFO], + [AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])]) + + +# At least one Unix system, Apple Macintosh Rhapsody 5.5, +# does not have -lm ... + +AC_DEFUN([GROFF_LIBM], + [AC_CHECK_LIB([m], [sin], [LIBM=-lm]) + AC_SUBST([LIBM])]) + + +# ... while the MinGW implementation of GCC for Microsoft Win32 +# does not seem to have -lc. + +AC_DEFUN([GROFF_LIBC], + [AC_CHECK_LIB([c], [main], [LIBC=-lc]) + AC_SUBST([LIBC])]) + + +# Check for EBCDIC -- stolen from the OS390 Unix LYNX port + +AC_DEFUN([GROFF_EBCDIC], + [AC_MSG_CHECKING([whether character set is EBCDIC]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +/* Treat any failure as ASCII for compatibility with existing art. + Use compile-time rather than run-time tests for cross-compiler + tolerance. */ +#if '0' != 240 +make an error "Character set is not EBCDIC" +#endif + + ]]) + ], + [groff_cv_ebcdic="yes" + TTYDEVDIRS="font/devcp1047" + AC_MSG_RESULT([yes]) + AC_DEFINE(IS_EBCDIC_HOST, 1, + [Define if the host's encoding is EBCDIC.])], + [groff_cv_ebcdic="no" + TTYDEVDIRS="font/devascii font/devlatin1" + OTHERDEVDIRS="font/devlj4 font/devlbp" + AC_MSG_RESULT([no])]) + AC_SUBST([TTYDEVDIRS]) + AC_SUBST([OTHERDEVDIRS])]) + + +# Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with +# gcc) to OS/390 uses ASCII internally. + +AC_DEFUN([GROFF_OS390], + [if test "$groff_cv_ebcdic" = "yes"; then + AC_MSG_CHECKING([for OS/390 Unix]) + case `uname` in + OS/390) + CFLAGS="$CFLAGS -D_ALL_SOURCE" + AC_MSG_RESULT([yes]) ;; + *) + AC_MSG_RESULT([no]) ;; + esac + fi]) + + +# Check whether Windows scripts like 'afmtodit.cmd' should be installed. + +AC_DEFUN([GROFF_CMD_FILES], + [AC_MSG_CHECKING([whether to install .cmd wrapper scripts for Windows]) + case "$host_os" in + *mingw*) + make_winscripts=winscripts + AC_MSG_RESULT([yes]) ;; + *) + make_winscripts= + AC_MSG_RESULT([no]) ;; + esac + AC_SUBST([make_winscripts])]) + + +# Check whether we need a declaration for a function. +# +# Stolen from GNU bfd. + +AC_DEFUN([GROFF_NEED_DECLARATION], + [AC_MSG_CHECKING([whether $1 must be declared]) + AC_LANG_PUSH([C++]) + AC_CACHE_VAL([groff_cv_decl_needed_$1], + [AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_MATH_H +#include <math.h> +#endif + + ]], + [[ + +#ifndef $1 + char *p = (char *) $1; +#endif + + ]]) + ], + [groff_cv_decl_needed_$1=no], + [groff_cv_decl_needed_$1=yes])]) + AC_MSG_RESULT([$groff_cv_decl_needed_$1]) + if test $groff_cv_decl_needed_$1 = yes; then + AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), [1], + [Define if your C++ doesn't declare ]$1[().]) + fi + AC_LANG_POP([C++])]) + + +# If mkstemp() isn't available, use our own mkstemp.cpp file. + +AC_DEFUN([GROFF_MKSTEMP], + [AC_MSG_CHECKING([for mkstemp]) + AC_LANG_PUSH([C++]) + AC_LIBSOURCE([mkstemp.cpp]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <stdlib.h> +#include <unistd.h> +int (*f) (char *); + + ]], + [[ + +f = mkstemp; + + ]]) + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_MKSTEMP], [1], [Define if you have mkstemp().])], + [AC_MSG_RESULT([no]) + _AC_LIBOBJ([mkstemp])]) + AC_LANG_POP([C++])]) + + +# Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>, +# and declares uintmax_t. Taken from the fileutils package. + +AC_DEFUN([GROFF_INTTYPES_H], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([C++ <inttypes.h>]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <sys/types.h> +#include <inttypes.h> + + ]], + [[ + +uintmax_t i = (uintmax_t)-1; + + ]]) + ], + [groff_cv_header_inttypes_h=yes + AC_DEFINE([HAVE_CC_INTTYPES_H], [1], + [Define if you have a C++ <inttypes.h>.])], + [groff_cv_header_inttypes_h=no]) + AC_MSG_RESULT([$groff_cv_header_inttypes_h]) + AC_LANG_POP([C++])]) + + +# Test for working 'unsigned long long'. Taken from the fileutils package. + +AC_DEFUN([GROFF_UNSIGNED_LONG_LONG], + [AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([for unsigned long long]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + +unsigned long long ull = 1; +int i = 63; +unsigned long long ullmax = (unsigned long long)-1; + + ]], + [[ + +return ull << i | ull >> i | ullmax / ull | ullmax % ull; + + ]]) + ], + [groff_cv_type_unsigned_long_long=yes], + [groff_cv_type_unsigned_long_long=no]) + AC_MSG_RESULT([$groff_cv_type_unsigned_long_long]) + AC_LANG_POP([C++])]) + + +# Define uintmax_t to 'unsigned long' or 'unsigned long long' +# if <inttypes.h> does not exist. Taken from the fileutils package. + +AC_DEFUN([GROFF_UINTMAX_T], + [AC_REQUIRE([GROFF_INTTYPES_H]) + if test $groff_cv_header_inttypes_h = no; then + AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG]) + test $groff_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type], + [Define uintmax_t to 'unsigned long' or 'unsigned long long' if + <inttypes.h> does not exist.]) + fi]) + + +# Identify PATH_SEPARATOR character to use in GROFF_FONT_PATH and +# GROFF_TMAC_PATH which is appropriate for the target system (POSIX=':', +# MS-DOS/Win32=';'). +# +# The logic to resolve this test is already encapsulated in +# '$srcdir/src/include/nonposix.h'. + +AC_DEFUN([GROFF_TARGET_PATH_SEPARATOR], + [AC_MSG_CHECKING([separator character to use in groff search paths]) + cp "$srcdir"/src/include/nonposix.h conftest.h + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <ctype.h> +#include "conftest.h" + + ]], + [[ + +#if PATH_SEP_CHAR == ';' +make an error "Path separator is ';'" +#endif + + ]]) + ], + [GROFF_PATH_SEPARATOR=":"], + [GROFF_PATH_SEPARATOR=";"]) + AC_MSG_RESULT([$GROFF_PATH_SEPARATOR]) + AC_SUBST(GROFF_PATH_SEPARATOR)]) + + +# Check for X11. + +AC_DEFUN([GROFF_X11], [ + AC_REQUIRE([AC_PATH_XTRA]) + groff_no_x=$no_x + if test -z "$groff_no_x" + then + OLDCFLAGS=$CFLAGS + OLDLDFLAGS=$LDFLAGS + OLDLIBS=$LIBS + CFLAGS="$CFLAGS $X_CFLAGS" + LDFLAGS="$LDFLAGS $X_LIBS" + LIBS="$LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS" + + LIBS="$LIBS -lXaw" + AC_MSG_CHECKING([for Xaw library and header files]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <X11/Intrinsic.h> +#include <X11/Xaw/Simple.h> + + ]], + []) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + groff_no_x=yes]) + + LIBS="$LIBS -lXmu" + AC_MSG_CHECKING([for Xmu library and header files]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + +#include <X11/Intrinsic.h> +#include <X11/Xmu/Converters.h> + + ]], + []) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + groff_no_x=yes]) + + CFLAGS=$OLDCFLAGS + LDFLAGS=$OLDLDFLAGS + LIBS=$OLDLIBS + fi + + if ! test "$groff_no_x" = yes + then + XDEVDIRS="font/devX75 font/devX75-12 font/devX100 font/devX100-12" + XPROGDIRS="src/devices/xditview src/utils/xtotroff" + XLIBDIRS="src/libs/libxutil" + fi + + AC_SUBST([XDEVDIRS]) + AC_SUBST([XPROGDIRS]) + AC_SUBST([XLIBDIRS]) +]) + + +# Interpret the '--with-appdefdir' command-line option. + +dnl Don't quote AS_HELP_STRING! +dnl +dnl TODO: Include the computed default in the RHS of the help string. +AC_DEFUN([GROFF_APPDEFDIR_OPTION], [ + AC_ARG_WITH([appdefdir], + AS_HELP_STRING([--with-appdefdir=DIR], + [place X11 application defaults files in DIR])) +]) + + +# Get a default value for the application defaults directory. +# +# We ignore the 'XAPPLRES' and 'XUSERFILESEARCHPATH' environment +# variables. +# +# By default if --with-appdefdir is not used, we will install the +# gxditview application defaults in $prefix/lib/X11/app-defaults. +# +# Note that if --with-appdefdir was passed to 'configure', no prefix is +# added to 'appdefdir'. + +AC_DEFUN([GROFF_APPDEFDIR_DEFAULT], + [if test -z "$groff_no_x"; then + if test -z "$with_appdefdir"; then + if test "$prefix" = NONE; then + appdefdir=$ac_default_prefix/lib/X11/app-defaults + else + appdefdir=$prefix/lib/X11/app-defaults + fi + else + appdefdir=$with_appdefdir + fi + fi + AC_SUBST([appdefdir])]) + +# Emit warning if --with-appdefdir hasn't been used. + +AC_DEFUN([GROFF_APPDEFDIR_NOTICE], + [if test -z "$groff_no_x"; then + if test -z "$with_appdefdir"; then + AC_MSG_NOTICE([Default X11 application defaults directory \ +assumed. + + The application defaults files for gxditview (GXditview and + GXditview-color) will be installed in the following directory. + + $appdefdir + + To install elsewhere, say, '/etc/X11/app-defaults', add + '--with-appdefdir=/etc/X11/app-defaults' to the configure script + command-line options and rerun it (the 'prefix' value has no effect on + a --with-appdefdir option). + + If the gxditview app-defaults are installed in a directory that is not + one of the default X11 directories for this purpose (common defaults + are /usr/lib/X11/app-defaults, /usr/share/X11/app-defaults, and + /etc/X11/app-defaults), you will have to set the environment variable + XFILESEARCHPATH to this path. More details can be found in the X(7) + manual page, or in the document "X Toolkit Intrinsics - C Language + Interface manual". + ]) + fi + fi]) + + +AC_DEFUN([GROFF_LIBPROGRAMDIR_DEFAULT], + libprogramdir=$libdir/groff + AC_SUBST([libprogramdir])) + + +AC_DEFUN([GROFF_GLILYPONDDIR_DEFAULT], + glilypond_dir=$libprogramdir/glilypond + AC_SUBST([glilypond_dir])) + + +AC_DEFUN([GROFF_GPINYINDIR_DEFAULT], + gpinyin_dir=$libprogramdir/gpinyin + AC_SUBST([gpinyin_dir])) + + +AC_DEFUN([GROFF_REFERDIR_DEFAULT], + referdir=$libprogramdir/refer + AC_SUBST([referdir])) + +# Generation of doc/gnu.eps requires xpmtoppm. + +AC_DEFUN([GROFF_PROG_XPMTOPPM], + [AC_CHECK_PROG([XPMTOPPM], [xpmtoppm], [found], [missing])]) + +# Check for make built-in variable RM. + +AC_DEFUN([GROFF_MAKE_DEFINES_RM], [ + AC_MSG_CHECKING(whether make defines 'RM') + make=make + if test -n "$MAKE" + then + make=$MAKE + fi + cat <<EOF > test_make_rm.mk +all: + @if test -n "\$(RM)"; \ + then \ + echo yes; \ + else \ + echo no; \ + fi +EOF + groff_make_defines_rm=`"$make" -sf test_make_rm.mk` + AC_MSG_RESULT([$groff_make_defines_rm]) + rm -f test_make_rm.mk +]) + +# Check if diff has option -D, for gdiffmk. If not, check if gdiff is +# available on the system and make the same test. If either diff or +# gdiff is working, it is set to DIFF_PROG. If -D option is not +# available, DIFF_PROG is left to diff (gdiffmk will report a +# problem). + +AC_DEFUN([GROFF_DIFF_D], + [AC_MSG_CHECKING(for a diff program that supports option -D) + groff_has_diff_d_option=no + DIFF_PROG=diff + diff -Dx /dev/null /dev/null >/dev/null 2>&1 && groff_has_diff_d_option=yes + if test "$groff_has_diff_d_option" = no; then + AC_CHECK_PROGS([GDIFF], [gdiff]) + if test -n "$GDIFF"; then + "$GDIFF" -Dx /dev/null /dev/null >/dev/null 2>&1 && groff_has_diff_d_option=yes + if test "$groff_has_diff_d_option" = yes; then + DIFF_PROG="$GDIFF" + fi + fi + fi + AC_MSG_RESULT([$groff_has_diff_d_option]) + AC_SUBST([DIFF_PROG])]) + +# Check if 'test' supports the option -ef. + +AC_DEFUN([GROFF_HAVE_TEST_EF_OPTION], + [AC_MSG_CHECKING(whether test supports option -ef) + HAVE_TEST_EF_OPTION=no + test /dev/null -ef /dev/null > /dev/null 2>&1 && HAVE_TEST_EF_OPTION=yes + AC_MSG_RESULT([$HAVE_TEST_EF_OPTION]) + AC_SUBST([HAVE_TEST_EF_OPTION])]) + +# gdiffmk will attempt to use bash (for option -ef of 'test'). If bash +# is not available it will use /bin/sh. + +AC_DEFUN([GROFF_BASH], + [AC_PATH_PROGS([BASH_PROG], [bash], [no]) + if test "$BASH_PROG" = no; then + BASH_PROG=/bin/sh + fi + AC_SUBST([BASH_PROG])]) + +# Search for uchardet library used by preconv. + +AC_DEFUN([GROFF_UCHARDET], [ + AC_ARG_WITH([uchardet], + AS_HELP_STRING([--with-uchardet={auto|no|yes}], + [build 'preconv' against uchardet library to automatically \ +detect input file encoding])) + AS_IF([test "$with_uchardet" != no], + [PKG_CHECK_MODULES([UCHARDET], + [uchardet >= 0.0.1], + [AC_DEFINE([HAVE_UCHARDET], [1], + [uchardet library availability]) + groff_have_uchardet=yes], [ + if test "$with_uchardet" = yes + then + AC_MSG_FAILURE([could not find uchardet library]) + fi + groff_have_uchardet=no])], + [groff_have_uchardet=no]) +]) + +AC_DEFUN([GROFF_UCHARDET_NOTICE], [ + if test "$groff_have_uchardet" = no && test "$with_uchardet" != no + then + AC_MSG_NOTICE([The uchardet library was not found. + + The 'preconv' preprocessor program will be unable to attempt automatic + inference of an input file's character encoding. See the preconv(1) + man page. + ]) + fi +]) + + +AC_DEFUN([GROFF_USE_GROFF_ALLOCATOR], [ + AC_ARG_ENABLE([groff-allocator], + [AS_HELP_STRING([--enable-groff-allocator], [enable libgroff's \ +allocator for C++ new/delete])], + [test "$enableval" = yes && groff_use_own_allocator=yes], + [groff_use_own_allocator=no]) +]) diff --git a/m4/iconv.m4 b/m4/iconv.m4 new file mode 100644 index 0000000..ec7cd0a --- /dev/null +++ b/m4/iconv.m4 @@ -0,0 +1,271 @@ +# iconv.m4 serial 19 (gettext-0.18.2) +dnl Copyright (C) 2000-2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <stdlib.h> +#include <iconv.h> + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_func_iconv=yes]) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <stdlib.h> +#include <iconv.h> + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_lib_iconv=yes] + [am_cv_func_iconv=yes]) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ + dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, + dnl Solaris 10. + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + am_cv_func_iconv_works=no + for ac_iconv_const in '' 'const'; do + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <iconv.h> +#include <string.h> + +#ifndef ICONV_CONST +# define ICONV_CONST $ac_iconv_const +#endif + ]], + [[int result = 0; + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + ICONV_CONST char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + result |= 1; + iconv_close (cd_utf8_to_88591); + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\263"; + char buf[10]; + ICONV_CONST char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + result |= 2; + iconv_close (cd_ascii_to_88591); + } + } + /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\304"; + static char buf[2] = { (char)0xDE, (char)0xAD }; + ICONV_CONST char *inptr = input; + size_t inbytesleft = 1; + char *outptr = buf; + size_t outbytesleft = 1; + size_t res = iconv (cd_88591_to_utf8, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) + result |= 4; + iconv_close (cd_88591_to_utf8); + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + ICONV_CONST char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + result |= 8; + iconv_close (cd_88591_to_utf8); + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + result |= 16; + return result; +]])], + [am_cv_func_iconv_works=yes], , + [case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac]) + test "$am_cv_func_iconv_works" = no || break + done + LIBS="$am_save_LIBS" + ]) + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + AC_DEFINE([HAVE_ICONV], [1], + [Define if you have the iconv() function and it works.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST([LIBICONV]) + AC_SUBST([LTLIBICONV]) +]) + +dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to +dnl avoid warnings like +dnl "warning: AC_REQUIRE: 'AM_ICONV' was expanded before it was required". +dnl This is tricky because of the way 'aclocal' is implemented: +dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. +dnl Otherwise aclocal's initial scan pass would miss the macro definition. +dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. +dnl Otherwise aclocal would emit many "Use of uninitialized value $1" +dnl warnings. +m4_define([gl_iconv_AC_DEFUN], + m4_version_prereq([2.64], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [m4_ifdef([gl_00GNULIB], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [[AC_DEFUN( + [$1], [$2])]])])) +gl_iconv_AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL([am_cv_proto_iconv], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <stdlib.h> +#include <iconv.h> +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif + ]], + [[]])], + [am_cv_proto_iconv_arg1=""], + [am_cv_proto_iconv_arg1="const"]) + 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);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([ + $am_cv_proto_iconv]) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + [Define as const if the declaration of iconv() needs const.]) + dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>. + m4_ifdef([gl_ICONV_H_DEFAULTS], + [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) + if test -n "$am_cv_proto_iconv_arg1"; then + ICONV_CONST="const" + fi + ]) + fi +]) diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 new file mode 100644 index 0000000..d3eb0fc --- /dev/null +++ b/m4/lib-ld.m4 @@ -0,0 +1,119 @@ +# lib-ld.m4 serial 6 +dnl Copyright (C) 1996-2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Subroutines of libtool.m4, +dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid +dnl collision with libtool.m4. + +dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], +[# I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 </dev/null` in +*GNU* | *'with BFD'*) + acl_cv_prog_gnu_ld=yes + ;; +*) + acl_cv_prog_gnu_ld=no + ;; +esac]) +with_gnu_ld=$acl_cv_prog_gnu_ld +]) + +dnl From libtool-2.4. Sets the variable LD. +AC_DEFUN([AC_LIB_PROG_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld [default=no]])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` + while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL([acl_cv_path_LD], +[if test -z "$LD"; then + acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$acl_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break + ;; + *) + test "$with_gnu_ld" != yes && break + ;; + esac + fi + done + IFS="$acl_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$acl_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT([$LD]) +else + AC_MSG_RESULT([no]) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_LIB_PROG_LD_GNU +]) diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 new file mode 100644 index 0000000..4aa359a --- /dev/null +++ b/m4/lib-link.m4 @@ -0,0 +1,777 @@ +# lib-link.m4 serial 26 (gettext-0.18.2) +dnl Copyright (C) 2001-2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ([2.54]) + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname +dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + AC_SUBST([LIB]NAME[_PREFIX]) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + popdef([NAME]) + popdef([Name]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message]) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. The missing-message +dnl defaults to 'no' and may contain additional hints for the user. +dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} +dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname +dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, + dnl because these -l options might require -L options that are present in + dnl LIBS. -l options benefit only from the -L options listed before it. + dnl Otherwise, add it to the front of LIBS, because it may be a static + dnl library that depends on another static library that is present in LIBS. + dnl Static libraries benefit only from the static libraries listed after + dnl it. + case " $LIB[]NAME" in + *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; + *) LIBS="$LIB[]NAME $LIBS" ;; + esac + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[$3]], [[$4]])], + [ac_cv_lib[]Name=yes], + [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + LIB[]NAME[]_PREFIX= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + AC_SUBST([LIB]NAME[_PREFIX]) + popdef([NAME]) + popdef([Name]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl acl_libext, +dnl acl_shlibext, +dnl acl_libname_spec, +dnl acl_library_names_spec, +dnl acl_hardcode_libdir_flag_spec, +dnl acl_hardcode_libdir_separator, +dnl acl_hardcode_direct, +dnl acl_hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + dnl Tell automake >= 1.10 to complain if config.rpath is missing. + m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE([rpath], + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_FROMPACKAGE(name, package) +dnl declares that libname comes from the given package. The configure file +dnl will then not have a --with-libname-prefix option but a +dnl --with-package-prefix option. Several libraries can come from the same +dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar +dnl macro call that searches for libname. +AC_DEFUN([AC_LIB_FROMPACKAGE], +[ + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_frompackage_]NAME, [$2]) + popdef([NAME]) + pushdef([PACK],[$2]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_libsinpackage_]PACKUP, + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) + popdef([PACKUP]) + popdef([PACK]) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found +dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) + dnl Autoconf >= 2.61 supports dots in --with options. + pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_ARG_WITH(P_A_C_K[-prefix], +[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib + --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-search. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + LIB[]NAME[]_PREFIX= + dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been + dnl computed. So it has to be reset here. + HAVE_LIB[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + dnl The same code as in the loop below: + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$acl_hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi + popdef([P_A_C_K]) + popdef([PACKLIBS]) + popdef([PACKUP]) + popdef([PACK]) + popdef([NAME]) +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +dnl For those cases where a variable contains several -L and -l options +dnl referring to unknown libraries and directories, this macro determines the +dnl necessary additional linker options for the runtime path. +dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) +dnl sets LDADDVAR to linker options needed together with LIBSVALUE. +dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, +dnl otherwise linking without libtool is assumed. +AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], +[ + AC_REQUIRE([AC_LIB_RPATH]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + $1= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode directories into the resulting + dnl binary. + rpathdirs= + next= + for opt in $2; do + if test -n "$next"; then + dir="$next" + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n ""$3""; then + dnl libtool is used for linking. Use -R options. + for dir in $rpathdirs; do + $1="${$1}${$1:+ }-R$dir" + done + else + dnl The linker is used for linking directly. + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user + dnl must pass all path elements in one option. + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="$flag" + else + dnl The -rpath options are cumulative. + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="${$1}${$1:+ }$flag" + done + fi + fi + fi + fi + fi + AC_SUBST([$1]) +]) diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 new file mode 100644 index 0000000..ff90f8f --- /dev/null +++ b/m4/lib-prefix.m4 @@ -0,0 +1,224 @@ +# lib-prefix.m4 serial 7 (gettext-0.18) +dnl Copyright (C) 2001-2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_PREPARE_MULTILIB creates +dnl - a variable acl_libdirstem, containing the basename of the libdir, either +dnl "lib" or "lib64" or "lib/64", +dnl - a variable acl_libdirstem2, as a secondary possible value for +dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or +dnl "lib/amd64". +AC_DEFUN([AC_LIB_PREPARE_MULTILIB], +[ + dnl There is no formal standard regarding lib and lib64. + dnl On glibc systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine + dnl the compiler's default mode by looking at the compiler's library search + dnl path. If at least one of its elements ends in /lib64 or points to a + dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. + dnl Otherwise we use the default, namely "lib". + dnl On Solaris systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or + dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. + AC_REQUIRE([AC_CANONICAL_HOST]) + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment + dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>. + dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." + dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the + dnl symlink is missing, so we set acl_libdirstem2 too. + AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], + [AC_EGREP_CPP([sixtyfour bits], [ +#ifdef _LP64 +sixtyfour bits +#endif + ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) + ]) + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" +]) diff --git a/m4/localcharset.m4 b/m4/localcharset.m4 new file mode 100644 index 0000000..677aea5 --- /dev/null +++ b/m4/localcharset.m4 @@ -0,0 +1,17 @@ +# localcharset.m4 serial 7 +dnl Copyright (C) 2002-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_LOCALCHARSET], +[ + dnl Prerequisites of lib/localcharset.c. + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_REQUIRE([gl_FCNTL_O_FLAGS]) + AC_CHECK_DECLS_ONCE([getc_unlocked]) + + dnl Prerequisites of the lib/Makefile.am snippet. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_GLIBC21]) +]) |