* src/devices/grops/ps.cc (ps_output::put_float): Revert change
[s-roff.git] / aclocal.m4
blob9d7d33cfe9bd70266a4e5b7c7ad812001547da8c
1 # Autoconf macros for groff.
2 # Copyright (C) 1989-1995, 2001, 2002, 2003 Free Software Foundation, Inc.
3
4 # This file is part of groff.
5
6 # groff is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free
8 # Software Foundation; either version 2, or (at your option) any later
9 # version.
10
11 # groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 # for more details.
15
16 # You should have received a copy of the GNU General Public License along
17 # with groff; see the file COPYING.  If not, write to the Free Software
18 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 AC_DEFUN([GROFF_PRINT],
21   [if test -z "$PSPRINT"; then
22      AC_CHECK_PROGS([LPR], [lpr])
23      AC_CHECK_PROGS([LP], [lp])
24      if test -n "$LPR" && test -n "$LP"; then
25        # HP-UX provides an lpr command that emulates lpr using lp,
26        # but it doesn't have lpq; in this case we want to use lp
27        # rather than lpr.
28        AC_CHECK_PROGS([LPQ], [lpq])
29        test -n "$LPQ" || LPR=
30      fi
31      if test -n "$LPR"; then
32        PSPRINT="$LPR"
33      elif test -n "$LP"; then
34        PSPRINT="$LP"
35      fi
36    fi
37    AC_SUBST([PSPRINT])
38    AC_MSG_CHECKING([for command to use for printing PostScript files])
39    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
49    fi
50    AC_SUBST([DVIPRINT])
51    AC_MSG_RESULT([$DVIPRINT])])
53 # Bison generated parsers have problems with C++ compilers other than g++.
54 # So byacc is preferred over bison.
56 AC_DEFUN([GROFF_PROG_YACC],
57   [AC_CHECK_PROGS([YACC], [byacc 'bison -y'], [yacc])])
59 # The following programs are needed for grohtml.
61 AC_DEFUN([GROFF_HTML_PROGRAMS],
62   [make_html=html
63    make_install_html=install_html
65    missing=
66    AC_FOREACH([groff_prog],
67      [pnmcut pnmcrop pnmtopng psselect pnmtops gs],
68      [AC_CHECK_PROG(groff_prog, groff_prog, [found], [missing])
69       if test $[]groff_prog = missing; then
70         missing="$missing groff_prog"
71       fi;])
73    if test -n "$missing"; then
74      cnt=0
75      for i in $missing
76      do
77        cnt=`expr $cnt + 1`
78        eval "prog$cnt=$i"
79      done
80      plural="s"
81      case $cnt in
82      1)
83        plural=""
84        progs="\`$prog1'" ;;
85      2)
86        progs="\`$prog1' and \`$prog2'" ;;
87      3)
88        progs="\`$prog1', \`$prog2', and \`$prog3'" ;;
89      4)
90        progs="\`$prog1', \`$prog2', \`$prog3', and \`$prog4'" ;;
91      5)
92        progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', and \`$prog5'" ;;
93      6)
94        progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', \`$prog5', and \`$prog6'" ;;
95      esac
97      make_html=
98      make_install_html=
100      AC_MSG_WARN([
102   The program$plural
103     $progs
104   can't be found in the path, thus the HTML backend of groff (grohtml)
105   won't work properly.  Consequently, no documentation in HTML format
106   is built and installed.
107      ])
108    fi
110    AC_SUBST([make_html])
111    AC_SUBST([make_install_html])])
113 # Check whether pnmtops can handle the -nosetpage option.
115 AC_DEFUN([GROFF_PNMTOPS_NOSETPAGE],
116   [AC_MSG_CHECKING([whether pnmtops can handle the -nosetpage option])
117    if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 ; then
118      AC_MSG_RESULT([yes])
119      pnmtops_nosetpage="pnmtops -nosetpage"
120    else
121      AC_MSG_RESULT([no])
122      pnmtops_nosetpage="pnmtops"
123    fi
124    AC_SUBST([pnmtops_nosetpage])])
126 # GROFF_CSH_HACK(if hack present, if not present)
128 AC_DEFUN([GROFF_CSH_HACK],
129   [AC_MSG_CHECKING([for csh hash hack])
131 cat <<EOF >conftest.sh
132 #!/bin/sh
133 true || exit 0
134 export PATH || exit 0
135 exit 1
138    chmod +x conftest.sh
139    if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
140      AC_MSG_RESULT([yes])
141      $1
142    else
143      AC_MSG_RESULT([no])
144      $2
145    fi
146    rm -f conftest.sh])
148 # From udodo!hans@relay.NL.net (Hans Zuidam)
150 AC_DEFUN([GROFF_ISC_SYSV3],
151   [AC_MSG_CHECKING([for ISC 3.x or 4.x])
152    if grep ['[34]\.'] /usr/options/cb.name >/dev/null 2>&1
153    then
154      AC_MSG_RESULT([yes])
155      AC_DEFINE([_SYSV3], [1], [Define if you have ISC 3.x or 4.x.])
156    else
157      AC_MSG_RESULT([no])
158    fi])
160 AC_DEFUN([GROFF_POSIX],
161   [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
162    AC_LANG_PUSH([C++])
163    AC_COMPILE_IFELSE([
164        AC_LANG_PROGRAM([[
166 #include <stdio.h>
167 extern "C" { void fileno(int); }
169        ]])
170      ],
171      [AC_MSG_RESULT([yes])
172       AC_DEFINE([_POSIX_SOURCE], [1],
173         [Define if -D_POSIX_SOURCE is necessary.])],
174      [AC_MSG_RESULT([no])])
175    AC_LANG_POP([C++])])
177 # srand() of SunOS 4.1.3 has return type int instead of void
179 AC_DEFUN([GROFF_SRAND],
180   [AC_LANG_PUSH([C++])
181    AC_MSG_CHECKING([for return type of srand])
182    AC_COMPILE_IFELSE([
183        AC_LANG_PROGRAM([[
185 #include <stdlib.h>
186 extern "C" { void srand(unsigned int); }
188        ]])
189      ],
190      [AC_MSG_RESULT([void])
191       AC_DEFINE([RET_TYPE_SRAND_IS_VOID], [1],
192         [Define if srand() returns void not int.])],
193      [AC_MSG_RESULT([int])])
194    AC_LANG_POP([C++])])
196 AC_DEFUN([GROFF_SYS_NERR],
197   [AC_LANG_PUSH([C++])
198    AC_MSG_CHECKING([for sys_nerr in <errno.h>, <stdio.h>, or <stdlib.h>])
199    AC_COMPILE_IFELSE([
200        AC_LANG_PROGRAM([[
202 #include <errno.h>
203 #include <stdio.h>
204 #include <stdlib.h>
206        ]],
207        [[
209 int k;
210 k = sys_nerr;
212        ]])
213      ],
214      [AC_MSG_RESULT([yes])
215       AC_DEFINE([HAVE_SYS_NERR], [1],
216         [Define if you have sys_nerr in <errno.h>, <stdio.h>, or <stdio.h>.])],
217      [AC_MSG_RESULT([no])])
218    AC_LANG_POP([C++])])
220 AC_DEFUN([GROFF_SYS_ERRLIST],
221   [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>])
222    AC_COMPILE_IFELSE([
223        AC_LANG_PROGRAM([[
225 #include <errno.h>
226 #include <stdio.h>
227 #include <stdlib.h>
229        ]],
230        [[
232 int k;
233 k = (int)sys_errlist[0];
235        ]])
236      ],
237      [AC_MSG_RESULT([yes])
238       AC_DEFINE([HAVE_SYS_ERRLIST], [1],
239         [Define if you have sys_errlist in <errno.h>, <stdio.h>, or <stdlib.h>.])],
240      [AC_MSG_RESULT([no])])])
242 AC_DEFUN([GROFF_OSFCN_H],
243   [AC_LANG_PUSH([C++])
244    AC_MSG_CHECKING([C++ <osfcn.h>])
245    AC_COMPILE_IFELSE([
246        AC_LANG_PROGRAM([[
248 #include <osfcn.h>
250        ]],
251        [[
253 read(0, 0, 0);
254 open(0, 0);
256        ]])
257      ],
258      [AC_MSG_RESULT([yes])
259       AC_DEFINE([HAVE_CC_OSFCN_H], [1],
260         [Define if you have a C++ <osfcn.h>.])],
261      [AC_MSG_RESULT([no])])
262    AC_LANG_POP([C++])])
264 AC_DEFUN([GROFF_LIMITS_H],
265   [AC_LANG_PUSH([C++])
266    AC_MSG_CHECKING([C++ <limits.h>])
267    AC_COMPILE_IFELSE([
268        AC_LANG_PROGRAM([[
270 #include <limits.h>
272        ]],
273        [[
275 int x = INT_MIN;
276 int y = INT_MAX;
277 int z = UCHAR_MAX;
279        ]])
280      ],
281      [AC_MSG_RESULT([yes])
282       AC_DEFINE([HAVE_CC_LIMITS_H], [1],
283         [Define if you have a C++ <limits.h>.])],
284      [AC_MSG_RESULT([no])])
285    AC_LANG_POP([C++])])
287 AC_DEFUN([GROFF_STDINT_H],
288   [AC_LANG_PUSH([C++])
289    AC_MSG_CHECKING([C++ <stdint.h>])
290    AC_COMPILE_IFELSE([
291        AC_LANG_PROGRAM([[
293 #include <stdint.h>
295        ]],
296        [[
298 uint32_t x;
299 int32_t y;
301        ]])
302      ],
303      [AC_MSG_RESULT([yes])
304       AC_DEFINE([HAVE_CC_STDINT_H], [1],
305         [Define if you have a C++ <stdint.h>.])],
306      [AC_MSG_RESULT([no])])
307    AC_LANG_POP([C++])])
309 AC_DEFUN([GROFF_TIME_T],
310   [AC_LANG_PUSH([C++])
311    AC_MSG_CHECKING([for declaration of time_t])
312    AC_COMPILE_IFELSE([
313        AC_LANG_PROGRAM([[
315 #include <time.h>
317        ]],
318        [[
320 time_t t = time(0);
321 struct tm *p = localtime(&t);
323        ]])
324      ],
325      [AC_MSG_RESULT([yes])],
326      [AC_MSG_RESULT([no])
327       AC_DEFINE([LONG_FOR_TIME_T], [1],
328         [Define if localtime() takes a long * not a time_t *.])])
329    AC_LANG_POP([C++])])
331 AC_DEFUN([GROFF_STRUCT_EXCEPTION],
332   [AC_MSG_CHECKING([struct exception])
333    AC_COMPILE_IFELSE([
334        AC_LANG_PROGRAM([[
336 #include <math.h>
338        ]],
339        [[
341 struct exception e;
343        ]])
344      ],
345      [AC_MSG_RESULT([yes])
346       AC_DEFINE([HAVE_STRUCT_EXCEPTION], [1],
347         [Define if <math.h> defines struct exception.])],
348      [AC_MSG_RESULT([no])])])
350 AC_DEFUN([GROFF_ARRAY_DELETE],
351   [AC_LANG_PUSH([C++])
352    AC_MSG_CHECKING([whether ANSI array delete syntax is supported])
353    AC_COMPILE_IFELSE([
354        AC_LANG_PROGRAM(, [[
356 char *p = new char[5];
357 delete [] p;
359        ]])
360      ],
361      [AC_MSG_RESULT([yes])],
362      [AC_MSG_RESULT([no])
363       AC_DEFINE([ARRAY_DELETE_NEEDS_SIZE], [1],
364         [Define if your C++ doesn't understand `delete []'.])])
365    AC_LANG_POP([C++])])
367 AC_DEFUN([GROFF_TRADITIONAL_CPP],
368   [AC_LANG_PUSH([C++])
369    AC_MSG_CHECKING([traditional preprocessor])
370    AC_COMPILE_IFELSE([
371        AC_LANG_PROGRAM([[
373 #define name2(a, b) a/**/b
375        ]],
376        [[
378 int name2(foo, bar);
380        ]])
381      ],
382      [AC_MSG_RESULT([yes])
383       AC_DEFINE([TRADITIONAL_CPP], [1],
384         [Define if your C++ compiler uses a traditional (Reiser) preprocessor.])],
385      [AC_MSG_RESULT([no])])
386    AC_LANG_POP([C++])])
388 AC_DEFUN([GROFF_WCOREFLAG],
389   [AC_MSG_CHECKING([w_coredump])
390    AC_RUN_IFELSE([
391        AC_LANG_PROGRAM([[
393 #include <sys/types.h>
394 #include <sys/wait.h>
396        ]],
397        [[
399 main()
401 #ifdef WCOREFLAG
402   exit(1);
403 #else
404   int i = 0;
405   ((union wait *)&i)->w_coredump = 1;
406   exit(i != 0200);
407 #endif
410        ]])
411      ],
412      [AC_MSG_RESULT([yes])
413       AC_DEFINE(WCOREFLAG, 0200,
414         [Define if the 0200 bit of the status returned by wait() indicates
415          whether a core image was produced for a process that was terminated
416          by a signal.])],
417      [AC_MSG_RESULT([no])],
418      [AC_MSG_RESULT([no])])])
420 AC_DEFUN([GROFF_BROKEN_SPOOLER_FLAGS],
421   [AC_MSG_CHECKING([default value for grops -b option])
422    test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=0
423    AC_MSG_RESULT([$BROKEN_SPOOLER_FLAGS])
424    AC_SUBST([BROKEN_SPOOLER_FLAGS])])
426 AC_DEFUN([GROFF_PAGE],
427   [AC_MSG_CHECKING([default paper size])
428    groff_prefix=$prefix
429    test "x$prefix" = xNONE && groff_prefix=$ac_default_prefix
430    if test -z "$PAGE"; then
431      descfile=
432      if test -r $groff_prefix/share/groff/font/devps/DESC; then
433        descfile=$groff_prefix/share/groff/font/devps/DESC
434      elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
435        descfile=$groff_prefix/lib/groff/font/devps/DESC
436      else
437        for f in $groff_prefix/share/groff/*/font/devps/DESC; do
438          if test -r $f; then
439            descfile=$f
440            break
441          fi
442        done
443      fi
445      if test -n "$descfile"; then
446        if grep ['^paperlength[   ]\+841890'] $descfile >/dev/null 2>&1; then
447          PAGE=A4
448        elif grep ['^papersize[   ]\+[aA]4'] $descfile >/dev/null 2>&1; then
449          PAGE=A4
450        fi
451      fi
452    fi
454    if test -z "$PAGE"; then
455      dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
456          /etc/resolv.conf 2>/dev/null`
457      if test -z "$dom"; then
458        dom=`(domainname) 2>/dev/null | tr -d '+'`
459        if test -z "$dom" \
460           || test "$dom" = '(none)'; then
461          dom=`(hostname) 2>/dev/null | grep '\.'`
462        fi
463      fi
464      # If the top-level domain is two letters and it's not `us' or `ca'
465      # then they probably use A4 paper.
466      case "$dom" in
467      [*.[Uu][Ss]|*.[Cc][Aa])]
468        ;;
469      [*.[A-Za-z][A-Za-z])]
470        PAGE=A4 ;;
471      esac
472    fi
474    test -n "$PAGE" || PAGE=letter
475    if test "x$PAGE" = "xA4"; then
476      AC_DEFINE([PAGEA4], [1],
477        [Define if the printer's page size is A4.])
478    fi
479    AC_MSG_RESULT([$PAGE])
480    AC_SUBST([PAGE])])
482 AC_DEFUN([GROFF_CXX_CHECK],
483   [AC_REQUIRE([AC_PROG_CXX])
484    AC_LANG_PUSH([C++])
485    if test "$cross_compiling" = no; then
486      AC_MSG_CHECKING([that C++ compiler can compile simple program])
487    fi
488    AC_RUN_IFELSE([
489        AC_LANG_SOURCE([[
491 int main() {
492   return 0;
495        ]])
496      ],
497      [AC_MSG_RESULT([yes])],
498      [AC_MSG_RESULT([no])
499       AC_MSG_ERROR([a working C++ compiler is required])],
500      [:])
502    if test "$cross_compiling" = no; then
503      AC_MSG_CHECKING([that C++ static constructors and destructors are called])
504    fi
505    AC_RUN_IFELSE([
506        AC_LANG_SOURCE([[
508 extern "C" {
509   void _exit(int);
512 int i;
513 struct A {
514   char dummy;
515   A() { i = 1; }
516   ~A() { if (i == 1) _exit(0); }
519 A a;
521 int main()
523   return 1;
526        ]])
527      ],
528      [AC_MSG_RESULT([yes])],
529      [AC_MSG_RESULT([no])
530       AC_MSG_ERROR([a working C++ compiler is required])],
531      [:])
533    AC_MSG_CHECKING([that header files support C++])
534    AC_LINK_IFELSE([
535        AC_LANG_PROGRAM([[
537 #include <stdio.h>
539        ]],
540        [[
542 fopen(0, 0);
544        ]])
545      ],
546      [AC_MSG_RESULT([yes])],
547      [AC_MSG_RESULT([no])
548       AC_MSG_ERROR([header files do not support C++
549                    (if you are using a version of gcc/g++ earlier than 2.5,
550                    you should install libg++)])])
551    AC_LANG_POP([C++])])
553 AC_DEFUN([GROFF_TMAC],
554   [AC_MSG_CHECKING([for prefix of system macro packages])
555    sys_tmac_prefix=
556    sys_tmac_file_prefix=
557    for d in /usr/share/lib/tmac /usr/lib/tmac; do
558      for t in "" tmac.; do
559        for m in an s m; do
560          f=$d/$t$m
561          if test -z "$sys_tmac_prefix" \
562             && test -f $f \
563             && grep '^\.if' $f >/dev/null 2>&1; then
564            sys_tmac_prefix=$d/$t
565            sys_tmac_file_prefix=$t
566          fi
567        done
568      done
569    done
570    AC_MSG_RESULT([$sys_tmac_prefix])
571    AC_SUBST([sys_tmac_prefix])
573    AC_MSG_CHECKING([which system macro packages should be made available])
574    tmac_wrap=
575    if test "x$sys_tmac_file_prefix" = "xtmac."; then
576      for f in $sys_tmac_prefix*; do
577        suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
578        case "$suff" in
579        e)
580          ;;
581        *)
582          grep "Copyright.*Free Software Foundation" $f >/dev/null \
583               || tmac_wrap="$tmac_wrap $suff" ;;
584        esac 
585      done
586    elif test -n "$sys_tmac_prefix"; then
587      files=`echo $sys_tmac_prefix*`
588      grep "\\.so" $files >conftest.sol
589      for f in $files; do
590        case "$f" in
591        ${sys_tmac_prefix}e)
592          ;;
593        *.me)
594          ;;
595        */ms.*)
596          ;;
597        *)
598          b=`basename $f`
599          if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
600             || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
601            :
602          else
603            suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
604            case "$suff" in
605            tmac.*)
606              ;;
607            *)
608              tmac_wrap="$tmac_wrap $suff" ;;
609            esac
610          fi
611        esac
612      done
613      rm -f conftest.sol
614    fi
615    AC_MSG_RESULT([$tmac_wrap])
616    AC_SUBST([tmac_wrap])])
618 AC_DEFUN([GROFF_G],
619   [AC_MSG_CHECKING([for existing troff installation])
620    if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
621      AC_MSG_RESULT([yes])
622      g=g
623    else
624      AC_MSG_RESULT([no])
625      g=
626    fi
627    AC_SUBST([g])])
629 # We need the path to install-sh to be absolute.
631 AC_DEFUN([GROFF_INSTALL_SH],
632   [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])
633    ac_dir=`cd $ac_aux_dir; pwd`
634    ac_install_sh="$ac_dir/install-sh -c"])
636 # Test whether install-info is available.
638 AC_DEFUN([GROFF_INSTALL_INFO],
639   [AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])])
641 # At least one UNIX system, Apple Macintosh Rhapsody 5.5,
642 # does not have -lm ...
644 AC_DEFUN([GROFF_LIBM],
645   [AC_CHECK_LIB([m], [sin], [LIBM=-lm])
646    AC_SUBST([LIBM])])
648 # ... while the MinGW implementation of GCC for Microsoft Win32
649 # does not seem to have -lc.
651 AC_DEFUN([GROFF_LIBC],
652   [AC_CHECK_LIB([c], [main], [LIBC=-lc])
653    AC_SUBST([LIBC])])
655 # Check for EBCDIC -- stolen from the OS390 Unix LYNX port
657 AC_DEFUN([GROFF_EBCDIC],
658   [AC_MSG_CHECKING([whether character set is EBCDIC])
659    AC_COMPILE_IFELSE([
660        AC_LANG_PROGRAM([[
662 /* Treat any failure as ASCII for compatibility with existing art.
663    Use compile-time rather than run-time tests for cross-compiler
664    tolerance. */
665 #if '0' != 240
666 make an error "Character set is not EBCDIC"
667 #endif
669        ]])
670      ],
671      [groff_cv_ebcdic="yes"
672       TTYDEVDIRS="font/devcp1047"
673       AC_MSG_RESULT([yes])
674       AC_DEFINE(IS_EBCDIC_HOST, 1,
675         [Define if the host's encoding is EBCDIC.])],
676      [groff_cv_ebcdic="no"
677      TTYDEVDIRS="font/devascii font/devlatin1"
678      OTHERDEVDIRS="font/devlj4 font/devlbp"
679      AC_MSG_RESULT([no])])
680    AC_SUBST([TTYDEVDIRS])
681    AC_SUBST([OTHERDEVDIRS])])
683 # Check for OS/390 Unix.  We test for EBCDIC also -- the Linux port (with
684 # gcc) to OS/390 uses ASCII internally.
686 AC_DEFUN([GROFF_OS390],
687   [if test "$groff_cv_ebcdic" = "yes"; then
688      AC_MSG_CHECKING([for OS/390 Unix])
689      case `uname` in
690      OS/390)
691        CFLAGS="$CFLAGS -D_ALL_SOURCE"
692        AC_MSG_RESULT([yes]) ;;
693      *)
694        AC_MSG_RESULT([no]) ;;
695      esac
696    fi])
698 # Check whether we need a declaration for a function.
700 # Stolen from GNU bfd.
702 AC_DEFUN([GROFF_NEED_DECLARATION],
703   [AC_MSG_CHECKING([whether $1 must be declared])
704    AC_LANG_PUSH([C++])
705    AC_CACHE_VAL([groff_cv_decl_needed_$1],
706      [AC_COMPILE_IFELSE([
707           AC_LANG_PROGRAM([[
709 #include <stdio.h>
710 #ifdef HAVE_STRING_H
711 #include <string.h>
712 #endif
713 #ifdef HAVE_STRINGS_H
714 #include <strings.h>
715 #endif
716 #ifdef HAVE_STDLIB_H
717 #include <stdlib.h>
718 #endif
719 #ifdef HAVE_SYS_TIME_H
720 #include <sys/time.h>
721 #endif
722 #ifdef HAVE_UNISTD_H
723 #include <unistd.h>
724 #endif
725 #ifdef HAVE_MATH_H
726 #include <math.h>
727 #endif
729           ]],
730           [[
732 #ifndef $1
733   char *p = (char *) $1;
734 #endif
736           ]])
737       ],
738       [groff_cv_decl_needed_$1=no],
739       [groff_cv_decl_needed_$1=yes])])
740    AC_MSG_RESULT([$groff_cv_decl_needed_$1])
741    if test $groff_cv_decl_needed_$1 = yes; then
742      AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), [1],
743        [Define if your C++ doesn't declare ]$1[().])
744    fi
745    AC_LANG_POP([C++])])
747 # If mkstemp() isn't available, use our own mkstemp.cpp file.
749 AC_DEFUN([GROFF_MKSTEMP],
750   [AC_MSG_CHECKING([for mkstemp])
751    AC_LANG_PUSH([C++])
752    AC_LIBSOURCE([mkstemp.cpp])
753    AC_LINK_IFELSE([
754        AC_LANG_PROGRAM([[
756 #include <stdlib.h>
757 #include <unistd.h>
758 int (*f) (char *);
760        ]],
761        [[
763 f = mkstemp;
765        ]])
766      ],
767      [AC_MSG_RESULT([yes])
768       AC_DEFINE([HAVE_MKSTEMP], [1], [Define if you have mkstemp().])],
769      [AC_MSG_RESULT([no])
770       _AC_LIBOBJ([mkstemp])])
771    AC_LANG_POP([C++])])
773 # Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
774 # and declares uintmax_t.  Taken from the fileutils package.
776 AC_DEFUN([GROFF_INTTYPES_H],
777   [AC_LANG_PUSH([C++])
778    AC_MSG_CHECKING([for inttypes.h])
779    AC_COMPILE_IFELSE([
780        AC_LANG_PROGRAM([[
782 #include <sys/types.h>
783 #include <inttypes.h>
785        ]],
786        [[
788 uintmax_t i = (uintmax_t)-1;
790        ]])
791      ],
792      [groff_cv_header_inttypes_h=yes],
793      [groff_cv_header_inttypes_h=no])
794    AC_MSG_RESULT([$groff_cv_header_inttypes_h])
795    AC_LANG_POP([C++])])
797 # Test for working `unsigned long long'.  Taken from the fileutils package.
799 AC_DEFUN([GROFF_UNSIGNED_LONG_LONG],
800   [AC_LANG_PUSH([C++])
801    AC_MSG_CHECKING([for unsigned long long])
802    AC_LINK_IFELSE([
803        AC_LANG_PROGRAM([[
805 unsigned long long ull = 1;
806 int i = 63;
807 unsigned long long ullmax = (unsigned long long)-1;
809        ]],
810        [[
812 return ull << i | ull >> i | ullmax / ull | ullmax % ull;
814        ]])
815      ],
816      [groff_cv_type_unsigned_long_long=yes],
817      [groff_cv_type_unsigned_long_long=no])
818    AC_MSG_RESULT([$groff_cv_type_unsigned_long_long])
819    AC_LANG_POP([C++])])
821 # Define uintmax_t to `unsigned long' or `unsigned long long'
822 # if <inttypes.h> does not exist.  Taken from the fileutils package.
824 AC_DEFUN([GROFF_UINTMAX_T],
825   [AC_REQUIRE([GROFF_INTTYPES_H])
826    if test $groff_cv_header_inttypes_h = no; then
827      AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
828      test $groff_cv_type_unsigned_long_long = yes \
829           && ac_type='unsigned long long' \
830           || ac_type='unsigned long'
831      AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
832        [Define uintmax_t to `unsigned long' or `unsigned long long' if
833         <inttypes.h> does not exist.])
834    fi])
836 # Identify PATH_SEPARATOR character to use in GROFF_FONT_PATH and
837 # GROFF_TMAC_PATH which is appropriate for the target system (POSIX=':',
838 # MS-DOS/Win32=';').
840 # The logic to resolve this test is already encapsulated in
841 # `${srcdir}/src/include/nonposix.h'.
843 AC_DEFUN([GROFF_TARGET_PATH_SEPARATOR],
844   [AC_MSG_CHECKING([separator character to use in groff search paths])
845    cp ${srcdir}/src/include/nonposix.h conftest.h
846    AC_COMPILE_IFELSE([
847        AC_LANG_PROGRAM([[
848         
849 #include <ctype.h>
850 #include "conftest.h"
852        ]],
853        [[
855 #if PATH_SEP_CHAR == ';'
856 make an error "Path separator is ';'"
857 #endif
859        ]])
860      ],
861      [GROFF_PATH_SEPARATOR=":"],
862      [GROFF_PATH_SEPARATOR=";"])
863    AC_MSG_RESULT([$GROFF_PATH_SEPARATOR])
864    AC_SUBST(GROFF_PATH_SEPARATOR)])