1 dnl Autoconf macros for groff.
2 dnl Copyright (C) 1989-1995, 2001, 2002 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 The following programs are needed for grohtml.
63 AC_DEFUN(GROFF_HTML_PROGRAMS,
65 make_install_html=install_html
66 AC_CHECK_PROG(pnmcut, pnmcut, found, missing)
67 AC_CHECK_PROG(pnmcrop, pnmcrop, found, missing)
68 AC_CHECK_PROG(pnmtopng, pnmtopng, found, missing)
69 AC_CHECK_PROG(gs, gs gsos2, found, missing)
70 AC_CHECK_PROG(psselect, psselect, found, missing)
71 case "x$pnmcut$pnmcrop$pnmtopng$gs$psselect" in
77 Since one or more of the above five programs can't be found in the path,
78 the HTML backend of groff (grohtml) won't work properly. Consequently,
79 no documentation in HTML format is built and installed.
83 AC_SUBST(make_install_html)])dnl
86 dnl GROFF_CSH_HACK(if hack present, if not present)
88 AC_DEFUN(GROFF_CSH_HACK,
89 [AC_MSG_CHECKING([for csh hash hack])
90 cat <<EOF >conftest.sh
97 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
98 AC_MSG_RESULT(yes); $1
100 AC_MSG_RESULT(no); $2
102 rm -f conftest.sh])dnl
105 dnl From udodo!hans@relay.NL.net (Hans Zuidam)
107 AC_DEFUN(GROFF_ISC_SYSV3,
108 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
110 if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
115 [Define if you have ISC 3.x or 4.x.])
121 AC_DEFUN(GROFF_POSIX,
122 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
124 AC_TRY_COMPILE([#include <stdio.h>
125 extern "C" { void fileno(int); }],,
126 AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE, 1,
127 [Define if -D_POSIX_SOURCE is necessary.]),
129 AC_LANG_POP(C++)])dnl
132 dnl srand() of SunOS 4.1.3 has return type int instead of void
134 AC_DEFUN(GROFF_SRAND,
136 AC_MSG_CHECKING([for return type of srand])
137 AC_TRY_COMPILE([#include <stdlib.h>
138 extern "C" { void srand(unsigned int); }],,
139 AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID, 1,
140 [Define if srand() returns void not int.]),
142 AC_LANG_POP(C++)])dnl
145 AC_DEFUN(GROFF_SYS_NERR,
147 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
148 AC_TRY_COMPILE([#include <errno.h>
150 [int k; k = sys_nerr;],
151 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR, 1,
152 [Define if you have sysnerr in <errno.h> or
155 AC_LANG_POP(C++)])dnl
158 AC_DEFUN(GROFF_SYS_ERRLIST,
159 [AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>])
160 AC_TRY_COMPILE([#include <errno.h>
162 [int k; k = (int)sys_errlist[0];],
163 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST, 1,
164 [Define if you have sys_errlist in <errno.h>
166 AC_MSG_RESULT(no))])dnl
169 AC_DEFUN(GROFF_OSFCN_H,
171 AC_MSG_CHECKING([C++ <osfcn.h>])
172 AC_TRY_COMPILE([#include <osfcn.h>],
173 [read(0, 0, 0); open(0, 0);],
174 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H, 1,
175 [Define if you have a C++ <osfcn.h>.]),
177 AC_LANG_POP(C++)])dnl
180 AC_DEFUN(GROFF_LIMITS_H,
182 AC_MSG_CHECKING([C++ <limits.h>])
183 AC_TRY_COMPILE([#include <limits.h>],
184 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
185 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H, 1,
186 [Define if you have a C++ <limits.h>.]),
188 AC_LANG_POP(C++)])dnl
191 AC_DEFUN(GROFF_TIME_T,
193 AC_MSG_CHECKING([for declaration of time_t])
194 AC_TRY_COMPILE([#include <time.h>],
195 [time_t t = time(0); struct tm *p = localtime(&t);],
197 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T, 1,
198 [Define if localtime() takes a long * not a
200 AC_LANG_POP(C++)])dnl
203 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
204 [AC_MSG_CHECKING([struct exception])
205 AC_TRY_COMPILE([#include <math.h>],
206 [struct exception e;],
207 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1,
208 [Define if <math.h> defines struct exception.]),
209 AC_MSG_RESULT(no))])dnl
212 AC_DEFUN(GROFF_ARRAY_DELETE,
214 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
215 AC_TRY_COMPILE(, [char *p = new char[5]; delete [] p;],
217 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE, 1,
218 [Define if your C++ doesn't understand
220 AC_LANG_POP(C++)])dnl
224 AC_DEFUN(GROFF_TRADITIONAL_CPP,
226 AC_MSG_CHECKING([traditional preprocessor])
227 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
228 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP, 1,
229 [Define if your C++ compiler uses a
230 traditional (Reiser) preprocessor.]),
232 AC_LANG_POP(C++)])dnl
235 AC_DEFUN(GROFF_WCOREFLAG,
236 [AC_MSG_CHECKING([w_coredump])
237 AC_TRY_RUN([#include <sys/types.h>
238 #include <sys/wait.h>
245 ((union wait *)&i)->w_coredump = 1;
249 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG, 0200,
250 [Define if the 0200 bit of the status returned
251 by wait() indicates whether a core image was
252 produced for a process that was terminated by
255 AC_MSG_RESULT(no))])dnl
258 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
259 [AC_MSG_CHECKING([default value for grops -b option])
260 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
261 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
262 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
266 [AC_MSG_CHECKING([default paper size])
268 test "x$prefix" = xNONE && groff_prefix=$ac_default_prefix
269 if test -z "$PAGE"; then
271 if test -r $groff_prefix/share/groff/font/devps/DESC; then
272 descfile=$groff_prefix/share/groff/font/devps/DESC
273 elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
274 descfile=$groff_prefix/lib/groff/font/devps/DESC
276 for f in $groff_prefix/share/groff/*/font/devps/DESC; do
283 if test -n "$descfile"; then
285 if grep '^paperlength[ ]\+841890' $descfile
286 >/dev/null 2>&1; then
288 elif grep '^papersize[ ]\+[aA]4' $descfile \
289 >/dev/null 2>&1; then
295 if test -z "$PAGE"; then
296 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
297 /etc/resolv.conf 2>/dev/null`
298 if test -z "$dom"; then
299 dom=`(domainname) 2>/dev/null | tr -d '+'`
301 || test "$dom" = '(none)'; then
302 dom=`(hostname) 2>/dev/null | grep '\.'`
306 # If the top-level domain is two letters and it's not `us' or `ca'
307 # then they probably use A4 paper.
309 *.[Uu][Ss]|*.[Cc][Aa]) ;;
310 *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
314 test -n "$PAGE" || PAGE=letter
315 if test "x$PAGE" = "xA4"; then
317 [Define if the printer's page size is A4.])
323 AC_DEFUN(GROFF_CXX_CHECK,
324 [AC_REQUIRE([AC_PROG_CXX])
326 if test "$cross_compiling" = no; then
327 AC_MSG_CHECKING([that C++ compiler can compile simple program])
329 AC_TRY_RUN([int main() { return 0; }],
331 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
333 if test "$cross_compiling" = no; then
334 AC_MSG_CHECKING([that C++ static constructors and destructors are called])
344 ~A() { if (i == 1) _exit(0); }
347 int main() { return 1; }
350 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
352 AC_MSG_CHECKING([that header files support C++])
353 AC_TRY_LINK([#include <stdio.h>],
356 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++)]))
357 AC_LANG_POP(C++)])dnl
361 [AC_MSG_CHECKING([for prefix of system macro packages])
363 sys_tmac_file_prefix=
364 for d in /usr/share/lib/tmac /usr/lib/tmac; do
365 for t in "" tmac.; do
368 if test -z "$sys_tmac_prefix" \
370 && grep '^\.if' $f >/dev/null 2>&1; then
371 sys_tmac_prefix=$d/$t
372 sys_tmac_file_prefix=$t
377 AC_MSG_RESULT($sys_tmac_prefix)
378 AC_SUBST(sys_tmac_prefix)
380 AC_MSG_CHECKING([which system macro packages should be made available])
381 if test "x$sys_tmac_file_prefix" = "xtmac."; then
382 for f in $sys_tmac_prefix*; do
383 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
387 grep "Copyright.*Free Software Foundation" $f >/dev/null \
388 || tmac_wrap="$tmac_wrap $suff" ;;
391 elif test -n "$sys_tmac_prefix"; then
392 files=`echo $sys_tmac_prefix*`
393 grep "\\.so" $files >conftest.sol
396 ${sys_tmac_prefix}e) ;;
401 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
402 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
405 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
408 *) tmac_wrap="$tmac_wrap $suff" ;;
415 AC_MSG_RESULT([$tmac_wrap])
416 AC_SUBST(tmac_wrap)])dnl
420 [AC_MSG_CHECKING([for existing troff installation])
421 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
431 dnl We need the path to install-sh to be absolute.
433 AC_DEFUN(GROFF_INSTALL_SH,
434 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
435 ac_dir=`cd $ac_aux_dir; pwd`
436 ac_install_sh="$ac_dir/install-sh -c"])dnl
439 dnl Test whether install-info is available.
441 AC_DEFUN(GROFF_INSTALL_INFO,
442 [AC_CHECK_PROGS(INSTALL_INFO, install-info, :)])dnl
445 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
446 dnl does not have -lm.
449 [AC_CHECK_LIB(m,sin,LIBM=-lm)
453 dnl We need top_srcdir to be absolute.
455 AC_DEFUN(GROFF_SRCDIR,
456 [ac_srcdir_defaulted=no
457 srcdir=`cd $srcdir; pwd`])dnl
460 dnl This simplifies Makefile rules.
462 AC_DEFUN(GROFF_BUILDDIR,
463 [groff_top_builddir=`pwd`
464 AC_SUBST(groff_top_builddir)])dnl
467 dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port
469 AC_DEFUN(GROFF_EBCDIC,
470 [AC_MSG_CHECKING([whether character set is EBCDIC])
472 [/* Treat any failure as ASCII for compatibility with existing art.
473 Use compile-time rather than run-time tests for cross-compiler
476 make an error "Character set is not EBCDIC"
478 groff_cv_ebcdic="yes"
479 TTYDEVDIRS="font/devcp1047"
481 AC_DEFINE(IS_EBCDIC_HOST, 1,
482 [Define if the host's encoding is EBCDIC.]),
484 TTYDEVDIRS="font/devascii font/devlatin1"
485 OTHERDEVDIRS="font/devlj4 font/devlbp"
488 AC_SUBST(OTHERDEVDIRS)])dnl
491 dnl Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with
492 dnl gcc) to OS/390 uses ASCII internally.
494 AC_DEFUN(GROFF_OS390,
495 [if test "$groff_cv_ebcdic" = "yes"; then
496 AC_MSG_CHECKING([for OS/390 Unix])
499 CFLAGS="$CFLAGS -D_ALL_SOURCE"
500 AC_MSG_RESULT(yes) ;;
507 dnl Check whether we need a declaration for a function.
509 dnl Stolen from GNU bfd.
511 AC_DEFUN(GROFF_NEED_DECLARATION,
512 [AC_MSG_CHECKING([whether $1 must be declared])
514 AC_CACHE_VAL(groff_cv_decl_needed_$1,
520 #ifdef HAVE_STRINGS_H
526 #ifdef HAVE_SYS_TIME_H
527 #include <sys/time.h>
536 char *p = (char *) $1;
538 groff_cv_decl_needed_$1=no,
539 groff_cv_decl_needed_$1=yes)])
540 AC_MSG_RESULT($groff_cv_decl_needed_$1)
541 if test $groff_cv_decl_needed_$1 = yes; then
542 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
543 [Define if your C++ doesn't declare ]$1[().])
545 AC_LANG_POP(C++)])dnl
548 dnl If mkstemp() isn't available, use our own mkstemp.cc file.
550 AC_DEFUN(GROFF_MKSTEMP,
551 [AC_MSG_CHECKING([for mkstemp])
553 AC_LIBSOURCE(mkstemp.cc)
554 AC_TRY_LINK([#include <stdlib.h>
558 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_MKSTEMP, 1,
559 [Define if you have mkstemp().]),
560 AC_MSG_RESULT(no);_AC_LIBOBJ(mkstemp))
561 AC_LANG_POP(C++)])dnl
564 dnl Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
565 dnl and declares uintmax_t. Taken from the fileutils package.
567 AC_DEFUN(GROFF_INTTYPES_H,
569 AC_MSG_CHECKING([for inttypes.h])
570 AC_TRY_COMPILE([#include <sys/types.h>
571 #include <inttypes.h>],
572 [uintmax_t i = (uintmax_t)-1;],
573 groff_cv_header_inttypes_h=yes,
574 groff_cv_header_inttypes_h=no)
575 AC_MSG_RESULT($groff_cv_header_inttypes_h)
576 AC_LANG_POP(C++)])dnl
579 dnl Test for working `unsigned long long'. Taken from the fileutils package.
581 AC_DEFUN(GROFF_UNSIGNED_LONG_LONG,
583 AC_MSG_CHECKING([for unsigned long long])
584 AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
585 [unsigned long long ullmax = (unsigned long long)-1;
586 return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
587 groff_cv_type_unsigned_long_long=yes,
588 groff_cv_type_unsigned_long_long=no)
589 AC_MSG_RESULT($groff_cv_type_unsigned_long_long)
590 AC_LANG_POP(C++)])dnl
593 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
594 dnl if <inttypes.h> does not exist. Taken from the fileutils package.
596 AC_DEFUN(GROFF_UINTMAX_T,
597 [AC_REQUIRE([GROFF_INTTYPES_H])
598 if test $groff_cv_header_inttypes_h = no; then
599 AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
600 test $groff_cv_type_unsigned_long_long = yes \
601 && ac_type='unsigned long long' \
602 || ac_type='unsigned long'
603 AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
604 [Define uintmax_t to `unsigned long' or
605 `unsigned long long' if <inttypes.h> does not