* man/groff_char.man: Check `ECFONTS' register.
[s-roff.git] / aclocal.m4
blob1fde4e4c606a9767f65adacd2c069bdbf2246081
1 dnl Autoconf macros for groff.
2 dnl Copyright (C) 1989-1995, 2001 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, 1,
90                   [Define if you have ISC 3.x or 4.x.])
91 else
92         AC_MSG_RESULT(no)
93 fi])dnl
94 dnl
95 dnl
96 AC_DEFUN(GROFF_POSIX,
97 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
98 AC_LANG_PUSH(C++)
99 AC_TRY_COMPILE([#include <stdio.h>
100 extern "C" { void fileno(int); }],,
101 AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE, 1,
102                              [Define if -D_POSIX_SOURCE is necessary.]),
103 AC_MSG_RESULT(no))
104 AC_LANG_POP(C++)])dnl
107 dnl srand() of SunOS 4.1.3 has return type int instead of void
109 AC_DEFUN(GROFF_SRAND,
110 [AC_LANG_PUSH(C++)
111 AC_MSG_CHECKING([for return type of srand])
112 AC_TRY_COMPILE([#include <stdlib.h>
113 extern "C" { void srand(unsigned int); }],,
114 AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID, 1,
115                               [Define if srand() returns void not int.]),
116 AC_MSG_RESULT(int))
117 AC_LANG_POP(C++)])dnl
120 AC_DEFUN(GROFF_SYS_NERR,
121 [AC_LANG_PUSH(C++)
122 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
123 AC_TRY_COMPILE([#include <errno.h>
124 #include <stdio.h>],
125 [int k; k = sys_nerr;],
126 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR, 1,
127                              [Define if you have sysnerr in <errno.h> or
128                               <stdio.h>.]),
129 AC_MSG_RESULT(no))
130 AC_LANG_POP(C++)])dnl
133 AC_DEFUN(GROFF_SYS_ERRLIST,
134 [AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>])
135 AC_TRY_COMPILE([#include <errno.h>
136 #include <stdio.h>],
137 [int k; k = (int)sys_errlist[0];],
138 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST, 1,
139                              [Define if you have sys_errlist in <errno.h>
140                               or in <stdio.h>.]),
141 AC_MSG_RESULT(no))])dnl
144 AC_DEFUN(GROFF_OSFCN_H,
145 [AC_LANG_PUSH(C++)
146 AC_MSG_CHECKING([C++ <osfcn.h>])
147 AC_TRY_COMPILE([#include <osfcn.h>],
148 [read(0, 0, 0); open(0, 0);],
149 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H, 1,
150                              [Define if you have a C++ <osfcn.h>.]),
151 AC_MSG_RESULT(no))
152 AC_LANG_POP(C++)])dnl
155 AC_DEFUN(GROFF_LIMITS_H,
156 [AC_LANG_PUSH(C++)
157 AC_MSG_CHECKING([C++ <limits.h>])
158 AC_TRY_COMPILE([#include <limits.h>],
159 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
160 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H, 1,
161                              [Define if you have a C++ <limits.h>.]),
162 AC_MSG_RESULT(no))
163 AC_LANG_POP(C++)])dnl
166 AC_DEFUN(GROFF_TIME_T,
167 [AC_LANG_PUSH(C++)
168 AC_MSG_CHECKING([for declaration of time_t])
169 AC_TRY_COMPILE([#include <time.h>],
170 [time_t t = time(0); struct tm *p = localtime(&t);],
171 AC_MSG_RESULT(yes),
172 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T, 1,
173                             [Define if localtime() takes a long * not a
174                              time_t *.]))
175 AC_LANG_POP(C++)])dnl
178 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
179 [AC_MSG_CHECKING([struct exception])
180 AC_TRY_COMPILE([#include <math.h>],
181 [struct exception e;],
182 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1,
183                              [Define if <math.h> defines struct exception.]),
184 AC_MSG_RESULT(no))])dnl
187 AC_DEFUN(GROFF_ARRAY_DELETE,
188 [AC_LANG_PUSH(C++)
189 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
190 AC_TRY_COMPILE(, [char *p = new char[5]; delete [] p;],
191 AC_MSG_RESULT(yes),
192 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE, 1,
193                             [Define if your C++ doesn't understand
194                              `delete []'.]))
195 AC_LANG_POP(C++)])dnl
199 AC_DEFUN(GROFF_TRADITIONAL_CPP,
200 [AC_LANG_PUSH(C++)
201 AC_MSG_CHECKING([traditional preprocessor])
202 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
203 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP, 1,
204                              [Define if your C++ compiler uses a
205                               traditional (Reiser) preprocessor.]),
206 AC_MSG_RESULT(no))
207 AC_LANG_POP(C++)])dnl
210 AC_DEFUN(GROFF_WCOREFLAG,
211 [AC_MSG_CHECKING([w_coredump])
212 AC_TRY_RUN([#include <sys/types.h>
213 #include <sys/wait.h>
214 main()
216 #ifdef WCOREFLAG
217   exit(1);
218 #else
219   int i = 0;
220   ((union wait *)&i)->w_coredump = 1;
221   exit(i != 0200);
222 #endif
224 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG, 0200,
225                              [Define if the 0200 bit of the status returned
226                               by wait() indicates whether a core image was
227                               produced for a process that was terminated by
228                               a signal.]),
229 AC_MSG_RESULT(no),
230 AC_MSG_RESULT(no))])dnl
233 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
234 [AC_MSG_CHECKING([default value for grops -b option])
235 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
236 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
237 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
240 AC_DEFUN(GROFF_PAGE,
241 [AC_MSG_CHECKING([default paper size])
242 if test -z "$PAGE"; then
243         descfile=
244         if test -r $prefix/share/groff/font/devps/DESC; then
245                 descfile=$prefix/share/groff/font/devps/DESC
246         elif test -r $prefix/lib/groff/font/devps/DESC; then
247                 descfile=$prefix/lib/groff/font/devps/DESC
248         else
249                 for f in $prefix/share/groff/*/font/devps/DESC; do
250                         if test -r $f; then
251                                 descfile=$f
252                                 break
253                         fi
254                 done
255         fi
256         if test -n "$descfile" \
257           && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
258                 PAGE=A4
259         fi
261 if test -z "$PAGE"; then
262         dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
263             /etc/resolv.conf 2>/dev/null`
264         if test -z "$dom"; then
265                 dom=`(domainname) 2>/dev/null | tr -d '+'`
266                 if test -z "$dom" \
267                   || test "$dom" = '(none)'; then
268                         dom=`(hostname) 2>/dev/null | grep '\.'`
269                 fi
270         fi
271 changequote(,)dnl
272         # If the top-level domain is two letters and it's not `us' or `ca'
273         # then they probably use A4 paper.
274         case "$dom" in
275         *.[Uu][Ss]|*.[Cc][Aa]) ;;
276         *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
277         esac
278 changequote([,])dnl
280 test -n "$PAGE" || PAGE=letter
281 if test "x$PAGE" = "xA4"; then
282         AC_DEFINE(PAGEA4, 1,
283                   [Define if the printer's page size is A4.])
285 AC_MSG_RESULT($PAGE)
286 AC_SUBST(PAGE)])dnl
289 AC_DEFUN(GROFF_CXX_CHECK,
290 [AC_REQUIRE([AC_PROG_CXX])
291 AC_LANG_PUSH(C++)
292 if test "$cross_compiling" = no; then
293         AC_MSG_CHECKING([that C++ compiler can compile simple program])
295 AC_TRY_RUN([int main() { return 0; }],
296 AC_MSG_RESULT(yes),
297 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
299 if test "$cross_compiling" = no; then
300         AC_MSG_CHECKING([that C++ static constructors and destructors are called])
302 AC_TRY_RUN([
303 extern "C" {
304   void _exit(int);
306 int i;
307 struct A {
308   char dummy;
309   A() { i = 1; }
310   ~A() { if (i == 1) _exit(0); }
312 A a;
313 int main() { return 1; }
315 AC_MSG_RESULT(yes),
316 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
318 AC_MSG_CHECKING([that header files support C++])
319 AC_TRY_LINK([#include <stdio.h>],
320 [fopen(0, 0);],
321 AC_MSG_RESULT(yes),
322 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++)]))
323 AC_LANG_POP(C++)])dnl
326 AC_DEFUN(GROFF_TMAC,
327 [AC_MSG_CHECKING([for prefix of system macro packages])
328 sys_tmac_prefix=
329 sys_tmac_file_prefix=
330 for d in /usr/share/lib/tmac /usr/lib/tmac; do
331         for t in "" tmac.; do
332                 for m in an s m; do
333                         f=$d/$t$m
334                         if test -z "$sys_tmac_prefix" \
335                           && test -f $f \
336                           && grep '^\.if' $f >/dev/null 2>&1; then
337                                 sys_tmac_prefix=$d/$t
338                                 sys_tmac_file_prefix=$t
339                         fi
340                 done
341         done
342 done
343 AC_MSG_RESULT($sys_tmac_prefix)
344 AC_SUBST(sys_tmac_prefix)
345 tmac_wrap=
346 AC_MSG_CHECKING([which system macro packages should be made available])
347 if test "x$sys_tmac_file_prefix" = "xtmac."; then
348         for f in $sys_tmac_prefix*; do
349                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
350                 case "$suff" in
351                 e) ;;
352                 *)
353                         grep "Copyright.*Free Software Foundation" $f >/dev/null \
354                           || tmac_wrap="$tmac_wrap $suff" ;;
355                 esac 
356         done
357 elif test -n "$sys_tmac_prefix"; then
358         files=`echo $sys_tmac_prefix*`
359         grep "\\.so" $files >conftest.sol
360         for f in $files; do
361                 case "$f" in
362                 ${sys_tmac_prefix}e) ;;
363                 *.me) ;;
364                 */ms.*) ;;
365                 *)
366                         b=`basename $f`
367                         if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
368                           || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
369                                 :
370                         else
371                                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
372                                 case "$suff" in
373                                 tmac.*) ;;
374                                 *) tmac_wrap="$tmac_wrap $suff" ;;
375                                 esac
376                         fi
377                 esac
378         done
379         rm -f conftest.sol
381 AC_MSG_RESULT([$tmac_wrap])
382 AC_SUBST(tmac_wrap)])dnl
385 AC_DEFUN(GROFF_G,
386 [AC_MSG_CHECKING([for existing troff installation])
387 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
388         AC_MSG_RESULT(yes)
389         g=g
390 else
391         AC_MSG_RESULT(no)
392         g=
394 AC_SUBST(g)])dnl
397 dnl We need the path to install-sh to be absolute.
399 AC_DEFUN(GROFF_INSTALL_SH,
400 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
401 ac_dir=`cd $ac_aux_dir; pwd`
402 ac_install_sh="$ac_dir/install-sh -c"])dnl
405 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
406 dnl does not have -lm.
408 AC_DEFUN(GROFF_LIBM,
409 [AC_CHECK_LIB(m,sin,LIBM=-lm)
410 AC_SUBST(LIBM)])dnl
413 dnl We need top_srcdir to be absolute.
415 AC_DEFUN(GROFF_SRCDIR,
416 [ac_srcdir_defaulted=no
417 srcdir=`cd $srcdir; pwd`])dnl
420 dnl This simplifies Makefile rules.
422 AC_DEFUN(GROFF_BUILDDIR,
423 [top_builddir=`pwd`
424 AC_SUBST(top_builddir)])dnl
427 dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port
429 AC_DEFUN(GROFF_EBCDIC,
430 [AC_MSG_CHECKING([whether character set is EBCDIC])
431 AC_TRY_COMPILE(,
432 [/* Treat any failure as ASCII for compatibility with existing art.
433     Use compile-time rather than run-time tests for cross-compiler
434     tolerance. */
435 #if '0' != 240
436 make an error "Character set is not EBCDIC"
437 #endif],
438 groff_cv_ebcdic="yes"
439  TTYDEVDIRS="font/devcp1047"
440  AC_MSG_RESULT(yes)
441  AC_DEFINE(IS_EBCDIC_HOST, 1,
442            [Define if the host's encoding is EBCDIC.]),
443 groff_cv_ebcdic="no"
444  TTYDEVDIRS="font/devascii font/devlatin1"
445  OTHERDEVDIRS="font/devlj4 font/devlbp"
446  AC_MSG_RESULT(no))
447 AC_SUBST(TTYDEVDIRS)
448 AC_SUBST(OTHERDEVDIRS)])dnl
451 dnl Check for OS/390 Unix.  We test for EBCDIC also -- the Linux port (with
452 dnl gcc) to OS/390 uses ASCII internally.
454 AC_DEFUN(GROFF_OS390,
455 [if test "$groff_cv_ebcdic" = "yes"; then
456         AC_MSG_CHECKING([for OS/390 Unix])
457         case `uname` in
458         OS/390)
459                 CFLAGS="$CFLAGS -D_ALL_SOURCE"
460                 AC_MSG_RESULT(yes) ;;
461         *)
462                 AC_MSG_RESULT(no) ;;
463         esac
464 fi])dnl
467 dnl Check whether we need a declaration for a function.
469 dnl Stolen from GNU bfd.
471 AC_DEFUN(GROFF_NEED_DECLARATION,
472 [AC_MSG_CHECKING([whether $1 must be declared])
473 AC_LANG_PUSH(C++)
474 AC_CACHE_VAL(groff_cv_decl_needed_$1,
475 [AC_TRY_COMPILE([
476 #include <stdio.h>
477 #ifdef HAVE_STRING_H
478 #include <string.h>
479 #endif
480 #ifdef HAVE_STRINGS_H
481 #include <strings.h>
482 #endif
483 #ifdef HAVE_STDLIB_H
484 #include <stdlib.h>
485 #endif
486 #ifdef HAVE_SYS_TIME_H
487 #include <sys/time.h>
488 #endif
489 #ifdef HAVE_UNISTD_H
490 #include <unistd.h>
491 #endif
492 #ifdef HAVE_MATH_H
493 #include <math.h>
494 #endif],
495 [char *(*pfn) = (char *(*)) $1],
496 groff_cv_decl_needed_$1=no,
497 groff_cv_decl_needed_$1=yes)])
498 AC_MSG_RESULT($groff_cv_decl_needed_$1)
499 if test $groff_cv_decl_needed_$1 = yes; then
500         AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
501                   [Define if your C++ doesn't declare ]$1[().])
503 AC_LANG_POP(C++)])dnl
506 dnl If mkstemp() isn't available, use our own mkstemp.cc file.
508 AC_DEFUN(GROFF_MKSTEMP,
509 [AC_MSG_CHECKING([for mkstemp])
510 AC_LANG_PUSH(C++)
511 AC_LIBSOURCE(mkstemp.cc)
512 AC_TRY_LINK([#include <stdlib.h>
513 int (*f) (char *);],
514 [f = mkstemp;],
515 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_MKSTEMP, 1,
516                              [Define if you have mkstemp().]),
517 AC_MSG_RESULT(no);_AC_LIBOBJ(mkstemp))
518 AC_LANG_POP(C++)])dnl
521 dnl Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
522 dnl and declares uintmax_t.  Taken from the fileutils package.
524 AC_DEFUN(GROFF_INTTYPES_H,
525 [AC_LANG_PUSH(C++)
526 AC_MSG_CHECKING([for inttypes.h])
527 AC_TRY_COMPILE([#include <sys/types.h>
528 #include <inttypes.h>],
529 [uintmax_t i = (uintmax_t)-1;],
530 groff_cv_header_inttypes_h=yes,
531 groff_cv_header_inttypes_h=no)
532 AC_MSG_RESULT($groff_cv_header_inttypes_h)
533 AC_LANG_POP(C++)])dnl
536 dnl Test for working `unsigned long long'.  Taken from the fileutils package.
538 AC_DEFUN(GROFF_UNSIGNED_LONG_LONG,
539 [AC_LANG_PUSH(C++)
540 AC_MSG_CHECKING([for unsigned long long])
541 AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
542 [unsigned long long ullmax = (unsigned long long)-1;
543 return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
544 groff_cv_type_unsigned_long_long=yes,
545 groff_cv_type_unsigned_long_long=no)
546 AC_MSG_RESULT($groff_cv_type_unsigned_long_long)
547 AC_LANG_POP(C++)])dnl
550 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
551 dnl if <inttypes.h> does not exist.  Taken from the fileutils package.
553 AC_DEFUN(GROFF_UINTMAX_T,
554 [AC_REQUIRE([GROFF_INTTYPES_H])
555 if test $groff_cv_header_inttypes_h = no; then
556         AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
557         test $groff_cv_type_unsigned_long_long = yes \
558           && ac_type='unsigned long long' \
559           || ac_type='unsigned long'
560         AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
561                            [Define uintmax_t to `unsigned long' or
562                             `unsigned long long' if <inttypes.h> does not
563                             exist.])
564 fi])dnl