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)])
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 AC_DEFUN(GROFF_PUTENV,
109 AC_MSG_CHECKING([declaration of putenv])
110 AC_TRY_COMPILE([#include <stdlib.h>
111 extern "C" { void putenv(int); }],,
113 AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_PUTENV))
117 AC_DEFUN(GROFF_POPEN,
120 AC_MSG_CHECKING([declaration of popen])
121 AC_TRY_COMPILE([#include <stdio.h>
122 extern "C" { void popen(int); }],,
124 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_POPEN))
128 AC_DEFUN(GROFF_PCLOSE,
131 AC_MSG_CHECKING([declaration of pclose])
132 AC_TRY_COMPILE([#include <stdio.h>
133 extern "C" { void pclose(int); }],,
135 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_PCLOSE))
139 AC_DEFUN(GROFF_SYS_NERR,
142 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
143 AC_TRY_COMPILE([#include <errno.h>
145 [int k; k = sys_nerr;],
146 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR),
151 AC_DEFUN(GROFF_SYS_ERRLIST,
154 AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>])
155 AC_TRY_COMPILE([#include <errno.h>
157 [int k; k = (int)sys_errlist[0];],
158 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST),
163 AC_DEFUN(GROFF_HYPOT,
166 AC_MSG_CHECKING([declaration of hypot])
167 AC_TRY_COMPILE([#include <math.h>
168 extern "C" { double hypot(double,double); }],,
170 AC_MSG_RESULT(yes);AC_DEFINE(MATH_H_DECLARES_HYPOT))
174 AC_DEFUN(GROFF_OSFCN_H,
177 AC_MSG_CHECKING([C++ <osfcn.h>])
178 AC_TRY_COMPILE([#include <osfcn.h>],
179 [read(0, 0, 0); open(0, 0);],
180 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
185 AC_DEFUN(GROFF_LIMITS_H,
188 AC_MSG_CHECKING([C++ <limits.h>])
189 AC_TRY_COMPILE([#include <limits.h>],
190 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
191 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),
196 AC_DEFUN(GROFF_TIME_T,
199 AC_MSG_CHECKING([for declaration of time_t])
200 AC_TRY_COMPILE([#include <time.h>],
201 [time_t t = time(0); struct tm *p = localtime(&t);],
203 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
207 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
208 [AC_MSG_CHECKING([struct exception])
209 AC_TRY_COMPILE([#include <math.h>],
210 [struct exception e;],
211 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
212 AC_MSG_RESULT(no))])dnl
215 AC_DEFUN(GROFF_ARRAY_DELETE,
218 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
221 char *p = new char[5]; delete [] p;changequote([,]),
223 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
228 AC_DEFUN(GROFF_TRADITIONAL_CPP,
231 AC_MSG_CHECKING([traditional preprocessor])
232 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
233 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
238 AC_DEFUN(GROFF_WCOREFLAG,
239 [AC_MSG_CHECKING([w_coredump])
240 AC_TRY_RUN([#include <sys/types.h>
241 #include <sys/wait.h>
248 ((union wait *)&i)->w_coredump = 1;
252 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),
254 AC_MSG_RESULT(no))])dnl
257 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
258 [AC_MSG_CHECKING([default value for grops -b option])
259 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
260 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
261 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
265 [AC_MSG_CHECKING([default paper size])
266 if test -z "$PAGE"; then
268 if test -r $prefix/share/groff/font/devps/DESC; then
269 descfile=$prefix/share/groff/font/devps/DESC
270 elif test -r $prefix/lib/groff/font/devps/DESC; then
271 descfile=$prefix/lib/groff/font/devps/DESC
273 if test -n "$descfile" \
274 && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
280 if test -z "$PAGE"; then
281 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
282 /etc/resolv.conf 2>/dev/null`
283 if test -z "$dom"; then
284 dom=`(domainname) 2>/dev/null | tr -d '+'`
285 if test -z "$dom"; then
286 dom=`(hostname) 2>/dev/null | grep '\.'`
290 # If the top-level domain is two letters and it's not `us' or `ca'
291 # then they probably use A4 paper.
293 *.[Uu][Ss]|*.[Cc][Aa]) ;;
294 *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
298 test -n "$PAGE" || PAGE=letter
303 AC_DEFUN(GROFF_CXX_CHECK,
304 [AC_REQUIRE([AC_C_CROSS])
305 AC_REQUIRE([AC_PROG_CXX])
308 if test "$cross_compiling" = no; then
309 AC_MSG_CHECKING([that C++ compiler can compile simple program])
311 AC_TRY_RUN([int main() { return 0; }],
313 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
315 if test "$cross_compiling" = no; then
316 AC_MSG_CHECKING([that C++ static constructors and destructors are called])
326 ~A() { if (i == 1) _exit(0); }
329 int main() { return 1; }
332 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
334 AC_MSG_CHECKING([that header files support C++])
335 AC_TRY_LINK([#include <stdio.h>],
338 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++)]))
344 [AC_MSG_CHECKING([for prefix of system macro packages])
346 sys_tmac_file_prefix=
347 for d in /usr/share/lib/tmac /usr/lib/tmac; do
348 for t in "" tmac.; do
351 if test -z "$sys_tmac_prefix" \
353 && grep '^\.if' $f >/dev/null 2>&1; then
354 sys_tmac_prefix=$d/$t
355 sys_tmac_file_prefix=$t
360 AC_MSG_RESULT($sys_tmac_prefix)
361 AC_SUBST(sys_tmac_prefix)
363 AC_MSG_CHECKING([which system macro packages should be made available])
364 if test "x$sys_tmac_file_prefix" = "xtmac."; then
365 for f in $sys_tmac_prefix*; do
366 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
370 grep "Copyright.*Free Software Foundation" $f >/dev/null \
371 || tmac_wrap="$tmac_wrap $suff" ;;
374 elif test -n "$sys_tmac_prefix"; then
375 files=`echo $sys_tmac_prefix*`
376 grep "\\.so" $files >conftest.sol
379 ${sys_tmac_prefix}e) ;;
384 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
385 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
388 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
391 *) tmac_wrap="$tmac_wrap $suff" ;;
398 AC_MSG_RESULT([$tmac_wrap])
404 [AC_MSG_CHECKING([for existing troff installation])
405 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
416 dnl We need the path to install-sh to be absolute.
418 AC_DEFUN(GROFF_INSTALL_SH,
419 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
420 ac_dir=`cd $ac_aux_dir; pwd`
421 ac_install_sh="$ac_dir/install-sh -c"
425 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
426 dnl does not have -lm.
429 [AC_CHECK_LIB(m,sin,LIBM=-lm)
434 dnl We need top_srcdir to be absolute.
436 AC_DEFUN(GROFF_SRCDIR,
437 [ac_srcdir_defaulted=no
438 srcdir=`cd $srcdir; pwd`
442 dnl This simplifies Makefile rules.
444 AC_DEFUN(GROFF_BUILDDIR,
446 AC_SUBST(top_builddir)