1 dnl Autoconf macros for groff.
2 dnl Copyright (C) 1989-1995, 2001, 2002, 2003 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
67 AC_CHECK_PROG(pnmcut, pnmcut, found, missing)
68 if test $pnmcut = missing; then
69 missing="$missing pnmcut"
71 AC_CHECK_PROG(pnmcrop, pnmcrop, found, missing)
72 if test $pnmcrop = missing; then
73 missing="$missing pnmcrop"
75 AC_CHECK_PROG(pnmtopng, pnmtopng, found, missing)
76 if test $pnmtopng = missing; then
77 missing="$missing pnmtopng"
79 AC_CHECK_PROG(gs, gs gsos2, found, missing)
80 if test $gs = missing; then
83 AC_CHECK_PROG(psselect, psselect, found, missing)
84 if test $psselect = missing; then
85 missing="$missing psselect"
87 AC_CHECK_PROG(pnmtops, pnmtops, found, missing)
88 if test $pnmtops = missing; then
89 missing="$missing pnmtops"
91 if test -n "$missing"; then
104 progs="\`$prog1' and \`$prog2'" ;;
106 progs="\`$prog1', \`$prog2', and \`$prog3'" ;;
108 progs="\`$prog1', \`$prog2', \`$prog3', and \`$prog4'" ;;
110 progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', and \`$prog5'" ;;
112 progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', \`$prog5', and \`$prog6'" ;;
120 can't be found in the path, thus the HTML backend of groff (grohtml)
121 won't work properly. Consequently, no documentation in HTML format
122 is built and installed.
126 AC_SUBST(make_install_html)])dnl
128 dnl check to see whether pnmtops can handle the -nosetpage option
130 AC_DEFUN(GROFF_PNMTOPS_NOSETPAGE,
131 [AC_MSG_CHECKING([whether pnmtops can handle the -nosetpage option])
132 if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 ; then
134 pnmtops_nosetpage="pnmtops -nosetpage"
137 pnmtops_nosetpage="pnmtops"
139 AC_SUBST(pnmtops_nosetpage)
143 dnl GROFF_CSH_HACK(if hack present, if not present)
145 AC_DEFUN(GROFF_CSH_HACK,
146 [AC_MSG_CHECKING([for csh hash hack])
147 cat <<EOF >conftest.sh
150 export PATH || exit 0
154 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
155 AC_MSG_RESULT(yes); $1
157 AC_MSG_RESULT(no); $2
159 rm -f conftest.sh])dnl
162 dnl From udodo!hans@relay.NL.net (Hans Zuidam)
164 AC_DEFUN(GROFF_ISC_SYSV3,
165 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
167 if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
172 [Define if you have ISC 3.x or 4.x.])
178 AC_DEFUN(GROFF_POSIX,
179 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
181 AC_TRY_COMPILE([#include <stdio.h>
182 extern "C" { void fileno(int); }],,
183 AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE, 1,
184 [Define if -D_POSIX_SOURCE is necessary.]),
186 AC_LANG_POP(C++)])dnl
189 dnl srand() of SunOS 4.1.3 has return type int instead of void
191 AC_DEFUN(GROFF_SRAND,
193 AC_MSG_CHECKING([for return type of srand])
194 AC_TRY_COMPILE([#include <stdlib.h>
195 extern "C" { void srand(unsigned int); }],,
196 AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID, 1,
197 [Define if srand() returns void not int.]),
199 AC_LANG_POP(C++)])dnl
202 AC_DEFUN(GROFF_SYS_NERR,
204 AC_MSG_CHECKING([for sys_nerr in <errno.h>, <stdio.h>, or <stdlib.h>])
205 AC_TRY_COMPILE([#include <errno.h>
207 #include <stdlib.h>],
208 [int k; k = sys_nerr;],
209 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR, 1,
210 [Define if you have sys_nerr in <errno.h> or
213 AC_LANG_POP(C++)])dnl
216 AC_DEFUN(GROFF_SYS_ERRLIST,
217 [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>])
218 AC_TRY_COMPILE([#include <errno.h>
220 #include <stdlib.h>],
221 [int k; k = (int)sys_errlist[0];],
222 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST, 1,
223 [Define if you have sys_errlist in <errno.h>,
224 <stdio.h>, or <stdlib.h>.]),
225 AC_MSG_RESULT(no))])dnl
228 AC_DEFUN(GROFF_OSFCN_H,
230 AC_MSG_CHECKING([C++ <osfcn.h>])
231 AC_TRY_COMPILE([#include <osfcn.h>],
232 [read(0, 0, 0); open(0, 0);],
233 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H, 1,
234 [Define if you have a C++ <osfcn.h>.]),
236 AC_LANG_POP(C++)])dnl
239 AC_DEFUN(GROFF_LIMITS_H,
241 AC_MSG_CHECKING([C++ <limits.h>])
242 AC_TRY_COMPILE([#include <limits.h>],
243 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
244 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H, 1,
245 [Define if you have a C++ <limits.h>.]),
247 AC_LANG_POP(C++)])dnl
250 AC_DEFUN(GROFF_STDINT_H,
252 AC_MSG_CHECKING([C++ <stdint.h>])
253 AC_TRY_COMPILE([#include <stdint.h>],
254 [uint32_t x; int32_t y;],
255 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_STDINT_H, 1,
256 [Define if you have a C++ <stdint.h>.]),
258 AC_LANG_POP(C++)])dnl
261 AC_DEFUN(GROFF_TIME_T,
263 AC_MSG_CHECKING([for declaration of time_t])
264 AC_TRY_COMPILE([#include <time.h>],
265 [time_t t = time(0); struct tm *p = localtime(&t);],
267 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T, 1,
268 [Define if localtime() takes a long * not a
270 AC_LANG_POP(C++)])dnl
273 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
274 [AC_MSG_CHECKING([struct exception])
275 AC_TRY_COMPILE([#include <math.h>],
276 [struct exception e;],
277 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1,
278 [Define if <math.h> defines struct exception.]),
279 AC_MSG_RESULT(no))])dnl
282 AC_DEFUN(GROFF_ARRAY_DELETE,
284 AC_MSG_CHECKING([whether ANSI array delete syntax is supported])
285 AC_TRY_COMPILE(, [char *p = new char[5]; delete [] p;],
287 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE, 1,
288 [Define if your C++ doesn't understand
290 AC_LANG_POP(C++)])dnl
294 AC_DEFUN(GROFF_TRADITIONAL_CPP,
296 AC_MSG_CHECKING([traditional preprocessor])
297 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
298 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP, 1,
299 [Define if your C++ compiler uses a
300 traditional (Reiser) preprocessor.]),
302 AC_LANG_POP(C++)])dnl
305 AC_DEFUN(GROFF_WCOREFLAG,
306 [AC_MSG_CHECKING([w_coredump])
307 AC_TRY_RUN([#include <sys/types.h>
308 #include <sys/wait.h>
315 ((union wait *)&i)->w_coredump = 1;
319 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG, 0200,
320 [Define if the 0200 bit of the status returned
321 by wait() indicates whether a core image was
322 produced for a process that was terminated by
325 AC_MSG_RESULT(no))])dnl
328 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
329 [AC_MSG_CHECKING([default value for grops -b option])
330 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
331 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
332 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
336 [AC_MSG_CHECKING([default paper size])
338 test "x$prefix" = xNONE && groff_prefix=$ac_default_prefix
339 if test -z "$PAGE"; then
341 if test -r $groff_prefix/share/groff/font/devps/DESC; then
342 descfile=$groff_prefix/share/groff/font/devps/DESC
343 elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
344 descfile=$groff_prefix/lib/groff/font/devps/DESC
346 for f in $groff_prefix/share/groff/*/font/devps/DESC; do
353 if test -n "$descfile"; then
355 if grep '^paperlength[ ]\+841890' $descfile
356 >/dev/null 2>&1; then
358 elif grep '^papersize[ ]\+[aA]4' $descfile \
359 >/dev/null 2>&1; then
365 if test -z "$PAGE"; then
366 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
367 /etc/resolv.conf 2>/dev/null`
368 if test -z "$dom"; then
369 dom=`(domainname) 2>/dev/null | tr -d '+'`
371 || test "$dom" = '(none)'; then
372 dom=`(hostname) 2>/dev/null | grep '\.'`
376 # If the top-level domain is two letters and it's not `us' or `ca'
377 # then they probably use A4 paper.
379 *.[Uu][Ss]|*.[Cc][Aa]) ;;
380 *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
384 test -n "$PAGE" || PAGE=letter
385 if test "x$PAGE" = "xA4"; then
387 [Define if the printer's page size is A4.])
393 AC_DEFUN(GROFF_CXX_CHECK,
394 [AC_REQUIRE([AC_PROG_CXX])
396 if test "$cross_compiling" = no; then
397 AC_MSG_CHECKING([that C++ compiler can compile simple program])
399 AC_TRY_RUN([int main() { return 0; }],
401 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
403 if test "$cross_compiling" = no; then
404 AC_MSG_CHECKING([that C++ static constructors and destructors are called])
414 ~A() { if (i == 1) _exit(0); }
417 int main() { return 1; }
420 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
422 AC_MSG_CHECKING([that header files support C++])
423 AC_TRY_LINK([#include <stdio.h>],
426 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++)]))
427 AC_LANG_POP(C++)])dnl
431 [AC_MSG_CHECKING([for prefix of system macro packages])
433 sys_tmac_file_prefix=
434 for d in /usr/share/lib/tmac /usr/lib/tmac; do
435 for t in "" tmac.; do
438 if test -z "$sys_tmac_prefix" \
440 && grep '^\.if' $f >/dev/null 2>&1; then
441 sys_tmac_prefix=$d/$t
442 sys_tmac_file_prefix=$t
447 AC_MSG_RESULT($sys_tmac_prefix)
448 AC_SUBST(sys_tmac_prefix)
450 AC_MSG_CHECKING([which system macro packages should be made available])
451 if test "x$sys_tmac_file_prefix" = "xtmac."; then
452 for f in $sys_tmac_prefix*; do
453 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
457 grep "Copyright.*Free Software Foundation" $f >/dev/null \
458 || tmac_wrap="$tmac_wrap $suff" ;;
461 elif test -n "$sys_tmac_prefix"; then
462 files=`echo $sys_tmac_prefix*`
463 grep "\\.so" $files >conftest.sol
466 ${sys_tmac_prefix}e) ;;
471 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
472 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
475 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
478 *) tmac_wrap="$tmac_wrap $suff" ;;
485 AC_MSG_RESULT([$tmac_wrap])
486 AC_SUBST(tmac_wrap)])dnl
490 [AC_MSG_CHECKING([for existing troff installation])
491 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
501 dnl We need the path to install-sh to be absolute.
503 AC_DEFUN(GROFF_INSTALL_SH,
504 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
505 ac_dir=`cd $ac_aux_dir; pwd`
506 ac_install_sh="$ac_dir/install-sh -c"])dnl
509 dnl Test whether install-info is available.
511 AC_DEFUN(GROFF_INSTALL_INFO,
512 [AC_CHECK_PROGS(INSTALL_INFO, install-info, :)])dnl
515 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
516 dnl does not have -lm ...
519 [AC_CHECK_LIB(m,sin,LIBM=-lm)
523 dnl ... while the MinGW implementation of GCC for Microsoft Win32
524 dnl does not seem to have -lc.
527 [AC_CHECK_LIB(c,main,LIBC=-lc)
531 dnl We need top_srcdir to be absolute.
533 AC_DEFUN(GROFF_SRCDIR,
534 [ac_srcdir_defaulted=no
535 srcdir=`cd $srcdir; pwd`])dnl
538 dnl This simplifies Makefile rules.
540 AC_DEFUN(GROFF_BUILDDIR,
541 [groff_top_builddir=`pwd`
542 AC_SUBST(groff_top_builddir)])dnl
545 dnl Check for EBCDIC -- stolen from the OS390 Unix LYNX port
547 AC_DEFUN(GROFF_EBCDIC,
548 [AC_MSG_CHECKING([whether character set is EBCDIC])
550 [/* Treat any failure as ASCII for compatibility with existing art.
551 Use compile-time rather than run-time tests for cross-compiler
554 make an error "Character set is not EBCDIC"
556 groff_cv_ebcdic="yes"
557 TTYDEVDIRS="font/devcp1047"
559 AC_DEFINE(IS_EBCDIC_HOST, 1,
560 [Define if the host's encoding is EBCDIC.]),
562 TTYDEVDIRS="font/devascii font/devlatin1"
563 OTHERDEVDIRS="font/devlj4 font/devlbp"
566 AC_SUBST(OTHERDEVDIRS)])dnl
569 dnl Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with
570 dnl gcc) to OS/390 uses ASCII internally.
572 AC_DEFUN(GROFF_OS390,
573 [if test "$groff_cv_ebcdic" = "yes"; then
574 AC_MSG_CHECKING([for OS/390 Unix])
577 CFLAGS="$CFLAGS -D_ALL_SOURCE"
578 AC_MSG_RESULT(yes) ;;
585 dnl Check whether we need a declaration for a function.
587 dnl Stolen from GNU bfd.
589 AC_DEFUN(GROFF_NEED_DECLARATION,
590 [AC_MSG_CHECKING([whether $1 must be declared])
592 AC_CACHE_VAL(groff_cv_decl_needed_$1,
598 #ifdef HAVE_STRINGS_H
604 #ifdef HAVE_SYS_TIME_H
605 #include <sys/time.h>
614 char *p = (char *) $1;
616 groff_cv_decl_needed_$1=no,
617 groff_cv_decl_needed_$1=yes)])
618 AC_MSG_RESULT($groff_cv_decl_needed_$1)
619 if test $groff_cv_decl_needed_$1 = yes; then
620 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
621 [Define if your C++ doesn't declare ]$1[().])
623 AC_LANG_POP(C++)])dnl
626 dnl If mkstemp() isn't available, use our own mkstemp.cpp file.
628 AC_DEFUN(GROFF_MKSTEMP,
629 [AC_MSG_CHECKING([for mkstemp])
631 AC_LIBSOURCE(mkstemp.cpp)
632 AC_TRY_LINK([#include <stdlib.h>
636 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_MKSTEMP, 1,
637 [Define if you have mkstemp().]),
638 AC_MSG_RESULT(no);_AC_LIBOBJ(mkstemp))
639 AC_LANG_POP(C++)])dnl
642 dnl Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
643 dnl and declares uintmax_t. Taken from the fileutils package.
645 AC_DEFUN(GROFF_INTTYPES_H,
647 AC_MSG_CHECKING([for inttypes.h])
648 AC_TRY_COMPILE([#include <sys/types.h>
649 #include <inttypes.h>],
650 [uintmax_t i = (uintmax_t)-1;],
651 groff_cv_header_inttypes_h=yes,
652 groff_cv_header_inttypes_h=no)
653 AC_MSG_RESULT($groff_cv_header_inttypes_h)
654 AC_LANG_POP(C++)])dnl
657 dnl Test for working `unsigned long long'. Taken from the fileutils package.
659 AC_DEFUN(GROFF_UNSIGNED_LONG_LONG,
661 AC_MSG_CHECKING([for unsigned long long])
662 AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
663 [unsigned long long ullmax = (unsigned long long)-1;
664 return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
665 groff_cv_type_unsigned_long_long=yes,
666 groff_cv_type_unsigned_long_long=no)
667 AC_MSG_RESULT($groff_cv_type_unsigned_long_long)
668 AC_LANG_POP(C++)])dnl
671 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
672 dnl if <inttypes.h> does not exist. Taken from the fileutils package.
674 AC_DEFUN(GROFF_UINTMAX_T,
675 [AC_REQUIRE([GROFF_INTTYPES_H])
676 if test $groff_cv_header_inttypes_h = no; then
677 AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
678 test $groff_cv_type_unsigned_long_long = yes \
679 && ac_type='unsigned long long' \
680 || ac_type='unsigned long'
681 AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
682 [Define uintmax_t to `unsigned long' or
683 `unsigned long long' if <inttypes.h> does not