aclocal.m4 revision 79543
1dnl Autoconf macros for groff. 2dnl Copyright (C) 1989-1995, 2001 Free Software Foundation, Inc. 3dnl 4dnl This file is part of groff. 5dnl 6dnl groff is free software; you can redistribute it and/or modify it under 7dnl the terms of the GNU General Public License as published by the Free 8dnl Software Foundation; either version 2, or (at your option) any later 9dnl version. 10dnl 11dnl groff is distributed in the hope that it will be useful, but WITHOUT ANY 12dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or 13dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14dnl for more details. 15dnl 16dnl You should have received a copy of the GNU General Public License along 17dnl with groff; see the file COPYING. If not, write to the Free Software 18dnl Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19dnl 20dnl 21AC_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 37fi 38AC_SUBST(PSPRINT) 39AC_MSG_CHECKING([for command to use for printing PostScript files]) 40AC_MSG_RESULT($PSPRINT) 41# Figure out DVIPRINT from PSPRINT. 42AC_MSG_CHECKING([for command to use for printing dvi files]) 43if test -n "$PSPRINT" && test -z "$DVIPRINT"; then 44 if test "X$PSPRINT" = "Xlpr"; then 45 DVIPRINT="lpr -d" 46 else 47 DVIPRINT="$PSPRINT" 48 fi 49fi 50AC_SUBST(DVIPRINT) 51AC_MSG_RESULT($DVIPRINT)])dnl 52dnl 53dnl 54dnl Bison generated parsers have problems with C++ compilers other than g++. 55dnl So byacc is preferred over bison. 56dnl 57AC_DEFUN(GROFF_PROG_YACC, 58[AC_CHECK_PROGS(YACC, byacc 'bison -y', yacc)])dnl 59dnl 60dnl 61dnl GROFF_CSH_HACK(if hack present, if not present) 62dnl 63AC_DEFUN(GROFF_CSH_HACK, 64[AC_MSG_CHECKING([for csh hash hack]) 65cat <<EOF >conftest.sh 66#!/bin/sh 67true || exit 0 68export PATH || exit 0 69exit 1 70EOF 71chmod +x conftest.sh 72if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then 73 AC_MSG_RESULT(yes); $1 74else 75 AC_MSG_RESULT(no); $2 76fi 77rm -f conftest.sh])dnl 78dnl 79dnl 80dnl From udodo!hans@relay.NL.net (Hans Zuidam) 81dnl 82AC_DEFUN(GROFF_ISC_SYSV3, 83[AC_MSG_CHECKING([for ISC 3.x or 4.x]) 84changequote(,)dnl 85if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1 86changequote([,])dnl 87then 88 AC_MSG_RESULT(yes) 89 AC_DEFINE(_SYSV3) 90else 91 AC_MSG_RESULT(no) 92fi])dnl 93dnl 94dnl 95AC_DEFUN(GROFF_POSIX, 96[AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary]) 97AC_LANG_PUSH(C++) 98AC_TRY_COMPILE([#include <stdio.h> 99extern "C" { void fileno(int); }],, 100AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE), 101AC_MSG_RESULT(no)) 102AC_LANG_POP(C++)])dnl 103dnl 104dnl 105dnl srand() of SunOS 4.1.3 has return type int instead of void 106dnl 107AC_DEFUN(GROFF_SRAND, 108[AC_LANG_PUSH(C++) 109AC_MSG_CHECKING([for return type of srand]) 110AC_TRY_COMPILE([#include <stdlib.h> 111extern "C" { void srand(unsigned int); }],, 112AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID), 113AC_MSG_RESULT(int)) 114AC_LANG_POP(C++)])dnl 115dnl 116dnl 117AC_DEFUN(GROFF_SYS_NERR, 118[AC_LANG_PUSH(C++) 119AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>]) 120AC_TRY_COMPILE([#include <errno.h> 121#include <stdio.h>], 122[int k; k = sys_nerr;], 123AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR), 124AC_MSG_RESULT(no)) 125AC_LANG_POP(C++)])dnl 126dnl 127dnl 128AC_DEFUN(GROFF_SYS_ERRLIST, 129[AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>]) 130AC_TRY_COMPILE([#include <errno.h> 131#include <stdio.h>], 132[int k; k = (int)sys_errlist[0];], 133AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST), 134AC_MSG_RESULT(no))])dnl 135dnl 136dnl 137AC_DEFUN(GROFF_OSFCN_H, 138[AC_LANG_PUSH(C++) 139AC_MSG_CHECKING([C++ <osfcn.h>]) 140AC_TRY_COMPILE([#include <osfcn.h>], 141[read(0, 0, 0); open(0, 0);], 142AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H), 143AC_MSG_RESULT(no)) 144AC_LANG_POP(C++)])dnl 145dnl 146dnl 147AC_DEFUN(GROFF_LIMITS_H, 148[AC_LANG_PUSH(C++) 149AC_MSG_CHECKING([C++ <limits.h>]) 150AC_TRY_COMPILE([#include <limits.h>], 151[int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;], 152AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H), 153AC_MSG_RESULT(no)) 154AC_LANG_POP(C++)])dnl 155dnl 156dnl 157AC_DEFUN(GROFF_TIME_T, 158[AC_LANG_PUSH(C++) 159AC_MSG_CHECKING([for declaration of time_t]) 160AC_TRY_COMPILE([#include <time.h>], 161[time_t t = time(0); struct tm *p = localtime(&t);], 162AC_MSG_RESULT(yes), 163AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T)) 164AC_LANG_POP(C++)])dnl 165dnl 166dnl 167AC_DEFUN(GROFF_STRUCT_EXCEPTION, 168[AC_MSG_CHECKING([struct exception]) 169AC_TRY_COMPILE([#include <math.h>], 170[struct exception e;], 171AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION), 172AC_MSG_RESULT(no))])dnl 173dnl 174dnl 175AC_DEFUN(GROFF_ARRAY_DELETE, 176[AC_LANG_PUSH(C++) 177AC_MSG_CHECKING([whether ANSI array delete syntax supported]) 178AC_TRY_COMPILE(, 179changequote(,)dnl 180char *p = new char[5]; delete [] p;changequote([,]), 181AC_MSG_RESULT(yes), 182AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE)) 183AC_LANG_POP(C++)])dnl 184dnl 185dnl 186dnl 187AC_DEFUN(GROFF_TRADITIONAL_CPP, 188[AC_LANG_PUSH(C++) 189AC_MSG_CHECKING([traditional preprocessor]) 190AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);], 191AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP), 192AC_MSG_RESULT(no)) 193AC_LANG_POP(C++)])dnl 194dnl 195dnl 196AC_DEFUN(GROFF_WCOREFLAG, 197[AC_MSG_CHECKING([w_coredump]) 198AC_TRY_RUN([#include <sys/types.h> 199#include <sys/wait.h> 200main() 201{ 202#ifdef WCOREFLAG 203 exit(1); 204#else 205 int i = 0; 206 ((union wait *)&i)->w_coredump = 1; 207 exit(i != 0200); 208#endif 209}], 210AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200), 211AC_MSG_RESULT(no), 212AC_MSG_RESULT(no))])dnl 213dnl 214dnl 215AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS, 216[AC_MSG_CHECKING([default value for grops -b option]) 217test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7 218AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS) 219AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl 220dnl 221dnl 222AC_DEFUN(GROFF_PAGE, 223[AC_MSG_CHECKING([default paper size]) 224if test -z "$PAGE"; then 225 descfile= 226 if test -r $prefix/share/groff/font/devps/DESC; then 227 descfile=$prefix/share/groff/font/devps/DESC 228 elif test -r $prefix/lib/groff/font/devps/DESC; then 229 descfile=$prefix/lib/groff/font/devps/DESC 230 else 231 for f in $prefix/share/groff/*/font/devps/DESC; do 232 if test -r $f; then 233 descfile=$f 234 break 235 fi 236 done 237 fi 238 if test -n "$descfile" \ 239 && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then 240 PAGE=A4 241 fi 242fi 243if test -z "$PAGE"; then 244 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \ 245 /etc/resolv.conf 2>/dev/null` 246 if test -z "$dom"; then 247 dom=`(domainname) 2>/dev/null | tr -d '+'` 248 if test -z "$dom" \ 249 || test "$dom" = '(none)'; then 250 dom=`(hostname) 2>/dev/null | grep '\.'` 251 fi 252 fi 253changequote(,)dnl 254 # If the top-level domain is two letters and it's not `us' or `ca' 255 # then they probably use A4 paper. 256 case "$dom" in 257 *.[Uu][Ss]|*.[Cc][Aa]) ;; 258 *.[A-Za-z][A-Za-z]) PAGE=A4 ;; 259 esac 260changequote([,])dnl 261fi 262test -n "$PAGE" || PAGE=letter 263AC_MSG_RESULT($PAGE) 264AC_SUBST(PAGE)])dnl 265dnl 266dnl 267AC_DEFUN(GROFF_CXX_CHECK, 268[AC_REQUIRE([AC_PROG_CXX]) 269AC_LANG_PUSH(C++) 270if test "$cross_compiling" = no; then 271 AC_MSG_CHECKING([that C++ compiler can compile simple program]) 272fi 273AC_TRY_RUN([int main() { return 0; }], 274AC_MSG_RESULT(yes), 275AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 276:) 277if test "$cross_compiling" = no; then 278 AC_MSG_CHECKING([that C++ static constructors and destructors are called]) 279fi 280AC_TRY_RUN([ 281extern "C" { 282 void _exit(int); 283} 284int i; 285struct A { 286 char dummy; 287 A() { i = 1; } 288 ~A() { if (i == 1) _exit(0); } 289}; 290A a; 291int main() { return 1; } 292], 293AC_MSG_RESULT(yes), 294AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 295:) 296AC_MSG_CHECKING([that header files support C++]) 297AC_TRY_LINK([#include <stdio.h>], 298[fopen(0, 0);], 299AC_MSG_RESULT(yes), 300AC_MSG_RESULT(no);AC_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++)])) 301AC_LANG_POP(C++)])dnl 302dnl 303dnl 304AC_DEFUN(GROFF_TMAC, 305[AC_MSG_CHECKING([for prefix of system macro packages]) 306sys_tmac_prefix= 307sys_tmac_file_prefix= 308for d in /usr/share/lib/tmac /usr/lib/tmac; do 309 for t in "" tmac.; do 310 for m in an s m; do 311 f=$d/$t$m 312 if test -z "$sys_tmac_prefix" \ 313 && test -f $f \ 314 && grep '^\.if' $f >/dev/null 2>&1; then 315 sys_tmac_prefix=$d/$t 316 sys_tmac_file_prefix=$t 317 fi 318 done 319 done 320done 321AC_MSG_RESULT($sys_tmac_prefix) 322AC_SUBST(sys_tmac_prefix) 323tmac_wrap= 324AC_MSG_CHECKING([which system macro packages should be made available]) 325if test "x$sys_tmac_file_prefix" = "xtmac."; then 326 for f in $sys_tmac_prefix*; do 327 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 328 case "$suff" in 329 e) ;; 330 *) 331 grep "Copyright.*Free Software Foundation" $f >/dev/null \ 332 || tmac_wrap="$tmac_wrap $suff" ;; 333 esac 334 done 335elif test -n "$sys_tmac_prefix"; then 336 files=`echo $sys_tmac_prefix*` 337 grep "\\.so" $files >conftest.sol 338 for f in $files; do 339 case "$f" in 340 ${sys_tmac_prefix}e) ;; 341 *.me) ;; 342 */ms.*) ;; 343 *) 344 b=`basename $f` 345 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \ 346 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then 347 : 348 else 349 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 350 case "$suff" in 351 tmac.*) ;; 352 *) tmac_wrap="$tmac_wrap $suff" ;; 353 esac 354 fi 355 esac 356 done 357 rm -f conftest.sol 358fi 359AC_MSG_RESULT([$tmac_wrap]) 360AC_SUBST(tmac_wrap)])dnl 361dnl 362dnl 363AC_DEFUN(GROFF_G, 364[AC_MSG_CHECKING([for existing troff installation]) 365if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then 366 AC_MSG_RESULT(yes) 367 g=g 368else 369 AC_MSG_RESULT(no) 370 g= 371fi 372AC_SUBST(g)])dnl 373dnl 374dnl 375dnl We need the path to install-sh to be absolute. 376dnl 377AC_DEFUN(GROFF_INSTALL_SH, 378[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 379ac_dir=`cd $ac_aux_dir; pwd` 380ac_install_sh="$ac_dir/install-sh -c"])dnl 381dnl 382dnl 383dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5, 384dnl does not have -lm. 385dnl 386AC_DEFUN(GROFF_LIBM, 387[AC_CHECK_LIB(m,sin,LIBM=-lm) 388AC_SUBST(LIBM)])dnl 389dnl 390dnl 391dnl We need top_srcdir to be absolute. 392dnl 393AC_DEFUN(GROFF_SRCDIR, 394[ac_srcdir_defaulted=no 395srcdir=`cd $srcdir; pwd`])dnl 396dnl 397dnl 398dnl This simplifies Makefile rules. 399dnl 400AC_DEFUN(GROFF_BUILDDIR, 401[top_builddir=`pwd` 402AC_SUBST(top_builddir)])dnl 403dnl 404dnl 405dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port 406dnl 407AC_DEFUN(GROFF_EBCDIC, 408[AC_MSG_CHECKING([whether character set is EBCDIC]) 409AC_TRY_COMPILE(, 410[/* Treat any failure as ASCII for compatibility with existing art. 411 Use compile-time rather than run-time tests for cross-compiler 412 tolerance. */ 413#if '0' != 240 414make an error "Character set is not EBCDIC" 415#endif], 416groff_cv_ebcdic="yes" 417 TTYDEVDIRS="font/devcp1047" 418 AC_MSG_RESULT(yes) 419 AC_DEFINE(IS_EBCDIC_HOST), 420groff_cv_ebcdic="no" 421 TTYDEVDIRS="font/devascii font/devlatin1 font/devutf8" 422 AC_MSG_RESULT(no)) 423AC_SUBST(TTYDEVDIRS)])dnl 424dnl 425dnl 426dnl Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with 427dnl gcc) to OS/390 uses ASCII internally. 428dnl 429AC_DEFUN(GROFF_OS390, 430[if test "$groff_cv_ebcdic" = "yes"; then 431 AC_MSG_CHECKING([for OS/390 Unix]) 432 case `uname` in 433 OS/390) 434 CFLAGS="$CFLAGS -D_ALL_SOURCE" 435 AC_MSG_RESULT(yes) ;; 436 *) 437 AC_MSG_RESULT(no) ;; 438 esac 439fi])dnl 440dnl 441dnl 442dnl Check whether we need a declaration for a function. 443dnl 444dnl Stolen from GNU bfd. 445dnl 446AC_DEFUN(GROFF_NEED_DECLARATION, 447[AC_MSG_CHECKING([whether $1 must be declared]) 448AC_LANG_PUSH(C++) 449AC_CACHE_VAL(groff_cv_decl_needed_$1, 450[AC_TRY_COMPILE([ 451#include <stdio.h> 452#ifdef HAVE_STRING_H 453#include <string.h> 454#endif 455#ifdef HAVE_STRINGS_H 456#include <strings.h> 457#endif 458#ifdef HAVE_STDLIB_H 459#include <stdlib.h> 460#endif 461#ifdef HAVE_UNISTD_H 462#include <unistd.h> 463#endif 464#ifdef HAVE_MATH_H 465#include <math.h> 466#endif], 467[char *(*pfn) = (char *(*)) $1], 468groff_cv_decl_needed_$1=no, 469groff_cv_decl_needed_$1=yes)]) 470AC_MSG_RESULT($groff_cv_decl_needed_$1) 471if test $groff_cv_decl_needed_$1 = yes; then 472 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z])) 473fi 474AC_LANG_POP(C++)])dnl 475dnl 476dnl 477dnl Check for mkstemp() and its function prototype. 478dnl 479AC_DEFUN(GROFF_MKSTEMP, 480[AC_CHECK_FUNC(mkstemp, 481[AC_DEFINE(HAVE_MKSTEMP) 482AC_MSG_CHECKING([for mkstemp prototype in <stdlib.h>]) 483AC_EGREP_CPP(mkstemp, 484[#include <stdlib.h>], 485AC_MSG_RESULT(yes);AC_DEFINE(HAVE_MKSTEMP_PROTO), 486AC_MSG_RESULT(no))])]) 487