1 dnl Autoconf macros for groff.
2 dnl Copyright (C) 1989, 1990, 1991, 1992, 1995 Free Software Foundation, Inc.
4 dnl This file is part of groff.
6 dnl groff is free software; you can redistribute it and/or modify it under
7 dnl the terms of the GNU General Public License as published by the Free
8 dnl Software Foundation; either version 2, or (at your option) any later
11 dnl groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 dnl You should have received a copy of the GNU General Public License along
17 dnl with groff; see the file COPYING. If not, write to the Free Software
18 dnl Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 [if test -z "$PSPRINT"; then
23 AC_CHECK_PROGS(LPR,lpr)
25 if test -n "$LPR" && test -n "$LP"; then
26 # HP-UX provides an lpr command that emulates lpr using lp,
27 # but it doesn't have lpq; in this case we want to use lp
29 AC_CHECK_PROGS(LPQ,lpq)
30 test -n "$LPQ" || LPR=
32 if test -n "$LPR"; then
34 elif test -n "$LP"; then
39 AC_MSG_CHECKING([for command to use for printing PostScript files])
40 AC_MSG_RESULT($PSPRINT)
41 # Figure out DVIPRINT from PSPRINT.
42 AC_MSG_CHECKING([for command to use for printing dvi files])
43 if test -n "$PSPRINT" && test -z "$DVIPRINT"; then
44 if test "X$PSPRINT" = "Xlpr"; then
51 AC_MSG_RESULT($DVIPRINT)])dnl
54 dnl Bison generated parsers have problems with C++ compilers other than g++.
55 dnl So byacc is preferred over bison.
57 AC_DEFUN(GROFF_PROG_YACC,
58 [AC_CHECK_PROGS(YACC, byacc 'bison -y', yacc)])dnl
61 dnl GROFF_CSH_HACK(if hack present, if not present)
63 AC_DEFUN(GROFF_CSH_HACK,
64 [AC_MSG_CHECKING([for csh hash hack])
65 cat <<EOF >conftest.sh
72 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
73 AC_MSG_RESULT(yes); $1
77 rm -f conftest.sh])dnl
80 dnl From udodo!hans@relay.NL.net (Hans Zuidam)
82 AC_DEFUN(GROFF_ISC_SYSV3,
83 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
85 if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
96 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
99 AC_TRY_COMPILE([#include <stdio.h>
100 extern "C" { void fileno(int); }],,
101 AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE),
106 dnl srand() of SunOS 4.1.3 has return type int instead of void
108 AC_DEFUN(GROFF_SRAND,
111 AC_MSG_CHECKING([for return type of srand])
112 AC_TRY_COMPILE([#include <stdlib.h>
113 extern "C" { void srand(unsigned int); }],,
114 AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID),
119 AC_DEFUN(GROFF_SYS_NERR,
122 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
123 AC_TRY_COMPILE([#include <errno.h>
125 [int k; k = sys_nerr;],
126 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR),
131 AC_DEFUN(GROFF_SYS_ERRLIST,
132 [AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>])
133 AC_TRY_COMPILE([#include <errno.h>
135 [int k; k = (int)sys_errlist[0];],
136 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST),
137 AC_MSG_RESULT(no))])dnl
140 AC_DEFUN(GROFF_OSFCN_H,
143 AC_MSG_CHECKING([C++ <osfcn.h>])
144 AC_TRY_COMPILE([#include <osfcn.h>],
145 [read(0, 0, 0); open(0, 0);],
146 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
151 AC_DEFUN(GROFF_LIMITS_H,
154 AC_MSG_CHECKING([C++ <limits.h>])
155 AC_TRY_COMPILE([#include <limits.h>],
156 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
157 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),
162 AC_DEFUN(GROFF_TIME_T,
165 AC_MSG_CHECKING([for declaration of time_t])
166 AC_TRY_COMPILE([#include <time.h>],
167 [time_t t = time(0); struct tm *p = localtime(&t);],
169 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
173 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
174 [AC_MSG_CHECKING([struct exception])
175 AC_TRY_COMPILE([#include <math.h>],
176 [struct exception e;],
177 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
178 AC_MSG_RESULT(no))])dnl
181 AC_DEFUN(GROFF_ARRAY_DELETE,
184 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
187 char *p = new char[5]; delete [] p;changequote([,]),
189 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
194 AC_DEFUN(GROFF_TRADITIONAL_CPP,
197 AC_MSG_CHECKING([traditional preprocessor])
198 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
199 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
204 AC_DEFUN(GROFF_WCOREFLAG,
205 [AC_MSG_CHECKING([w_coredump])
206 AC_TRY_RUN([#include <sys/types.h>
207 #include <sys/wait.h>
214 ((union wait *)&i)->w_coredump = 1;
218 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),
220 AC_MSG_RESULT(no))])dnl
223 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
224 [AC_MSG_CHECKING([default value for grops -b option])
225 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
226 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
227 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
231 [AC_MSG_CHECKING([default paper size])
232 if test -z "$PAGE"; then
234 if test -r $prefix/share/groff/font/devps/DESC; then
235 descfile=$prefix/share/groff/font/devps/DESC
236 elif test -r $prefix/lib/groff/font/devps/DESC; then
237 descfile=$prefix/lib/groff/font/devps/DESC
239 for f in $prefix/share/groff/*/font/devps/DESC; do
246 if test -n "$descfile" \
247 && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
253 if test -z "$PAGE"; then
254 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
255 /etc/resolv.conf 2>/dev/null`
256 if test -z "$dom"; then
257 dom=`(domainname) 2>/dev/null | tr -d '+'`
258 if test -z "$dom"; then
259 dom=`(hostname) 2>/dev/null | grep '\.'`
263 # If the top-level domain is two letters and it's not `us' or `ca'
264 # then they probably use A4 paper.
266 *.[Uu][Ss]|*.[Cc][Aa]) ;;
267 *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
271 test -n "$PAGE" || PAGE=letter
276 AC_DEFUN(GROFF_CXX_CHECK,
277 [AC_REQUIRE([AC_PROG_CXX])
280 if test "$cross_compiling" = no; then
281 AC_MSG_CHECKING([that C++ compiler can compile simple program])
283 AC_TRY_RUN([int main() { return 0; }],
285 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
287 if test "$cross_compiling" = no; then
288 AC_MSG_CHECKING([that C++ static constructors and destructors are called])
298 ~A() { if (i == 1) _exit(0); }
301 int main() { return 1; }
304 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
306 AC_MSG_CHECKING([that header files support C++])
307 AC_TRY_LINK([#include <stdio.h>],
310 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++)]))
315 [AC_MSG_CHECKING([for prefix of system macro packages])
317 sys_tmac_file_prefix=
318 for d in /usr/share/lib/tmac /usr/lib/tmac; do
319 for t in "" tmac.; do
322 if test -z "$sys_tmac_prefix" \
324 && grep '^\.if' $f >/dev/null 2>&1; then
325 sys_tmac_prefix=$d/$t
326 sys_tmac_file_prefix=$t
331 AC_MSG_RESULT($sys_tmac_prefix)
332 AC_SUBST(sys_tmac_prefix)
334 AC_MSG_CHECKING([which system macro packages should be made available])
335 if test "x$sys_tmac_file_prefix" = "xtmac."; then
336 for f in $sys_tmac_prefix*; do
337 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
341 grep "Copyright.*Free Software Foundation" $f >/dev/null \
342 || tmac_wrap="$tmac_wrap $suff" ;;
345 elif test -n "$sys_tmac_prefix"; then
346 files=`echo $sys_tmac_prefix*`
347 grep "\\.so" $files >conftest.sol
350 ${sys_tmac_prefix}e) ;;
355 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
356 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
359 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
362 *) tmac_wrap="$tmac_wrap $suff" ;;
369 AC_MSG_RESULT([$tmac_wrap])
370 AC_SUBST(tmac_wrap)])dnl
374 [AC_MSG_CHECKING([for existing troff installation])
375 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
385 dnl We need the path to install-sh to be absolute.
387 AC_DEFUN(GROFF_INSTALL_SH,
388 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
389 ac_dir=`cd $ac_aux_dir; pwd`
390 ac_install_sh="$ac_dir/install-sh -c"])dnl
393 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
394 dnl does not have -lm.
397 [AC_CHECK_LIB(m,sin,LIBM=-lm)
401 dnl We need top_srcdir to be absolute.
403 AC_DEFUN(GROFF_SRCDIR,
404 [ac_srcdir_defaulted=no
405 srcdir=`cd $srcdir; pwd`])dnl
408 dnl This simplifies Makefile rules.
410 AC_DEFUN(GROFF_BUILDDIR,
412 AC_SUBST(top_builddir)])dnl
415 dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port
417 AC_DEFUN(GROFF_EBCDIC,
418 [AC_MSG_CHECKING([whether character set is EBCDIC])
420 [/* Treat any failure as ASCII for compatibility with existing art.
421 Use compile-time rather than run-time tests for cross-compiler
424 make an error "Character set is not EBCDIC"
426 groff_cv_ebcdic="yes"
427 TTYDEVDIRS="font/devcp1047"
429 AC_DEFINE(IS_EBCDIC_HOST),
431 TTYDEVDIRS="font/devascii font/devlatin1 font/devutf8"
433 AC_SUBST(TTYDEVDIRS)])dnl
436 dnl Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with
437 dnl gcc) to OS/390 uses ASCII internally.
439 AC_DEFUN(GROFF_OS390,
441 if test "$groff_cv_ebcdic" = "yes"; then
442 AC_MSG_CHECKING([for OS/390 Unix])
445 CFLAGS="$CFLAGS -D_ALL_SOURCE"
447 AC_MSG_RESULT(yes) ;;
454 dnl Finally, we must modify a base function of autoconf to replace the
455 dnl ASCII char `012' with its generic equivalent `\n' if we run under
456 dnl OS/390 Unix -- unfortunately, not all `tr' variants understand `\n',
457 dnl so this hack is necessary.
459 define([AC_OUTPUT_MAKE_DEFS],
460 [# Transform confdefs.h into DEFS.
461 dnl Using a here document instead of a string reduces the quoting nightmare.
462 # Protect against shell expansion while executing Makefile rules.
463 # Protect against Makefile macro expansion.
464 cat > conftest.defs <<\EOF
465 changequote(<<, >>)dnl
466 s%<<#define>> \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
467 s%[ `~<<#>>$^&*(){}\\|;'"<>?]%\\&%g
473 if test "$groff_cv_os390" = "yes"; then
474 DEFS=`sed -f conftest.defs confdefs.h | tr '\n' ' '`
476 DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
482 dnl Check whether we need a declaration for a function.
484 dnl Stolen from GNU bfd.
486 AC_DEFUN(GROFF_NEED_DECLARATION,
487 [AC_MSG_CHECKING([whether $1 must be declared])
490 AC_CACHE_VAL(groff_cv_decl_needed_$1,
496 #ifdef HAVE_STRINGS_H
509 [char *(*pfn) = (char *(*)) $1],
510 groff_cv_decl_needed_$1=no,
511 groff_cv_decl_needed_$1=yes)])
512 AC_MSG_RESULT($groff_cv_decl_needed_$1)
513 if test $groff_cv_decl_needed_$1 = yes; then
514 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]))