aclocal.m4 revision 75584
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_SAVE 98AC_LANG_CPLUSPLUS 99AC_TRY_COMPILE([#include <stdio.h> 100extern "C" { void fileno(int); }],, 101AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE), 102AC_MSG_RESULT(no)) 103AC_LANG_RESTORE])dnl 104dnl 105dnl 106dnl srand() of SunOS 4.1.3 has return type int instead of void 107dnl 108AC_DEFUN(GROFF_SRAND, 109[AC_LANG_SAVE 110AC_LANG_CPLUSPLUS 111AC_MSG_CHECKING([for return type of srand]) 112AC_TRY_COMPILE([#include <stdlib.h> 113extern "C" { void srand(unsigned int); }],, 114AC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID), 115AC_MSG_RESULT(int)) 116AC_LANG_RESTORE])dnl 117dnl 118dnl 119AC_DEFUN(GROFF_SYS_NERR, 120[AC_LANG_SAVE 121AC_LANG_CPLUSPLUS 122AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>]) 123AC_TRY_COMPILE([#include <errno.h> 124#include <stdio.h>], 125[int k; k = sys_nerr;], 126AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR), 127AC_MSG_RESULT(no)) 128AC_LANG_RESTORE])dnl 129dnl 130dnl 131AC_DEFUN(GROFF_SYS_ERRLIST, 132[AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>]) 133AC_TRY_COMPILE([#include <errno.h> 134#include <stdio.h>], 135[int k; k = (int)sys_errlist[0];], 136AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST), 137AC_MSG_RESULT(no))])dnl 138dnl 139dnl 140AC_DEFUN(GROFF_OSFCN_H, 141[AC_LANG_SAVE 142AC_LANG_CPLUSPLUS 143AC_MSG_CHECKING([C++ <osfcn.h>]) 144AC_TRY_COMPILE([#include <osfcn.h>], 145[read(0, 0, 0); open(0, 0);], 146AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H), 147AC_MSG_RESULT(no)) 148AC_LANG_RESTORE])dnl 149dnl 150dnl 151AC_DEFUN(GROFF_LIMITS_H, 152[AC_LANG_SAVE 153AC_LANG_CPLUSPLUS 154AC_MSG_CHECKING([C++ <limits.h>]) 155AC_TRY_COMPILE([#include <limits.h>], 156[int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;], 157AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H), 158AC_MSG_RESULT(no)) 159AC_LANG_RESTORE])dnl 160dnl 161dnl 162AC_DEFUN(GROFF_TIME_T, 163[AC_LANG_SAVE 164AC_LANG_CPLUSPLUS 165AC_MSG_CHECKING([for declaration of time_t]) 166AC_TRY_COMPILE([#include <time.h>], 167[time_t t = time(0); struct tm *p = localtime(&t);], 168AC_MSG_RESULT(yes), 169AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T)) 170AC_LANG_RESTORE])dnl 171dnl 172dnl 173AC_DEFUN(GROFF_STRUCT_EXCEPTION, 174[AC_MSG_CHECKING([struct exception]) 175AC_TRY_COMPILE([#include <math.h>], 176[struct exception e;], 177AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION), 178AC_MSG_RESULT(no))])dnl 179dnl 180dnl 181AC_DEFUN(GROFF_ARRAY_DELETE, 182[AC_LANG_SAVE 183AC_LANG_CPLUSPLUS 184AC_MSG_CHECKING([whether ANSI array delete syntax supported]) 185AC_TRY_COMPILE(, 186changequote(,)dnl 187char *p = new char[5]; delete [] p;changequote([,]), 188AC_MSG_RESULT(yes), 189AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE)) 190AC_LANG_RESTORE])dnl 191dnl 192dnl 193dnl 194AC_DEFUN(GROFF_TRADITIONAL_CPP, 195[AC_LANG_SAVE 196AC_LANG_CPLUSPLUS 197AC_MSG_CHECKING([traditional preprocessor]) 198AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);], 199AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP), 200AC_MSG_RESULT(no)) 201AC_LANG_RESTORE])dnl 202dnl 203dnl 204AC_DEFUN(GROFF_WCOREFLAG, 205[AC_MSG_CHECKING([w_coredump]) 206AC_TRY_RUN([#include <sys/types.h> 207#include <sys/wait.h> 208main() 209{ 210#ifdef WCOREFLAG 211 exit(1); 212#else 213 int i = 0; 214 ((union wait *)&i)->w_coredump = 1; 215 exit(i != 0200); 216#endif 217}], 218AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200), 219AC_MSG_RESULT(no), 220AC_MSG_RESULT(no))])dnl 221dnl 222dnl 223AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS, 224[AC_MSG_CHECKING([default value for grops -b option]) 225test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7 226AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS) 227AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl 228dnl 229dnl 230AC_DEFUN(GROFF_PAGE, 231[AC_MSG_CHECKING([default paper size]) 232if test -z "$PAGE"; then 233 descfile= 234 if test -r $prefix/share/groff/font/devps/DESC; then 235 descfile=$prefix/share/groff/font/devps/DESC 236 elif test -r $prefix/lib/groff/font/devps/DESC; then 237 descfile=$prefix/lib/groff/font/devps/DESC 238 else 239 for f in $prefix/share/groff/*/font/devps/DESC; do 240 if test -r $f; then 241 descfile=$f 242 break 243 fi 244 done 245 fi 246 if test -n "$descfile" \ 247 && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then 248 PAGE=A4 249 else 250 PAGE=letter 251 fi 252fi 253if test -z "$PAGE"; then 254 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \ 255 /etc/resolv.conf 2>/dev/null` 256 if test -z "$dom"; then 257 dom=`(domainname) 2>/dev/null | tr -d '+'` 258 if test -z "$dom"; then 259 dom=`(hostname) 2>/dev/null | grep '\.'` 260 fi 261 fi 262changequote(,)dnl 263 # If the top-level domain is two letters and it's not `us' or `ca' 264 # then they probably use A4 paper. 265 case "$dom" in 266 *.[Uu][Ss]|*.[Cc][Aa]) ;; 267 *.[A-Za-z][A-Za-z]) PAGE=A4 ;; 268 esac 269changequote([,])dnl 270fi 271test -n "$PAGE" || PAGE=letter 272AC_MSG_RESULT($PAGE) 273AC_SUBST(PAGE)])dnl 274dnl 275dnl 276AC_DEFUN(GROFF_CXX_CHECK, 277[AC_REQUIRE([AC_PROG_CXX]) 278AC_LANG_SAVE 279AC_LANG_CPLUSPLUS 280if test "$cross_compiling" = no; then 281 AC_MSG_CHECKING([that C++ compiler can compile simple program]) 282fi 283AC_TRY_RUN([int main() { return 0; }], 284AC_MSG_RESULT(yes), 285AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 286:) 287if test "$cross_compiling" = no; then 288 AC_MSG_CHECKING([that C++ static constructors and destructors are called]) 289fi 290AC_TRY_RUN([ 291extern "C" { 292 void _exit(int); 293} 294int i; 295struct A { 296 char dummy; 297 A() { i = 1; } 298 ~A() { if (i == 1) _exit(0); } 299}; 300A a; 301int main() { return 1; } 302], 303AC_MSG_RESULT(yes), 304AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 305:) 306AC_MSG_CHECKING([that header files support C++]) 307AC_TRY_LINK([#include <stdio.h>], 308[fopen(0, 0);], 309AC_MSG_RESULT(yes), 310AC_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++)])) 311AC_LANG_RESTORE])dnl 312dnl 313dnl 314AC_DEFUN(GROFF_TMAC, 315[AC_MSG_CHECKING([for prefix of system macro packages]) 316sys_tmac_prefix= 317sys_tmac_file_prefix= 318for d in /usr/share/lib/tmac /usr/lib/tmac; do 319 for t in "" tmac.; do 320 for m in an s m; do 321 f=$d/$t$m 322 if test -z "$sys_tmac_prefix" \ 323 && test -f $f \ 324 && grep '^\.if' $f >/dev/null 2>&1; then 325 sys_tmac_prefix=$d/$t 326 sys_tmac_file_prefix=$t 327 fi 328 done 329 done 330done 331AC_MSG_RESULT($sys_tmac_prefix) 332AC_SUBST(sys_tmac_prefix) 333tmac_wrap= 334AC_MSG_CHECKING([which system macro packages should be made available]) 335if test "x$sys_tmac_file_prefix" = "xtmac."; then 336 for f in $sys_tmac_prefix*; do 337 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 338 case "$suff" in 339 e) ;; 340 *) 341 grep "Copyright.*Free Software Foundation" $f >/dev/null \ 342 || tmac_wrap="$tmac_wrap $suff" ;; 343 esac 344 done 345elif test -n "$sys_tmac_prefix"; then 346 files=`echo $sys_tmac_prefix*` 347 grep "\\.so" $files >conftest.sol 348 for f in $files; do 349 case "$f" in 350 ${sys_tmac_prefix}e) ;; 351 *.me) ;; 352 */ms.*) ;; 353 *) 354 b=`basename $f` 355 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \ 356 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then 357 : 358 else 359 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 360 case "$suff" in 361 tmac.*) ;; 362 *) tmac_wrap="$tmac_wrap $suff" ;; 363 esac 364 fi 365 esac 366 done 367 rm -f conftest.sol 368fi 369AC_MSG_RESULT([$tmac_wrap]) 370AC_SUBST(tmac_wrap)])dnl 371dnl 372dnl 373AC_DEFUN(GROFF_G, 374[AC_MSG_CHECKING([for existing troff installation]) 375if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then 376 AC_MSG_RESULT(yes) 377 g=g 378else 379 AC_MSG_RESULT(no) 380 g= 381fi 382AC_SUBST(g)])dnl 383dnl 384dnl 385dnl We need the path to install-sh to be absolute. 386dnl 387AC_DEFUN(GROFF_INSTALL_SH, 388[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 389ac_dir=`cd $ac_aux_dir; pwd` 390ac_install_sh="$ac_dir/install-sh -c"])dnl 391dnl 392dnl 393dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5, 394dnl does not have -lm. 395dnl 396AC_DEFUN(GROFF_LIBM, 397[AC_CHECK_LIB(m,sin,LIBM=-lm) 398AC_SUBST(LIBM)])dnl 399dnl 400dnl 401dnl We need top_srcdir to be absolute. 402dnl 403AC_DEFUN(GROFF_SRCDIR, 404[ac_srcdir_defaulted=no 405srcdir=`cd $srcdir; pwd`])dnl 406dnl 407dnl 408dnl This simplifies Makefile rules. 409dnl 410AC_DEFUN(GROFF_BUILDDIR, 411[top_builddir=`pwd` 412AC_SUBST(top_builddir)])dnl 413dnl 414dnl 415dnl Check for EBCDIC - stolen from the OS390 Unix LYNX port 416dnl 417AC_DEFUN(GROFF_EBCDIC, 418[AC_MSG_CHECKING([whether character set is EBCDIC]) 419AC_TRY_COMPILE(, 420[/* Treat any failure as ASCII for compatibility with existing art. 421 Use compile-time rather than run-time tests for cross-compiler 422 tolerance. */ 423#if '0' != 240 424make an error "Character set is not EBCDIC" 425#endif], 426groff_cv_ebcdic="yes" 427 TTYDEVDIRS="font/devcp1047" 428 AC_MSG_RESULT(yes) 429 AC_DEFINE(IS_EBCDIC_HOST), 430groff_cv_ebcdic="no" 431 TTYDEVDIRS="font/devascii font/devlatin1 font/devutf8" 432 AC_MSG_RESULT(no)) 433AC_SUBST(TTYDEVDIRS)])dnl 434dnl 435dnl 436dnl Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with 437dnl gcc) to OS/390 uses ASCII internally. 438dnl 439AC_DEFUN(GROFF_OS390, 440[groff_cv_os390="no" 441if test "$groff_cv_ebcdic" = "yes"; then 442 AC_MSG_CHECKING([for OS/390 Unix]) 443 case `uname` in 444 OS/390) 445 CFLAGS="$CFLAGS -D_ALL_SOURCE" 446 groff_cv_os390="yes" 447 AC_MSG_RESULT(yes) ;; 448 *) 449 AC_MSG_RESULT(no) ;; 450 esac 451fi])dnl 452dnl 453dnl 454dnl Finally, we must modify a base function of autoconf to replace the 455dnl ASCII char `012' with its generic equivalent `\n' if we run under 456dnl OS/390 Unix -- unfortunately, not all `tr' variants understand `\n', 457dnl so this hack is necessary. 458dnl 459define([AC_OUTPUT_MAKE_DEFS], 460[# Transform confdefs.h into DEFS. 461dnl Using a here document instead of a string reduces the quoting nightmare. 462# Protect against shell expansion while executing Makefile rules. 463# Protect against Makefile macro expansion. 464cat > conftest.defs <<\EOF 465changequote(<<, >>)dnl 466s%<<#define>> \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g 467s%[ `~<<#>>$^&*(){}\\|;'"<>?]%\\&%g 468s%\[%\\&%g 469s%\]%\\&%g 470s%\$%$$%g 471changequote([, ])dnl 472EOF 473if test "$groff_cv_os390" = "yes"; then 474 DEFS=`sed -f conftest.defs confdefs.h | tr '\n' ' '` 475else 476 DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` 477fi 478rm -f conftest.defs 479])dnl 480dnl 481dnl 482dnl Check whether we need a declaration for a function. 483dnl 484dnl Stolen from GNU bfd. 485dnl 486AC_DEFUN(GROFF_NEED_DECLARATION, 487[AC_MSG_CHECKING([whether $1 must be declared]) 488AC_LANG_SAVE 489AC_LANG_CPLUSPLUS 490AC_CACHE_VAL(groff_cv_decl_needed_$1, 491[AC_TRY_COMPILE([ 492#include <stdio.h> 493#ifdef HAVE_STRING_H 494#include <string.h> 495#else 496#ifdef HAVE_STRINGS_H 497#include <strings.h> 498#endif 499#endif 500#ifdef HAVE_STDLIB_H 501#include <stdlib.h> 502#endif 503#ifdef HAVE_UNISTD_H 504#include <unistd.h> 505#endif 506#ifdef HAVE_MATH_H 507#include <math.h> 508#endif], 509[char *(*pfn) = (char *(*)) $1], 510groff_cv_decl_needed_$1=no, 511groff_cv_decl_needed_$1=yes)]) 512AC_MSG_RESULT($groff_cv_decl_needed_$1) 513if test $groff_cv_decl_needed_$1 = yes; then 514 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z])) 515fi 516AC_LANG_RESTORE])dnl 517