Adding EBCDIC code page 1047.
[s-roff.git] / aclocal.m4
blob030fbcd75e3a1c12c6f105594a091bf84557b89d
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 AC_DEFUN(GROFF_SYS_NERR,
140 [AC_LANG_SAVE
141 AC_LANG_CPLUSPLUS
142 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
143 AC_TRY_COMPILE([#include <errno.h>
144 #include <stdio.h>],
145 [int k; k = sys_nerr;],
146 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR),
147 AC_MSG_RESULT(no))
148 AC_LANG_RESTORE])dnl
151 AC_DEFUN(GROFF_SYS_ERRLIST,
152 [AC_LANG_SAVE
153 AC_LANG_CPLUSPLUS
154 AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>])
155 AC_TRY_COMPILE([#include <errno.h>
156 #include <stdio.h>],
157 [int k; k = (int)sys_errlist[0];],
158 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST),
159 AC_MSG_RESULT(no))
160 AC_LANG_RESTORE])dnl
163 AC_DEFUN(GROFF_HYPOT,
164 [AC_LANG_SAVE
165 AC_LANG_CPLUSPLUS
166 AC_MSG_CHECKING([declaration of hypot])
167 AC_TRY_COMPILE([#include <math.h>
168 extern "C" { double hypot(double,double); }],,
169 AC_MSG_RESULT(no),
170 AC_MSG_RESULT(yes);AC_DEFINE(MATH_H_DECLARES_HYPOT))
171 AC_LANG_RESTORE])dnl
174 AC_DEFUN(GROFF_OSFCN_H,
175 [AC_LANG_SAVE
176 AC_LANG_CPLUSPLUS
177 AC_MSG_CHECKING([C++ <osfcn.h>])
178 AC_TRY_COMPILE([#include <osfcn.h>],
179 [read(0, 0, 0); open(0, 0);],
180 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
181 AC_MSG_RESULT(no))
182 AC_LANG_RESTORE])dnl
185 AC_DEFUN(GROFF_LIMITS_H,
186 [AC_LANG_SAVE
187 AC_LANG_CPLUSPLUS
188 AC_MSG_CHECKING([C++ <limits.h>])
189 AC_TRY_COMPILE([#include <limits.h>],
190 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
191 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),
192 AC_MSG_RESULT(no))
193 AC_LANG_RESTORE])dnl
196 AC_DEFUN(GROFF_TIME_T,
197 [AC_LANG_SAVE
198 AC_LANG_CPLUSPLUS
199 AC_MSG_CHECKING([for declaration of time_t])
200 AC_TRY_COMPILE([#include <time.h>],
201 [time_t t = time(0); struct tm *p = localtime(&t);],
202 AC_MSG_RESULT(yes),
203 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
204 AC_LANG_RESTORE])dnl
207 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
208 [AC_MSG_CHECKING([struct exception])
209 AC_TRY_COMPILE([#include <math.h>],
210 [struct exception e;],
211 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
212 AC_MSG_RESULT(no))])dnl
215 AC_DEFUN(GROFF_ARRAY_DELETE,
216 [AC_LANG_SAVE
217 AC_LANG_CPLUSPLUS
218 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
219 AC_TRY_COMPILE(,
220 changequote(,)dnl
221 char *p = new char[5]; delete [] p;changequote([,]),
222 AC_MSG_RESULT(yes),
223 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
224 AC_LANG_RESTORE])dnl
228 AC_DEFUN(GROFF_TRADITIONAL_CPP,
229 [AC_LANG_SAVE
230 AC_LANG_CPLUSPLUS
231 AC_MSG_CHECKING([traditional preprocessor])
232 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
233 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
234 AC_MSG_RESULT(no))
235 AC_LANG_RESTORE])dnl
238 AC_DEFUN(GROFF_WCOREFLAG,
239 [AC_MSG_CHECKING([w_coredump])
240 AC_TRY_RUN([#include <sys/types.h>
241 #include <sys/wait.h>
242 main()
244 #ifdef WCOREFLAG
245   exit(1);
246 #else
247   int i = 0;
248   ((union wait *)&i)->w_coredump = 1;
249   exit(i != 0200);
250 #endif
252 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),
253 AC_MSG_RESULT(no),
254 AC_MSG_RESULT(no))])dnl
257 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
258 [AC_MSG_CHECKING([default value for grops -b option])
259 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
260 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
261 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
264 AC_DEFUN(GROFF_PAGE,
265 [AC_MSG_CHECKING([default paper size])
266 if test -z "$PAGE"; then
267         descfile=
268         if test -r $prefix/share/groff/font/devps/DESC; then
269                 descfile=$prefix/share/groff/font/devps/DESC
270         elif test -r $prefix/lib/groff/font/devps/DESC; then
271                 descfile=$prefix/lib/groff/font/devps/DESC
272         fi
273         if test -n "$descfile" \
274           && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
275                 PAGE=A4
276         else
277                 PAGE=letter
278         fi
280 if test -z "$PAGE"; then
281         dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
282             /etc/resolv.conf 2>/dev/null`
283         if test -z "$dom"; then
284                 dom=`(domainname) 2>/dev/null | tr -d '+'`
285                 if test -z "$dom"; then
286                         dom=`(hostname) 2>/dev/null | grep '\.'`
287                 fi
288         fi
289 changequote(,)dnl
290         # If the top-level domain is two letters and it's not `us' or `ca'
291         # then they probably use A4 paper.
292         case "$dom" in
293         *.[Uu][Ss]|*.[Cc][Aa]) ;;
294         *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
295         esac
296 changequote([,])dnl
298 test -n "$PAGE" || PAGE=letter
299 AC_MSG_RESULT($PAGE)
300 AC_SUBST(PAGE)])dnl
303 AC_DEFUN(GROFF_CXX_CHECK,
304 [AC_REQUIRE([AC_C_CROSS])
305 AC_REQUIRE([AC_PROG_CXX])
306 AC_LANG_SAVE
307 AC_LANG_CPLUSPLUS
308 if test "$cross_compiling" = no; then
309         AC_MSG_CHECKING([that C++ compiler can compile simple program])
311 AC_TRY_RUN([int main() { return 0; }],
312 AC_MSG_RESULT(yes),
313 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
315 if test "$cross_compiling" = no; then
316         AC_MSG_CHECKING([that C++ static constructors and destructors are called])
318 AC_TRY_RUN([
319 extern "C" {
320   void _exit(int);
322 int i;
323 struct A {
324   char dummy;
325   A() { i = 1; }
326   ~A() { if (i == 1) _exit(0); }
328 A a;
329 int main() { return 1; }
331 AC_MSG_RESULT(yes),
332 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
334 AC_MSG_CHECKING([that header files support C++])
335 AC_TRY_LINK([#include <stdio.h>],
336 [fopen(0, 0);],
337 AC_MSG_RESULT(yes),
338 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++)]))
339 AC_LANG_RESTORE])dnl
342 AC_DEFUN(GROFF_TMAC,
343 [AC_MSG_CHECKING([for prefix of system macro packages])
344 sys_tmac_prefix=
345 sys_tmac_file_prefix=
346 for d in /usr/share/lib/tmac /usr/lib/tmac; do
347         for t in "" tmac.; do
348                 for m in an s m; do
349                         f=$d/$t$m
350                         if test -z "$sys_tmac_prefix" \
351                           && test -f $f \
352                           && grep '^\.if' $f >/dev/null 2>&1; then
353                                 sys_tmac_prefix=$d/$t
354                                 sys_tmac_file_prefix=$t
355                         fi
356                 done
357         done
358 done
359 AC_MSG_RESULT($sys_tmac_prefix)
360 AC_SUBST(sys_tmac_prefix)
361 tmac_wrap=
362 AC_MSG_CHECKING([which system macro packages should be made available])
363 if test "x$sys_tmac_file_prefix" = "xtmac."; then
364         for f in $sys_tmac_prefix*; do
365                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
366                 case "$suff" in
367                 e) ;;
368                 *)
369                         grep "Copyright.*Free Software Foundation" $f >/dev/null \
370                           || tmac_wrap="$tmac_wrap $suff" ;;
371                 esac 
372         done
373 elif test -n "$sys_tmac_prefix"; then
374         files=`echo $sys_tmac_prefix*`
375         grep "\\.so" $files >conftest.sol
376         for f in $files; do
377                 case "$f" in
378                 ${sys_tmac_prefix}e) ;;
379                 *.me) ;;
380                 */ms.*) ;;
381                 *)
382                         b=`basename $f`
383                         if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
384                           || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
385                                 :
386                         else
387                                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
388                                 case "$suff" in
389                                 tmac.*) ;;
390                                 *) tmac_wrap="$tmac_wrap $suff" ;;
391                                 esac
392                         fi
393                 esac
394         done
395         rm -f conftest.sol
397 AC_MSG_RESULT([$tmac_wrap])
398 AC_SUBST(tmac_wrap)])dnl
401 AC_DEFUN(GROFF_G,
402 [AC_MSG_CHECKING([for existing troff installation])
403 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
404         AC_MSG_RESULT(yes)
405         g=g
406 else
407         AC_MSG_RESULT(no)
408         g=
410 AC_SUBST(g)])dnl
413 dnl We need the path to install-sh to be absolute.
415 AC_DEFUN(GROFF_INSTALL_SH,
416 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
417 ac_dir=`cd $ac_aux_dir; pwd`
418 ac_install_sh="$ac_dir/install-sh -c"])dnl
421 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
422 dnl does not have -lm.
424 AC_DEFUN(GROFF_LIBM,
425 [AC_CHECK_LIB(m,sin,LIBM=-lm)
426 AC_SUBST(LIBM)])dnl
429 dnl We need top_srcdir to be absolute.
431 AC_DEFUN(GROFF_SRCDIR,
432 [ac_srcdir_defaulted=no
433 srcdir=`cd $srcdir; pwd`])dnl
436 dnl This simplifies Makefile rules.
438 AC_DEFUN(GROFF_BUILDDIR,
439 [top_builddir=`pwd`
440 AC_SUBST(top_builddir)])dnl
443 dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port
445 AC_DEFUN(GROFF_EBCDIC,
446 [AC_MSG_CHECKING([whether character set is EBCDIC])
447 AC_TRY_COMPILE(,
448 [/* Treat any failure as ASCII for compatibility with existing art.
449     Use compile-time rather than run-time tests for cross-compiler
450     tolerance. */
451 #if '0' != 240
452 make an error "Character set is not EBCDIC"
453 #endif],
454 groff_cv_ebcdic="yes"
455  TTYDEVDIRS="font/devcp1047"
456  AC_MSG_RESULT(yes)
457  AC_DEFINE(IS_EBCDIC_HOST),
458 groff_cv_ebcdic="no"
459  TTYDEVDIRS="font/devascii font/devlatin1"
460  AC_MSG_RESULT(no))
461 AC_SUBST(TTYDEVDIRS)])dnl
464 dnl Check for OS/390 Unix.  We test for EBCDIC also -- the Linux port (with
465 dnl gcc) to OS/390 uses ASCII internally.
467 AC_DEFUN(GROFF_OS390,
468 [groff_cv_os390="no"
469 if test "$groff_cv_ebcdic" = "yes"; then
470         AC_MSG_CHECKING([for OS/390 Unix])
471         case `uname` in
472         OS/390)
473                 CFLAGS="$CFLAGS -D_ALL_SOURCE"
474                 groff_cv_os390="yes"
475                 AC_MSG_RESULT(yes) ;;
476         *)
477                 AC_MSG_RESULT(no) ;;
478         esac
479 fi])dnl
482 dnl Finally, we must modify a base function of autoconf to replace the
483 dnl ASCII char `012' with its generic equivalent `\n' if we run under
484 dnl OS/390 Unix -- unfortunately, not all `tr' variants understand `\n',
485 dnl so this hack is necessary.
487 define([AC_OUTPUT_MAKE_DEFS],
488 [# Transform confdefs.h into DEFS.
489 dnl Using a here document instead of a string reduces the quoting nightmare.
490 # Protect against shell expansion while executing Makefile rules.
491 # Protect against Makefile macro expansion.
492 cat > conftest.defs <<\EOF
493 changequote(<<, >>)dnl
494 s%<<#define>> \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
495 s%[     `~<<#>>$^&*(){}\\|;'"<>?]%\\&%g
496 s%\[%\\&%g
497 s%\]%\\&%g
498 s%\$%$$%g
499 changequote([, ])dnl
501 if test "$groff_cv_os390" = "yes"; then
502         DEFS=`sed -f conftest.defs confdefs.h | tr '\n' ' '`
503 else
504         DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
506 rm -f conftest.defs