* src/include/lib.h: Added xtmptemplate and made xtmpfile
[s-roff.git] / aclocal.m4
blob1a278c2b61dccaa78b0d8358de81e078ee03201d
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)])
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_GETOPT,
107 [AC_LANG_SAVE
108 AC_LANG_CPLUSPLUS
109 AC_MSG_CHECKING([declaration of getopt in stdlib.h])
110 AC_TRY_COMPILE([#include <stdlib.h>
111 extern "C" { void getopt(int); }],,
112 AC_MSG_RESULT(no),
113 AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_GETOPT))
114 AC_MSG_CHECKING([declaration of getopt in unistd.h])
115 AC_TRY_COMPILE([#include <sys/types.h>
116 #include <unistd.h>
117 extern "C" { void getopt(int); }],,
118 AC_MSG_RESULT(no),
119 AC_MSG_RESULT(yes);AC_DEFINE(UNISTD_H_DECLARES_GETOPT))
120 AC_LANG_RESTORE])dnl
123 AC_DEFUN(GROFF_PUTENV,
124 [AC_LANG_SAVE
125 AC_LANG_CPLUSPLUS
126 AC_MSG_CHECKING([declaration of putenv])
127 AC_TRY_COMPILE([#include <stdlib.h>
128 extern "C" { void putenv(int); }],,
129 AC_MSG_RESULT(no),
130 AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_PUTENV))
131 AC_LANG_RESTORE])dnl
134 AC_DEFUN(GROFF_POPEN,
135 [AC_LANG_SAVE
136 AC_LANG_CPLUSPLUS
137 AC_MSG_CHECKING([declaration of popen])
138 AC_TRY_COMPILE([#include <stdio.h>
139 extern "C" { void popen(int); }],,
140 AC_MSG_RESULT(no),
141 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_POPEN))
142 AC_LANG_RESTORE])dnl
145 AC_DEFUN(GROFF_PCLOSE,
146 [AC_LANG_SAVE
147 AC_LANG_CPLUSPLUS
148 AC_MSG_CHECKING([declaration of pclose])
149 AC_TRY_COMPILE([#include <stdio.h>
150 extern "C" { void pclose(int); }],,
151 AC_MSG_RESULT(no),
152 AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_PCLOSE))
153 AC_LANG_RESTORE])dnl
156 AC_DEFUN(GROFF_SYS_NERR,
157 [AC_LANG_SAVE
158 AC_LANG_CPLUSPLUS
159 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
160 AC_TRY_COMPILE([#include <errno.h>
161 #include <stdio.h>],
162 [int k; k = sys_nerr;],
163 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR),
164 AC_MSG_RESULT(no))
165 AC_LANG_RESTORE])dnl
168 AC_DEFUN(GROFF_SYS_ERRLIST,
169 [AC_LANG_SAVE
170 AC_LANG_CPLUSPLUS
171 AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>])
172 AC_TRY_COMPILE([#include <errno.h>
173 #include <stdio.h>],
174 [int k; k = (int)sys_errlist[0];],
175 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST),
176 AC_MSG_RESULT(no))
177 AC_LANG_RESTORE])dnl
180 AC_DEFUN(GROFF_HYPOT,
181 [AC_LANG_SAVE
182 AC_LANG_CPLUSPLUS
183 AC_MSG_CHECKING([declaration of hypot])
184 AC_TRY_COMPILE([#include <math.h>
185 extern "C" { double hypot(double,double); }],,
186 AC_MSG_RESULT(no),
187 AC_MSG_RESULT(yes);AC_DEFINE(MATH_H_DECLARES_HYPOT))
188 AC_LANG_RESTORE])dnl
191 AC_DEFUN(GROFF_OSFCN_H,
192 [AC_LANG_SAVE
193 AC_LANG_CPLUSPLUS
194 AC_MSG_CHECKING([C++ <osfcn.h>])
195 AC_TRY_COMPILE([#include <osfcn.h>],
196 [read(0, 0, 0); open(0, 0);],
197 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
198 AC_MSG_RESULT(no))
199 AC_LANG_RESTORE])dnl
202 AC_DEFUN(GROFF_LIMITS_H,
203 [AC_LANG_SAVE
204 AC_LANG_CPLUSPLUS
205 AC_MSG_CHECKING([C++ <limits.h>])
206 AC_TRY_COMPILE([#include <limits.h>],
207 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
208 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),
209 AC_MSG_RESULT(no))
210 AC_LANG_RESTORE])dnl
213 AC_DEFUN(GROFF_TIME_T,
214 [AC_LANG_SAVE
215 AC_LANG_CPLUSPLUS
216 AC_MSG_CHECKING([for declaration of time_t])
217 AC_TRY_COMPILE([#include <time.h>],
218 [time_t t = time(0); struct tm *p = localtime(&t);],
219 AC_MSG_RESULT(yes),
220 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
221 AC_LANG_RESTORE])dnl
224 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
225 [AC_MSG_CHECKING([struct exception])
226 AC_TRY_COMPILE([#include <math.h>],
227 [struct exception e;],
228 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
229 AC_MSG_RESULT(no))])dnl
232 AC_DEFUN(GROFF_ARRAY_DELETE,
233 [AC_LANG_SAVE
234 AC_LANG_CPLUSPLUS
235 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
236 AC_TRY_COMPILE(,
237 changequote(,)dnl
238 char *p = new char[5]; delete [] p;changequote([,]),
239 AC_MSG_RESULT(yes),
240 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
241 AC_LANG_RESTORE])dnl
245 AC_DEFUN(GROFF_TRADITIONAL_CPP,
246 [AC_LANG_SAVE
247 AC_LANG_CPLUSPLUS
248 AC_MSG_CHECKING([traditional preprocessor])
249 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
250 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
251 AC_MSG_RESULT(no))
252 AC_LANG_RESTORE])dnl
255 AC_DEFUN(GROFF_WCOREFLAG,
256 [AC_MSG_CHECKING([w_coredump])
257 AC_TRY_RUN([#include <sys/types.h>
258 #include <sys/wait.h>
259 main()
261 #ifdef WCOREFLAG
262   exit(1);
263 #else
264   int i = 0;
265   ((union wait *)&i)->w_coredump = 1;
266   exit(i != 0200);
267 #endif
269 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),
270 AC_MSG_RESULT(no),
271 AC_MSG_RESULT(no))])dnl
274 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
275 [AC_MSG_CHECKING([default value for grops -b option])
276 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
277 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
278 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
281 AC_DEFUN(GROFF_PAGE,
282 [AC_MSG_CHECKING([default paper size])
283 if test -z "$PAGE"; then
284         descfile=
285         if test -r $prefix/share/groff/font/devps/DESC; then
286                 descfile=$prefix/share/groff/font/devps/DESC
287         elif test -r $prefix/lib/groff/font/devps/DESC; then
288                 descfile=$prefix/lib/groff/font/devps/DESC
289         fi
290         if test -n "$descfile" \
291           && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
292                 PAGE=A4
293         else
294                 PAGE=letter
295         fi
297 if test -z "$PAGE"; then
298         dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
299             /etc/resolv.conf 2>/dev/null`
300         if test -z "$dom"; then
301                 dom=`(domainname) 2>/dev/null | tr -d '+'`
302                 if test -z "$dom"; then
303                         dom=`(hostname) 2>/dev/null | grep '\.'`
304                 fi
305         fi
306 changequote(,)dnl
307         # If the top-level domain is two letters and it's not `us' or `ca'
308         # then they probably use A4 paper.
309         case "$dom" in
310         *.[Uu][Ss]|*.[Cc][Aa]) ;;
311         *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
312         esac
313 changequote([,])dnl
315 test -n "$PAGE" || PAGE=letter
316 AC_MSG_RESULT($PAGE)
317 AC_SUBST(PAGE)])dnl
320 AC_DEFUN(GROFF_CXX_CHECK,
321 [AC_REQUIRE([AC_C_CROSS])
322 AC_REQUIRE([AC_PROG_CXX])
323 AC_LANG_SAVE
324 AC_LANG_CPLUSPLUS
325 if test "$cross_compiling" = no; then
326         AC_MSG_CHECKING([that C++ compiler can compile simple program])
328 AC_TRY_RUN([int main() { return 0; }],
329 AC_MSG_RESULT(yes),
330 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
332 if test "$cross_compiling" = no; then
333         AC_MSG_CHECKING([that C++ static constructors and destructors are called])
335 AC_TRY_RUN([
336 extern "C" {
337   void _exit(int);
339 int i;
340 struct A {
341   char dummy;
342   A() { i = 1; }
343   ~A() { if (i == 1) _exit(0); }
345 A a;
346 int main() { return 1; }
348 AC_MSG_RESULT(yes),
349 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
351 AC_MSG_CHECKING([that header files support C++])
352 AC_TRY_LINK([#include <stdio.h>],
353 [fopen(0, 0);],
354 AC_MSG_RESULT(yes),
355 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++)]))
356 AC_LANG_RESTORE
357 ])dnl
360 AC_DEFUN(GROFF_TMAC,
361 [AC_MSG_CHECKING([for prefix of system macro packages])
362 sys_tmac_prefix=
363 sys_tmac_file_prefix=
364 for d in /usr/share/lib/tmac /usr/lib/tmac; do
365         for t in "" tmac.; do
366                 for m in an s m; do
367                         f=$d/$t$m
368                         if test -z "$sys_tmac_prefix" \
369                           && test -f $f \
370                           && grep '^\.if' $f >/dev/null 2>&1; then
371                                 sys_tmac_prefix=$d/$t
372                                 sys_tmac_file_prefix=$t
373                         fi
374                 done
375         done
376 done
377 AC_MSG_RESULT($sys_tmac_prefix)
378 AC_SUBST(sys_tmac_prefix)
379 tmac_wrap=
380 AC_MSG_CHECKING([which system macro packages should be made available])
381 if test "x$sys_tmac_file_prefix" = "xtmac."; then
382         for f in $sys_tmac_prefix*; do
383                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
384                 case "$suff" in
385                 e) ;;
386                 *)
387                         grep "Copyright.*Free Software Foundation" $f >/dev/null \
388                           || tmac_wrap="$tmac_wrap $suff" ;;
389                 esac 
390         done
391 elif test -n "$sys_tmac_prefix"; then
392         files=`echo $sys_tmac_prefix*`
393         grep "\\.so" $files >conftest.sol
394         for f in $files; do
395                 case "$f" in
396                 ${sys_tmac_prefix}e) ;;
397                 *.me) ;;
398                 */ms.*) ;;
399                 *)
400                         b=`basename $f`
401                         if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
402                           || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
403                                 :
404                         else
405                                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
406                                 case "$suff" in
407                                 tmac.*) ;;
408                                 *) tmac_wrap="$tmac_wrap $suff" ;;
409                                 esac
410                         fi
411                 esac
412         done
413         rm -f conftest.sol
415 AC_MSG_RESULT([$tmac_wrap])
416 AC_SUBST(tmac_wrap)
417 ])dnl
420 AC_DEFUN(GROFF_G,
421 [AC_MSG_CHECKING([for existing troff installation])
422 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
423         AC_MSG_RESULT(yes)
424         g=g
425 else
426         AC_MSG_RESULT(no)
427         g=
429 AC_SUBST(g)
430 ])dnl
433 dnl We need the path to install-sh to be absolute.
435 AC_DEFUN(GROFF_INSTALL_SH,
436 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
437 ac_dir=`cd $ac_aux_dir; pwd`
438 ac_install_sh="$ac_dir/install-sh -c"
439 ])dnl
442 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
443 dnl does not have -lm.
445 AC_DEFUN(GROFF_LIBM,
446 [AC_CHECK_LIB(m,sin,LIBM=-lm)
447 AC_SUBST(LIBM)
448 ])dnl
451 dnl We need top_srcdir to be absolute.
453 AC_DEFUN(GROFF_SRCDIR,
454 [ac_srcdir_defaulted=no
455 srcdir=`cd $srcdir; pwd`
456 ])dnl
459 dnl This simplifies Makefile rules.
461 AC_DEFUN(GROFF_BUILDDIR,
462 [top_builddir=`pwd`
463 AC_SUBST(top_builddir)