aclocal.m4 revision 18099
118099Spstdnl Autoconf macros for groff.
218099Spstdnl Copyright (C) 1989, 1990, 1991, 1992, 1995 Free Software Foundation, Inc.
318099Spstdnl 
418099Spstdnl This file is part of groff.
518099Spstdnl 
618099Spstdnl groff is free software; you can redistribute it and/or modify it under
718099Spstdnl the terms of the GNU General Public License as published by the Free
818099Spstdnl Software Foundation; either version 2, or (at your option) any later
918099Spstdnl version.
1018099Spstdnl 
1118099Spstdnl groff is distributed in the hope that it will be useful, but WITHOUT ANY
1218099Spstdnl WARRANTY; without even the implied warranty of MERCHANTABILITY or
1318099Spstdnl FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1418099Spstdnl for more details.
1518099Spstdnl 
1618099Spstdnl You should have received a copy of the GNU General Public License along
1718099Spstdnl with groff; see the file COPYING.  If not, write to the Free Software
1818099Spstdnl Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1918099Spstdnl
2018099SpstAC_DEFUN(GROFF_PRINT,
2118099Spst[if test -z "$PSPRINT"
2218099Spstthen
2318099Spst	AC_CHECK_PROGS(LPR,lpr)
2418099Spst	AC_CHECK_PROGS(LP,lp)
2518099Spst	if test -n "$LPR" && test -n "$LP"
2618099Spst	then
2718099Spst		# HP-UX provides an lpr command that emulates lpr using lp,
2818099Spst		# but it doesn't have lpq; in this case we want to use lp
2918099Spst		# rather than lpr.
3018099Spst		AC_CHECK_PROGS(LPQ,lpq)
3118099Spst		test -n "$LPQ" || LPR=
3218099Spst	fi
3318099Spst	if test -n "$LPR"
3418099Spst	then
3518099Spst		PSPRINT="$LPR"
3618099Spst	elif test -n "$LP"
3718099Spst	then
3818099Spst		PSPRINT="$LP"
3918099Spst	fi
4018099Spstfi
4118099SpstAC_SUBST(PSPRINT)
4218099SpstAC_MSG_CHECKING([for command to use for printing PostScript files])
4318099SpstAC_MSG_RESULT($PSPRINT)
4418099Spst# Figure out DVIPRINT from PSPRINT.
4518099SpstAC_MSG_CHECKING([for command to use for printing dvi files])
4618099Spstif test -n "$PSPRINT" && test -z "$DVIPRINT"
4718099Spstthen
4818099Spst	if test "X$PSPRINT" = "Xlpr"
4918099Spst	then
5018099Spst		DVIPRINT="lpr -d"
5118099Spst	else
5218099Spst		DVIPRINT="$PSPRINT"
5318099Spst	fi
5418099Spstfi
5518099SpstAC_SUBST(DVIPRINT)
5618099SpstAC_MSG_RESULT($DVIPRINT)])dnl
5718099Spstdnl Bison generated parsers have problems with C++ compilers other than g++.
5818099Spstdnl So byacc is preferred over bison.
5918099SpstAC_DEFUN(GROFF_PROG_YACC,
6018099Spst[AC_CHECK_PROGS(YACC, byacc 'bison -y', yacc)])
6118099Spstdnl GROFF_CSH_HACK(if hack present, if not present)
6218099SpstAC_DEFUN(GROFF_CSH_HACK,
6318099Spst[AC_MSG_CHECKING([for csh hash hack])
6418099Spstcat <<EOF >conftest.sh
6518099Spst#!/bin/sh
6618099Spsttrue || exit 0
6718099Spstexport PATH || exit 0
6818099Spstexit 1
6918099SpstEOF
7018099Spstchmod +x conftest.sh
7118099Spstif echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1
7218099Spstthen
7318099Spst	AC_MSG_RESULT(yes); $1
7418099Spstelse
7518099Spst	AC_MSG_RESULT(no); $2
7618099Spstfi
7718099Spstrm -f conftest.sh
7818099Spst])dnl
7918099Spstdnl From udodo!hans@relay.NL.net (Hans Zuidam)
8018099SpstAC_DEFUN(GROFF_ISC_SYSV3,
8118099Spst[AC_MSG_CHECKING([for ISC 3.x or 4.x])
8218099Spstchangequote(,)dnl
8318099Spstif grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
8418099Spstchangequote([,])dnl
8518099Spstthen
8618099Spst	AC_MSG_RESULT(yes)
8718099Spst	AC_DEFINE(_SYSV3)
8818099Spstelse
8918099Spst	AC_MSG_RESULT(no)
9018099Spstfi])dnl
9118099SpstAC_DEFUN(GROFF_POSIX,
9218099Spst[AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
9318099SpstAC_LANG_SAVE
9418099SpstAC_LANG_CPLUSPLUS
9518099SpstAC_TRY_COMPILE([#include <stdio.h>
9618099Spstextern "C" { void fileno(int); }],,
9718099SpstAC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE),
9818099SpstAC_MSG_RESULT(no))
9918099SpstAC_LANG_RESTORE])dnl
10018099SpstAC_DEFUN(GROFF_GETOPT,
10118099Spst[AC_LANG_SAVE
10218099SpstAC_LANG_CPLUSPLUS
10318099SpstAC_MSG_CHECKING([declaration of getopt in stdlib.h])
10418099SpstAC_TRY_COMPILE(
10518099Spst[#include <stdlib.h>
10618099Spstextern "C" { void getopt(int); }],,AC_MSG_RESULT(no),
10718099SpstAC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_GETOPT))
10818099SpstAC_MSG_CHECKING([declaration of getopt in unistd.h])
10918099SpstAC_TRY_COMPILE([#include <sys/types.h>
11018099Spst#include <unistd.h>
11118099Spstextern "C" { void getopt(int); }],,AC_MSG_RESULT(no),
11218099SpstAC_MSG_RESULT(yes);AC_DEFINE(UNISTD_H_DECLARES_GETOPT))
11318099SpstAC_LANG_RESTORE])dnl
11418099SpstAC_DEFUN(GROFF_PUTENV,
11518099Spst[AC_LANG_SAVE
11618099SpstAC_LANG_CPLUSPLUS
11718099SpstAC_MSG_CHECKING([declaration of putenv])
11818099SpstAC_TRY_COMPILE([#include <stdlib.h>
11918099Spstextern "C" { void putenv(int); }],,AC_MSG_RESULT(no),
12018099SpstAC_MSG_RESULT(yes)
12118099SpstAC_DEFINE(STDLIB_H_DECLARES_PUTENV))
12218099SpstAC_LANG_RESTORE])dnl
12318099SpstAC_DEFUN(GROFF_POPEN,
12418099Spst[AC_LANG_SAVE
12518099SpstAC_LANG_CPLUSPLUS
12618099SpstAC_MSG_CHECKING([declaration of popen])
12718099SpstAC_TRY_COMPILE([#include <stdio.h>
12818099Spstextern "C" { void popen(int); }],,AC_MSG_RESULT(no),
12918099SpstAC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_POPEN))
13018099SpstAC_LANG_RESTORE])dnl
13118099SpstAC_DEFUN(GROFF_PCLOSE,
13218099Spst[AC_LANG_SAVE
13318099SpstAC_LANG_CPLUSPLUS
13418099SpstAC_MSG_CHECKING([declaration of pclose])
13518099SpstAC_TRY_COMPILE([#include <stdio.h>
13618099Spstextern "C" { void pclose(int); }],,AC_MSG_RESULT(no),
13718099SpstAC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_PCLOSE))
13818099SpstAC_LANG_RESTORE])dnl
13918099SpstAC_DEFUN(GROFF_OSFCN_H,
14018099Spst[AC_LANG_SAVE
14118099SpstAC_LANG_CPLUSPLUS
14218099SpstAC_MSG_CHECKING([C++ <osfcn.h>])
14318099SpstAC_TRY_COMPILE([#include <osfcn.h>],
14418099Spst[read(0, 0, 0); open(0, 0);],AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
14518099SpstAC_MSG_RESULT(no))
14618099SpstAC_LANG_RESTORE])dnl
14718099SpstAC_DEFUN(GROFF_LIMITS_H,
14818099Spst[AC_LANG_SAVE
14918099SpstAC_LANG_CPLUSPLUS
15018099SpstAC_MSG_CHECKING([C++ <limits.h>])
15118099SpstAC_TRY_COMPILE([#include <limits.h>],
15218099Spst[int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
15318099SpstAC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),AC_MSG_RESULT(no))
15418099SpstAC_LANG_RESTORE])dnl
15518099SpstAC_DEFUN(GROFF_TIME_T,
15618099Spst[AC_LANG_SAVE
15718099SpstAC_LANG_CPLUSPLUS
15818099SpstAC_MSG_CHECKING([for declaration of time_t])
15918099SpstAC_TRY_COMPILE([#include <time.h>],
16018099Spst[time_t t = time(0); struct tm *p = localtime(&t);],AC_MSG_RESULT(yes),
16118099SpstAC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
16218099SpstAC_LANG_RESTORE])dnl
16318099SpstAC_DEFUN(GROFF_STRUCT_EXCEPTION,
16418099Spst[AC_MSG_CHECKING([struct exception])
16518099SpstAC_TRY_COMPILE([#include <math.h>],
16618099Spst[struct exception e;],
16718099SpstAC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
16818099SpstAC_MSG_RESULT(no))])dnl
16918099SpstAC_DEFUN(GROFF_ARRAY_DELETE,
17018099Spst[AC_LANG_SAVE
17118099SpstAC_LANG_CPLUSPLUS
17218099SpstAC_MSG_CHECKING([whether ANSI array delete syntax supported])
17318099SpstAC_TRY_COMPILE(,
17418099Spstchangequote(,)dnl
17518099Spstchar *p = new char[5]; delete [] p;changequote([,]),
17618099SpstAC_MSG_RESULT(yes),AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
17718099SpstAC_LANG_RESTORE])dnl
17818099Spstdnl
17918099SpstAC_DEFUN(GROFF_TRADITIONAL_CPP,
18018099Spst[AC_LANG_SAVE
18118099SpstAC_LANG_CPLUSPLUS
18218099SpstAC_MSG_CHECKING([traditional preprocessor])
18318099SpstAC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
18418099SpstAC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
18518099SpstAC_MSG_RESULT(no))
18618099SpstAC_LANG_RESTORE])dnl
18718099Spst
18818099SpstAC_DEFUN(GROFF_WCOREFLAG,
18918099Spst[AC_MSG_CHECKING([w_coredump])
19018099SpstAC_TRY_RUN([
19118099Spst#include <sys/types.h>
19218099Spst#include <sys/wait.h>
19318099Spstmain()
19418099Spst{
19518099Spst#ifdef WCOREFLAG
19618099Spst  exit(1);
19718099Spst#else
19818099Spst  int i = 0;
19918099Spst  ((union wait *)&i)->w_coredump = 1;
20018099Spst  exit(i != 0200);
20118099Spst#endif
20218099Spst}
20318099Spst],AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),AC_MSG_RESULT(no),
20418099SpstAC_MSG_RESULT(no))])dnl
20518099Spstdnl
20618099SpstAC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
20718099Spst[AC_MSG_CHECKING([default value for grops -b option])
20818099Spsttest -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
20918099SpstAC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
21018099SpstAC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
21118099Spstdnl
21218099SpstAC_DEFUN(GROFF_PAGE,
21318099Spst[AC_MSG_CHECKING([default paper size])
21418099Spstif test -z "$PAGE"
21518099Spstthen
21618099Spst	descfile=
21718099Spst	if test -r $prefix/share/groff/font/devps/DESC
21818099Spst	then
21918099Spst		descfile=$prefix/share/groff/font/devps/DESC
22018099Spst	elif test -r $prefix/lib/groff/font/devps/DESC
22118099Spst	then
22218099Spst		descfile=$prefix/lib/groff/font/devps/DESC
22318099Spst	fi
22418099Spst	if test -n "$descfile" \
22518099Spst	  && grep "^paperlength 841890" $descfile >/dev/null 2>&1
22618099Spst	then
22718099Spst		PAGE=A4
22818099Spst	else
22918099Spst		PAGE=letter
23018099Spst	fi
23118099Spstfi
23218099Spstif test -z "$PAGE"
23318099Spstthen
23418099Spst	dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
23518099Spst	    /etc/resolv.conf 2>/dev/null`
23618099Spst
23718099Spst	if test -z "$dom"
23818099Spst	then
23918099Spst		dom=`(domainname) 2>/dev/null | tr -d '+'`
24018099Spst		if test -z "$dom"
24118099Spst		then
24218099Spst			dom=`(hostname) 2>/dev/null | grep '\.'`
24318099Spst		fi
24418099Spst	fi
24518099Spst
24618099Spstchangequote(,)dnl
24718099Spst	# If the top-level domain is two letters and it's not `us' or `ca'
24818099Spst	# then they probably use A4 paper.
24918099Spst	case "$dom" in
25018099Spst	*.[Uu][Ss]|*.[Cc][Aa]) ;;
25118099Spst	*.[A-Za-z][A-Za-z]) PAGE=A4 ;;
25218099Spst	esac
25318099Spstchangequote([,])dnl
25418099Spstfi
25518099Spsttest -n "$PAGE" || PAGE=letter
25618099SpstAC_MSG_RESULT($PAGE)
25718099SpstAC_SUBST(PAGE)])dnl
25818099Spstdnl
25918099SpstAC_DEFUN(GROFF_CXX_CHECK,
26018099Spst[AC_REQUIRE([AC_C_CROSS])
26118099SpstAC_REQUIRE([AC_PROG_CXX])
26218099SpstAC_LANG_SAVE
26318099SpstAC_LANG_CPLUSPLUS
26418099Spstif test "$cross_compiling" = no; then
26518099SpstAC_MSG_CHECKING([that C++ compiler can compile simple program])
26618099Spstfi
26718099SpstAC_TRY_RUN([int main() { return 0; }],
26818099SpstAC_MSG_RESULT(yes),
26918099SpstAC_MSG_RESULT(no)
27018099SpstAC_MSG_ERROR([a working C++ compiler is required]),:)
27118099Spstif test "$cross_compiling" = no; then
27218099SpstAC_MSG_CHECKING([that C++ static constructors and destructors are called])
27318099Spstfi
27418099SpstAC_TRY_RUN([
27518099Spstextern "C" {
27618099Spst  void _exit(int);
27718099Spst}
27818099Spstint i;
27918099Spststruct A {
28018099Spst  char dummy;
28118099Spst  A() { i = 1; }
28218099Spst  ~A() { if (i == 1) _exit(0); }
28318099Spst};
28418099SpstA a;
28518099Spstint main() { return 1; }
28618099Spst],
28718099SpstAC_MSG_RESULT(yes),
28818099SpstAC_MSG_RESULT(no)
28918099SpstAC_MSG_ERROR([a working C++ compiler is required]),:)
29018099SpstAC_MSG_CHECKING([that header files support C++])
29118099SpstAC_TRY_LINK([#include <stdio.h>],
29218099Spst[fopen(0, 0);],AC_MSG_RESULT(yes),
29318099SpstAC_MSG_RESULT(no)
29418099SpstAC_MSG_ERROR([header files do not support C++ (if you are using a version of gcc/g++ earlier than 2.5, you should install libg++)]))
29518099SpstAC_LANG_RESTORE
29618099Spst])dnl
29718099Spstdnl
29818099SpstAC_DEFUN(GROFF_TMAC,
29918099Spst[
30018099SpstAC_MSG_CHECKING([for prefix of system macro packages])
30118099Spstsys_tmac_prefix=
30218099Spstsys_tmac_file_prefix=
30318099Spstfor d in /usr/share/lib/tmac /usr/lib/tmac
30418099Spstdo
30518099Spst	for t in "" tmac.
30618099Spst	do
30718099Spst		for m in an s m
30818099Spst		do
30918099Spst			f=$d/$t$m
31018099Spst			if test -z "$sys_tmac_prefix" \
31118099Spst			  && test -f $f \
31218099Spst			  && grep '^\.if' $f >/dev/null 2>&1
31318099Spst			then
31418099Spst				sys_tmac_prefix=$d/$t
31518099Spst				sys_tmac_file_prefix=$t
31618099Spst			fi
31718099Spst		done
31818099Spst	done
31918099Spstdone
32018099SpstAC_MSG_RESULT($sys_tmac_prefix)
32118099SpstAC_SUBST(sys_tmac_prefix)
32218099Spsttmac_wrap=
32318099SpstAC_MSG_CHECKING([which system macro packages should be made available])
32418099Spstif test "x$sys_tmac_file_prefix" = "xtmac."
32518099Spstthen
32618099Spst	for f in $sys_tmac_prefix*
32718099Spst	do
32818099Spst		suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
32918099Spst		case "$suff" in
33018099Spst		e);;
33118099Spst		*)
33218099Spst		grep "Copyright.*Free Software Foundation" $f >/dev/null \
33318099Spst		  || tmac_wrap="$tmac_wrap $suff"
33418099Spst		;;
33518099Spst		esac 
33618099Spst	done
33718099Spstelif test -n "$sys_tmac_prefix"
33818099Spstthen
33918099Spst	files=`echo $sys_tmac_prefix*`
34018099Spst	grep "\\.so" $files >conftest.sol
34118099Spst	for f in $files
34218099Spst	do
34318099Spst		case "$f" in
34418099Spst		${sys_tmac_prefix}e) ;;
34518099Spst		*.me) ;;
34618099Spst		*/ms.*) ;;
34718099Spst		*)
34818099Spst		b=`basename $f`
34918099Spst		if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
35018099Spst		  || grep -l "Copyright.*Free Software Foundation" $f >/dev/null
35118099Spst		then
35218099Spst			:
35318099Spst		else
35418099Spst			suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
35518099Spst			case "$suff" in
35618099Spst			tmac.*);;
35718099Spst			*) tmac_wrap="$tmac_wrap $suff" ;;
35818099Spst			esac
35918099Spst		fi
36018099Spst		esac
36118099Spst	done
36218099Spst	rm -f conftest.sol
36318099Spstfi
36418099SpstAC_MSG_RESULT([$tmac_wrap])
36518099SpstAC_SUBST(tmac_wrap)
36618099Spst])dnl
36718099SpstAC_DEFUN(GROFF_G,
36818099Spst[AC_MSG_CHECKING([for existing troff installation])
36918099Spstif test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" \
37018099Spst  = x0
37118099Spstthen
37218099Spst	AC_MSG_RESULT(yes)
37318099Spst	g=g
37418099Spstelse
37518099Spst	AC_MSG_RESULT(no)
37618099Spst	g=
37718099Spstfi
37818099SpstAC_SUBST(g)
37918099Spst])dnl
38018099Spstdnl We need the path to install-sh to be absolute.
38118099SpstAC_DEFUN(GROFF_INSTALL_SH,
38218099Spst[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
38318099Spstac_dir=`cd $ac_aux_dir; pwd`
38418099Spstac_install_sh="$ac_dir/install-sh -c"
38518099Spst])
386