* contrib/mom/Makefile.sub: Fix last change to make it really work.
[s-roff.git] / aclocal.m4
blobaf9543e230509505f50680752b278a94ff1f3436
1 dnl Autoconf macros for groff.
2 dnl Copyright (C) 1989-1995, 2001, 2002 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 The following programs are needed for grohtml.
62 dnl
63 AC_DEFUN(GROFF_HTML_PROGRAMS,
64 [make_html=html
65 make_install_html=install_html
66 missing=
67 AC_CHECK_PROG(pnmcut, pnmcut, found, missing)
68 if test $pnmcut = missing; then
69         missing="$missing pnmcut"
71 AC_CHECK_PROG(pnmcrop, pnmcrop, found, missing)
72 if test $pnmcrop = missing; then
73         missing="$missing pnmcrop"
75 AC_CHECK_PROG(pnmtopng, pnmtopng, found, missing)
76 if test $pnmtopng = missing; then
77         missing="$missing pnmtopng"
79 AC_CHECK_PROG(gs, gs gsos2, found, missing)
80 if test $gs = missing; then
81         missing="$missing gs"
83 AC_CHECK_PROG(psselect, psselect, found, missing)
84 if test $psselect = missing; then
85         missing="$missing psselect"
87 AC_CHECK_PROG(pnmtops, pnmtops, found, missing)
88 if test $pnmtops = missing; then
89         missing="$missing pnmtops"
91 if test -n "$missing"; then
92         cnt=0
93         for i in $missing
94         do
95                 cnt=`expr $cnt + 1`
96                 eval "prog$cnt=$i"
97         done
98         plural="s"
99         case $cnt in
100         1)
101                 plural=""
102                 progs="\`$prog1'" ;;
103         2)
104                 progs="\`$prog1' and \`$prog2'" ;;
105         3)
106                 progs="\`$prog1', \`$prog2', and \`$prog3'" ;;
107         4)
108                 progs="\`$prog1', \`$prog2', \`$prog3', and \`$prog4'" ;;
109         5)
110                 progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', and \`$prog5'" ;;
111         6)
112                 progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', \`$prog5', and \`$prog6'" ;;
113         esac
114         make_html=
115         make_install_html=
116         AC_MSG_WARN([
118   The program$plural
119     $progs
120   can't be found in the path, thus the HTML backend of groff (grohtml)
121   won't work properly.  Consequently, no documentation in HTML format
122   is built and installed.
125 AC_SUBST(make_html)
126 AC_SUBST(make_install_html)])dnl
128 dnl check to see whether pnmtops can handle the -nosetpage option
130 AC_DEFUN(GROFF_PNMTOPS_NOSETPAGE,
131 [AC_MSG_CHECKING([whether pnmtops can handle the -nosetpage option])
132 if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 ; then
133         AC_MSG_RESULT(yes)
134         pnmtops_nosetpage="pnmtops -nosetpage"
135 else
136         AC_MSG_RESULT(no)
137         pnmtops_nosetpage="pnmtops"
139 AC_SUBST(pnmtops_nosetpage)
140 ])dnl
143 dnl GROFF_CSH_HACK(if hack present, if not present)
145 AC_DEFUN(GROFF_CSH_HACK,
146 [AC_MSG_CHECKING([for csh hash hack])
147 cat <<EOF >conftest.sh
148 #!/bin/sh
149 true || exit 0
150 export PATH || exit 0
151 exit 1
153 chmod +x conftest.sh
154 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
155         AC_MSG_RESULT(yes); $1
156 else
157         AC_MSG_RESULT(no); $2
159 rm -f conftest.sh])dnl
162 dnl From udodo!hans@relay.NL.net (Hans Zuidam)
164 AC_DEFUN(GROFF_ISC_SYSV3,
165 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
166 changequote(,)dnl
167 if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
168 changequote([,])dnl
169 then
170         AC_MSG_RESULT(yes)
171         AC_DEFINE(_SYSV3, 1,
172                   [Define if you have ISC 3.x or 4.x.])
173 else
174         AC_MSG_RESULT(no)
175 fi])dnl
178 AC_DEFUN(GROFF_POSIX,
179 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
180 AC_LANG_PUSH(C++)
181 AC_TRY_COMPILE([#include <stdio.h>
182 extern "C" { void fileno(int); }],,
183 AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE, 1,
184                              [Define if -D_POSIX_SOURCE is necessary.]),
185 AC_MSG_RESULT(no))
186 AC_LANG_POP(C++)])dnl
189 dnl srand() of SunOS 4.1.3 has return type int instead of void
191 AC_DEFUN(GROFF_SRAND,
192 [AC_LANG_PUSH(C++)
193 AC_MSG_CHECKING([for return type of srand])
194 AC_TRY_COMPILE([#include <stdlib.h>
195 extern "C" { void srand(unsigned int); }],,
196 AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID, 1,
197                               [Define if srand() returns void not int.]),
198 AC_MSG_RESULT(int))
199 AC_LANG_POP(C++)])dnl
202 AC_DEFUN(GROFF_SYS_NERR,
203 [AC_LANG_PUSH(C++)
204 AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>])
205 AC_TRY_COMPILE([#include <errno.h>
206 #include <stdio.h>],
207 [int k; k = sys_nerr;],
208 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR, 1,
209                              [Define if you have sysnerr in <errno.h> or
210                               <stdio.h>.]),
211 AC_MSG_RESULT(no))
212 AC_LANG_POP(C++)])dnl
215 AC_DEFUN(GROFF_SYS_ERRLIST,
216 [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>])
217 AC_TRY_COMPILE([#include <errno.h>
218 #include <stdio.h>
219 #include <stdlib.h>],
220 [int k; k = (int)sys_errlist[0];],
221 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST, 1,
222                              [Define if you have sys_errlist in <errno.h>,
223                               <stdio.h>, or <stdlib.h>.]),
224 AC_MSG_RESULT(no))])dnl
227 AC_DEFUN(GROFF_OSFCN_H,
228 [AC_LANG_PUSH(C++)
229 AC_MSG_CHECKING([C++ <osfcn.h>])
230 AC_TRY_COMPILE([#include <osfcn.h>],
231 [read(0, 0, 0); open(0, 0);],
232 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H, 1,
233                              [Define if you have a C++ <osfcn.h>.]),
234 AC_MSG_RESULT(no))
235 AC_LANG_POP(C++)])dnl
238 AC_DEFUN(GROFF_LIMITS_H,
239 [AC_LANG_PUSH(C++)
240 AC_MSG_CHECKING([C++ <limits.h>])
241 AC_TRY_COMPILE([#include <limits.h>],
242 [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
243 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H, 1,
244                              [Define if you have a C++ <limits.h>.]),
245 AC_MSG_RESULT(no))
246 AC_LANG_POP(C++)])dnl
249 AC_DEFUN(GROFF_STDINT_H,
250 [AC_LANG_PUSH(C++)
251 AC_MSG_CHECKING([C++ <stdint.h>])
252 AC_TRY_COMPILE([#include <stdint.h>],
253 [uint32_t x; int32_t y;],
254 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_STDINT_H, 1,
255                              [Define if you have a C++ <stdint.h>.]),
256 AC_MSG_RESULT(no))
257 AC_LANG_POP(C++)])dnl
260 AC_DEFUN(GROFF_TIME_T,
261 [AC_LANG_PUSH(C++)
262 AC_MSG_CHECKING([for declaration of time_t])
263 AC_TRY_COMPILE([#include <time.h>],
264 [time_t t = time(0); struct tm *p = localtime(&t);],
265 AC_MSG_RESULT(yes),
266 AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T, 1,
267                             [Define if localtime() takes a long * not a
268                              time_t *.]))
269 AC_LANG_POP(C++)])dnl
272 AC_DEFUN(GROFF_STRUCT_EXCEPTION,
273 [AC_MSG_CHECKING([struct exception])
274 AC_TRY_COMPILE([#include <math.h>],
275 [struct exception e;],
276 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1,
277                              [Define if <math.h> defines struct exception.]),
278 AC_MSG_RESULT(no))])dnl
281 AC_DEFUN(GROFF_ARRAY_DELETE,
282 [AC_LANG_PUSH(C++)
283 AC_MSG_CHECKING([whether ANSI array delete syntax supported])
284 AC_TRY_COMPILE(, [char *p = new char[5]; delete [] p;],
285 AC_MSG_RESULT(yes),
286 AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE, 1,
287                             [Define if your C++ doesn't understand
288                              `delete []'.]))
289 AC_LANG_POP(C++)])dnl
293 AC_DEFUN(GROFF_TRADITIONAL_CPP,
294 [AC_LANG_PUSH(C++)
295 AC_MSG_CHECKING([traditional preprocessor])
296 AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
297 AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP, 1,
298                              [Define if your C++ compiler uses a
299                               traditional (Reiser) preprocessor.]),
300 AC_MSG_RESULT(no))
301 AC_LANG_POP(C++)])dnl
304 AC_DEFUN(GROFF_WCOREFLAG,
305 [AC_MSG_CHECKING([w_coredump])
306 AC_TRY_RUN([#include <sys/types.h>
307 #include <sys/wait.h>
308 main()
310 #ifdef WCOREFLAG
311   exit(1);
312 #else
313   int i = 0;
314   ((union wait *)&i)->w_coredump = 1;
315   exit(i != 0200);
316 #endif
318 AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG, 0200,
319                              [Define if the 0200 bit of the status returned
320                               by wait() indicates whether a core image was
321                               produced for a process that was terminated by
322                               a signal.]),
323 AC_MSG_RESULT(no),
324 AC_MSG_RESULT(no))])dnl
327 AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
328 [AC_MSG_CHECKING([default value for grops -b option])
329 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
330 AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
331 AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
334 AC_DEFUN(GROFF_PAGE,
335 [AC_MSG_CHECKING([default paper size])
336 groff_prefix=$prefix
337 test "x$prefix" = xNONE && groff_prefix=$ac_default_prefix
338 if test -z "$PAGE"; then
339         descfile=
340         if test -r $groff_prefix/share/groff/font/devps/DESC; then
341                 descfile=$groff_prefix/share/groff/font/devps/DESC
342         elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
343                 descfile=$groff_prefix/lib/groff/font/devps/DESC
344         else
345                 for f in $groff_prefix/share/groff/*/font/devps/DESC; do
346                         if test -r $f; then
347                                 descfile=$f
348                                 break
349                         fi
350                 done
351         fi
352         if test -n "$descfile"; then
353 changequote(,)dnl
354                 if grep '^paperlength[   ]\+841890' $descfile
355                   >/dev/null 2>&1; then
356                         PAGE=A4
357                 elif grep '^papersize[   ]\+[aA]4' $descfile \
358                   >/dev/null 2>&1; then
359                         PAGE=A4
360                 fi
361 changequote([,])dnl
362         fi
364 if test -z "$PAGE"; then
365         dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
366             /etc/resolv.conf 2>/dev/null`
367         if test -z "$dom"; then
368                 dom=`(domainname) 2>/dev/null | tr -d '+'`
369                 if test -z "$dom" \
370                   || test "$dom" = '(none)'; then
371                         dom=`(hostname) 2>/dev/null | grep '\.'`
372                 fi
373         fi
374 changequote(,)dnl
375         # If the top-level domain is two letters and it's not `us' or `ca'
376         # then they probably use A4 paper.
377         case "$dom" in
378         *.[Uu][Ss]|*.[Cc][Aa]) ;;
379         *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
380         esac
381 changequote([,])dnl
383 test -n "$PAGE" || PAGE=letter
384 if test "x$PAGE" = "xA4"; then
385         AC_DEFINE(PAGEA4, 1,
386                   [Define if the printer's page size is A4.])
388 AC_MSG_RESULT($PAGE)
389 AC_SUBST(PAGE)])dnl
392 AC_DEFUN(GROFF_CXX_CHECK,
393 [AC_REQUIRE([AC_PROG_CXX])
394 AC_LANG_PUSH(C++)
395 if test "$cross_compiling" = no; then
396         AC_MSG_CHECKING([that C++ compiler can compile simple program])
398 AC_TRY_RUN([int main() { return 0; }],
399 AC_MSG_RESULT(yes),
400 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
402 if test "$cross_compiling" = no; then
403         AC_MSG_CHECKING([that C++ static constructors and destructors are called])
405 AC_TRY_RUN([
406 extern "C" {
407   void _exit(int);
409 int i;
410 struct A {
411   char dummy;
412   A() { i = 1; }
413   ~A() { if (i == 1) _exit(0); }
415 A a;
416 int main() { return 1; }
418 AC_MSG_RESULT(yes),
419 AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]),
421 AC_MSG_CHECKING([that header files support C++])
422 AC_TRY_LINK([#include <stdio.h>],
423 [fopen(0, 0);],
424 AC_MSG_RESULT(yes),
425 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++)]))
426 AC_LANG_POP(C++)])dnl
429 AC_DEFUN(GROFF_TMAC,
430 [AC_MSG_CHECKING([for prefix of system macro packages])
431 sys_tmac_prefix=
432 sys_tmac_file_prefix=
433 for d in /usr/share/lib/tmac /usr/lib/tmac; do
434         for t in "" tmac.; do
435                 for m in an s m; do
436                         f=$d/$t$m
437                         if test -z "$sys_tmac_prefix" \
438                           && test -f $f \
439                           && grep '^\.if' $f >/dev/null 2>&1; then
440                                 sys_tmac_prefix=$d/$t
441                                 sys_tmac_file_prefix=$t
442                         fi
443                 done
444         done
445 done
446 AC_MSG_RESULT($sys_tmac_prefix)
447 AC_SUBST(sys_tmac_prefix)
448 tmac_wrap=
449 AC_MSG_CHECKING([which system macro packages should be made available])
450 if test "x$sys_tmac_file_prefix" = "xtmac."; then
451         for f in $sys_tmac_prefix*; do
452                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
453                 case "$suff" in
454                 e) ;;
455                 *)
456                         grep "Copyright.*Free Software Foundation" $f >/dev/null \
457                           || tmac_wrap="$tmac_wrap $suff" ;;
458                 esac 
459         done
460 elif test -n "$sys_tmac_prefix"; then
461         files=`echo $sys_tmac_prefix*`
462         grep "\\.so" $files >conftest.sol
463         for f in $files; do
464                 case "$f" in
465                 ${sys_tmac_prefix}e) ;;
466                 *.me) ;;
467                 */ms.*) ;;
468                 *)
469                         b=`basename $f`
470                         if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
471                           || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
472                                 :
473                         else
474                                 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
475                                 case "$suff" in
476                                 tmac.*) ;;
477                                 *) tmac_wrap="$tmac_wrap $suff" ;;
478                                 esac
479                         fi
480                 esac
481         done
482         rm -f conftest.sol
484 AC_MSG_RESULT([$tmac_wrap])
485 AC_SUBST(tmac_wrap)])dnl
488 AC_DEFUN(GROFF_G,
489 [AC_MSG_CHECKING([for existing troff installation])
490 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
491         AC_MSG_RESULT(yes)
492         g=g
493 else
494         AC_MSG_RESULT(no)
495         g=
497 AC_SUBST(g)])dnl
500 dnl We need the path to install-sh to be absolute.
502 AC_DEFUN(GROFF_INSTALL_SH,
503 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
504 ac_dir=`cd $ac_aux_dir; pwd`
505 ac_install_sh="$ac_dir/install-sh -c"])dnl
508 dnl Test whether install-info is available.
510 AC_DEFUN(GROFF_INSTALL_INFO,
511 [AC_CHECK_PROGS(INSTALL_INFO, install-info, :)])dnl
514 dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5,
515 dnl does not have -lm.
517 AC_DEFUN(GROFF_LIBM,
518 [AC_CHECK_LIB(m,sin,LIBM=-lm)
519 AC_SUBST(LIBM)])dnl
522 dnl We need top_srcdir to be absolute.
524 AC_DEFUN(GROFF_SRCDIR,
525 [ac_srcdir_defaulted=no
526 srcdir=`cd $srcdir; pwd`])dnl
529 dnl This simplifies Makefile rules.
531 AC_DEFUN(GROFF_BUILDDIR,
532 [groff_top_builddir=`pwd`
533 AC_SUBST(groff_top_builddir)])dnl
536 dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port
538 AC_DEFUN(GROFF_EBCDIC,
539 [AC_MSG_CHECKING([whether character set is EBCDIC])
540 AC_TRY_COMPILE(,
541 [/* Treat any failure as ASCII for compatibility with existing art.
542     Use compile-time rather than run-time tests for cross-compiler
543     tolerance. */
544 #if '0' != 240
545 make an error "Character set is not EBCDIC"
546 #endif],
547 groff_cv_ebcdic="yes"
548  TTYDEVDIRS="font/devcp1047"
549  AC_MSG_RESULT(yes)
550  AC_DEFINE(IS_EBCDIC_HOST, 1,
551            [Define if the host's encoding is EBCDIC.]),
552 groff_cv_ebcdic="no"
553  TTYDEVDIRS="font/devascii font/devlatin1"
554  OTHERDEVDIRS="font/devlj4 font/devlbp"
555  AC_MSG_RESULT(no))
556 AC_SUBST(TTYDEVDIRS)
557 AC_SUBST(OTHERDEVDIRS)])dnl
560 dnl Check for OS/390 Unix.  We test for EBCDIC also -- the Linux port (with
561 dnl gcc) to OS/390 uses ASCII internally.
563 AC_DEFUN(GROFF_OS390,
564 [if test "$groff_cv_ebcdic" = "yes"; then
565         AC_MSG_CHECKING([for OS/390 Unix])
566         case `uname` in
567         OS/390)
568                 CFLAGS="$CFLAGS -D_ALL_SOURCE"
569                 AC_MSG_RESULT(yes) ;;
570         *)
571                 AC_MSG_RESULT(no) ;;
572         esac
573 fi])dnl
576 dnl Check whether we need a declaration for a function.
578 dnl Stolen from GNU bfd.
580 AC_DEFUN(GROFF_NEED_DECLARATION,
581 [AC_MSG_CHECKING([whether $1 must be declared])
582 AC_LANG_PUSH(C++)
583 AC_CACHE_VAL(groff_cv_decl_needed_$1,
584 [AC_TRY_COMPILE([
585 #include <stdio.h>
586 #ifdef HAVE_STRING_H
587 #include <string.h>
588 #endif
589 #ifdef HAVE_STRINGS_H
590 #include <strings.h>
591 #endif
592 #ifdef HAVE_STDLIB_H
593 #include <stdlib.h>
594 #endif
595 #ifdef HAVE_SYS_TIME_H
596 #include <sys/time.h>
597 #endif
598 #ifdef HAVE_UNISTD_H
599 #include <unistd.h>
600 #endif
601 #ifdef HAVE_MATH_H
602 #include <math.h>
603 #endif],
604 [#ifndef $1
605   char *p = (char *) $1;
606 #endif],
607 groff_cv_decl_needed_$1=no,
608 groff_cv_decl_needed_$1=yes)])
609 AC_MSG_RESULT($groff_cv_decl_needed_$1)
610 if test $groff_cv_decl_needed_$1 = yes; then
611         AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
612                   [Define if your C++ doesn't declare ]$1[().])
614 AC_LANG_POP(C++)])dnl
617 dnl If mkstemp() isn't available, use our own mkstemp.cpp file.
619 AC_DEFUN(GROFF_MKSTEMP,
620 [AC_MSG_CHECKING([for mkstemp])
621 AC_LANG_PUSH(C++)
622 AC_LIBSOURCE(mkstemp.cpp)
623 AC_TRY_LINK([#include <stdlib.h>
624 #include <unistd.h>
625 int (*f) (char *);],
626 [f = mkstemp;],
627 AC_MSG_RESULT(yes);AC_DEFINE(HAVE_MKSTEMP, 1,
628                              [Define if you have mkstemp().]),
629 AC_MSG_RESULT(no);_AC_LIBOBJ(mkstemp))
630 AC_LANG_POP(C++)])dnl
633 dnl Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
634 dnl and declares uintmax_t.  Taken from the fileutils package.
636 AC_DEFUN(GROFF_INTTYPES_H,
637 [AC_LANG_PUSH(C++)
638 AC_MSG_CHECKING([for inttypes.h])
639 AC_TRY_COMPILE([#include <sys/types.h>
640 #include <inttypes.h>],
641 [uintmax_t i = (uintmax_t)-1;],
642 groff_cv_header_inttypes_h=yes,
643 groff_cv_header_inttypes_h=no)
644 AC_MSG_RESULT($groff_cv_header_inttypes_h)
645 AC_LANG_POP(C++)])dnl
648 dnl Test for working `unsigned long long'.  Taken from the fileutils package.
650 AC_DEFUN(GROFF_UNSIGNED_LONG_LONG,
651 [AC_LANG_PUSH(C++)
652 AC_MSG_CHECKING([for unsigned long long])
653 AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
654 [unsigned long long ullmax = (unsigned long long)-1;
655 return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
656 groff_cv_type_unsigned_long_long=yes,
657 groff_cv_type_unsigned_long_long=no)
658 AC_MSG_RESULT($groff_cv_type_unsigned_long_long)
659 AC_LANG_POP(C++)])dnl
662 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
663 dnl if <inttypes.h> does not exist.  Taken from the fileutils package.
665 AC_DEFUN(GROFF_UINTMAX_T,
666 [AC_REQUIRE([GROFF_INTTYPES_H])
667 if test $groff_cv_header_inttypes_h = no; then
668         AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
669         test $groff_cv_type_unsigned_long_long = yes \
670           && ac_type='unsigned long long' \
671           || ac_type='unsigned long'
672         AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
673                            [Define uintmax_t to `unsigned long' or
674                             `unsigned long long' if <inttypes.h> does not
675                             exist.])
676 fi])dnl