1 # Autoconf macros for groff.
2 # Copyright (C) 1989-1995, 2001, 2002, 2003 Free Software Foundation, Inc.
4 # This file is part of groff.
6 # groff is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free
8 # Software Foundation; either version 2, or (at your option) any later
11 # groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 # You should have received a copy of the GNU General Public License along
17 # with groff; see the file COPYING. If not, write to the Free Software
18 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 AC_DEFUN([GROFF_PRINT],
21 [if test -z "$PSPRINT"; then
22 AC_CHECK_PROGS([LPR], [lpr])
23 AC_CHECK_PROGS([LP], [lp])
24 if test -n "$LPR" && test -n "$LP"; then
25 # HP-UX provides an lpr command that emulates lpr using lp,
26 # but it doesn't have lpq; in this case we want to use lp
28 AC_CHECK_PROGS([LPQ], [lpq])
29 test -n "$LPQ" || LPR=
31 if test -n "$LPR"; then
33 elif test -n "$LP"; then
38 AC_MSG_CHECKING([for command to use for printing PostScript files])
39 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])])
53 # Bison generated parsers have problems with C++ compilers other than g++.
54 # So byacc is preferred over bison.
56 AC_DEFUN([GROFF_PROG_YACC],
57 [AC_CHECK_PROGS([YACC], [byacc 'bison -y'], [yacc])])
59 # The following programs are needed for grohtml.
61 AC_DEFUN([GROFF_HTML_PROGRAMS],
63 make_install_html=install_html
66 AC_FOREACH([groff_prog],
67 [pnmcut pnmcrop pnmtopng psselect pnmtops gs],
68 [AC_CHECK_PROG(groff_prog, groff_prog, [found], [missing])
69 if test $[]groff_prog = missing; then
70 missing="$missing groff_prog"
73 if test -n "$missing"; then
86 progs="\`$prog1' and \`$prog2'" ;;
88 progs="\`$prog1', \`$prog2', and \`$prog3'" ;;
90 progs="\`$prog1', \`$prog2', \`$prog3', and \`$prog4'" ;;
92 progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', and \`$prog5'" ;;
94 progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', \`$prog5', and \`$prog6'" ;;
104 can't be found in the path, thus the HTML backend of groff (grohtml)
105 won't work properly. Consequently, no documentation in HTML format
106 is built and installed.
110 AC_SUBST([make_html])
111 AC_SUBST([make_install_html])])
113 # Check whether pnmtops can handle the -nosetpage option.
115 AC_DEFUN([GROFF_PNMTOPS_NOSETPAGE],
116 [AC_MSG_CHECKING([whether pnmtops can handle the -nosetpage option])
117 if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 ; then
119 pnmtops_nosetpage="pnmtops -nosetpage"
122 pnmtops_nosetpage="pnmtops"
124 AC_SUBST([pnmtops_nosetpage])])
126 # GROFF_CSH_HACK(if hack present, if not present)
128 AC_DEFUN([GROFF_CSH_HACK],
129 [AC_MSG_CHECKING([for csh hash hack])
131 cat <<EOF >conftest.sh
134 export PATH || exit 0
139 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
148 # From udodo!hans@relay.NL.net (Hans Zuidam)
150 AC_DEFUN([GROFF_ISC_SYSV3],
151 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
152 if grep ['[34]\.'] /usr/options/cb.name >/dev/null 2>&1
155 AC_DEFINE([_SYSV3], [1], [Define if you have ISC 3.x or 4.x.])
160 AC_DEFUN([GROFF_POSIX],
161 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
167 extern "C" { void fileno(int); }
171 [AC_MSG_RESULT([yes])
172 AC_DEFINE([_POSIX_SOURCE], [1],
173 [Define if -D_POSIX_SOURCE is necessary.])],
174 [AC_MSG_RESULT([no])])
177 # srand() of SunOS 4.1.3 has return type int instead of void
179 AC_DEFUN([GROFF_SRAND],
181 AC_MSG_CHECKING([for return type of srand])
186 extern "C" { void srand(unsigned int); }
190 [AC_MSG_RESULT([void])
191 AC_DEFINE([RET_TYPE_SRAND_IS_VOID], [1],
192 [Define if srand() returns void not int.])],
193 [AC_MSG_RESULT([int])])
196 AC_DEFUN([GROFF_SYS_NERR],
198 AC_MSG_CHECKING([for sys_nerr in <errno.h>, <stdio.h>, or <stdlib.h>])
214 [AC_MSG_RESULT([yes])
215 AC_DEFINE([HAVE_SYS_NERR], [1],
216 [Define if you have sys_nerr in <errno.h>, <stdio.h>, or <stdio.h>.])],
217 [AC_MSG_RESULT([no])])
220 AC_DEFUN([GROFF_SYS_ERRLIST],
221 [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>])
233 k = (int)sys_errlist[0];
237 [AC_MSG_RESULT([yes])
238 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
239 [Define if you have sys_errlist in <errno.h>, <stdio.h>, or <stdlib.h>.])],
240 [AC_MSG_RESULT([no])])])
242 AC_DEFUN([GROFF_OSFCN_H],
244 AC_MSG_CHECKING([C++ <osfcn.h>])
258 [AC_MSG_RESULT([yes])
259 AC_DEFINE([HAVE_CC_OSFCN_H], [1],
260 [Define if you have a C++ <osfcn.h>.])],
261 [AC_MSG_RESULT([no])])
264 AC_DEFUN([GROFF_LIMITS_H],
266 AC_MSG_CHECKING([C++ <limits.h>])
281 [AC_MSG_RESULT([yes])
282 AC_DEFINE([HAVE_CC_LIMITS_H], [1],
283 [Define if you have a C++ <limits.h>.])],
284 [AC_MSG_RESULT([no])])
287 AC_DEFUN([GROFF_STDINT_H],
289 AC_MSG_CHECKING([C++ <stdint.h>])
303 [AC_MSG_RESULT([yes])
304 AC_DEFINE([HAVE_CC_STDINT_H], [1],
305 [Define if you have a C++ <stdint.h>.])],
306 [AC_MSG_RESULT([no])])
309 AC_DEFUN([GROFF_TIME_T],
311 AC_MSG_CHECKING([for declaration of time_t])
321 struct tm *p = localtime(&t);
325 [AC_MSG_RESULT([yes])],
327 AC_DEFINE([LONG_FOR_TIME_T], [1],
328 [Define if localtime() takes a long * not a time_t *.])])
331 AC_DEFUN([GROFF_STRUCT_EXCEPTION],
332 [AC_MSG_CHECKING([struct exception])
345 [AC_MSG_RESULT([yes])
346 AC_DEFINE([HAVE_STRUCT_EXCEPTION], [1],
347 [Define if <math.h> defines struct exception.])],
348 [AC_MSG_RESULT([no])])])
350 AC_DEFUN([GROFF_ARRAY_DELETE],
352 AC_MSG_CHECKING([whether ANSI array delete syntax is supported])
356 char *p = new char[5];
361 [AC_MSG_RESULT([yes])],
363 AC_DEFINE([ARRAY_DELETE_NEEDS_SIZE], [1],
364 [Define if your C++ doesn't understand `delete []'.])])
367 AC_DEFUN([GROFF_TRADITIONAL_CPP],
369 AC_MSG_CHECKING([traditional preprocessor])
373 #define name2(a, b) a/**/b
382 [AC_MSG_RESULT([yes])
383 AC_DEFINE([TRADITIONAL_CPP], [1],
384 [Define if your C++ compiler uses a traditional (Reiser) preprocessor.])],
385 [AC_MSG_RESULT([no])])
388 AC_DEFUN([GROFF_WCOREFLAG],
389 [AC_MSG_CHECKING([w_coredump])
393 #include <sys/types.h>
394 #include <sys/wait.h>
405 ((union wait *)&i)->w_coredump = 1;
412 [AC_MSG_RESULT([yes])
413 AC_DEFINE(WCOREFLAG, 0200,
414 [Define if the 0200 bit of the status returned by wait() indicates
415 whether a core image was produced for a process that was terminated
417 [AC_MSG_RESULT([no])],
418 [AC_MSG_RESULT([no])])])
420 AC_DEFUN([GROFF_BROKEN_SPOOLER_FLAGS],
421 [AC_MSG_CHECKING([default value for grops -b option])
422 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=0
423 AC_MSG_RESULT([$BROKEN_SPOOLER_FLAGS])
424 AC_SUBST([BROKEN_SPOOLER_FLAGS])])
426 AC_DEFUN([GROFF_PAGE],
427 [AC_MSG_CHECKING([default paper size])
429 test "x$prefix" = xNONE && groff_prefix=$ac_default_prefix
430 if test -z "$PAGE"; then
432 if test -r $groff_prefix/share/groff/font/devps/DESC; then
433 descfile=$groff_prefix/share/groff/font/devps/DESC
434 elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
435 descfile=$groff_prefix/lib/groff/font/devps/DESC
437 for f in $groff_prefix/share/groff/*/font/devps/DESC; do
445 if test -n "$descfile"; then
446 if grep ['^paperlength[ ]\+841890'] $descfile >/dev/null 2>&1; then
448 elif grep ['^papersize[ ]\+[aA]4'] $descfile >/dev/null 2>&1; then
454 if test -z "$PAGE"; then
455 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
456 /etc/resolv.conf 2>/dev/null`
457 if test -z "$dom"; then
458 dom=`(domainname) 2>/dev/null | tr -d '+'`
460 || test "$dom" = '(none)'; then
461 dom=`(hostname) 2>/dev/null | grep '\.'`
464 # If the top-level domain is two letters and it's not `us' or `ca'
465 # then they probably use A4 paper.
467 [*.[Uu][Ss]|*.[Cc][Aa])]
469 [*.[A-Za-z][A-Za-z])]
474 test -n "$PAGE" || PAGE=letter
475 if test "x$PAGE" = "xA4"; then
476 AC_DEFINE([PAGEA4], [1],
477 [Define if the printer's page size is A4.])
479 AC_MSG_RESULT([$PAGE])
482 AC_DEFUN([GROFF_CXX_CHECK],
483 [AC_REQUIRE([AC_PROG_CXX])
485 if test "$cross_compiling" = no; then
486 AC_MSG_CHECKING([that C++ compiler can compile simple program])
497 [AC_MSG_RESULT([yes])],
499 AC_MSG_ERROR([a working C++ compiler is required])],
502 if test "$cross_compiling" = no; then
503 AC_MSG_CHECKING([that C++ static constructors and destructors are called])
516 ~A() { if (i == 1) _exit(0); }
528 [AC_MSG_RESULT([yes])],
530 AC_MSG_ERROR([a working C++ compiler is required])],
533 AC_MSG_CHECKING([that header files support C++])
546 [AC_MSG_RESULT([yes])],
548 AC_MSG_ERROR([header files do not support C++
549 (if you are using a version of gcc/g++ earlier than 2.5,
550 you should install libg++)])])
553 AC_DEFUN([GROFF_TMAC],
554 [AC_MSG_CHECKING([for prefix of system macro packages])
556 sys_tmac_file_prefix=
557 for d in /usr/share/lib/tmac /usr/lib/tmac; do
558 for t in "" tmac.; do
561 if test -z "$sys_tmac_prefix" \
563 && grep '^\.if' $f >/dev/null 2>&1; then
564 sys_tmac_prefix=$d/$t
565 sys_tmac_file_prefix=$t
570 AC_MSG_RESULT([$sys_tmac_prefix])
571 AC_SUBST([sys_tmac_prefix])
573 AC_MSG_CHECKING([which system macro packages should be made available])
575 if test "x$sys_tmac_file_prefix" = "xtmac."; then
576 for f in $sys_tmac_prefix*; do
577 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
582 grep "Copyright.*Free Software Foundation" $f >/dev/null \
583 || tmac_wrap="$tmac_wrap $suff" ;;
586 elif test -n "$sys_tmac_prefix"; then
587 files=`echo $sys_tmac_prefix*`
588 grep "\\.so" $files >conftest.sol
599 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
600 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
603 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
608 tmac_wrap="$tmac_wrap $suff" ;;
615 AC_MSG_RESULT([$tmac_wrap])
616 AC_SUBST([tmac_wrap])])
619 [AC_MSG_CHECKING([for existing troff installation])
620 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
629 # We need the path to install-sh to be absolute.
631 AC_DEFUN([GROFF_INSTALL_SH],
632 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])
633 ac_dir=`cd $ac_aux_dir; pwd`
634 ac_install_sh="$ac_dir/install-sh -c"])
636 # Test whether install-info is available.
638 AC_DEFUN([GROFF_INSTALL_INFO],
639 [AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])])
641 # At least one UNIX system, Apple Macintosh Rhapsody 5.5,
642 # does not have -lm ...
644 AC_DEFUN([GROFF_LIBM],
645 [AC_CHECK_LIB([m], [sin], [LIBM=-lm])
648 # ... while the MinGW implementation of GCC for Microsoft Win32
649 # does not seem to have -lc.
651 AC_DEFUN([GROFF_LIBC],
652 [AC_CHECK_LIB([c], [main], [LIBC=-lc])
655 # Check for EBCDIC -- stolen from the OS390 Unix LYNX port
657 AC_DEFUN([GROFF_EBCDIC],
658 [AC_MSG_CHECKING([whether character set is EBCDIC])
662 /* Treat any failure as ASCII for compatibility with existing art.
663 Use compile-time rather than run-time tests for cross-compiler
666 make an error "Character set is not EBCDIC"
671 [groff_cv_ebcdic="yes"
672 TTYDEVDIRS="font/devcp1047"
674 AC_DEFINE(IS_EBCDIC_HOST, 1,
675 [Define if the host's encoding is EBCDIC.])],
676 [groff_cv_ebcdic="no"
677 TTYDEVDIRS="font/devascii font/devlatin1"
678 OTHERDEVDIRS="font/devlj4 font/devlbp"
679 AC_MSG_RESULT([no])])
680 AC_SUBST([TTYDEVDIRS])
681 AC_SUBST([OTHERDEVDIRS])])
683 # Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with
684 # gcc) to OS/390 uses ASCII internally.
686 AC_DEFUN([GROFF_OS390],
687 [if test "$groff_cv_ebcdic" = "yes"; then
688 AC_MSG_CHECKING([for OS/390 Unix])
691 CFLAGS="$CFLAGS -D_ALL_SOURCE"
692 AC_MSG_RESULT([yes]) ;;
694 AC_MSG_RESULT([no]) ;;
698 # Check whether we need a declaration for a function.
700 # Stolen from GNU bfd.
702 AC_DEFUN([GROFF_NEED_DECLARATION],
703 [AC_MSG_CHECKING([whether $1 must be declared])
705 AC_CACHE_VAL([groff_cv_decl_needed_$1],
713 #ifdef HAVE_STRINGS_H
719 #ifdef HAVE_SYS_TIME_H
720 #include <sys/time.h>
733 char *p = (char *) $1;
738 [groff_cv_decl_needed_$1=no],
739 [groff_cv_decl_needed_$1=yes])])
740 AC_MSG_RESULT([$groff_cv_decl_needed_$1])
741 if test $groff_cv_decl_needed_$1 = yes; then
742 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), [1],
743 [Define if your C++ doesn't declare ]$1[().])
747 # If mkstemp() isn't available, use our own mkstemp.cpp file.
749 AC_DEFUN([GROFF_MKSTEMP],
750 [AC_MSG_CHECKING([for mkstemp])
752 AC_LIBSOURCE([mkstemp.cpp])
767 [AC_MSG_RESULT([yes])
768 AC_DEFINE([HAVE_MKSTEMP], [1], [Define if you have mkstemp().])],
770 _AC_LIBOBJ([mkstemp])])
773 # Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
774 # and declares uintmax_t. Taken from the fileutils package.
776 AC_DEFUN([GROFF_INTTYPES_H],
778 AC_MSG_CHECKING([for inttypes.h])
782 #include <sys/types.h>
783 #include <inttypes.h>
788 uintmax_t i = (uintmax_t)-1;
792 [groff_cv_header_inttypes_h=yes],
793 [groff_cv_header_inttypes_h=no])
794 AC_MSG_RESULT([$groff_cv_header_inttypes_h])
797 # Test for working `unsigned long long'. Taken from the fileutils package.
799 AC_DEFUN([GROFF_UNSIGNED_LONG_LONG],
801 AC_MSG_CHECKING([for unsigned long long])
805 unsigned long long ull = 1;
807 unsigned long long ullmax = (unsigned long long)-1;
812 return ull << i | ull >> i | ullmax / ull | ullmax % ull;
816 [groff_cv_type_unsigned_long_long=yes],
817 [groff_cv_type_unsigned_long_long=no])
818 AC_MSG_RESULT([$groff_cv_type_unsigned_long_long])
821 # Define uintmax_t to `unsigned long' or `unsigned long long'
822 # if <inttypes.h> does not exist. Taken from the fileutils package.
824 AC_DEFUN([GROFF_UINTMAX_T],
825 [AC_REQUIRE([GROFF_INTTYPES_H])
826 if test $groff_cv_header_inttypes_h = no; then
827 AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
828 test $groff_cv_type_unsigned_long_long = yes \
829 && ac_type='unsigned long long' \
830 || ac_type='unsigned long'
831 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
832 [Define uintmax_t to `unsigned long' or `unsigned long long' if
833 <inttypes.h> does not exist.])
836 # Identify PATH_SEPARATOR character to use in GROFF_FONT_PATH and
837 # GROFF_TMAC_PATH which is appropriate for the target system (POSIX=':',
840 # The logic to resolve this test is already encapsulated in
841 # `${srcdir}/src/include/nonposix.h'.
843 AC_DEFUN([GROFF_TARGET_PATH_SEPARATOR],
844 [AC_MSG_CHECKING([separator character to use in groff search paths])
845 cp ${srcdir}/src/include/nonposix.h conftest.h
850 #include "conftest.h"
855 #if PATH_SEP_CHAR == ';'
856 make an error "Path separator is ';'"
861 [GROFF_PATH_SEPARATOR=":"],
862 [GROFF_PATH_SEPARATOR=";"])
863 AC_MSG_RESULT([$GROFF_PATH_SEPARATOR])
864 AC_SUBST(GROFF_PATH_SEPARATOR)])