Provide `pdfroff' shell script, and manpage to document it;
[s-roff.git] / aclocal.m4
bloba74e6d3167ba856b1f28ab892ef4cd1a59becd70
1 # Autoconf macros for groff.
2 # Copyright (C) 1989-1995, 2001, 2002, 2003, 2004, 2005
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 # Check location of `gs'.
129 AC_DEFUN([GROFF_GHOSTSCRIPT_PATH],
130   [AC_PATH_TOOL(GHOSTSCRIPT, gs gsos2, missing)
131    AC_SUBST(GHOSTSCRIPT)])
133 # GROFF_CSH_HACK(if hack present, if not present)
135 AC_DEFUN([GROFF_CSH_HACK],
136   [AC_MSG_CHECKING([for csh hash hack])
138 cat <<EOF >conftest.sh
139 #!/bin/sh
140 true || exit 0
141 export PATH || exit 0
142 exit 1
145    chmod +x conftest.sh
146    if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
147      AC_MSG_RESULT([yes])
148      $1
149    else
150      AC_MSG_RESULT([no])
151      $2
152    fi
153    rm -f conftest.sh])
155 # From udodo!hans@relay.NL.net (Hans Zuidam)
157 AC_DEFUN([GROFF_ISC_SYSV3],
158   [AC_MSG_CHECKING([for ISC 3.x or 4.x])
159    if grep ['[34]\.'] /usr/options/cb.name >/dev/null 2>&1
160    then
161      AC_MSG_RESULT([yes])
162      AC_DEFINE([_SYSV3], [1], [Define if you have ISC 3.x or 4.x.])
163    else
164      AC_MSG_RESULT([no])
165    fi])
167 AC_DEFUN([GROFF_POSIX],
168   [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
169    AC_LANG_PUSH([C++])
170    AC_COMPILE_IFELSE([
171        AC_LANG_PROGRAM([[
173 #include <stdio.h>
174 extern "C" { void fileno(int); }
176        ]])
177      ],
178      [AC_MSG_RESULT([yes])
179       AC_DEFINE([_POSIX_SOURCE], [1],
180         [Define if -D_POSIX_SOURCE is necessary.])],
181      [AC_MSG_RESULT([no])])
182    AC_LANG_POP([C++])])
184 # srand() of SunOS 4.1.3 has return type int instead of void
186 AC_DEFUN([GROFF_SRAND],
187   [AC_LANG_PUSH([C++])
188    AC_MSG_CHECKING([for return type of srand])
189    AC_COMPILE_IFELSE([
190        AC_LANG_PROGRAM([[
192 #include <stdlib.h>
193 extern "C" { void srand(unsigned int); }
195        ]])
196      ],
197      [AC_MSG_RESULT([void])
198       AC_DEFINE([RET_TYPE_SRAND_IS_VOID], [1],
199         [Define if srand() returns void not int.])],
200      [AC_MSG_RESULT([int])])
201    AC_LANG_POP([C++])])
203 AC_DEFUN([GROFF_SYS_NERR],
204   [AC_LANG_PUSH([C++])
205    AC_MSG_CHECKING([for sys_nerr in <errno.h>, <stdio.h>, or <stdlib.h>])
206    AC_COMPILE_IFELSE([
207        AC_LANG_PROGRAM([[
209 #include <errno.h>
210 #include <stdio.h>
211 #include <stdlib.h>
213        ]],
214        [[
216 int k;
217 k = sys_nerr;
219        ]])
220      ],
221      [AC_MSG_RESULT([yes])
222       AC_DEFINE([HAVE_SYS_NERR], [1],
223         [Define if you have sys_nerr in <errno.h>, <stdio.h>, or <stdio.h>.])],
224      [AC_MSG_RESULT([no])])
225    AC_LANG_POP([C++])])
227 AC_DEFUN([GROFF_SYS_ERRLIST],
228   [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>])
229    AC_COMPILE_IFELSE([
230        AC_LANG_PROGRAM([[
232 #include <errno.h>
233 #include <stdio.h>
234 #include <stdlib.h>
236        ]],
237        [[
239 int k;
240 k = (int)sys_errlist[0];
242        ]])
243      ],
244      [AC_MSG_RESULT([yes])
245       AC_DEFINE([HAVE_SYS_ERRLIST], [1],
246         [Define if you have sys_errlist in <errno.h>, <stdio.h>, or <stdlib.h>.])],
247      [AC_MSG_RESULT([no])])])
249 AC_DEFUN([GROFF_OSFCN_H],
250   [AC_LANG_PUSH([C++])
251    AC_MSG_CHECKING([C++ <osfcn.h>])
252    AC_COMPILE_IFELSE([
253        AC_LANG_PROGRAM([[
255 #include <osfcn.h>
257        ]],
258        [[
260 read(0, 0, 0);
261 open(0, 0);
263        ]])
264      ],
265      [AC_MSG_RESULT([yes])
266       AC_DEFINE([HAVE_CC_OSFCN_H], [1],
267         [Define if you have a C++ <osfcn.h>.])],
268      [AC_MSG_RESULT([no])])
269    AC_LANG_POP([C++])])
271 AC_DEFUN([GROFF_LIMITS_H],
272   [AC_LANG_PUSH([C++])
273    AC_MSG_CHECKING([C++ <limits.h>])
274    AC_COMPILE_IFELSE([
275        AC_LANG_PROGRAM([[
277 #include <limits.h>
279        ]],
280        [[
282 int x = INT_MIN;
283 int y = INT_MAX;
284 int z = UCHAR_MAX;
286        ]])
287      ],
288      [AC_MSG_RESULT([yes])
289       AC_DEFINE([HAVE_CC_LIMITS_H], [1],
290         [Define if you have a C++ <limits.h>.])],
291      [AC_MSG_RESULT([no])])
292    AC_LANG_POP([C++])])
294 AC_DEFUN([GROFF_TIME_T],
295   [AC_LANG_PUSH([C++])
296    AC_MSG_CHECKING([for declaration of time_t])
297    AC_COMPILE_IFELSE([
298        AC_LANG_PROGRAM([[
300 #include <time.h>
302        ]],
303        [[
305 time_t t = time(0);
306 struct tm *p = localtime(&t);
308        ]])
309      ],
310      [AC_MSG_RESULT([yes])],
311      [AC_MSG_RESULT([no])
312       AC_DEFINE([LONG_FOR_TIME_T], [1],
313         [Define if localtime() takes a long * not a time_t *.])])
314    AC_LANG_POP([C++])])
316 AC_DEFUN([GROFF_STRUCT_EXCEPTION],
317   [AC_MSG_CHECKING([struct exception])
318    AC_COMPILE_IFELSE([
319        AC_LANG_PROGRAM([[
321 #include <math.h>
323        ]],
324        [[
326 struct exception e;
328        ]])
329      ],
330      [AC_MSG_RESULT([yes])
331       AC_DEFINE([HAVE_STRUCT_EXCEPTION], [1],
332         [Define if <math.h> defines struct exception.])],
333      [AC_MSG_RESULT([no])])])
335 AC_DEFUN([GROFF_ARRAY_DELETE],
336   [AC_LANG_PUSH([C++])
337    AC_MSG_CHECKING([whether ANSI array delete syntax is supported])
338    AC_COMPILE_IFELSE([
339        AC_LANG_PROGRAM(, [[
341 char *p = new char[5];
342 delete [] p;
344        ]])
345      ],
346      [AC_MSG_RESULT([yes])],
347      [AC_MSG_RESULT([no])
348       AC_DEFINE([ARRAY_DELETE_NEEDS_SIZE], [1],
349         [Define if your C++ doesn't understand `delete []'.])])
350    AC_LANG_POP([C++])])
352 AC_DEFUN([GROFF_TRADITIONAL_CPP],
353   [AC_LANG_PUSH([C++])
354    AC_MSG_CHECKING([traditional preprocessor])
355    AC_COMPILE_IFELSE([
356        AC_LANG_PROGRAM([[
358 #define name2(a, b) a/**/b
360        ]],
361        [[
363 int name2(foo, bar);
365        ]])
366      ],
367      [AC_MSG_RESULT([yes])
368       AC_DEFINE([TRADITIONAL_CPP], [1],
369         [Define if your C++ compiler uses a traditional (Reiser) preprocessor.])],
370      [AC_MSG_RESULT([no])])
371    AC_LANG_POP([C++])])
373 AC_DEFUN([GROFF_WCOREFLAG],
374   [AC_MSG_CHECKING([w_coredump])
375    AC_RUN_IFELSE([
376        AC_LANG_PROGRAM([[
378 #include <sys/types.h>
379 #include <sys/wait.h>
381        ]],
382        [[
384 main()
386 #ifdef WCOREFLAG
387   exit(1);
388 #else
389   int i = 0;
390   ((union wait *)&i)->w_coredump = 1;
391   exit(i != 0200);
392 #endif
395        ]])
396      ],
397      [AC_MSG_RESULT([yes])
398       AC_DEFINE(WCOREFLAG, 0200,
399         [Define if the 0200 bit of the status returned by wait() indicates
400          whether a core image was produced for a process that was terminated
401          by a signal.])],
402      [AC_MSG_RESULT([no])],
403      [AC_MSG_RESULT([no])])])
405 AC_DEFUN([GROFF_BROKEN_SPOOLER_FLAGS],
406   [AC_MSG_CHECKING([default value for grops -b option])
407    test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=0
408    AC_MSG_RESULT([$BROKEN_SPOOLER_FLAGS])
409    AC_SUBST([BROKEN_SPOOLER_FLAGS])])
411 AC_DEFUN([GROFF_PAGE],
412   [AC_MSG_CHECKING([default paper size])
413    groff_prefix=$prefix
414    test "x$prefix" = "xNONE" && groff_prefix=$ac_default_prefix
415    if test -z "$PAGE"; then
416      descfile=
417      if test -r $groff_prefix/share/groff/font/devps/DESC; then
418        descfile=$groff_prefix/share/groff/font/devps/DESC
419      elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
420        descfile=$groff_prefix/lib/groff/font/devps/DESC
421      else
422        for f in $groff_prefix/share/groff/*/font/devps/DESC; do
423          if test -r $f; then
424            descfile=$f
425            break
426          fi
427        done
428      fi
430      if test -n "$descfile"; then
431        if grep ['^paperlength[   ]\+841890'] $descfile >/dev/null 2>&1; then
432          PAGE=A4
433        elif grep ['^papersize[   ]\+[aA]4'] $descfile >/dev/null 2>&1; then
434          PAGE=A4
435        fi
436      fi
437    fi
439    if test -z "$PAGE"; then
440      dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
441          /etc/resolv.conf 2>/dev/null`
442      if test -z "$dom"; then
443        dom=`(domainname) 2>/dev/null | tr -d '+'`
444        if test -z "$dom" \
445           || test "$dom" = '(none)'; then
446          dom=`(hostname) 2>/dev/null | grep '\.'`
447        fi
448      fi
449      # If the top-level domain is two letters and it's not `us' or `ca'
450      # then they probably use A4 paper.
451      case "$dom" in
452      [*.[Uu][Ss]|*.[Cc][Aa])]
453        ;;
454      [*.[A-Za-z][A-Za-z])]
455        PAGE=A4 ;;
456      esac
457    fi
459    test -n "$PAGE" || PAGE=letter
460    if test "x$PAGE" = "xA4"; then
461      AC_DEFINE([PAGEA4], [1],
462        [Define if the printer's page size is A4.])
463    fi
464    AC_MSG_RESULT([$PAGE])
465    AC_SUBST([PAGE])])
467 AC_DEFUN([GROFF_CXX_CHECK],
468   [AC_REQUIRE([AC_PROG_CXX])
469    AC_LANG_PUSH([C++])
470    if test "$cross_compiling" = no; then
471      AC_MSG_CHECKING([that C++ compiler can compile simple program])
472    fi
473    AC_RUN_IFELSE([
474        AC_LANG_SOURCE([[
476 int main() {
477   return 0;
480        ]])
481      ],
482      [AC_MSG_RESULT([yes])],
483      [AC_MSG_RESULT([no])
484       AC_MSG_ERROR([a working C++ compiler is required])],
485      [:])
487    if test "$cross_compiling" = no; then
488      AC_MSG_CHECKING([that C++ static constructors and destructors are called])
489    fi
490    AC_RUN_IFELSE([
491        AC_LANG_SOURCE([[
493 extern "C" {
494   void _exit(int);
497 int i;
498 struct A {
499   char dummy;
500   A() { i = 1; }
501   ~A() { if (i == 1) _exit(0); }
504 A a;
506 int main()
508   return 1;
511        ]])
512      ],
513      [AC_MSG_RESULT([yes])],
514      [AC_MSG_RESULT([no])
515       AC_MSG_ERROR([a working C++ compiler is required])],
516      [:])
518    AC_MSG_CHECKING([that header files support C++])
519    AC_LINK_IFELSE([
520        AC_LANG_PROGRAM([[
522 #include <stdio.h>
524        ]],
525        [[
527 fopen(0, 0);
529        ]])
530      ],
531      [AC_MSG_RESULT([yes])],
532      [AC_MSG_RESULT([no])
533       AC_MSG_ERROR([header files do not support C++
534                    (if you are using a version of gcc/g++ earlier than 2.5,
535                    you should install libg++)])])
536    AC_LANG_POP([C++])])
538 AC_DEFUN([GROFF_TMAC],
539   [AC_MSG_CHECKING([for prefix of system macro packages])
540    sys_tmac_prefix=
541    sys_tmac_file_prefix=
542    for d in /usr/share/lib/tmac /usr/lib/tmac; do
543      for t in "" tmac.; do
544        for m in an s m; do
545          f=$d/$t$m
546          if test -z "$sys_tmac_prefix" \
547             && test -f $f \
548             && grep '^\.if' $f >/dev/null 2>&1; then
549            sys_tmac_prefix=$d/$t
550            sys_tmac_file_prefix=$t
551          fi
552        done
553      done
554    done
555    AC_MSG_RESULT([$sys_tmac_prefix])
556    AC_SUBST([sys_tmac_prefix])
558    AC_MSG_CHECKING([which system macro packages should be made available])
559    tmac_wrap=
560    if test "x$sys_tmac_file_prefix" = "xtmac."; then
561      for f in $sys_tmac_prefix*; do
562        suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
563        case "$suff" in
564        e)
565          ;;
566        *)
567          grep "Copyright.*Free Software Foundation" $f >/dev/null \
568               || tmac_wrap="$tmac_wrap $suff" ;;
569        esac
570      done
571    elif test -n "$sys_tmac_prefix"; then
572      files=`echo $sys_tmac_prefix*`
573      grep "\\.so" $files >conftest.sol
574      for f in $files; do
575        case "$f" in
576        ${sys_tmac_prefix}e)
577          ;;
578        *.me)
579          ;;
580        */ms.*)
581          ;;
582        *)
583          b=`basename $f`
584          if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
585             || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
586            :
587          else
588            suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
589            case "$suff" in
590            tmac.*)
591              ;;
592            *)
593              tmac_wrap="$tmac_wrap $suff" ;;
594            esac
595          fi
596        esac
597      done
598      rm -f conftest.sol
599    fi
600    AC_MSG_RESULT([$tmac_wrap])
601    AC_SUBST([tmac_wrap])])
603 AC_DEFUN([GROFF_G],
604   [AC_MSG_CHECKING([for existing troff installation])
605    if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
606      AC_MSG_RESULT([yes])
607      g=g
608    else
609      AC_MSG_RESULT([no])
610      g=
611    fi
612    AC_SUBST([g])])
614 # We need the path to install-sh to be absolute.
616 AC_DEFUN([GROFF_INSTALL_SH],
617   [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])
618    ac_dir=`cd $ac_aux_dir; pwd`
619    ac_install_sh="$ac_dir/install-sh -c"])
621 # Test whether install-info is available.
623 AC_DEFUN([GROFF_INSTALL_INFO],
624   [AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])])
626 # At least one UNIX system, Apple Macintosh Rhapsody 5.5,
627 # does not have -lm ...
629 AC_DEFUN([GROFF_LIBM],
630   [AC_CHECK_LIB([m], [sin], [LIBM=-lm])
631    AC_SUBST([LIBM])])
633 # ... while the MinGW implementation of GCC for Microsoft Win32
634 # does not seem to have -lc.
636 AC_DEFUN([GROFF_LIBC],
637   [AC_CHECK_LIB([c], [main], [LIBC=-lc])
638    AC_SUBST([LIBC])])
640 # Check for EBCDIC -- stolen from the OS390 Unix LYNX port
642 AC_DEFUN([GROFF_EBCDIC],
643   [AC_MSG_CHECKING([whether character set is EBCDIC])
644    AC_COMPILE_IFELSE([
645        AC_LANG_PROGRAM([[
647 /* Treat any failure as ASCII for compatibility with existing art.
648    Use compile-time rather than run-time tests for cross-compiler
649    tolerance. */
650 #if '0' != 240
651 make an error "Character set is not EBCDIC"
652 #endif
654        ]])
655      ],
656      [groff_cv_ebcdic="yes"
657       TTYDEVDIRS="font/devcp1047"
658       AC_MSG_RESULT([yes])
659       AC_DEFINE(IS_EBCDIC_HOST, 1,
660         [Define if the host's encoding is EBCDIC.])],
661      [groff_cv_ebcdic="no"
662      TTYDEVDIRS="font/devascii font/devlatin1"
663      OTHERDEVDIRS="font/devlj4 font/devlbp"
664      AC_MSG_RESULT([no])])
665    AC_SUBST([TTYDEVDIRS])
666    AC_SUBST([OTHERDEVDIRS])])
668 # Check for OS/390 Unix.  We test for EBCDIC also -- the Linux port (with
669 # gcc) to OS/390 uses ASCII internally.
671 AC_DEFUN([GROFF_OS390],
672   [if test "$groff_cv_ebcdic" = "yes"; then
673      AC_MSG_CHECKING([for OS/390 Unix])
674      case `uname` in
675      OS/390)
676        CFLAGS="$CFLAGS -D_ALL_SOURCE"
677        AC_MSG_RESULT([yes]) ;;
678      *)
679        AC_MSG_RESULT([no]) ;;
680      esac
681    fi])
683 # Check whether we need a declaration for a function.
685 # Stolen from GNU bfd.
687 AC_DEFUN([GROFF_NEED_DECLARATION],
688   [AC_MSG_CHECKING([whether $1 must be declared])
689    AC_LANG_PUSH([C++])
690    AC_CACHE_VAL([groff_cv_decl_needed_$1],
691      [AC_COMPILE_IFELSE([
692           AC_LANG_PROGRAM([[
694 #include <stdio.h>
695 #ifdef HAVE_STRING_H
696 #include <string.h>
697 #endif
698 #ifdef HAVE_STRINGS_H
699 #include <strings.h>
700 #endif
701 #ifdef HAVE_STDLIB_H
702 #include <stdlib.h>
703 #endif
704 #ifdef HAVE_SYS_TIME_H
705 #include <sys/time.h>
706 #endif
707 #ifdef HAVE_UNISTD_H
708 #include <unistd.h>
709 #endif
710 #ifdef HAVE_MATH_H
711 #include <math.h>
712 #endif
714           ]],
715           [[
717 #ifndef $1
718   char *p = (char *) $1;
719 #endif
721           ]])
722       ],
723       [groff_cv_decl_needed_$1=no],
724       [groff_cv_decl_needed_$1=yes])])
725    AC_MSG_RESULT([$groff_cv_decl_needed_$1])
726    if test $groff_cv_decl_needed_$1 = yes; then
727      AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), [1],
728        [Define if your C++ doesn't declare ]$1[().])
729    fi
730    AC_LANG_POP([C++])])
732 # If mkstemp() isn't available, use our own mkstemp.cpp file.
734 AC_DEFUN([GROFF_MKSTEMP],
735   [AC_MSG_CHECKING([for mkstemp])
736    AC_LANG_PUSH([C++])
737    AC_LIBSOURCE([mkstemp.cpp])
738    AC_LINK_IFELSE([
739        AC_LANG_PROGRAM([[
741 #include <stdlib.h>
742 #include <unistd.h>
743 int (*f) (char *);
745        ]],
746        [[
748 f = mkstemp;
750        ]])
751      ],
752      [AC_MSG_RESULT([yes])
753       AC_DEFINE([HAVE_MKSTEMP], [1], [Define if you have mkstemp().])],
754      [AC_MSG_RESULT([no])
755       _AC_LIBOBJ([mkstemp])])
756    AC_LANG_POP([C++])])
758 # Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
759 # and declares uintmax_t.  Taken from the fileutils package.
761 AC_DEFUN([GROFF_INTTYPES_H],
762   [AC_LANG_PUSH([C++])
763    AC_MSG_CHECKING([C++ <inttypes.h>])
764    AC_COMPILE_IFELSE([
765        AC_LANG_PROGRAM([[
767 #include <sys/types.h>
768 #include <inttypes.h>
770        ]],
771        [[
773 uintmax_t i = (uintmax_t)-1;
775        ]])
776      ],
777      [groff_cv_header_inttypes_h=yes
778       AC_DEFINE([HAVE_CC_INTTYPES_H], [1],
779         [Define if you have a C++ <inttypes.h>.])],
780      [groff_cv_header_inttypes_h=no])
781    AC_MSG_RESULT([$groff_cv_header_inttypes_h])
782    AC_LANG_POP([C++])])
784 # Test for working `unsigned long long'.  Taken from the fileutils package.
786 AC_DEFUN([GROFF_UNSIGNED_LONG_LONG],
787   [AC_LANG_PUSH([C++])
788    AC_MSG_CHECKING([for unsigned long long])
789    AC_LINK_IFELSE([
790        AC_LANG_PROGRAM([[
792 unsigned long long ull = 1;
793 int i = 63;
794 unsigned long long ullmax = (unsigned long long)-1;
796        ]],
797        [[
799 return ull << i | ull >> i | ullmax / ull | ullmax % ull;
801        ]])
802      ],
803      [groff_cv_type_unsigned_long_long=yes],
804      [groff_cv_type_unsigned_long_long=no])
805    AC_MSG_RESULT([$groff_cv_type_unsigned_long_long])
806    AC_LANG_POP([C++])])
808 # Define uintmax_t to `unsigned long' or `unsigned long long'
809 # if <inttypes.h> does not exist.  Taken from the fileutils package.
811 AC_DEFUN([GROFF_UINTMAX_T],
812   [AC_REQUIRE([GROFF_INTTYPES_H])
813    if test $groff_cv_header_inttypes_h = no; then
814      AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
815      test $groff_cv_type_unsigned_long_long = yes \
816           && ac_type='unsigned long long' \
817           || ac_type='unsigned long'
818      AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
819        [Define uintmax_t to `unsigned long' or `unsigned long long' if
820         <inttypes.h> does not exist.])
821    fi])
823 # Identify PATH_SEPARATOR character to use in GROFF_FONT_PATH and
824 # GROFF_TMAC_PATH which is appropriate for the target system (POSIX=':',
825 # MS-DOS/Win32=';').
827 # The logic to resolve this test is already encapsulated in
828 # `${srcdir}/src/include/nonposix.h'.
830 AC_DEFUN([GROFF_TARGET_PATH_SEPARATOR],
831   [AC_MSG_CHECKING([separator character to use in groff search paths])
832    cp ${srcdir}/src/include/nonposix.h conftest.h
833    AC_COMPILE_IFELSE([
834        AC_LANG_PROGRAM([[
835         
836 #include <ctype.h>
837 #include "conftest.h"
839        ]],
840        [[
842 #if PATH_SEP_CHAR == ';'
843 make an error "Path separator is ';'"
844 #endif
846        ]])
847      ],
848      [GROFF_PATH_SEPARATOR=":"],
849      [GROFF_PATH_SEPARATOR=";"])
850    AC_MSG_RESULT([$GROFF_PATH_SEPARATOR])
851    AC_SUBST(GROFF_PATH_SEPARATOR)])
853 # Check for X11.
855 AC_DEFUN([GROFF_X11],
856   [AC_REQUIRE([AC_PATH_XTRA])
857    groff_no_x=$no_x
858    if test -z "$groff_no_x"; then
859      OLDCFLAGS=$CFLAGS
860      OLDLDFLAGS=$LDFLAGS
861      OLDLIBS=$LIBS
862      CFLAGS="$CFLAGS $X_CFLAGS"
863      LDFLAGS="$LDFLAGS $X_LIBS"
864      LIBS="$LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
866      LIBS="$LIBS -lXaw"
867      AC_MSG_CHECKING([for Xaw library and header files])
868      AC_LINK_IFELSE([
869          AC_LANG_PROGRAM([[
871 #include <X11/Intrinsic.h>
872 #include <X11/Xaw/Simple.h>
874          ]],
875          [])
876        ],
877        [AC_MSG_RESULT([yes])],
878        [AC_MSG_RESULT([no])
879         groff_no_x="yes"])
881      LIBS="$LIBS -lXmu"
882      AC_MSG_CHECKING([for Xmu library and header files])
883      AC_LINK_IFELSE([
884          AC_LANG_PROGRAM([[
886 #include <X11/Intrinsic.h>
887 #include <X11/Xmu/Converters.h>
889          ]],
890          [])
891        ],
892        [AC_MSG_RESULT([yes])],
893        [AC_MSG_RESULT([no])
894         groff_no_x="yes"])
896      CFLAGS=$OLDCFLAGS
897      LDFLAGS=$OLDLDFLAGS
898      LIBS=$OLDLIBS
899    fi
901    if test "x$groff_no_x" = "xyes"; then
902      AC_MSG_NOTICE([gxditview and xtotroff won't be built])
903    else
904      XDEVDIRS="font/devX75 font/devX75-12 font/devX100 font/devX100-12"
905      XPROGDIRS="src/devices/xditview src/utils/xtotroff"
906      XLIBDIRS="src/libs/libxutil"
907    fi
909    AC_SUBST([XDEVDIRS])
910    AC_SUBST([XPROGDIRS])
911    AC_SUBST([XLIBDIRS])])
913 # Set up the `--with-appresdir' command line option.
915 AC_DEFUN([GROFF_APPRESDIR_OPTION],
916   [AC_ARG_WITH([appresdir],
917      dnl Don't quote AS_HELP_STRING!
918      AS_HELP_STRING([--with-appresdir=DIR],
919                     [X11 application resource files]))])
921 # Get a default value for the application resource directory.
923 # We ignore the `XAPPLRES' and `XUSERFILESEARCHPATH' environment variables.
925 # The goal is to find the `root' of X11.  Under most systems this is
926 # `/usr/X11/lib'.  Application default files are then in
927 # `/usr/X11/lib/X11/app-defaults'.
929 # Based on autoconf's AC_PATH_X macro.
931 AC_DEFUN([GROFF_APPRESDIR_DEFAULT],
932   [if test -z "$groff_no_x"; then
933      # Create an Imakefile, run `xmkmf', then `make'.
934      rm -f -r conftest.dir
935      if mkdir conftest.dir; then
936        cd conftest.dir
937        # Make sure to not put `make' in the Imakefile rules,
938        # since we grep it out.
939        cat >Imakefile <<'EOF'
941 xlibdirs:
942         @echo 'groff_x_usrlibdir="${USRLIBDIR}"; groff_x_libdir="${LIBDIR}"'
945        if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
946          # GNU make sometimes prints "make[1]: Entering...",
947          # which would confuse us.
948          eval `${MAKE-make} xlibdirs 2>/dev/null | grep -v make`
950          # Open Windows `xmkmf' reportedly sets LIBDIR instead of USRLIBDIR.
951          for groff_extension in a so sl; do
952            if test ! -f $groff_x_usrlibdir/libX11.$groff_extension &&
953               test -f $groff_x_libdir/libX11.$groff_extension; then
954              groff_x_usrlibdir=$groff_x_libdir
955              break
956            fi
957          done
958        fi
960        cd ..
961        rm -f -r conftest.dir
962      fi
964      # In case the test with `xmkmf' wasn't successful, try a suite of
965      # standard directories.  Check `X11' before `X11Rn' because it is often
966      # a symlink to the current release.
967      groff_x_libdirs='
968        /usr/X11/lib
969        /usr/X11R6/lib
970        /usr/X11R5/lib
971        /usr/X11R4/lib
973        /usr/lib/X11
974        /usr/lib/X11R6
975        /usr/lib/X11R5
976        /usr/lib/X11R4
978        /usr/local/X11/lib
979        /usr/local/X11R6/lib
980        /usr/local/X11R5/lib
981        /usr/local/X11R4/lib
983        /usr/local/lib/X11
984        /usr/local/lib/X11R6
985        /usr/local/lib/X11R5
986        /usr/local/lib/X11R4
988        /usr/X386/lib
989        /usr/x386/lib
990        /usr/XFree86/lib/X11
992        /usr/lib
993        /usr/local/lib
994        /usr/unsupported/lib
995        /usr/athena/lib
996        /usr/local/x11r5/lib
997        /usr/lpp/Xamples/lib
999        /usr/openwin/lib
1000        /usr/openwin/share/lib'
1002      if test -z "$groff_x_usrlibdir"; then
1003        # We only test whether libX11 exists.
1004        for groff_dir in $groff_x_libdirs; do
1005          for groff_extension in a so sl; do
1006            if test ! -r $groff_dir/libX11.$groff_extension; then
1007              groff_x_usrlibdir=$groff_dir
1008              break 2
1009            fi
1010          done
1011        done
1012      fi
1014      if test "x$with_appresdir" = "x"; then
1015        appresdir=$groff_x_usrlibdir/X11/app-defaults
1016      else
1017        appresdir=$with_appresdir
1018      fi
1019    fi
1020    AC_SUBST([appresdir])])
1023 # Emit warning if --with-appresdir hasn't been used.
1025 AC_DEFUN([GROFF_APPRESDIR_CHECK],
1026   [if test -z "$groff_no_x"; then
1027      if test "x$with_appresdir" = "x"; then
1028        AC_MSG_NOTICE([
1030   The application resource file for gxditview will be installed as
1032     $appresdir/GXditview
1034   (an existing file will be saved as `GXditview.old').
1035   To install it into a different directory, say, `/etc/gxditview',
1036   add `--with-appresdir=/etc/gxditview' to the configure script
1037   command line options and rerun it.  The environment variable
1038   `APPLRESDIR' must then be set to `/etc/' (note the trailing slash),
1039   omitting the `gxditview' part which is automatically appended by
1040   the X11 searching routines for resource files.  More details can be
1041   found in the X(7) manual page.
1042        ])
1043      fi
1044    fi])