1 # Autoconf macros for groff.
2 # Copyright (C) 1989-2014 Free Software Foundation, Inc.
4 # This file is part of groff.
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 3 of the License, or
9 # (at your option) any later version.
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
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 AC_DEFUN([GROFF_PRINT],
20 [if test -z "$PSPRINT"; then
21 AC_CHECK_PROGS([LPR], [lpr])
22 AC_CHECK_PROGS([LP], [lp])
23 if test -n "$LPR" && test -n "$LP"; then
24 # HP-UX provides an lpr command that emulates lpr using lp,
25 # but it doesn't have lpq; in this case we want to use lp
27 AC_CHECK_PROGS([LPQ], [lpq])
28 test -n "$LPQ" || LPR=
30 if test -n "$LPR"; then
32 elif test -n "$LP"; then
37 AC_MSG_CHECKING([for command to use for printing PostScript files])
38 AC_MSG_RESULT([$PSPRINT])
40 # Figure out DVIPRINT from PSPRINT.
41 AC_MSG_CHECKING([for command to use for printing dvi files])
42 if test -n "$PSPRINT" && test -z "$DVIPRINT"; then
43 if test "x$PSPRINT" = "xlpr"; then
50 AC_MSG_RESULT([$DVIPRINT])])
52 # Bison generated parsers have problems with C++ compilers other than g++.
53 # So byacc is preferred over bison.
55 AC_DEFUN([GROFF_PROG_YACC],
56 [AC_CHECK_PROGS([YACC], [byacc 'bison -y'], [yacc])])
59 # We need Perl 5.6.1 or newer.
61 AC_DEFUN([GROFF_PERL],
63 AC_PATH_PROG([PERL], [perl], [no])
64 if test "x$PERL" = "xno"; then
65 AC_MSG_ERROR([perl binary not found], 1)
67 AX_PROG_PERL_VERSION([$PERLVERSION], true, \
68 AC_MSG_ERROR([perl version is too old], 1))])
71 # It is possible to fine-tune generation of documentation.
73 AC_DEFUN([GROFF_DOC_CHECK],
75 [AS_HELP_STRING([--with-doc[[=TYPE]]],
76 [choose which manuals (beside man pages) are desirable. \
77 TYPE can be `yes' or `no', or a comma-separated list of \
78 one or multiple of `html', `info', `other', `pdf', and \
79 `examples', to restrict what is produced])],
82 test "x$doc" = xno && doc=''
83 if test "x$doc" = xyes; then
84 doc_dist_target_ok=yes
91 # Don't use case/esac, verify input.
104 test "x$i" = xhtml && { docadd_html=yes; continue; }
105 test "x$i" = xinfo && { docadd_info=yes; continue; }
106 test "x$i" = xother && { docadd_other=yes; continue; }
107 test "x$i" = xpdf && { docadd_pdf=yes; continue; }
108 test "x$i" = xexamples && { docadd_examples=yes; continue; }
109 AC_MSG_WARN([Invalid `--with-doc' argument:] $i)
112 if test $docadd_html = yes; then
113 make_install_shipped_htmldoc=install_shipped_htmldoc
114 make_uninstall_shipped_htmldoc=uninstall_shipped_htmldoc
116 make_install_shipped_htmldoc=
117 make_uninstall_shipped_htmldoc=
119 if test $docadd_other = yes; then
120 make_otherdoc=otherdoc
121 make_install_otherdoc=install_otherdoc
122 make_uninstall_otherdoc=uninstall_otherdoc
125 make_install_otherdoc=
126 make_uninstall_otherdoc=
128 if test $docadd_examples = yes; then
129 make_examples=examples
130 make_install_examples=install_examples
131 make_uninstall_examples=uninstall_examples
134 make_install_examples=
135 make_uninstall_examples=
137 AC_SUBST([doc_dist_target_ok])
138 AC_SUBST([make_install_shipped_htmldoc])
139 AC_SUBST([make_uninstall_shipped_htmldoc])
140 AC_SUBST([make_otherdoc])
141 AC_SUBST([make_install_otherdoc])
142 AC_SUBST([make_uninstall_otherdoc])
143 AC_SUBST([make_examples])
144 AC_SUBST([make_install_examples])
145 AC_SUBST([make_uninstall_examples])])
148 # We need makeinfo 4.8 or newer.
150 AC_DEFUN([GROFF_MAKEINFO],
151 [if test $docadd_info = yes; then
153 AC_CHECK_PROG([MAKEINFO], [makeinfo], [makeinfo])
154 if test -z "$MAKEINFO"; then
155 missing="\`makeinfo' is missing."
157 AC_MSG_CHECKING([for makeinfo version])
158 # We need an additional level of quoting to make sed's regexps work.
159 [makeinfo_version=`$MAKEINFO --version 2>&1 \
160 | sed -e 's/^.* \([^ ][^ ]*\)$/\1/' -e '1q'`]
161 AC_MSG_RESULT([$makeinfo_version])
162 # Consider only the first two numbers in version number string.
163 makeinfo_version_major=`IFS=.; set x $makeinfo_version; echo 0${2}`
164 makeinfo_version_minor=`IFS=.; set x $makeinfo_version; echo 0${3}`
165 makeinfo_version_numeric=`
166 expr ${makeinfo_version_major}000 \+ ${makeinfo_version_minor}`
167 if test $makeinfo_version_numeric -lt 4008; then
168 missing="\`makeinfo' is too old."
172 if test -n "$missing"; then
173 infofile=doc/groff.info
174 test -f ${infofile} || infofile=${srcdir}/${infofile}
175 if test ! -f ${infofile} \
176 || test ${srcdir}/doc/groff.texinfo -nt ${infofile}; then
177 AC_MSG_ERROR($missing
178 [Get the `texinfo' package version 4.8 or newer.])
181 [Get the `texinfo' package version 4.8 or newer if you want to convert
182 `groff.texinfo' into a PDF or HTML document.])
187 make_install_infodoc=install_infodoc
188 make_uninstall_infodoc=uninstall_infodoc
191 make_install_infodoc=
192 make_uninstall_infodoc=
196 AC_SUBST([make_infodoc])
197 AC_SUBST([make_install_infodoc])
198 AC_SUBST([make_uninstall_infodoc])])
201 # The following programs are needed for grohtml.
203 AC_DEFUN([GROFF_HTML_PROGRAMS],
205 make_install_htmldoc=
206 make_uninstall_htmldoc=
208 make_install_htmlexamples=
209 make_uninstall_htmlexamples=
210 AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH])
213 AC_FOREACH([groff_prog],
214 [pnmcut pnmcrop pnmtopng psselect pnmtops],
215 [AC_CHECK_PROG(groff_prog, groff_prog, [found], [missing])
216 if test $[]groff_prog = missing; then
217 missing="$missing \`groff_prog'"
220 test "$GHOSTSCRIPT" = "missing" && missing="$missing \`gs'"
222 if test -z "$missing"; then
223 if test $docadd_html = yes; then
225 make_install_htmldoc=install_htmldoc
226 make_uninstall_htmldoc=uninstall_htmldoc
227 if test $docadd_examples = yes; then
228 make_htmlexamples=html_examples
229 make_install_htmlexamples=install_htmlexamples
230 make_uninstall_htmlexamples=uninstall_htmlexamples
234 plural=`set $missing; test $[#] -gt 1 && echo s`
235 missing=`set $missing
237 while test $[#] -gt 0
240 1) missing="$missing$[1]" ;;
241 2) missing="$missing$[1] and " ;;
242 *) missing="$missing$[1], " ;;
249 test $docadd_html = yes && docnote=';
250 therefore, it will neither be possible to prepare, nor to install,
251 documentation in HTML format.'
253 AC_MSG_WARN([missing program$plural:
257 cannot be found in the PATH.
258 Consequently, groff's HTML backend (grohtml) will not work properly$docnote
260 doc_dist_target_ok=no
262 AC_SUBST([make_htmldoc])
263 AC_SUBST([make_install_htmldoc])
264 AC_SUBST([make_uninstall_htmldoc])
265 AC_SUBST([make_htmlexamples])
266 AC_SUBST([make_install_htmlexamples])
267 AC_SUBST([make_uninstall_htmlexamples])])
270 # To produce PDF docs, we need both awk and ghostscript.
272 AC_DEFUN([GROFF_PDFDOC_PROGRAMS],
275 make_uninstall_pdfdoc=
277 make_install_pdfexamples=
278 make_uninstall_pdfexamples=
279 AC_REQUIRE([GROFF_AWK_PATH])
280 AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH])
283 test "$AWK" = missing && missing="\`awk'"
284 test "$GHOSTSCRIPT" = missing && missing="$missing \`gs'"
285 if test -z "$missing"; then
286 if test $docadd_pdf = yes; then
288 make_install_pdfdoc=install_pdfdoc
289 make_uninstall_pdfdoc=uninstall_pdfdoc
290 if test $docadd_examples = yes; then
291 make_pdfexamples=pdfexamples
292 make_install_pdfexamples=install_pdfexamples
293 make_uninstall_pdfexamples=uninstall_pdfexamples
297 plural=`set $missing; test $[#] -eq 2 && echo s`
299 && missing=`set $missing; echo "$[1] and $[2]"` \
300 || missing=`echo $missing`
303 test $docadd_pdf = yes && docnote=';
304 therefore, it will neither be possible to prepare, nor to install,
305 documentation and most of the examples in PDF format.'
307 AC_MSG_WARN([missing program$plural:
309 The program$plural $missing cannot be found in the PATH.
310 Consequently, groff's PDF formatter (pdfroff) will not work properly$docnote
312 doc_dist_target_ok=no
314 AC_SUBST([make_pdfdoc])
315 AC_SUBST([make_install_pdfdoc])
316 AC_SUBST([make_uninstall_pdfdoc])
317 AC_SUBST([make_pdfexamples])
318 AC_SUBST([make_install_pdfexamples])
319 AC_SUBST([make_uninstall_pdfexamples])])
322 # Check whether pnmtops can handle the -nosetpage option.
324 AC_DEFUN([GROFF_PNMTOPS_NOSETPAGE],
325 [AC_MSG_CHECKING([whether pnmtops can handle the -nosetpage option])
326 if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 ; then
328 pnmtops_nosetpage="pnmtops -nosetpage"
331 pnmtops_nosetpage="pnmtops"
333 AC_SUBST([pnmtops_nosetpage])])
336 # Check location of `gs'; allow `--with-gs=PROG' option to override.
338 AC_DEFUN([GROFF_GHOSTSCRIPT_PATH],
339 [AC_REQUIRE([GROFF_GHOSTSCRIPT_PREFS])
341 [AS_HELP_STRING([--with-gs=PROG],
342 [actual [/path/]name of ghostscript executable])],
343 [GHOSTSCRIPT=$withval],
344 [AC_CHECK_TOOLS(GHOSTSCRIPT, [$ALT_GHOSTSCRIPT_PROGS], [missing])])
345 test "$GHOSTSCRIPT" = "no" && GHOSTSCRIPT=missing])
347 # Preferences for choice of `gs' program...
348 # (allow --with-alt-gs="LIST" to override).
350 AC_DEFUN([GROFF_GHOSTSCRIPT_PREFS],
351 [AC_ARG_WITH([alt-gs],
352 [AS_HELP_STRING([--with-alt-gs=LIST],
353 [alternative names for ghostscript executable])],
354 [ALT_GHOSTSCRIPT_PROGS="$withval"],
355 [ALT_GHOSTSCRIPT_PROGS="gs gswin32c gsos2"])
356 AC_SUBST([ALT_GHOSTSCRIPT_PROGS])])
359 # Check location of `awk'; allow `--with-awk=PROG' option to override.
361 AC_DEFUN([GROFF_AWK_PATH],
362 [AC_REQUIRE([GROFF_AWK_PREFS])
364 [AS_HELP_STRING([--with-awk=PROG],
365 [actual [/path/]name of awk executable])],
367 [AC_CHECK_TOOLS(AWK, [$ALT_AWK_PROGS], [missing])])
368 test "$AWK" = "no" && AWK=missing])
371 # Preferences for choice of `awk' program; allow --with-alt-awk="LIST"
374 AC_DEFUN([GROFF_AWK_PREFS],
375 [AC_ARG_WITH([alt-awk],
376 [AS_HELP_STRING([--with-alt-awk=LIST],
377 [alternative names for awk executable])],
378 [ALT_AWK_PROGS="$withval"],
379 [ALT_AWK_PROGS="gawk mawk nawk awk"])
380 AC_SUBST([ALT_AWK_PROGS])])
383 # GROFF_CSH_HACK(if hack present, if not present)
385 AC_DEFUN([GROFF_CSH_HACK],
386 [AC_MSG_CHECKING([for csh hash hack])
388 cat <<EOF >conftest.sh
391 export PATH || exit 0
396 if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then
406 # From udodo!hans@relay.NL.net (Hans Zuidam)
408 AC_DEFUN([GROFF_ISC_SYSV3],
409 [AC_MSG_CHECKING([for ISC 3.x or 4.x])
410 if grep ['[34]\.'] /usr/options/cb.name >/dev/null 2>&1
413 AC_DEFINE([_SYSV3], [1], [Define if you have ISC 3.x or 4.x.])
418 AC_DEFUN([GROFF_POSIX],
419 [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
425 extern "C" { void fileno(int); }
429 [AC_MSG_RESULT([yes])
430 AC_DEFINE([_POSIX_SOURCE], [1],
431 [Define if -D_POSIX_SOURCE is necessary.])],
432 [AC_MSG_RESULT([no])])
436 # srand() of SunOS 4.1.3 has return type int instead of void
438 AC_DEFUN([GROFF_SRAND],
440 AC_MSG_CHECKING([for return type of srand])
445 extern "C" { void srand(unsigned int); }
449 [AC_MSG_RESULT([void])
450 AC_DEFINE([RET_TYPE_SRAND_IS_VOID], [1],
451 [Define if srand() returns void not int.])],
452 [AC_MSG_RESULT([int])])
456 # In April 2005, autoconf's AC_TYPE_SIGNAL is still broken.
458 AC_DEFUN([GROFF_TYPE_SIGNAL],
459 [AC_MSG_CHECKING([for return type of signal handlers])
460 for groff_declaration in \
461 'extern "C" void (*signal (int, void (*)(int)))(int);' \
462 'extern "C" void (*signal (int, void (*)(int)) throw ())(int);' \
463 'void (*signal ()) ();'
468 #include <sys/types.h>
486 if test -n "$groff_declaration"; then
487 AC_MSG_RESULT([void])
488 AC_DEFINE([RETSIGTYPE], [void],
489 [Define as the return type of signal handlers
493 AC_DEFINE([RETSIGTYPE], [int],
494 [Define as the return type of signal handlers
499 AC_DEFUN([GROFF_SYS_NERR],
501 AC_MSG_CHECKING([for sys_nerr in <errno.h>, <stdio.h>, or <stdlib.h>])
517 [AC_MSG_RESULT([yes])
518 AC_DEFINE([HAVE_SYS_NERR], [1],
519 [Define if you have sys_nerr in <errno.h>, <stdio.h>, or <stdio.h>.])],
520 [AC_MSG_RESULT([no])])
523 AC_DEFUN([GROFF_SYS_ERRLIST],
524 [AC_MSG_CHECKING([for sys_errlist[] in <errno.h>, <stdio.h>, or <stdlib.h>])
536 k = (int)sys_errlist[0];
540 [AC_MSG_RESULT([yes])
541 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
542 [Define if you have sys_errlist in <errno.h>, <stdio.h>, or <stdlib.h>.])],
543 [AC_MSG_RESULT([no])])])
545 AC_DEFUN([GROFF_OSFCN_H],
547 AC_MSG_CHECKING([C++ <osfcn.h>])
561 [AC_MSG_RESULT([yes])
562 AC_DEFINE([HAVE_CC_OSFCN_H], [1],
563 [Define if you have a C++ <osfcn.h>.])],
564 [AC_MSG_RESULT([no])])
568 AC_DEFUN([GROFF_LIMITS_H],
570 AC_MSG_CHECKING([C++ <limits.h>])
585 [AC_MSG_RESULT([yes])
586 AC_DEFINE([HAVE_CC_LIMITS_H], [1],
587 [Define if you have a C++ <limits.h>.])],
588 [AC_MSG_RESULT([no])])
591 AC_DEFUN([GROFF_TIME_T],
593 AC_MSG_CHECKING([for declaration of time_t])
603 struct tm *p = localtime(&t);
607 [AC_MSG_RESULT([yes])],
609 AC_DEFINE([LONG_FOR_TIME_T], [1],
610 [Define if localtime() takes a long * not a time_t *.])])
613 AC_DEFUN([GROFF_STRUCT_EXCEPTION],
614 [AC_MSG_CHECKING([struct exception])
627 [AC_MSG_RESULT([yes])
628 AC_DEFINE([HAVE_STRUCT_EXCEPTION], [1],
629 [Define if <math.h> defines struct exception.])],
630 [AC_MSG_RESULT([no])])])
632 AC_DEFUN([GROFF_ARRAY_DELETE],
634 AC_MSG_CHECKING([whether ANSI array delete syntax is supported])
638 char *p = new char[5];
643 [AC_MSG_RESULT([yes])],
645 AC_DEFINE([ARRAY_DELETE_NEEDS_SIZE], [1],
646 [Define if your C++ doesn't understand `delete []'.])])
649 AC_DEFUN([GROFF_TRADITIONAL_CPP],
651 AC_MSG_CHECKING([traditional preprocessor])
655 #define name2(a, b) a/**/b
664 [AC_MSG_RESULT([yes])
665 AC_DEFINE([TRADITIONAL_CPP], [1],
666 [Define if your C++ compiler uses a traditional (Reiser) preprocessor.])],
667 [AC_MSG_RESULT([no])])
670 AC_DEFUN([GROFF_WCOREFLAG],
671 [AC_MSG_CHECKING([w_coredump])
675 #include <sys/types.h>
676 #include <sys/wait.h>
687 ((union wait *)&i)->w_coredump = 1;
694 [AC_MSG_RESULT([yes])
695 AC_DEFINE(WCOREFLAG, 0200,
696 [Define if the 0200 bit of the status returned by wait() indicates
697 whether a core image was produced for a process that was terminated
699 [AC_MSG_RESULT([no])],
700 [AC_MSG_RESULT([no])])])
703 AC_DEFUN([GROFF_BROKEN_SPOOLER_FLAGS],
704 [AC_MSG_CHECKING([default value for grops -b option])
705 test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=0
706 AC_MSG_RESULT([$BROKEN_SPOOLER_FLAGS])
707 AC_SUBST([BROKEN_SPOOLER_FLAGS])])
710 AC_DEFUN([GROFF_PAGE],
711 [AC_MSG_CHECKING([default paper size])
713 test "x$prefix" = "xNONE" && groff_prefix=$ac_default_prefix
714 if test -z "$PAGE"; then
716 if test -r $groff_prefix/share/groff/font/devps/DESC; then
717 descfile=$groff_prefix/share/groff/font/devps/DESC
718 elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
719 descfile=$groff_prefix/lib/groff/font/devps/DESC
721 for f in $groff_prefix/share/groff/*/font/devps/DESC; do
729 if test -n "$descfile"; then
730 if grep ['^paperlength[ ]\+841890'] $descfile >/dev/null 2>&1; then
732 elif grep ['^papersize[ ]\+[aA]4'] $descfile >/dev/null 2>&1; then
738 if test -z "$PAGE"; then
739 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
740 /etc/resolv.conf 2>/dev/null`
741 if test -z "$dom"; then
742 dom=`(domainname) 2>/dev/null | tr -d '+'`
744 || test "$dom" = '(none)'; then
745 dom=`(hostname) 2>/dev/null | grep '\.'`
748 # If the top-level domain is two letters and it's not `us' or `ca'
749 # then they probably use A4 paper.
751 [*.[Uu][Ss]|*.[Cc][Aa])]
753 [*.[A-Za-z][A-Za-z])]
758 test -n "$PAGE" || PAGE=letter
759 if test "x$PAGE" = "xA4"; then
760 AC_DEFINE([PAGEA4], [1],
761 [Define if the printer's page size is A4.])
763 AC_MSG_RESULT([$PAGE])
767 AC_DEFUN([GROFF_CXX_CHECK],
768 [AC_REQUIRE([AC_PROG_CXX])
770 if test "$cross_compiling" = no; then
771 AC_MSG_CHECKING([that C++ compiler can compile simple program])
782 [AC_MSG_RESULT([yes])],
784 AC_MSG_ERROR([a working C++ compiler is required])],
787 if test "$cross_compiling" = no; then
788 AC_MSG_CHECKING([that C++ static constructors and destructors are called])
801 ~A() { if (i == 1) _exit(0); }
813 [AC_MSG_RESULT([yes])],
815 AC_MSG_ERROR([a working C++ compiler is required])],
818 AC_MSG_CHECKING([that header files support C++])
831 [AC_MSG_RESULT([yes])],
833 AC_MSG_ERROR([header files do not support C++
834 (if you are using a version of gcc/g++ earlier than 2.5,
835 you should install libg++)])])
839 AC_DEFUN([GROFF_TMAC],
840 [AC_MSG_CHECKING([for prefix of system macro packages])
842 sys_tmac_file_prefix=
843 for d in /usr/share/lib/tmac /usr/lib/tmac; do
844 for t in "" tmac.; do
847 if test -z "$sys_tmac_prefix" \
849 && grep '^\.if' $f >/dev/null 2>&1; then
850 sys_tmac_prefix=$d/$t
851 sys_tmac_file_prefix=$t
856 AC_MSG_RESULT([$sys_tmac_prefix])
857 AC_SUBST([sys_tmac_prefix])
859 AC_MSG_CHECKING([which system macro packages should be made available])
861 if test "x$sys_tmac_file_prefix" = "xtmac."; then
862 for f in $sys_tmac_prefix*; do
863 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
868 grep "Copyright.*Free Software Foundation" $f >/dev/null \
869 || tmac_wrap="$tmac_wrap $suff" ;;
872 elif test -n "$sys_tmac_prefix"; then
873 files=`echo $sys_tmac_prefix*`
874 grep "\\.so" $files >conftest.sol
885 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
886 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then
889 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
894 tmac_wrap="$tmac_wrap $suff" ;;
901 AC_MSG_RESULT([$tmac_wrap])
902 AC_SUBST([tmac_wrap])])
906 [AC_MSG_CHECKING([for existing troff installation])
907 if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
917 # We need the path to install-sh to be absolute.
919 AC_DEFUN([GROFF_INSTALL_SH],
920 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])
921 ac_dir=`cd $ac_aux_dir; pwd`
922 ac_install_sh="$ac_dir/install-sh -c"])
925 # Test whether install-info is available.
927 AC_DEFUN([GROFF_INSTALL_INFO],
928 [if test $docadd_info = yes; then
929 AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])
933 # At least one UNIX system, Apple Macintosh Rhapsody 5.5,
934 # does not have -lm ...
936 AC_DEFUN([GROFF_LIBM],
937 [AC_CHECK_LIB([m], [sin], [LIBM=-lm])
941 # ... while the MinGW implementation of GCC for Microsoft Win32
942 # does not seem to have -lc.
944 AC_DEFUN([GROFF_LIBC],
945 [AC_CHECK_LIB([c], [main], [LIBC=-lc])
949 # Check for EBCDIC -- stolen from the OS390 Unix LYNX port
951 AC_DEFUN([GROFF_EBCDIC],
952 [AC_MSG_CHECKING([whether character set is EBCDIC])
956 /* Treat any failure as ASCII for compatibility with existing art.
957 Use compile-time rather than run-time tests for cross-compiler
960 make an error "Character set is not EBCDIC"
965 [groff_cv_ebcdic="yes"
966 TTYDEVDIRS="font/devcp1047"
968 AC_DEFINE(IS_EBCDIC_HOST, 1,
969 [Define if the host's encoding is EBCDIC.])],
970 [groff_cv_ebcdic="no"
971 TTYDEVDIRS="font/devascii font/devlatin1"
972 OTHERDEVDIRS="font/devlj4 font/devlbp"
973 AC_MSG_RESULT([no])])
974 AC_SUBST([TTYDEVDIRS])
975 AC_SUBST([OTHERDEVDIRS])])
978 # Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with
979 # gcc) to OS/390 uses ASCII internally.
981 AC_DEFUN([GROFF_OS390],
982 [if test "$groff_cv_ebcdic" = "yes"; then
983 AC_MSG_CHECKING([for OS/390 Unix])
986 CFLAGS="$CFLAGS -D_ALL_SOURCE"
987 AC_MSG_RESULT([yes]) ;;
989 AC_MSG_RESULT([no]) ;;
994 # Check whether Windows scripts like `afmtodit.cmd' should be installed.
996 AC_DEFUN([GROFF_CMD_FILES],
997 [AC_MSG_CHECKING([whether to install .cmd wrapper scripts for Windows])
1000 make_winscripts=winscripts
1001 make_install_winscripts=install_winscripts
1002 make_uninstall_winscripts=uninstall_winscripts
1003 AC_MSG_RESULT([yes]) ;;
1006 make_install_winscripts=
1007 make_uninstall_winscripts=
1008 AC_MSG_RESULT([no]) ;;
1010 AC_SUBST([make_winscripts])
1011 AC_SUBST([make_install_winscripts])
1012 AC_SUBST([make_uninstall_winscripts])])
1015 # Check whether we need a declaration for a function.
1017 # Stolen from GNU bfd.
1019 AC_DEFUN([GROFF_NEED_DECLARATION],
1020 [AC_MSG_CHECKING([whether $1 must be declared])
1022 AC_CACHE_VAL([groff_cv_decl_needed_$1],
1023 [AC_COMPILE_IFELSE([
1027 #ifdef HAVE_STRING_H
1030 #ifdef HAVE_STRINGS_H
1031 #include <strings.h>
1033 #ifdef HAVE_STDLIB_H
1036 #ifdef HAVE_SYS_TIME_H
1037 #include <sys/time.h>
1039 #ifdef HAVE_UNISTD_H
1050 char *p = (char *) $1;
1055 [groff_cv_decl_needed_$1=no],
1056 [groff_cv_decl_needed_$1=yes])])
1057 AC_MSG_RESULT([$groff_cv_decl_needed_$1])
1058 if test $groff_cv_decl_needed_$1 = yes; then
1059 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), [1],
1060 [Define if your C++ doesn't declare ]$1[().])
1062 AC_LANG_POP([C++])])
1065 # If mkstemp() isn't available, use our own mkstemp.cpp file.
1067 AC_DEFUN([GROFF_MKSTEMP],
1068 [AC_MSG_CHECKING([for mkstemp])
1070 AC_LIBSOURCE([mkstemp.cpp])
1085 [AC_MSG_RESULT([yes])
1086 AC_DEFINE([HAVE_MKSTEMP], [1], [Define if you have mkstemp().])],
1087 [AC_MSG_RESULT([no])
1088 _AC_LIBOBJ([mkstemp])])
1089 AC_LANG_POP([C++])])
1092 # Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>,
1093 # and declares uintmax_t. Taken from the fileutils package.
1095 AC_DEFUN([GROFF_INTTYPES_H],
1096 [AC_LANG_PUSH([C++])
1097 AC_MSG_CHECKING([C++ <inttypes.h>])
1101 #include <sys/types.h>
1102 #include <inttypes.h>
1107 uintmax_t i = (uintmax_t)-1;
1111 [groff_cv_header_inttypes_h=yes
1112 AC_DEFINE([HAVE_CC_INTTYPES_H], [1],
1113 [Define if you have a C++ <inttypes.h>.])],
1114 [groff_cv_header_inttypes_h=no])
1115 AC_MSG_RESULT([$groff_cv_header_inttypes_h])
1116 AC_LANG_POP([C++])])
1119 # Test for working `unsigned long long'. Taken from the fileutils package.
1121 AC_DEFUN([GROFF_UNSIGNED_LONG_LONG],
1122 [AC_LANG_PUSH([C++])
1123 AC_MSG_CHECKING([for unsigned long long])
1127 unsigned long long ull = 1;
1129 unsigned long long ullmax = (unsigned long long)-1;
1134 return ull << i | ull >> i | ullmax / ull | ullmax % ull;
1138 [groff_cv_type_unsigned_long_long=yes],
1139 [groff_cv_type_unsigned_long_long=no])
1140 AC_MSG_RESULT([$groff_cv_type_unsigned_long_long])
1141 AC_LANG_POP([C++])])
1144 # Define uintmax_t to `unsigned long' or `unsigned long long'
1145 # if <inttypes.h> does not exist. Taken from the fileutils package.
1147 AC_DEFUN([GROFF_UINTMAX_T],
1148 [AC_REQUIRE([GROFF_INTTYPES_H])
1149 if test $groff_cv_header_inttypes_h = no; then
1150 AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG])
1151 test $groff_cv_type_unsigned_long_long = yes \
1152 && ac_type='unsigned long long' \
1153 || ac_type='unsigned long'
1154 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
1155 [Define uintmax_t to `unsigned long' or `unsigned long long' if
1156 <inttypes.h> does not exist.])
1160 # Identify PATH_SEPARATOR character to use in GROFF_FONT_PATH and
1161 # GROFF_TMAC_PATH which is appropriate for the target system (POSIX=':',
1162 # MS-DOS/Win32=';').
1164 # The logic to resolve this test is already encapsulated in
1165 # `${srcdir}/src/include/nonposix.h'.
1167 AC_DEFUN([GROFF_TARGET_PATH_SEPARATOR],
1168 [AC_MSG_CHECKING([separator character to use in groff search paths])
1169 cp ${srcdir}/src/include/nonposix.h conftest.h
1174 #include "conftest.h"
1179 #if PATH_SEP_CHAR == ';'
1180 make an error "Path separator is ';'"
1185 [GROFF_PATH_SEPARATOR=":"],
1186 [GROFF_PATH_SEPARATOR=";"])
1187 AC_MSG_RESULT([$GROFF_PATH_SEPARATOR])
1188 AC_SUBST(GROFF_PATH_SEPARATOR)])
1193 AC_DEFUN([GROFF_X11],
1194 [AC_REQUIRE([AC_PATH_XTRA])
1196 if test -z "$groff_no_x"; then
1200 CFLAGS="$CFLAGS $X_CFLAGS"
1201 LDFLAGS="$LDFLAGS $X_LIBS"
1202 LIBS="$LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
1205 AC_MSG_CHECKING([for Xaw library and header files])
1209 #include <X11/Intrinsic.h>
1210 #include <X11/Xaw/Simple.h>
1215 [AC_MSG_RESULT([yes])],
1216 [AC_MSG_RESULT([no])
1220 AC_MSG_CHECKING([for Xmu library and header files])
1224 #include <X11/Intrinsic.h>
1225 #include <X11/Xmu/Converters.h>
1230 [AC_MSG_RESULT([yes])],
1231 [AC_MSG_RESULT([no])
1239 if test "x$groff_no_x" = "xyes"; then
1240 AC_MSG_NOTICE([gxditview and xtotroff won't be built])
1242 XDEVDIRS="font/devX75 font/devX75-12 font/devX100 font/devX100-12"
1243 XPROGDIRS="src/devices/xditview src/utils/xtotroff"
1244 XLIBDIRS="src/libs/libxutil"
1247 AC_SUBST([XDEVDIRS])
1248 AC_SUBST([XPROGDIRS])
1249 AC_SUBST([XLIBDIRS])])
1252 # Set up the `--with-appresdir' command line option.
1254 # Don't quote AS_HELP_STRING!
1255 AC_DEFUN([GROFF_APPRESDIR_OPTION],
1256 [AC_ARG_WITH([appresdir],
1257 AS_HELP_STRING([--with-appresdir=DIR],
1258 [X11 application resource files]))])
1261 # Get a default value for the application resource directory.
1263 # We ignore the `XAPPLRES' and `XUSERFILESEARCHPATH' environment variables.
1265 # By default if --with-appresdir is not used, we will install the
1266 # gxditview resources in $prefix/lib/X11/app-defaults.
1268 # Note that if --with-appresdir was passed to `configure', no prefix is
1269 # added to `appresdir'.
1271 AC_DEFUN([GROFF_APPRESDIR_DEFAULT],
1272 [if test -z "$groff_no_x"; then
1273 if test "x$with_appresdir" = "x"; then
1274 if test "x$prefix" = "xNONE"; then
1275 appresdir=$ac_default_prefix/lib/X11/app-defaults
1277 appresdir=$prefix/lib/X11/app-defaults
1280 appresdir=$with_appresdir
1283 AC_SUBST([appresdir])])
1285 # Emit warning if --with-appresdir hasn't been used.
1287 AC_DEFUN([GROFF_APPRESDIR_CHECK],
1288 [if test -z "$groff_no_x"; then
1289 if test "x$with_appresdir" = "x"; then
1291 The application resource files for gxditview (GXditview and
1292 GXditview-color) will be installed in:
1296 (existing files will be saved by appending `.old' to the file
1299 To install them into a different directory, say,
1300 `/etc/X11/app-defaults', add
1301 `--with-appresdir=/etc/X11/app-defaults' to the configure script
1302 command line options and rerun it (`prefix' value has no effect on
1303 a --with-appresdir option).
1305 If the gxditview resources are installed in a directory that is not
1306 one of the default X11 resources directories (common default
1307 directories are /usr/lib/X11/app-defaults,
1308 /usr/share/X11/app-defaults and /etc/X11/app-defaults), you will
1309 have to set the environment variable XFILESEARCHPATH to this
1310 path. More details can be found in the X(7) manual page, or in "X
1311 Toolkit Intrinsics - C Language Interface manual"
1317 # Set up the `--with-grofferdir' command line option.
1319 AC_DEFUN([GROFF_GROFFERDIR_OPTION],
1320 [AC_ARG_WITH([grofferdir],
1321 AS_HELP_STRING([--with-grofferdir=DIR],
1322 [groffer files location]))])
1325 AC_DEFUN([GROFF_GROFFERDIR_DEFAULT],
1326 [if test "x$with_grofferdir" = "x"; then
1327 groffer_dir=$libprogramdir/groffer
1329 groffer_dir=$with_grofferdir
1331 AC_SUBST([groffer_dir])])
1334 AC_DEFUN([GROFF_LIBPROGRAMDIR_DEFAULT],
1335 libprogramdir=$libdir/groff
1336 AC_SUBST([libprogramdir]))
1339 AC_DEFUN([GROFF_GLILYPONDDIR_DEFAULT],
1340 glilypond_dir=$libprogramdir/glilypond
1341 AC_SUBST([glilypond_dir]))
1344 AC_DEFUN([GROFF_GPINYINDIR_DEFAULT],
1345 gpinyin_dir=$libprogramdir/gpinyin
1346 AC_SUBST([gpinyin_dir]))
1349 AC_DEFUN([GROFF_GROGDIR_DEFAULT],
1350 grog_dir=$libprogramdir/grog
1351 AC_SUBST([grog_dir]))
1353 AC_DEFUN([GROFF_REFERDIR_DEFAULT],
1354 referdir=$libprogramdir/refer
1355 AC_SUBST([referdir]))