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.
21 [if test -z "$PSPRINT"
23 AC_CHECK_PROGS(LPR,lpr)
25 if test -n "$LPR" && test -n "$LP"
27 # HP-UX provides an lpr command that emulates lpr using lp,
28 # but it doesn't have lpq; in this case we want to use lp
30 AC_CHECK_PROGS(LPQ,lpq)
31 test -n "$LPQ" || LPR=
42 AC_MSG_CHECKING([for command to use for printing PostScript files])
43 AC_MSG_RESULT($PSPRINT)
44 # Figure out DVIPRINT from PSPRINT.
45 AC_MSG_CHECKING([for command to use for printing dvi files])
46 if test -n "$PSPRINT" && test -z "$DVIPRINT"
48 if test "X$PSPRINT" = "Xlpr"
56 AC_MSG_RESULT($DVIPRINT)])dnl
57 dnl Bison generated parsers have problems with C++ compilers other than g++.
58 dnl So byacc is preferred over bison.
59 AC_DEFUN(GROFF_PROG_YACC,
60 [AC_CHECK_PROGS(YACC, byacc 'bison -y', yacc)])
61 dnl GROFF_CSH_HACK(if hack present, if not present)
62 AC_DEFUN(GROFF_CSH_HACK,
63 [AC_MSG_CHECKING([for csh hash hack])
64 cat <<EOF >conftest.sh
71 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1
73 AC_MSG_RESULT(yes); $1
79 dnl From udodo!hans@relay.NL.net (Hans Zuidam)
80 AC_DEFUN(GROFF_ISC_SYSV3,
81 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
83 if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
92 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
95 AC_TRY_COMPILE([#include <stdio.h>
96 extern "C" { void fileno(int); }],,
97 AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE),
100 AC_DEFUN(GROFF_GETOPT,
103 AC_MSG_CHECKING([declaration of getopt in stdlib.h])
106 extern "C" { void getopt(int); }],,AC_MSG_RESULT(no),
107 AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_GETOPT))
108 AC_MSG_CHECKING([declaration of getopt in unistd.h])
109 AC_TRY_COMPILE([#include <sys/types.h>
111 extern "C" { void getopt(int); }],,AC_MSG_RESULT(no),
112 AC_MSG_RESULT(yes);AC_DEFINE(UNISTD_H_DECLARES_GETOPT))
114 AC_DEFUN(GROFF_PUTENV,
117 AC_MSG_CHECKING([declaration of putenv])
118 AC_TRY_COMPILE([#include <stdlib.h>
119 extern "C" { void putenv(int); }],,AC_MSG_RESULT(no),
121 AC_DEFINE(STDLIB_H_DECLARES_PUTENV))
123 AC_DEFUN(GROFF_POPEN,
126 AC_MSG_CHECKING([declaration of popen])
127 AC_TRY_COMPILE([#include <stdio.h>
128 extern "C" { void popen(int); }],,AC_MSG_RESULT(no),
129 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_POPEN))
131 AC_DEFUN(GROFF_PCLOSE,
134 AC_MSG_CHECKING([declaration of pclose])
135 AC_TRY_COMPILE([#include <stdio.h>
136 extern "C" { void pclose(int); }],,AC_MSG_RESULT(no),
137 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_PCLOSE))
139 AC_DEFUN(GROFF_OSFCN_H,
142 AC_MSG_CHECKING([C++ <osfcn.h>])
143 AC_TRY_COMPILE([#include <osfcn.h>],
144 [read(0, 0, 0); open(0, 0);],AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
147 AC_DEFUN(GROFF_LIMITS_H,
150 AC_MSG_CHECKING([C++ <limits.h>])
151 AC_TRY_COMPILE([#include <limits.h>],
152 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
153 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),AC_MSG_RESULT(no))
155 AC_DEFUN(GROFF_TIME_T,
158 AC_MSG_CHECKING([for declaration of time_t])
159 AC_TRY_COMPILE([#include <time.h>],
160 [time_t t = time(0); struct tm *p = localtime(&t);],AC_MSG_RESULT(yes),
161 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
163 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
164 [AC_MSG_CHECKING([struct exception])
165 AC_TRY_COMPILE([#include <math.h>],
166 [struct exception e;],
167 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
168 AC_MSG_RESULT(no))])dnl
169 AC_DEFUN(GROFF_ARRAY_DELETE,
172 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
175 char *p = new char[5]; delete [] p;changequote([,]),
176 AC_MSG_RESULT(yes),AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
179 AC_DEFUN(GROFF_TRADITIONAL_CPP,
182 AC_MSG_CHECKING([traditional preprocessor])
183 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
184 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
188 AC_DEFUN(GROFF_WCOREFLAG,
189 [AC_MSG_CHECKING([w_coredump])
191 #include <sys/types.h>
192 #include <sys/wait.h>
199 ((union wait *)&i)->w_coredump = 1;
203 ],AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),AC_MSG_RESULT(no),
204 AC_MSG_RESULT(no))])dnl
206 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
207 [AC_MSG_CHECKING([default value for grops -b option])
208 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
209 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
210 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
213 [AC_MSG_CHECKING([default paper size])
217 if test -r $prefix/share/groff/font/devps/DESC
219 descfile=$prefix/share/groff/font/devps/DESC
220 elif test -r $prefix/lib/groff/font/devps/DESC
222 descfile=$prefix/lib/groff/font/devps/DESC
224 if test -n "$descfile" \
225 && grep "^paperlength 841890" $descfile >/dev/null 2>&1
234 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
235 /etc/resolv.conf 2>/dev/null`
239 dom=`(domainname) 2>/dev/null | tr -d '+'`
242 dom=`(hostname) 2>/dev/null | grep '\.'`
247 # If the top-level domain is two letters and it's not `us' or `ca'
248 # then they probably use A4 paper.
250 *.[Uu][Ss]|*.[Cc][Aa]) ;;
251 *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
255 test -n "$PAGE" || PAGE=letter
259 AC_DEFUN(GROFF_CXX_CHECK,
260 [AC_REQUIRE([AC_C_CROSS])
261 AC_REQUIRE([AC_PROG_CXX])
264 if test "$cross_compiling" = no; then
265 AC_MSG_CHECKING([that C++ compiler can compile simple program])
267 AC_TRY_RUN([int main() { return 0; }],
270 AC_MSG_ERROR([a working C++ compiler is required]),:)
271 if test "$cross_compiling" = no; then
272 AC_MSG_CHECKING([that C++ static constructors and destructors are called])
282 ~A() { if (i == 1) _exit(0); }
285 int main() { return 1; }
289 AC_MSG_ERROR([a working C++ compiler is required]),:)
290 AC_MSG_CHECKING([that header files support C++])
291 AC_TRY_LINK([#include <stdio.h>],
292 [fopen(0, 0);],AC_MSG_RESULT(yes),
294 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++)]))
300 AC_MSG_CHECKING([for prefix of system macro packages])
302 sys_tmac_file_prefix=
303 for d in /usr/share/lib/tmac /usr/lib/tmac
310 if test -z "$sys_tmac_prefix" \
312 && grep '^\.if' $f >/dev/null 2>&1
314 sys_tmac_prefix=$d/$t
315 sys_tmac_file_prefix=$t
320 AC_MSG_RESULT($sys_tmac_prefix)
321 AC_SUBST(sys_tmac_prefix)
323 AC_MSG_CHECKING([which system macro packages should be made available])
324 if test "x$sys_tmac_file_prefix" = "xtmac."
326 for f in $sys_tmac_prefix*
328 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
332 grep "Copyright.*Free Software Foundation" $f >/dev/null \
333 || tmac_wrap="$tmac_wrap $suff"
337 elif test -n "$sys_tmac_prefix"
339 files=`echo $sys_tmac_prefix*`
340 grep "\\.so" $files >conftest.sol
344 ${sys_tmac_prefix}e) ;;
349 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
350 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null
354 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
357 *) tmac_wrap="$tmac_wrap $suff" ;;
364 AC_MSG_RESULT([$tmac_wrap])
368 [AC_MSG_CHECKING([for existing troff installation])
369 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" \
380 dnl We need the path to install-sh to be absolute.
381 AC_DEFUN(GROFF_INSTALL_SH,
382 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
383 ac_dir=`cd $ac_aux_dir; pwd`
384 ac_install_sh="$ac_dir/install-sh -c"