aclocal.m4 revision 55839
1dnl Autoconf macros for groff. 2dnl Copyright (C) 1989, 1990, 1991, 1992, 1995 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)]) 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 106AC_DEFUN(GROFF_GETOPT, 107[AC_LANG_SAVE 108AC_LANG_CPLUSPLUS 109AC_MSG_CHECKING([declaration of getopt in stdlib.h]) 110AC_TRY_COMPILE([#include <stdlib.h> 111extern "C" { void getopt(int); }],, 112AC_MSG_RESULT(no), 113AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_GETOPT)) 114AC_MSG_CHECKING([declaration of getopt in unistd.h]) 115AC_TRY_COMPILE([#include <sys/types.h> 116#include <unistd.h> 117extern "C" { void getopt(int); }],, 118AC_MSG_RESULT(no), 119AC_MSG_RESULT(yes);AC_DEFINE(UNISTD_H_DECLARES_GETOPT)) 120AC_LANG_RESTORE])dnl 121dnl 122dnl 123AC_DEFUN(GROFF_PUTENV, 124[AC_LANG_SAVE 125AC_LANG_CPLUSPLUS 126AC_MSG_CHECKING([declaration of putenv]) 127AC_TRY_COMPILE([#include <stdlib.h> 128extern "C" { void putenv(int); }],, 129AC_MSG_RESULT(no), 130AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_PUTENV)) 131AC_LANG_RESTORE])dnl 132dnl 133dnl 134AC_DEFUN(GROFF_POPEN, 135[AC_LANG_SAVE 136AC_LANG_CPLUSPLUS 137AC_MSG_CHECKING([declaration of popen]) 138AC_TRY_COMPILE([#include <stdio.h> 139extern "C" { void popen(int); }],, 140AC_MSG_RESULT(no), 141AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_POPEN)) 142AC_LANG_RESTORE])dnl 143dnl 144dnl 145AC_DEFUN(GROFF_PCLOSE, 146[AC_LANG_SAVE 147AC_LANG_CPLUSPLUS 148AC_MSG_CHECKING([declaration of pclose]) 149AC_TRY_COMPILE([#include <stdio.h> 150extern "C" { void pclose(int); }],, 151AC_MSG_RESULT(no), 152AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_PCLOSE)) 153AC_LANG_RESTORE])dnl 154dnl 155dnl 156AC_DEFUN(GROFF_SYS_NERR, 157[AC_LANG_SAVE 158AC_LANG_CPLUSPLUS 159AC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>]) 160AC_TRY_COMPILE([#include <errno.h> 161#include <stdio.h>], 162[int k; k = sys_nerr;], 163AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR), 164AC_MSG_RESULT(no)) 165AC_LANG_RESTORE])dnl 166dnl 167dnl 168AC_DEFUN(GROFF_SYS_ERRLIST, 169[AC_LANG_SAVE 170AC_LANG_CPLUSPLUS 171AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>]) 172AC_TRY_COMPILE([#include <errno.h> 173#include <stdio.h>], 174[int k; k = (int)sys_errlist[0];], 175AC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST), 176AC_MSG_RESULT(no)) 177AC_LANG_RESTORE])dnl 178dnl 179dnl 180AC_DEFUN(GROFF_HYPOT, 181[AC_LANG_SAVE 182AC_LANG_CPLUSPLUS 183AC_MSG_CHECKING([declaration of hypot]) 184AC_TRY_COMPILE([#include <math.h> 185extern "C" { double hypot(double,double); }],, 186AC_MSG_RESULT(no), 187AC_MSG_RESULT(yes);AC_DEFINE(MATH_H_DECLARES_HYPOT)) 188AC_LANG_RESTORE])dnl 189dnl 190dnl 191AC_DEFUN(GROFF_OSFCN_H, 192[AC_LANG_SAVE 193AC_LANG_CPLUSPLUS 194AC_MSG_CHECKING([C++ <osfcn.h>]) 195AC_TRY_COMPILE([#include <osfcn.h>], 196[read(0, 0, 0); open(0, 0);], 197AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H), 198AC_MSG_RESULT(no)) 199AC_LANG_RESTORE])dnl 200dnl 201dnl 202AC_DEFUN(GROFF_LIMITS_H, 203[AC_LANG_SAVE 204AC_LANG_CPLUSPLUS 205AC_MSG_CHECKING([C++ <limits.h>]) 206AC_TRY_COMPILE([#include <limits.h>], 207[int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;], 208AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H), 209AC_MSG_RESULT(no)) 210AC_LANG_RESTORE])dnl 211dnl 212dnl 213AC_DEFUN(GROFF_TIME_T, 214[AC_LANG_SAVE 215AC_LANG_CPLUSPLUS 216AC_MSG_CHECKING([for declaration of time_t]) 217AC_TRY_COMPILE([#include <time.h>], 218[time_t t = time(0); struct tm *p = localtime(&t);], 219AC_MSG_RESULT(yes), 220AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T)) 221AC_LANG_RESTORE])dnl 222dnl 223dnl 224AC_DEFUN(GROFF_STRUCT_EXCEPTION, 225[AC_MSG_CHECKING([struct exception]) 226AC_TRY_COMPILE([#include <math.h>], 227[struct exception e;], 228AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION), 229AC_MSG_RESULT(no))])dnl 230dnl 231dnl 232AC_DEFUN(GROFF_ARRAY_DELETE, 233[AC_LANG_SAVE 234AC_LANG_CPLUSPLUS 235AC_MSG_CHECKING([whether ANSI array delete syntax supported]) 236AC_TRY_COMPILE(, 237changequote(,)dnl 238char *p = new char[5]; delete [] p;changequote([,]), 239AC_MSG_RESULT(yes), 240AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE)) 241AC_LANG_RESTORE])dnl 242dnl 243dnl 244dnl 245AC_DEFUN(GROFF_TRADITIONAL_CPP, 246[AC_LANG_SAVE 247AC_LANG_CPLUSPLUS 248AC_MSG_CHECKING([traditional preprocessor]) 249AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);], 250AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP), 251AC_MSG_RESULT(no)) 252AC_LANG_RESTORE])dnl 253dnl 254dnl 255AC_DEFUN(GROFF_WCOREFLAG, 256[AC_MSG_CHECKING([w_coredump]) 257AC_TRY_RUN([#include <sys/types.h> 258#include <sys/wait.h> 259main() 260{ 261#ifdef WCOREFLAG 262 exit(1); 263#else 264 int i = 0; 265 ((union wait *)&i)->w_coredump = 1; 266 exit(i != 0200); 267#endif 268}], 269AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200), 270AC_MSG_RESULT(no), 271AC_MSG_RESULT(no))])dnl 272dnl 273dnl 274AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS, 275[AC_MSG_CHECKING([default value for grops -b option]) 276test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7 277AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS) 278AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl 279dnl 280dnl 281AC_DEFUN(GROFF_PAGE, 282[AC_MSG_CHECKING([default paper size]) 283if test -z "$PAGE"; then 284 descfile= 285 if test -r $prefix/share/groff/font/devps/DESC; then 286 descfile=$prefix/share/groff/font/devps/DESC 287 elif test -r $prefix/lib/groff/font/devps/DESC; then 288 descfile=$prefix/lib/groff/font/devps/DESC 289 fi 290 if test -n "$descfile" \ 291 && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then 292 PAGE=A4 293 else 294 PAGE=letter 295 fi 296fi 297if test -z "$PAGE"; then 298 dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \ 299 /etc/resolv.conf 2>/dev/null` 300 if test -z "$dom"; then 301 dom=`(domainname) 2>/dev/null | tr -d '+'` 302 if test -z "$dom"; then 303 dom=`(hostname) 2>/dev/null | grep '\.'` 304 fi 305 fi 306changequote(,)dnl 307 # If the top-level domain is two letters and it's not `us' or `ca' 308 # then they probably use A4 paper. 309 case "$dom" in 310 *.[Uu][Ss]|*.[Cc][Aa]) ;; 311 *.[A-Za-z][A-Za-z]) PAGE=A4 ;; 312 esac 313changequote([,])dnl 314fi 315test -n "$PAGE" || PAGE=letter 316AC_MSG_RESULT($PAGE) 317AC_SUBST(PAGE)])dnl 318dnl 319dnl 320AC_DEFUN(GROFF_CXX_CHECK, 321[AC_REQUIRE([AC_C_CROSS]) 322AC_REQUIRE([AC_PROG_CXX]) 323AC_LANG_SAVE 324AC_LANG_CPLUSPLUS 325if test "$cross_compiling" = no; then 326 AC_MSG_CHECKING([that C++ compiler can compile simple program]) 327fi 328AC_TRY_RUN([int main() { return 0; }], 329AC_MSG_RESULT(yes), 330AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 331:) 332if test "$cross_compiling" = no; then 333 AC_MSG_CHECKING([that C++ static constructors and destructors are called]) 334fi 335AC_TRY_RUN([ 336extern "C" { 337 void _exit(int); 338} 339int i; 340struct A { 341 char dummy; 342 A() { i = 1; } 343 ~A() { if (i == 1) _exit(0); } 344}; 345A a; 346int main() { return 1; } 347], 348AC_MSG_RESULT(yes), 349AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 350:) 351AC_MSG_CHECKING([that header files support C++]) 352AC_TRY_LINK([#include <stdio.h>], 353[fopen(0, 0);], 354AC_MSG_RESULT(yes), 355AC_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++)])) 356AC_LANG_RESTORE 357])dnl 358dnl 359dnl 360AC_DEFUN(GROFF_TMAC, 361[AC_MSG_CHECKING([for prefix of system macro packages]) 362sys_tmac_prefix= 363sys_tmac_file_prefix= 364for d in /usr/share/lib/tmac /usr/lib/tmac; do 365 for t in "" tmac.; do 366 for m in an s m; do 367 f=$d/$t$m 368 if test -z "$sys_tmac_prefix" \ 369 && test -f $f \ 370 && grep '^\.if' $f >/dev/null 2>&1; then 371 sys_tmac_prefix=$d/$t 372 sys_tmac_file_prefix=$t 373 fi 374 done 375 done 376done 377AC_MSG_RESULT($sys_tmac_prefix) 378AC_SUBST(sys_tmac_prefix) 379tmac_wrap= 380AC_MSG_CHECKING([which system macro packages should be made available]) 381if test "x$sys_tmac_file_prefix" = "xtmac."; then 382 for f in $sys_tmac_prefix*; do 383 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 384 case "$suff" in 385 e) ;; 386 *) 387 grep "Copyright.*Free Software Foundation" $f >/dev/null \ 388 || tmac_wrap="$tmac_wrap $suff" ;; 389 esac 390 done 391elif test -n "$sys_tmac_prefix"; then 392 files=`echo $sys_tmac_prefix*` 393 grep "\\.so" $files >conftest.sol 394 for f in $files; do 395 case "$f" in 396 ${sys_tmac_prefix}e) ;; 397 *.me) ;; 398 */ms.*) ;; 399 *) 400 b=`basename $f` 401 if grep "\\.so.*/$b\$" conftest.sol >/dev/null \ 402 || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then 403 : 404 else 405 suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 406 case "$suff" in 407 tmac.*) ;; 408 *) tmac_wrap="$tmac_wrap $suff" ;; 409 esac 410 fi 411 esac 412 done 413 rm -f conftest.sol 414fi 415AC_MSG_RESULT([$tmac_wrap]) 416AC_SUBST(tmac_wrap) 417])dnl 418dnl 419dnl 420AC_DEFUN(GROFF_G, 421[AC_MSG_CHECKING([for existing troff installation]) 422if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then 423 AC_MSG_RESULT(yes) 424 g=g 425else 426 AC_MSG_RESULT(no) 427 g= 428fi 429AC_SUBST(g) 430])dnl 431dnl 432dnl 433dnl We need the path to install-sh to be absolute. 434dnl 435AC_DEFUN(GROFF_INSTALL_SH, 436[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 437ac_dir=`cd $ac_aux_dir; pwd` 438ac_install_sh="$ac_dir/install-sh -c" 439])dnl 440dnl 441dnl 442dnl At least one UNIX system, Apple Macintosh Rhapsody 5.5, 443dnl does not have -lm. 444dnl 445AC_DEFUN(GROFF_LIBM, 446[AC_CHECK_LIB(m,sin,LIBM=-lm) 447AC_SUBST(LIBM) 448]) 449