* tmac/doc-syms (doc-str-St--p1003.1-2004): New string.
[s-roff.git] / aclocal.m4
blob95b36492064e641262e405d2ebb3af3601d89a47
1 # Autoconf macros for groff.
2 # Copyright (C) 1989-1995, 2001, 2002, 2003, 2004
3 # Free Software Foundation, Inc.
5 # This file is part of groff.
7 # groff is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 2, or (at your option) any later
10 # version.
12 # groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 # for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with groff; see the file COPYING.  If not, write to the Free Software
19 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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
37    fi
38    AC_SUBST([PSPRINT])
39    AC_MSG_CHECKING([for command to use for printing PostScript files])
40    AC_MSG_RESULT([$PSPRINT])
42    # Figure out DVIPRINT from PSPRINT.
43    AC_MSG_CHECKING([for command to use for printing dvi files])
44    if test -n "$PSPRINT" && test -z "$DVIPRINT"; then
45      if test "x$PSPRINT" = "xlpr"; then
46        DVIPRINT="lpr -d"
47      else
48        DVIPRINT="$PSPRINT"
49      fi
50    fi
51    AC_SUBST([DVIPRINT])
52    AC_MSG_RESULT([$DVIPRINT])])
54 # Bison generated parsers have problems with C++ compilers other than g++.
55 # So byacc is preferred over bison.
57 AC_DEFUN([GROFF_PROG_YACC],
58   [AC_CHECK_PROGS([YACC], [byacc 'bison -y'], [yacc])])
60 # The following programs are needed for grohtml.
62 AC_DEFUN([GROFF_HTML_PROGRAMS],
63   [make_html=html
64    make_install_html=install_html
66    missing=
67    AC_FOREACH([groff_prog],
68      [pnmcut pnmcrop pnmtopng psselect pnmtops gs],
69      [AC_CHECK_PROG(groff_prog, groff_prog, [found], [missing])
70       if test $[]groff_prog = missing; then
71         missing="$missing groff_prog"
72       fi;])
74    if test -n "$missing"; then
75      cnt=0
76      for i in $missing
77      do
78        cnt=`expr $cnt + 1`
79        eval "prog$cnt=$i"
80      done
81      plural="s"
82      case $cnt in
83      1)
84        plural=""
85        progs="\`$prog1'" ;;
86      2)
87        progs="\`$prog1' and \`$prog2'" ;;
88      3)
89        progs="\`$prog1', \`$prog2', and \`$prog3'" ;;
90      4)
91        progs="\`$prog1', \`$prog2', \`$prog3', and \`$prog4'" ;;
92      5)
93        progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', and \`$prog5'" ;;
94      6)
95        progs="\`$prog1', \`$prog2', \`$prog3', \`$prog4', \`$prog5', and \`$prog6'" ;;
96      esac
98      make_html=
99      make_install_html=
101      AC_MSG_WARN([
103   The program$plural
104     $progs
105   can't be found in the path, thus the HTML backend of groff (grohtml)
106   won't work properly.  Consequently, no documentation in HTML format
107   is built and installed.
108      ])
109    fi
111    AC_SUBST([make_html])
112    AC_SUBST([make_install_html])])
114 # Check whether pnmtops can handle the -nosetpage option.
116 AC_DEFUN([GROFF_PNMTOPS_NOSETPAGE],
117   [AC_MSG_CHECKING([whether pnmtops can handle the -nosetpage option])
118    if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 ; then
119      AC_MSG_RESULT([yes])
120      pnmtops_nosetpage="pnmtops -nosetpage"
121    else
122      AC_MSG_RESULT([no])
123      pnmtops_nosetpage="pnmtops"
124    fi
125    AC_SUBST([pnmtops_nosetpage])])
127 # GROFF_CSH_HACK(if hack present, if not present)
129 AC_DEFUN([GROFF_CSH_HACK],
130   [AC_MSG_CHECKING([for csh hash hack])
132 cat <<EOF >conftest.sh
133 #!/bin/sh
134 true || exit 0
135 export PATH || exit 0
136 exit 1
139    chmod +x conftest.sh
140    if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
141      AC_MSG_RESULT([yes])
142      $1
143    else
144      AC_MSG_RESULT([no])
145      $2
146    fi
147    rm -f conftest.sh])
149 # From udodo!hans@relay.NL.net (Hans Zuidam)
151 AC_DEFUN([GROFF_ISC_SYSV3],
152   [AC_MSG_CHECKING([for ISC 3.x or 4.x])
153    if grep ['[34]\.'] /usr/options/cb.name >/dev/null 2>&1
154    then
155      AC_MSG_RESULT([yes])
156      AC_DEFINE([_SYSV3], [1], [Define if you have ISC 3.x or 4.x.])
157    else
158      AC_MSG_RESULT([no])
159    fi])
161 AC_DEFUN([GROFF_POSIX],
162   [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
163    AC_LANG_PUSH([C++])
164    AC_COMPILE_IFELSE([
165        AC_LANG_PROGRAM([[
167 #include <stdio.h>
168 extern "C" { void fileno(int); }
170        ]])
171      ],
172      [AC_MSG_RESULT([yes])
173       AC_DEFINE([_POSIX_SOURCE], [1],
174         [Define if -D_POSIX_SOURCE is necessary.])],
175      [AC_MSG_RESULT([no])])
176    AC_LANG_POP([C++])])
178 # srand() of SunOS 4.1.3 has return type int instead of void
180 AC_DEFUN([GROFF_SRAND],
181   [AC_LANG_PUSH([C++])
182    AC_MSG_CHECKING([for return type of srand])
183    AC_COMPILE_IFELSE([
184        AC_LANG_PROGRAM([[
186 #include <stdlib.h>
187 extern "C" { void srand(unsigned int); }
189        ]])
190      ],
191      [AC_MSG_RESULT([void])
192       AC_DEFINE([RET_TYPE_SRAND_IS_VOID], [1],
193         [Define if srand() returns void not int.])],
194      [AC_MSG_RESULT([int])])
195    AC_LANG_POP([C++])])
197 AC_DEFUN([GROFF_SYS_NERR],
198   [AC_LANG_PUSH([C++])
199    AC_MSG_CHECKING([for sys_nerr in <errno.h>, <stdio.h>, or <stdlib.h>])
200    AC_COMPILE_IFELSE([
201        AC_LANG_PROGRAM([[
203 #include <errno.h>
204 #include <stdio.h>
205 #include <stdlib.h>
207        ]],
208        [[
210 int k;
211 k = sys_nerr;
213        ]])
214      ],
215      [AC_MSG_RESULT([yes])
216       AC_DEFINE([HAVE_SYS_NERR], [1],
217         [Define if you have sys_nerr in <errno.h>, <stdio.h>, or <stdio.h>.])],
218      [AC_MSG_RESULT([no])])
219    AC_LANG_POP([C++])])
221 AC_DEFUN([GROFF_SYS_ERRLIST],
222   [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>])
223    AC_COMPILE_IFELSE([
224        AC_LANG_PROGRAM([[
226 #include <errno.h>
227 #include <stdio.h>
228 #include <stdlib.h>
230        ]],
231        [[
233 int k;
234 k = (int)sys_errlist[0];
236        ]])
237      ],
238      [AC_MSG_RESULT([yes])
239       AC_DEFINE([HAVE_SYS_ERRLIST], [1],
240         [Define if you have sys_errlist in <errno.h>, <stdio.h>, or <stdlib.h>.])],
241      [AC_MSG_RESULT([no])])])
243 AC_DEFUN([GROFF_OSFCN_H],
244   [AC_LANG_PUSH([C++])
245    AC_MSG_CHECKING([C++ <osfcn.h>])
246    AC_COMPILE_IFELSE([
247        AC_LANG_PROGRAM([[
249 #include <osfcn.h>
251        ]],
252        [[
254 read(0, 0, 0);
255 open(0, 0);
257        ]])
258      ],
259      [AC_MSG_RESULT([yes])
260       AC_DEFINE([HAVE_CC_OSFCN_H], [1],
261         [Define if you have a C++ <osfcn.h>.])],
262      [AC_MSG_RESULT([no])])
263    AC_LANG_POP([C++])])
265 AC_DEFUN([GROFF_LIMITS_H],
266   [AC_LANG_PUSH([C++])
267    AC_MSG_CHECKING([C++ <limits.h>])
268    AC_COMPILE_IFELSE([
269        AC_LANG_PROGRAM([[
271 #include <limits.h>
273        ]],
274        [[
276 int x = INT_MIN;
277 int y = INT_MAX;
278 int z = UCHAR_MAX;
280        ]])
281      ],
282      [AC_MSG_RESULT([yes])
283       AC_DEFINE([HAVE_CC_LIMITS_H], [1],
284         [Define if you have a C++ <limits.h>.])],
285      [AC_MSG_RESULT([no])])
286    AC_LANG_POP([C++])])
288 AC_DEFUN([GROFF_TIME_T],
289   [AC_LANG_PUSH([C++])
290    AC_MSG_CHECKING([for declaration of time_t])
291    AC_COMPILE_IFELSE([
292        AC_LANG_PROGRAM([[
294 #include <time.h>
296        ]],
297        [[
299 time_t t = time(0);
300 struct tm *p = localtime(&t);
302        ]])
303      ],
304      [AC_MSG_RESULT([yes])],
305      [AC_MSG_RESULT([no])
306       AC_DEFINE([LONG_FOR_TIME_T], [1],
307         [Define if localtime() takes a long * not a time_t *.])])
308    AC_LANG_POP([C++])])
310 AC_DEFUN([GROFF_STRUCT_EXCEPTION],
311   [AC_MSG_CHECKING([struct exception])
312    AC_COMPILE_IFELSE([
313        AC_LANG_PROGRAM([[
315 #include <math.h>
317        ]],
318        [[
320 struct exception e;
322        ]])
323      ],
324      [AC_MSG_RESULT([yes])
325       AC_DEFINE([HAVE_STRUCT_EXCEPTION], [1],
326         [Define if <math.h> defines struct exception.])],
327      [AC_MSG_RESULT([no])])])
329 AC_DEFUN([GROFF_ARRAY_DELETE],
330   [AC_LANG_PUSH([C++])
331    AC_MSG_CHECKING([whether ANSI array delete syntax is supported])
332    AC_COMPILE_IFELSE([
333        AC_LANG_PROGRAM(, [[
335 char *p = new char[5];
336 delete [] p;
338        ]])
339      ],
340      [AC_MSG_RESULT([yes])],
341      [AC_MSG_RESULT([no])
342       AC_DEFINE([ARRAY_DELETE_NEEDS_SIZE], [1],
343         [Define if your C++ doesn't understand `delete []'.])])
344    AC_LANG_POP([C++])])
346 AC_DEFUN([GROFF_TRADITIONAL_CPP],
347   [AC_LANG_PUSH([C++])
348    AC_MSG_CHECKING([traditional preprocessor])
349    AC_COMPILE_IFELSE([
350        AC_LANG_PROGRAM([[
352 #define name2(a, b) a/**/b
354        ]],
355        [[
357 int name2(foo, bar);
359        ]])
360      ],
361      [AC_MSG_RESULT([yes])
362       AC_DEFINE([TRADITIONAL_CPP], [1],
363         [Define if your C++ compiler uses a traditional (Reiser) preprocessor.])],
364      [AC_MSG_RESULT([no])])
365    AC_LANG_POP([C++])])
367 AC_DEFUN([GROFF_WCOREFLAG],
368   [AC_MSG_CHECKING([w_coredump])
369    AC_RUN_IFELSE([
370        AC_LANG_PROGRAM([[
372 #include <sys/types.h>
373 #include <sys/wait.h>
375        ]],
376        [[
378 main()
380 #ifdef WCOREFLAG
381   exit(1);
382 #else
383   int i = 0;
384   ((union wait *)&i)->w_coredump = 1;
385   exit(i != 0200);
386 #endif
389        ]])
390      ],
391      [AC_MSG_RESULT([yes])
392       AC_DEFINE(WCOREFLAG, 0200,
393         [Define if the 0200 bit of the status returned by wait() indicates
394          whether a core image was produced for a process that was terminated
395          by a signal.])],
396      [AC_MSG_RESULT([no])],
397      [AC_MSG_RESULT([no])])])
399 AC_DEFUN([GROFF_BROKEN_SPOOLER_FLAGS],
400   [AC_MSG_CHECKING([default value for grops -b option])
401    test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=0
402    AC_MSG_RESULT([$BROKEN_SPOOLER_FLAGS])
403    AC_SUBST([BROKEN_SPOOLER_FLAGS])])
405 AC_DEFUN([GROFF_PAGE],
406   [AC_MSG_CHECKING([default paper size])
407    groff_prefix=$prefix
408    test "x$prefix" = "xNONE" && groff_prefix=$ac_default_prefix
409    if test -z "$PAGE"; then
410      descfile=
411      if test -r $groff_prefix/share/groff/font/devps/DESC; then
412        descfile=$groff_prefix/share/groff/font/devps/DESC
413      elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
414        descfile=$groff_prefix/lib/groff/font/devps/DESC
415      else
416        for f in $groff_prefix/share/groff/*/font/devps/DESC; do
417          if test -r $f; then
418            descfile=$f
419            break
420          fi
421        done
422      fi
424      if test -n "$descfile"; then
425        if grep ['^paperlength[   ]\+841890'] $descfile >/dev/null 2>&1; then
426          PAGE=A4
427        elif grep ['^papersize[   ]\+[aA]4'] $descfile >/dev/null 2>&1; then
428          PAGE=A4
429        fi
430      fi
431    fi
433    if test -z "$PAGE"; then
434      dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
435          /etc/resolv.conf 2>/dev/null`
436      if test -z "$dom"; then
437        dom=`(domainname) 2>/dev/null | tr -d '+'`
438        if test -z "$dom" \
439           || test "$dom" = '(none)'; then
440          dom=`(hostname) 2>/dev/null | grep '\.'`
441        fi
442      fi
443      # If the top-level domain is two letters and it's not `us' or `ca'
444      # then they probably use A4 paper.
445      case "$dom" in
446      [*.[Uu][Ss]|*.[Cc][Aa])]
447        ;;
448      [*.[A-Za-z][A-Za-z])]
449        PAGE=A4 ;;
450      esac
451    fi
453    test -n "$PAGE" || PAGE=letter
454    if test "x$PAGE" = "xA4"; then
455      AC_DEFINE([PAGEA4], [1],
456        [Define if the printer's page size is A4.])
457    fi
458    AC_MSG_RESULT([$PAGE])
459    AC_SUBST([PAGE])])
461 AC_DEFUN([GROFF_CXX_CHECK],
462   [AC_REQUIRE([AC_PROG_CXX])
463    AC_LANG_PUSH([C++])
464    if test "$cross_compiling" = no; then
465      AC_MSG_CHECKING([that C++ compiler can compile simple program])
466    fi
467    AC_RUN_IFELSE([
468        AC_LANG_SOURCE([[
470 int main() {
471   return 0;
474        ]])
475      ],
476      [AC_MSG_RESULT([yes])],
477      [AC_MSG_RESULT([no])
478       AC_MSG_ERROR([a working C++ compiler is required])],
479      [:])
481    if test "$cross_compiling" = no; then
482      AC_MSG_CHECKING([that C++ static constructors and destructors are called])
483    fi
484    AC_RUN_IFELSE([
485        AC_LANG_SOURCE([[
487 extern "C" {
488   void _exit(int);
491 int i;
492 struct A {
493   char dummy;
494   A() { i = 1; }
495   ~A() { if (i == 1) _exit(0); }
498 A a;
500 int main()
502   return 1;
505        ]])
506      ],
507      [AC_MSG_RESULT([yes])],
508      [AC_MSG_RESULT([no])
509       AC_MSG_ERROR([a working C++ compiler is required])],
510      [:])
512    AC_MSG_CHECKING([that header files support C++])
513    AC_LINK_IFELSE([
514        AC_LANG_PROGRAM([[
516 #include <stdio.h>
518        ]],
519        [[
521 fopen(0, 0);
523        ]])
524      ],
525      [AC_MSG_RESULT([yes])],
526      [AC_MSG_RESULT([no])
527       AC_MSG_ERROR([header files do not support C++
528                    (if you are using a version of gcc/g++ earlier than 2.5,
529                    you should install libg++)])])
530    AC_LANG_POP([C++])])
532 AC_DEFUN([GROFF_TMAC],
533   [AC_MSG_CHECKING([for prefix of system macro packages])
534    sys_tmac_prefix=
535    sys_tmac_file_prefix=
536    for d in /usr/share/lib/tmac /usr/lib/tmac; do
537      for t in "" tmac.; do
538        for m in an s m; do
539          f=$d/$t$m
540          if test -z "$sys_tmac_prefix" \
541             && test -f $f \
542             && grep '^\.if' $f >/dev/null 2>&1; then
543            sys_tmac_prefix=$d/$t
544            sys_tmac_file_prefix=$t
545          fi
546        done
547      done
548    done
549    AC_MSG_RESULT([$sys_tmac_prefix])
550    AC_SUBST([sys_tmac_prefix])
552    AC_MSG_CHECKING([which system macro packages should be made available])
553    tmac_wrap=
554    if test "x$sys_tmac_file_prefix" = "xtmac."; then
555      for f in $sys_tmac_prefix*; do
556        suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
557        case "$suff" in
558        e)
559          ;;
560        *)
561          grep "Copyright.*Free Software Foundation" $f >/dev/null \
562               || tmac_wrap="$tmac_wrap $suff" ;;
563        esac
564      done
565    elif test -n "$sys_tmac_prefix"; then
566      files=`echo $sys_tmac_prefix*`
567      grep "\\.so" $files >conftest.sol
568      for f in $files; do
569        case "$f" in
570        ${sys_tmac_prefix}e)
571          ;;
572        *.me)
573          ;;
574        */ms.*)
575          ;;
576        *)
577          b=`basename $f`
578          if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
579             || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
580            :
581          else
582            suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
583            case "$suff" in
584            tmac.*)
585              ;;
586            *)
587              tmac_wrap="$tmac_wrap $suff" ;;
588            esac
589          fi
590        esac
591      done
592      rm -f conftest.sol
593    fi
594    AC_MSG_RESULT([$tmac_wrap])
595    AC_SUBST([tmac_wrap])])
597 AC_DEFUN([GROFF_G],
598   [AC_MSG_CHECKING([for existing troff installation])
599    if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
600      AC_MSG_RESULT([yes])
601      g=g
602    else
603      AC_MSG_RESULT([no])
604      g=
605    fi
606    AC_SUBST([g])])
608 # We need the path to install-sh to be absolute.
610 AC_DEFUN([GROFF_INSTALL_SH],
611   [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])
612    ac_dir=`cd $ac_aux_dir; pwd`
613    ac_install_sh="$ac_dir/install-sh -c"])
615 # Test whether install-info is available.
617 AC_DEFUN([GROFF_INSTALL_INFO],
618   [AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])])
620 # At least one UNIX system, Apple Macintosh Rhapsody 5.5,
621 # does not have -lm ...
623 AC_DEFUN([GROFF_LIBM],
624   [AC_CHECK_LIB([m], [sin], [LIBM=-lm])
625    AC_SUBST([LIBM])])
627 # ... while the MinGW implementation of GCC for Microsoft Win32
628 # does not seem to have -lc.
630 AC_DEFUN([GROFF_LIBC],
631   [AC_CHECK_LIB([c], [main], [LIBC=-lc])
632    AC_SUBST([LIBC])])
634 # Check for EBCDIC -- stolen from the OS390 Unix LYNX port
636 AC_DEFUN([GROFF_EBCDIC],
637   [AC_MSG_CHECKING([whether character set is EBCDIC])
638    AC_COMPILE_IFELSE([
639        AC_LANG_PROGRAM([[
641 /* Treat any failure as ASCII for compatibility with existing art.
642    Use compile-time rather than run-time tests for cross-compiler
643    tolerance. */
644 #if '0' != 240
645 make an error "Character set is not EBCDIC"
646 #endif
648        ]])
649      ],
650      [groff_cv_ebcdic="yes"
651       TTYDEVDIRS="font/devcp1047"
652       AC_MSG_RESULT([yes])
653       AC_DEFINE(IS_EBCDIC_HOST, 1,
654         [Define if the host's encoding is EBCDIC.])],
655      [groff_cv_ebcdic="no"
656      TTYDEVDIRS="font/devascii font/devlatin1"
657      OTHERDEVDIRS="font/devlj4 font/devlbp"
658      AC_MSG_RESULT([no])])
659    AC_SUBST([TTYDEVDIRS])
660    AC_SUBST([OTHERDEVDIRS])])
662 # Check for OS/390 Unix.  We test for EBCDIC also -- the Linux port (with
663 # gcc) to OS/390 uses ASCII internally.
665 AC_DEFUN([GROFF_OS390],
666   [if test "$groff_cv_ebcdic" = "yes"; then
667      AC_MSG_CHECKING([for OS/390 Unix])
668      case `uname` in
669      OS/390)
670        CFLAGS="$CFLAGS -D_ALL_SOURCE"
671        AC_MSG_RESULT([yes]) ;;
672      *)
673        AC_MSG_RESULT([no]) ;;
674      esac
675    fi])
677 # Check whether we need a declaration for a function.
679 # Stolen from GNU bfd.
681 AC_DEFUN([GROFF_NEED_DECLARATION],
682   [AC_MSG_CHECKING([whether $1 must be declared])
683    AC_LANG_PUSH([C++])
684    AC_CACHE_VAL([groff_cv_decl_needed_$1],
685      [AC_COMPILE_IFELSE([
686           AC_LANG_PROGRAM([[
688 #include <stdio.h>
689 #ifdef HAVE_STRING_H
690 #include <string.h>
691 #endif
692 #ifdef HAVE_STRINGS_H
693 #include <strings.h>
694 #endif
695 #ifdef HAVE_STDLIB_H
696 #include <stdlib.h>
697 #endif
698 #ifdef HAVE_SYS_TIME_H
699 #include <sys/time.h>
700 #endif
701 #ifdef HAVE_UNISTD_H
702 #include <unistd.h>
703 #endif
704 #ifdef HAVE_MATH_H
705 #include <math.h>
706 #endif
708           ]],
709           [[
711 #ifndef $1
712   char *p = (char *) $1;
713 #endif
715           ]])
716       ],
717       [groff_cv_decl_needed_$1=no],
718       [groff_cv_decl_needed_$1=yes])])
719    AC_MSG_RESULT([$groff_cv_decl_needed_$1])
720    if test $groff_cv_decl_needed_$1 = yes; then
721      AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), [1],
722        [Define if your C++ doesn't declare ]$1[().])
723    fi
724    AC_LANG_POP([C++])])
726 # If mkstemp() isn't available, use our own mkstemp.cpp file.
728 AC_DEFUN([GROFF_MKSTEMP],
729   [AC_MSG_CHECKING([for mkstemp])
730    AC_LANG_PUSH([C++])
731    AC_LIBSOURCE([mkstemp.cpp])
732    AC_LINK_IFELSE([
733        AC_LANG_PROGRAM([[
735 #include <stdlib.h>
736 #include <unistd.h>
737 int (*f) (char *);
739        ]],
740        [[
742 f = mkstemp;
744        ]])
745      ],
746      [AC_MSG_RESULT([yes])
747       AC_DEFINE([HAVE_MKSTEMP], [1], [Define if you have mkstemp().])],
748      [AC_MSG_RESULT([no])
749       _AC_LIBOBJ([mkstemp])])
750    AC_LANG_POP([C++])])
752 # Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
753 # and declares uintmax_t.  Taken from the fileutils package.
755 AC_DEFUN([GROFF_INTTYPES_H],
756   [AC_LANG_PUSH([C++])
757    AC_MSG_CHECKING([C++ <inttypes.h>])
758    AC_COMPILE_IFELSE([
759        AC_LANG_PROGRAM([[
761 #include <sys/types.h>
762 #include <inttypes.h>
764        ]],
765        [[
767 uintmax_t i = (uintmax_t)-1;
769        ]])
770      ],
771      [groff_cv_header_inttypes_h=yes
772       AC_DEFINE([HAVE_CC_INTTYPES_H], [1],
773         [Define if you have a C++ <inttypes.h>.])],
774      [groff_cv_header_inttypes_h=no])
775    AC_MSG_RESULT([$groff_cv_header_inttypes_h])
776    AC_LANG_POP([C++])])
778 # Test for working `unsigned long long'.  Taken from the fileutils package.
780 AC_DEFUN([GROFF_UNSIGNED_LONG_LONG],
781   [AC_LANG_PUSH([C++])
782    AC_MSG_CHECKING([for unsigned long long])
783    AC_LINK_IFELSE([
784        AC_LANG_PROGRAM([[
786 unsigned long long ull = 1;
787 int i = 63;
788 unsigned long long ullmax = (unsigned long long)-1;
790        ]],
791        [[
793 return ull << i | ull >> i | ullmax / ull | ullmax % ull;
795        ]])
796      ],
797      [groff_cv_type_unsigned_long_long=yes],
798      [groff_cv_type_unsigned_long_long=no])
799    AC_MSG_RESULT([$groff_cv_type_unsigned_long_long])
800    AC_LANG_POP([C++])])
802 # Define uintmax_t to `unsigned long' or `unsigned long long'
803 # if <inttypes.h> does not exist.  Taken from the fileutils package.
805 AC_DEFUN([GROFF_UINTMAX_T],
806   [AC_REQUIRE([GROFF_INTTYPES_H])
807    if test $groff_cv_header_inttypes_h = no; then
808      AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
809      test $groff_cv_type_unsigned_long_long = yes \
810           && ac_type='unsigned long long' \
811           || ac_type='unsigned long'
812      AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
813        [Define uintmax_t to `unsigned long' or `unsigned long long' if
814         <inttypes.h> does not exist.])
815    fi])
817 # Identify PATH_SEPARATOR character to use in GROFF_FONT_PATH and
818 # GROFF_TMAC_PATH which is appropriate for the target system (POSIX=':',
819 # MS-DOS/Win32=';').
821 # The logic to resolve this test is already encapsulated in
822 # `${srcdir}/src/include/nonposix.h'.
824 AC_DEFUN([GROFF_TARGET_PATH_SEPARATOR],
825   [AC_MSG_CHECKING([separator character to use in groff search paths])
826    cp ${srcdir}/src/include/nonposix.h conftest.h
827    AC_COMPILE_IFELSE([
828        AC_LANG_PROGRAM([[
829         
830 #include <ctype.h>
831 #include "conftest.h"
833        ]],
834        [[
836 #if PATH_SEP_CHAR == ';'
837 make an error "Path separator is ';'"
838 #endif
840        ]])
841      ],
842      [GROFF_PATH_SEPARATOR=":"],
843      [GROFF_PATH_SEPARATOR=";"])
844    AC_MSG_RESULT([$GROFF_PATH_SEPARATOR])
845    AC_SUBST(GROFF_PATH_SEPARATOR)])
847 # Check for X11.
849 AC_DEFUN([GROFF_X11],
850   [AC_REQUIRE([AC_PATH_XTRA])
851    groff_no_x=$no_x
852    if test -z "$groff_no_x"; then
853      OLDCFLAGS=$CFLAGS
854      OLDLDFLAGS=$LDFLAGS
855      OLDLIBS=$LIBS
856      CFLAGS="$CFLAGS $X_CFLAGS"
857      LDFLAGS="$LDFLAGS $X_LIBS"
858      LIBS="$LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
860      LIBS="$LIBS -lXaw"
861      AC_MSG_CHECKING([for Xaw library and header files])
862      AC_LINK_IFELSE([
863          AC_LANG_PROGRAM([[
865 #include <X11/Intrinsic.h>
866 #include <X11/Xaw/Simple.h>
868          ]],
869          [])
870        ],
871        [AC_MSG_RESULT([yes])],
872        [AC_MSG_RESULT([no])
873         groff_no_x="yes"])
875      LIBS="$LIBS -lXmu"
876      AC_MSG_CHECKING([for Xmu library and header files])
877      AC_LINK_IFELSE([
878          AC_LANG_PROGRAM([[
880 #include <X11/Intrinsic.h>
881 #include <X11/Xmu/Converters.h>
883          ]],
884          [])
885        ],
886        [AC_MSG_RESULT([yes])],
887        [AC_MSG_RESULT([no])
888         groff_no_x="yes"])
890      CFLAGS=$OLDCFLAGS
891      LDFLAGS=$OLDLDFLAGS
892      LIBS=$OLDLIBS
893    fi
895    if test "x$groff_no_x" = "xyes"; then
896      AC_MSG_NOTICE([gxditview and xtotroff won't be built])
897    else
898      XDEVDIRS="font/devX75 font/devX75-12 font/devX100 font/devX100-12"
899      XPROGDIRS="src/devices/xditview src/utils/xtotroff"
900      XLIBDIRS="src/libs/libxutil"
901    fi
903    AC_SUBST([XDEVDIRS])
904    AC_SUBST([XPROGDIRS])
905    AC_SUBST([XLIBDIRS])])
907 # Set up the `--with-appresdir' command line option.
909 AC_DEFUN([GROFF_APPRESDIR_OPTION],
910   [AC_ARG_WITH([appresdir],
911      dnl Don't quote AS_HELP_STRING!
912      AS_HELP_STRING([--with-appresdir=DIR],
913                     [X11 application resource files]))])
915 # Get a default value for the application resource directory.
917 # We ignore the `XAPPLRES' and `XUSERFILESEARCHPATH' environment variables.
919 # The goal is to find the `root' of X11.  Under most systems this is
920 # `/usr/X11/lib'.  Application default files are then in
921 # `/usr/X11/lib/X11/app-defaults'.
923 # Based on autoconf's AC_PATH_X macro.
925 AC_DEFUN([GROFF_APPRESDIR_DEFAULT],
926   [if test -z "$groff_no_x"; then
927      # Create an Imakefile, run `xmkmf', then `make'.
928      rm -f -r conftest.dir
929      if mkdir conftest.dir; then
930        cd conftest.dir
931        # Make sure to not put `make' in the Imakefile rules,
932        # since we grep it out.
933        cat >Imakefile <<'EOF'
935 xlibdirs:
936         @echo 'groff_x_usrlibdir="${USRLIBDIR}"; groff_x_libdir="${LIBDIR}"'
939        if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
940          # GNU make sometimes prints "make[1]: Entering...",
941          # which would confuse us.
942          eval `${MAKE-make} xlibdirs 2>/dev/null | grep -v make`
944          # Open Windows `xmkmf' reportedly sets LIBDIR instead of USRLIBDIR.
945          for groff_extension in a so sl; do
946            if test ! -f $groff_x_usrlibdir/libX11.$groff_extension &&
947               test -f $groff_x_libdir/libX11.$groff_extension; then
948              groff_x_usrlibdir=$groff_x_libdir
949              break
950            fi
951          done
952        fi
954        cd ..
955        rm -f -r conftest.dir
956      fi
958      # In case the test with `xmkmf' wasn't successful, try a suite of
959      # standard directories.  Check `X11' before `X11Rn' because it is often
960      # a symlink to the current release.
961      groff_x_libdirs='
962        /usr/X11/lib
963        /usr/X11R6/lib
964        /usr/X11R5/lib
965        /usr/X11R4/lib
967        /usr/lib/X11
968        /usr/lib/X11R6
969        /usr/lib/X11R5
970        /usr/lib/X11R4
972        /usr/local/X11/lib
973        /usr/local/X11R6/lib
974        /usr/local/X11R5/lib
975        /usr/local/X11R4/lib
977        /usr/local/lib/X11
978        /usr/local/lib/X11R6
979        /usr/local/lib/X11R5
980        /usr/local/lib/X11R4
982        /usr/X386/lib
983        /usr/x386/lib
984        /usr/XFree86/lib/X11
986        /usr/lib
987        /usr/local/lib
988        /usr/unsupported/lib
989        /usr/athena/lib
990        /usr/local/x11r5/lib
991        /usr/lpp/Xamples/lib
993        /usr/openwin/lib
994        /usr/openwin/share/lib'
996      if test -z "$groff_x_usrlibdir"; then
997        # We only test whether libX11 exists.
998        for groff_dir in $groff_x_libdirs; do
999          for groff_extension in a so sl; do
1000            if test ! -r $groff_dir/libX11.$groff_extension; then
1001              groff_x_usrlibdir=$groff_dir
1002              break 2
1003            fi
1004          done
1005        done
1006      fi
1008      if test "x$with_appresdir" = "x"; then
1009        appresdir=$groff_x_usrlibdir/X11/app-defaults
1010      else
1011        appresdir=$with_appresdir
1012      fi
1013    fi
1014    AC_SUBST([appresdir])])
1017 # Emit warning if --with-appresdir hasn't been used.
1019 AC_DEFUN([GROFF_APPRESDIR_CHECK],
1020   [if test -z "$groff_no_x"; then
1021      if test "x$with_appresdir" = "x"; then
1022        AC_MSG_NOTICE([
1024   The application resource file for gxditview will be installed as
1026     $appresdir/GXditview
1028   (an existing file will be saved as `GXditview.old').
1029   To install it into a different directory, say, `/etc/gxditview',
1030   add `--with-appresdir=/etc/gxditview' to the configure script
1031   and rerun it.  The environment variable `APPLRESDIR' must then
1032   be set to `/etc/' (note the trailing slash), omitting the
1033   `gxditview' part which is automatically appended by the X11
1034   searching routines for resource files.  More details can be
1035   found in the X(7) manual page.
1036        ])
1037      fi
1038    fi])