* Fixing a lot of typos in groff_mm.man
[s-roff.git] / aclocal.m4
blob8bc06f50858b697da52d1fb9ea5b15a25fc7d993
1 dnl Autoconf macros for groff.
2 dnl Copyright (C) 1989, 1990, 1991, 1992, 1995 Free Software Foundation, Inc.
3 dnl 
4 dnl This file is part of groff.
5 dnl 
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
9 dnl version.
10 dnl 
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
14 dnl for more details.
15 dnl 
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.
19 dnl
20 dnl
21 AC_DEFUN(GROFF_PRINT,
22 [if test -z "$PSPRINT"; then
23         AC_CHECK_PROGS(LPR,lpr)
24         AC_CHECK_PROGS(LP,lp)
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
28                 # rather than lpr.
29                 AC_CHECK_PROGS(LPQ,lpq)
30                 test -n "$LPQ" || LPR=
31         fi
32         if test -n "$LPR"; then
33                 PSPRINT="$LPR"
34         elif test -n "$LP"; then
35                 PSPRINT="$LP"
36         fi
38 AC_SUBST(PSPRINT)
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
45                 DVIPRINT="lpr -d"
46         else
47                 DVIPRINT="$PSPRINT"
48         fi
50 AC_SUBST(DVIPRINT)
51 AC_MSG_RESULT($DVIPRINT)])dnl
52 dnl
53 dnl
54 dnl Bison generated parsers have problems with C++ compilers other than g++.
55 dnl So byacc is preferred over bison.
56 dnl
57 AC_DEFUN(GROFF_PROG_YACC,
58 [AC_CHECK_PROGS(YACC, byacc 'bison -y', yacc)])dnl
59 dnl
60 dnl
61 dnl GROFF_CSH_HACK(if hack present, if not present)
62 dnl
63 AC_DEFUN(GROFF_CSH_HACK,
64 [AC_MSG_CHECKING([for csh hash hack])
65 cat <<EOF >conftest.sh
66 #!/bin/sh
67 true || exit 0
68 export PATH || exit 0
69 exit 1
70 EOF
71 chmod +x conftest.sh
72 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
73         AC_MSG_RESULT(yes); $1
74 else
75         AC_MSG_RESULT(no); $2
77 rm -f conftest.sh])dnl
78 dnl
79 dnl
80 dnl From udodo!hans@relay.NL.net (Hans Zuidam)
81 dnl
82 AC_DEFUN(GROFF_ISC_SYSV3,
83 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
84 changequote(,)dnl
85 if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
86 changequote([,])dnl
87 then
88         AC_MSG_RESULT(yes)
89         AC_DEFINE(_SYSV3)
90 else
91         AC_MSG_RESULT(no)
92 fi])dnl
93 dnl
94 dnl
95 AC_DEFUN(GROFF_POSIX,
96 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
97 AC_LANG_SAVE
98 AC_LANG_CPLUSPLUS
99 AC_TRY_COMPILE([#include <stdio.h>
100 extern "C" { void fileno(int); }],,
101 AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE),
102 AC_MSG_RESULT(no))
103 AC_LANG_RESTORE])dnl
106 AC_DEFUN(GROFF_PUTENV,
107 [AC_LANG_SAVE
108 AC_LANG_CPLUSPLUS
109 AC_MSG_CHECKING([declaration of putenv])
110 AC_TRY_COMPILE([#include <stdlib.h>
111 extern "C" { void putenv(int); }],,
112 AC_MSG_RESULT(no),
113 AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_PUTENV))
114 AC_LANG_RESTORE])dnl
117 AC_DEFUN(GROFF_POPEN,
118 [AC_LANG_SAVE
119 AC_LANG_CPLUSPLUS
120 AC_MSG_CHECKING([declaration of popen])
121 AC_TRY_COMPILE([#include <stdio.h>
122 extern "C" { void popen(int); }],,
123 AC_MSG_RESULT(no),
124 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_POPEN))
125 AC_LANG_RESTORE])dnl
128 AC_DEFUN(GROFF_PCLOSE,
129 [AC_LANG_SAVE
130 AC_LANG_CPLUSPLUS
131 AC_MSG_CHECKING([declaration of pclose])
132 AC_TRY_COMPILE([#include <stdio.h>
133 extern "C" { void pclose(int); }],,
134 AC_MSG_RESULT(no),
135 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_PCLOSE))
136 AC_LANG_RESTORE])dnl
139 dnl srand() of SunOS 4.1.3 has return type int instead of void
141 AC_DEFUN(GROFF_SRAND,
142 [AC_LANG_SAVE
143 AC_LANG_CPLUSPLUS
144 AC_MSG_CHECKING([for return type of srand])
145 AC_TRY_COMPILE([#include <stdlib.h>
146 extern "C" { void srand(unsigned int); }],,
147 AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID),
148 AC_MSG_RESULT(int))
149 AC_LANG_RESTORE])dnl
152 AC_DEFUN(GROFF_SYS_NERR,
153 [AC_LANG_SAVE
154 AC_LANG_CPLUSPLUS
155 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
156 AC_TRY_COMPILE([#include <errno.h>
157 #include <stdio.h>],
158 [int k; k = sys_nerr;],
159 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR),
160 AC_MSG_RESULT(no))
161 AC_LANG_RESTORE])dnl
164 AC_DEFUN(GROFF_SYS_ERRLIST,
165 [AC_LANG_SAVE
166 AC_LANG_CPLUSPLUS
167 AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>])
168 AC_TRY_COMPILE([#include <errno.h>
169 #include <stdio.h>],
170 [int k; k = (int)sys_errlist[0];],
171 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST),
172 AC_MSG_RESULT(no))
173 AC_LANG_RESTORE])dnl
176 AC_DEFUN(GROFF_HYPOT,
177 [AC_LANG_SAVE
178 AC_LANG_CPLUSPLUS
179 AC_MSG_CHECKING([declaration of hypot])
180 AC_TRY_COMPILE([#include <math.h>
181 extern "C" { double hypot(double,double); }],,
182 AC_MSG_RESULT(no),
183 AC_MSG_RESULT(yes);AC_DEFINE(MATH_H_DECLARES_HYPOT))
184 AC_LANG_RESTORE])dnl
187 AC_DEFUN(GROFF_OSFCN_H,
188 [AC_LANG_SAVE
189 AC_LANG_CPLUSPLUS
190 AC_MSG_CHECKING([C++ <osfcn.h>])
191 AC_TRY_COMPILE([#include <osfcn.h>],
192 [read(0, 0, 0); open(0, 0);],
193 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
194 AC_MSG_RESULT(no))
195 AC_LANG_RESTORE])dnl
198 AC_DEFUN(GROFF_LIMITS_H,
199 [AC_LANG_SAVE
200 AC_LANG_CPLUSPLUS
201 AC_MSG_CHECKING([C++ <limits.h>])
202 AC_TRY_COMPILE([#include <limits.h>],
203 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
204 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),
205 AC_MSG_RESULT(no))
206 AC_LANG_RESTORE])dnl
209 AC_DEFUN(GROFF_TIME_T,
210 [AC_LANG_SAVE
211 AC_LANG_CPLUSPLUS
212 AC_MSG_CHECKING([for declaration of time_t])
213 AC_TRY_COMPILE([#include <time.h>],
214 [time_t t = time(0); struct tm *p = localtime(&t);],
215 AC_MSG_RESULT(yes),
216 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
217 AC_LANG_RESTORE])dnl
220 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
221 [AC_MSG_CHECKING([struct exception])
222 AC_TRY_COMPILE([#include <math.h>],
223 [struct exception e;],
224 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
225 AC_MSG_RESULT(no))])dnl
228 AC_DEFUN(GROFF_ARRAY_DELETE,
229 [AC_LANG_SAVE
230 AC_LANG_CPLUSPLUS
231 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
232 AC_TRY_COMPILE(,
233 changequote(,)dnl
234 char *p = new char[5]; delete [] p;changequote([,]),
235 AC_MSG_RESULT(yes),
236 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
237 AC_LANG_RESTORE])dnl
241 AC_DEFUN(GROFF_TRADITIONAL_CPP,
242 [AC_LANG_SAVE
243 AC_LANG_CPLUSPLUS
244 AC_MSG_CHECKING([traditional preprocessor])
245 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
246 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
247 AC_MSG_RESULT(no))
248 AC_LANG_RESTORE])dnl
251 AC_DEFUN(GROFF_WCOREFLAG,
252 [AC_MSG_CHECKING([w_coredump])
253 AC_TRY_RUN([#include <sys/types.h>
254 #include <sys/wait.h>
255 main()
257 #ifdef WCOREFLAG
258   exit(1);
259 #else
260   int i = 0;
261   ((union wait *)&i)->w_coredump = 1;
262   exit(i != 0200);
263 #endif
265 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),
266 AC_MSG_RESULT(no),
267 AC_MSG_RESULT(no))])dnl
270 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
271 [AC_MSG_CHECKING([default value for grops -b option])
272 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
273 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
274 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
277 AC_DEFUN(GROFF_PAGE,
278 [AC_MSG_CHECKING([default paper size])
279 if test -z "$PAGE"; then
280         descfile=
281         if test -r $prefix/share/groff/font/devps/DESC; then
282                 descfile=$prefix/share/groff/font/devps/DESC
283         elif test -r $prefix/lib/groff/font/devps/DESC; then
284                 descfile=$prefix/lib/groff/font/devps/DESC
285         fi
286         if test -n "$descfile" \
287           && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
288                 PAGE=A4
289         else
290                 PAGE=letter
291         fi
293 if test -z "$PAGE"; then
294         dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
295             /etc/resolv.conf 2>/dev/null`
296         if test -z "$dom"; then
297                 dom=`(domainname) 2>/dev/null | tr -d '+'`
298                 if test -z "$dom"; then
299                         dom=`(hostname) 2>/dev/null | grep '\.'`
300                 fi
301         fi
302 changequote(,)dnl
303         # If the top-level domain is two letters and it's not `us' or `ca'
304         # then they probably use A4 paper.
305         case "$dom" in
306         *.[Uu][Ss]|*.[Cc][Aa]) ;;
307         *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
308         esac
309 changequote([,])dnl
311 test -n "$PAGE" || PAGE=letter
312 AC_MSG_RESULT($PAGE)
313 AC_SUBST(PAGE)])dnl
316 AC_DEFUN(GROFF_CXX_CHECK,
317 [AC_REQUIRE([AC_PROG_CXX])
318 AC_LANG_SAVE
319 AC_LANG_CPLUSPLUS
320 if test "$cross_compiling" = no; then
321         AC_MSG_CHECKING([that C++ compiler can compile simple program])
323 AC_TRY_RUN([int main() { return 0; }],
324 AC_MSG_RESULT(yes),
325 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
327 if test "$cross_compiling" = no; then
328         AC_MSG_CHECKING([that C++ static constructors and destructors are called])
330 AC_TRY_RUN([
331 extern "C" {
332   void _exit(int);
334 int i;
335 struct A {
336   char dummy;
337   A() { i = 1; }
338   ~A() { if (i == 1) _exit(0); }
340 A a;
341 int main() { return 1; }
343 AC_MSG_RESULT(yes),
344 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
346 AC_MSG_CHECKING([that header files support C++])
347 AC_TRY_LINK([#include <stdio.h>],
348 [fopen(0, 0);],
349 AC_MSG_RESULT(yes),
350 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++)]))
351 AC_LANG_RESTORE])dnl
354 AC_DEFUN(GROFF_TMAC,
355 [AC_MSG_CHECKING([for prefix of system macro packages])
356 sys_tmac_prefix=
357 sys_tmac_file_prefix=
358 for d in /usr/share/lib/tmac /usr/lib/tmac; do
359         for t in "" tmac.; do
360                 for m in an s m; do
361                         f=$d/$t$m
362                         if test -z "$sys_tmac_prefix" \
363                           && test -f $f \
364                           && grep '^\.if' $f >/dev/null 2>&1; then
365                                 sys_tmac_prefix=$d/$t
366                                 sys_tmac_file_prefix=$t
367                         fi
368                 done
369         done
370 done
371 AC_MSG_RESULT($sys_tmac_prefix)
372 AC_SUBST(sys_tmac_prefix)
373 tmac_wrap=
374 AC_MSG_CHECKING([which system macro packages should be made available])
375 if test "x$sys_tmac_file_prefix" = "xtmac."; then
376         for f in $sys_tmac_prefix*; do
377                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
378                 case "$suff" in
379                 e) ;;
380                 *)
381                         grep "Copyright.*Free Software Foundation" $f >/dev/null \
382                           || tmac_wrap="$tmac_wrap $suff" ;;
383                 esac 
384         done
385 elif test -n "$sys_tmac_prefix"; then
386         files=`echo $sys_tmac_prefix*`
387         grep "\\.so" $files >conftest.sol
388         for f in $files; do
389                 case "$f" in
390                 ${sys_tmac_prefix}e) ;;
391                 *.me) ;;
392                 */ms.*) ;;
393                 *)
394                         b=`basename $f`
395                         if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
396                           || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
397                                 :
398                         else
399                                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
400                                 case "$suff" in
401                                 tmac.*) ;;
402                                 *) tmac_wrap="$tmac_wrap $suff" ;;
403                                 esac
404                         fi
405                 esac
406         done
407         rm -f conftest.sol
409 AC_MSG_RESULT([$tmac_wrap])
410 AC_SUBST(tmac_wrap)])dnl
413 AC_DEFUN(GROFF_G,
414 [AC_MSG_CHECKING([for existing troff installation])
415 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
416         AC_MSG_RESULT(yes)
417         g=g
418 else
419         AC_MSG_RESULT(no)
420         g=
422 AC_SUBST(g)])dnl
425 dnl We need the path to install-sh to be absolute.
427 AC_DEFUN(GROFF_INSTALL_SH,
428 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
429 ac_dir=`cd $ac_aux_dir; pwd`
430 ac_install_sh="$ac_dir/install-sh -c"])dnl
433 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
434 dnl does not have -lm.
436 AC_DEFUN(GROFF_LIBM,
437 [AC_CHECK_LIB(m,sin,LIBM=-lm)
438 AC_SUBST(LIBM)])dnl
441 dnl We need top_srcdir to be absolute.
443 AC_DEFUN(GROFF_SRCDIR,
444 [ac_srcdir_defaulted=no
445 srcdir=`cd $srcdir; pwd`])dnl
448 dnl This simplifies Makefile rules.
450 AC_DEFUN(GROFF_BUILDDIR,
451 [top_builddir=`pwd`
452 AC_SUBST(top_builddir)])dnl
455 dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port
457 AC_DEFUN(GROFF_EBCDIC,
458 [AC_MSG_CHECKING([whether character set is EBCDIC])
459 AC_TRY_COMPILE(,
460 [/* Treat any failure as ASCII for compatibility with existing art.
461     Use compile-time rather than run-time tests for cross-compiler
462     tolerance. */
463 #if '0' != 240
464 make an error "Character set is not EBCDIC"
465 #endif],
466 groff_cv_ebcdic="yes"
467  TTYDEVDIRS="font/devcp1047"
468  AC_MSG_RESULT(yes)
469  AC_DEFINE(IS_EBCDIC_HOST),
470 groff_cv_ebcdic="no"
471  TTYDEVDIRS="font/devascii font/devlatin1 font/devutf8"
472  AC_MSG_RESULT(no))
473 AC_SUBST(TTYDEVDIRS)])dnl
476 dnl Check for OS/390 Unix.  We test for EBCDIC also -- the Linux port (with
477 dnl gcc) to OS/390 uses ASCII internally.
479 AC_DEFUN(GROFF_OS390,
480 [groff_cv_os390="no"
481 if test "$groff_cv_ebcdic" = "yes"; then
482         AC_MSG_CHECKING([for OS/390 Unix])
483         case `uname` in
484         OS/390)
485                 CFLAGS="$CFLAGS -D_ALL_SOURCE"
486                 groff_cv_os390="yes"
487                 AC_MSG_RESULT(yes) ;;
488         *)
489                 AC_MSG_RESULT(no) ;;
490         esac
491 fi])dnl
494 dnl Finally, we must modify a base function of autoconf to replace the
495 dnl ASCII char `012' with its generic equivalent `\n' if we run under
496 dnl OS/390 Unix -- unfortunately, not all `tr' variants understand `\n',
497 dnl so this hack is necessary.
499 define([AC_OUTPUT_MAKE_DEFS],
500 [# Transform confdefs.h into DEFS.
501 dnl Using a here document instead of a string reduces the quoting nightmare.
502 # Protect against shell expansion while executing Makefile rules.
503 # Protect against Makefile macro expansion.
504 cat > conftest.defs <<\EOF
505 changequote(<<, >>)dnl
506 s%<<#define>> \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
507 s%[     `~<<#>>$^&*(){}\\|;'"<>?]%\\&%g
508 s%\[%\\&%g
509 s%\]%\\&%g
510 s%\$%$$%g
511 changequote([, ])dnl
513 if test "$groff_cv_os390" = "yes"; then
514         DEFS=`sed -f conftest.defs confdefs.h | tr '\n' ' '`
515 else
516         DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
518 rm -f conftest.defs