aclocal.m4 revision 104862
118099Spstdnl Autoconf macros for groff. 2104862Srudnl Copyright (C) 1989-1995, 2001, 2002 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 2055839Sasmodaidnl 2118099SpstAC_DEFUN(GROFF_PRINT, 2255839Sasmodai[if test -z "$PSPRINT"; then 2318099Spst AC_CHECK_PROGS(LPR,lpr) 2418099Spst AC_CHECK_PROGS(LP,lp) 2555839Sasmodai if test -n "$LPR" && test -n "$LP"; then 2618099Spst # HP-UX provides an lpr command that emulates lpr using lp, 2718099Spst # but it doesn't have lpq; in this case we want to use lp 2818099Spst # rather than lpr. 2918099Spst AC_CHECK_PROGS(LPQ,lpq) 3018099Spst test -n "$LPQ" || LPR= 3118099Spst fi 3255839Sasmodai if test -n "$LPR"; then 3318099Spst PSPRINT="$LPR" 3455839Sasmodai elif test -n "$LP"; then 3518099Spst PSPRINT="$LP" 3618099Spst fi 3718099Spstfi 3818099SpstAC_SUBST(PSPRINT) 3918099SpstAC_MSG_CHECKING([for command to use for printing PostScript files]) 4018099SpstAC_MSG_RESULT($PSPRINT) 4118099Spst# Figure out DVIPRINT from PSPRINT. 4218099SpstAC_MSG_CHECKING([for command to use for printing dvi files]) 4355839Sasmodaiif test -n "$PSPRINT" && test -z "$DVIPRINT"; then 4455839Sasmodai if test "X$PSPRINT" = "Xlpr"; then 4518099Spst DVIPRINT="lpr -d" 4618099Spst else 4718099Spst DVIPRINT="$PSPRINT" 4818099Spst fi 4918099Spstfi 5018099SpstAC_SUBST(DVIPRINT) 5118099SpstAC_MSG_RESULT($DVIPRINT)])dnl 5255839Sasmodaidnl 5355839Sasmodaidnl 5418099Spstdnl Bison generated parsers have problems with C++ compilers other than g++. 5518099Spstdnl So byacc is preferred over bison. 5655839Sasmodaidnl 5718099SpstAC_DEFUN(GROFF_PROG_YACC, 5869626Sru[AC_CHECK_PROGS(YACC, byacc 'bison -y', yacc)])dnl 5955839Sasmodaidnl 6055839Sasmodaidnl 61104862Srudnl The following programs are needed for grohtml. 62104862Srudnl 63104862SruAC_DEFUN(GROFF_HTML_PROGRAMS, 64104862Sru[make_html=html 65104862Srumake_install_html=install_html 66104862SruAC_CHECK_PROG(pnmcut, pnmcut, found, missing) 67104862SruAC_CHECK_PROG(pnmcrop, pnmcrop, found, missing) 68104862SruAC_CHECK_PROG(pnmtopng, pnmtopng, found, missing) 69104862SruAC_CHECK_PROG(gs, gs gsos2, found, missing) 70104862SruAC_CHECK_PROG(psselect, psselect, found, missing) 71104862Srucase "x$pnmcut$pnmcrop$pnmtopng$gs$psselect" in 72104862Sru*missing*) 73104862Sru make_html= 74104862Sru make_install_html= 75104862Sru AC_MSG_WARN([ 76104862Sru 77104862Sru Since one or more of the above five programs can't be found in the path, 78104862Sru the HTML backend of groff (grohtml) won't work properly. Consequently, 79104862Sru no documentation in HTML format is built and installed. 80104862Sru]) ;; 81104862Sruesac 82104862SruAC_SUBST(make_html) 83104862SruAC_SUBST(make_install_html)])dnl 84104862Srudnl 85104862Srudnl 8618099Spstdnl GROFF_CSH_HACK(if hack present, if not present) 8755839Sasmodaidnl 8818099SpstAC_DEFUN(GROFF_CSH_HACK, 8918099Spst[AC_MSG_CHECKING([for csh hash hack]) 9018099Spstcat <<EOF >conftest.sh 9118099Spst#!/bin/sh 9218099Spsttrue || exit 0 9318099Spstexport PATH || exit 0 9418099Spstexit 1 9518099SpstEOF 9618099Spstchmod +x conftest.sh 9755839Sasmodaiif echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1; then 9818099Spst AC_MSG_RESULT(yes); $1 9918099Spstelse 10018099Spst AC_MSG_RESULT(no); $2 10118099Spstfi 10255839Sasmodairm -f conftest.sh])dnl 10355839Sasmodaidnl 10455839Sasmodaidnl 10518099Spstdnl From udodo!hans@relay.NL.net (Hans Zuidam) 10655839Sasmodaidnl 10718099SpstAC_DEFUN(GROFF_ISC_SYSV3, 10818099Spst[AC_MSG_CHECKING([for ISC 3.x or 4.x]) 10918099Spstchangequote(,)dnl 11018099Spstif grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1 11118099Spstchangequote([,])dnl 11218099Spstthen 11318099Spst AC_MSG_RESULT(yes) 114104862Sru AC_DEFINE(_SYSV3, 1, 115104862Sru [Define if you have ISC 3.x or 4.x.]) 11618099Spstelse 11718099Spst AC_MSG_RESULT(no) 11818099Spstfi])dnl 11955839Sasmodaidnl 12055839Sasmodaidnl 12118099SpstAC_DEFUN(GROFF_POSIX, 12218099Spst[AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary]) 12379543SruAC_LANG_PUSH(C++) 12418099SpstAC_TRY_COMPILE([#include <stdio.h> 12518099Spstextern "C" { void fileno(int); }],, 126104862SruAC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE, 1, 127104862Sru [Define if -D_POSIX_SOURCE is necessary.]), 12818099SpstAC_MSG_RESULT(no)) 12979543SruAC_LANG_POP(C++)])dnl 13055839Sasmodaidnl 13155839Sasmodaidnl 13269626Srudnl srand() of SunOS 4.1.3 has return type int instead of void 13355839Sasmodaidnl 13469626SruAC_DEFUN(GROFF_SRAND, 13579543Sru[AC_LANG_PUSH(C++) 13669626SruAC_MSG_CHECKING([for return type of srand]) 13718099SpstAC_TRY_COMPILE([#include <stdlib.h> 13869626Sruextern "C" { void srand(unsigned int); }],, 139104862SruAC_MSG_RESULT(void);AC_DEFINE(RET_TYPE_SRAND_IS_VOID, 1, 140104862Sru [Define if srand() returns void not int.]), 14169626SruAC_MSG_RESULT(int)) 14279543SruAC_LANG_POP(C++)])dnl 14355839Sasmodaidnl 14455839Sasmodaidnl 14555839SasmodaiAC_DEFUN(GROFF_SYS_NERR, 14679543Sru[AC_LANG_PUSH(C++) 14755839SasmodaiAC_MSG_CHECKING([for sys_nerr in <errno.h> or <stdio.h>]) 14855839SasmodaiAC_TRY_COMPILE([#include <errno.h> 14955839Sasmodai#include <stdio.h>], 15055839Sasmodai[int k; k = sys_nerr;], 151104862SruAC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_NERR, 1, 152104862Sru [Define if you have sysnerr in <errno.h> or 153104862Sru <stdio.h>.]), 15455839SasmodaiAC_MSG_RESULT(no)) 15579543SruAC_LANG_POP(C++)])dnl 15655839Sasmodaidnl 15755839Sasmodaidnl 15855839SasmodaiAC_DEFUN(GROFF_SYS_ERRLIST, 15975584Sru[AC_MSG_CHECKING([for sys_errlist[] in <errno.h> or <stdio.h>]) 16055839SasmodaiAC_TRY_COMPILE([#include <errno.h> 16155839Sasmodai#include <stdio.h>], 16255839Sasmodai[int k; k = (int)sys_errlist[0];], 163104862SruAC_MSG_RESULT(yes);AC_DEFINE(HAVE_SYS_ERRLIST, 1, 164104862Sru [Define if you have sys_errlist in <errno.h> 165104862Sru or in <stdio.h>.]), 16675584SruAC_MSG_RESULT(no))])dnl 16755839Sasmodaidnl 16855839Sasmodaidnl 16918099SpstAC_DEFUN(GROFF_OSFCN_H, 17079543Sru[AC_LANG_PUSH(C++) 17118099SpstAC_MSG_CHECKING([C++ <osfcn.h>]) 17218099SpstAC_TRY_COMPILE([#include <osfcn.h>], 17355839Sasmodai[read(0, 0, 0); open(0, 0);], 174104862SruAC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H, 1, 175104862Sru [Define if you have a C++ <osfcn.h>.]), 17618099SpstAC_MSG_RESULT(no)) 17779543SruAC_LANG_POP(C++)])dnl 17855839Sasmodaidnl 17955839Sasmodaidnl 18018099SpstAC_DEFUN(GROFF_LIMITS_H, 18179543Sru[AC_LANG_PUSH(C++) 18218099SpstAC_MSG_CHECKING([C++ <limits.h>]) 18318099SpstAC_TRY_COMPILE([#include <limits.h>], 18418099Spst[int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;], 185104862SruAC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H, 1, 186104862Sru [Define if you have a C++ <limits.h>.]), 18755839SasmodaiAC_MSG_RESULT(no)) 18879543SruAC_LANG_POP(C++)])dnl 18955839Sasmodaidnl 19055839Sasmodaidnl 19118099SpstAC_DEFUN(GROFF_TIME_T, 19279543Sru[AC_LANG_PUSH(C++) 19318099SpstAC_MSG_CHECKING([for declaration of time_t]) 19418099SpstAC_TRY_COMPILE([#include <time.h>], 19555839Sasmodai[time_t t = time(0); struct tm *p = localtime(&t);], 19655839SasmodaiAC_MSG_RESULT(yes), 197104862SruAC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T, 1, 198104862Sru [Define if localtime() takes a long * not a 199104862Sru time_t *.])) 20079543SruAC_LANG_POP(C++)])dnl 20155839Sasmodaidnl 20255839Sasmodaidnl 20318099SpstAC_DEFUN(GROFF_STRUCT_EXCEPTION, 20418099Spst[AC_MSG_CHECKING([struct exception]) 20518099SpstAC_TRY_COMPILE([#include <math.h>], 20618099Spst[struct exception e;], 207104862SruAC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1, 208104862Sru [Define if <math.h> defines struct exception.]), 20918099SpstAC_MSG_RESULT(no))])dnl 21055839Sasmodaidnl 21155839Sasmodaidnl 21218099SpstAC_DEFUN(GROFF_ARRAY_DELETE, 21379543Sru[AC_LANG_PUSH(C++) 21418099SpstAC_MSG_CHECKING([whether ANSI array delete syntax supported]) 215104862SruAC_TRY_COMPILE(, [char *p = new char[5]; delete [] p;], 21655839SasmodaiAC_MSG_RESULT(yes), 217104862SruAC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE, 1, 218104862Sru [Define if your C++ doesn't understand 219104862Sru `delete []'.])) 22079543SruAC_LANG_POP(C++)])dnl 22118099Spstdnl 22255839Sasmodaidnl 22355839Sasmodaidnl 22418099SpstAC_DEFUN(GROFF_TRADITIONAL_CPP, 22579543Sru[AC_LANG_PUSH(C++) 22618099SpstAC_MSG_CHECKING([traditional preprocessor]) 22718099SpstAC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);], 228104862SruAC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP, 1, 229104862Sru [Define if your C++ compiler uses a 230104862Sru traditional (Reiser) preprocessor.]), 23118099SpstAC_MSG_RESULT(no)) 23279543SruAC_LANG_POP(C++)])dnl 23355839Sasmodaidnl 23455839Sasmodaidnl 23518099SpstAC_DEFUN(GROFF_WCOREFLAG, 23618099Spst[AC_MSG_CHECKING([w_coredump]) 23755839SasmodaiAC_TRY_RUN([#include <sys/types.h> 23818099Spst#include <sys/wait.h> 23918099Spstmain() 24018099Spst{ 24118099Spst#ifdef WCOREFLAG 24218099Spst exit(1); 24318099Spst#else 24418099Spst int i = 0; 24518099Spst ((union wait *)&i)->w_coredump = 1; 24618099Spst exit(i != 0200); 24718099Spst#endif 24855839Sasmodai}], 249104862SruAC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG, 0200, 250104862Sru [Define if the 0200 bit of the status returned 251104862Sru by wait() indicates whether a core image was 252104862Sru produced for a process that was terminated by 253104862Sru a signal.]), 25455839SasmodaiAC_MSG_RESULT(no), 25518099SpstAC_MSG_RESULT(no))])dnl 25618099Spstdnl 25755839Sasmodaidnl 25818099SpstAC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS, 25918099Spst[AC_MSG_CHECKING([default value for grops -b option]) 26018099Spsttest -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7 26118099SpstAC_MSG_RESULT($BROKEN_SPOOLER_FLAGS) 26218099SpstAC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl 26318099Spstdnl 26455839Sasmodaidnl 26518099SpstAC_DEFUN(GROFF_PAGE, 26618099Spst[AC_MSG_CHECKING([default paper size]) 267104862Srugroff_prefix=$prefix 268104862Srutest "x$prefix" = xNONE && groff_prefix=$ac_default_prefix 26955839Sasmodaiif test -z "$PAGE"; then 27018099Spst descfile= 271104862Sru if test -r $groff_prefix/share/groff/font/devps/DESC; then 272104862Sru descfile=$groff_prefix/share/groff/font/devps/DESC 273104862Sru elif test -r $groff_prefix/lib/groff/font/devps/DESC; then 274104862Sru descfile=$groff_prefix/lib/groff/font/devps/DESC 27575584Sru else 276104862Sru for f in $groff_prefix/share/groff/*/font/devps/DESC; do 27775584Sru if test -r $f; then 27875584Sru descfile=$f 27975584Sru break 28075584Sru fi 28175584Sru done 28218099Spst fi 283104862Sru if test -n "$descfile"; then 284104862Sruchangequote(,)dnl 285104862Sru if grep '^paperlength[ ]\+841890' $descfile 286104862Sru >/dev/null 2>&1; then 287104862Sru PAGE=A4 288104862Sru elif grep '^papersize[ ]\+[aA]4' $descfile \ 289104862Sru >/dev/null 2>&1; then 290104862Sru PAGE=A4 291104862Sru fi 292104862Sruchangequote([,])dnl 29318099Spst fi 29418099Spstfi 29555839Sasmodaiif test -z "$PAGE"; then 29618099Spst dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \ 29718099Spst /etc/resolv.conf 2>/dev/null` 29855839Sasmodai if test -z "$dom"; then 29918099Spst dom=`(domainname) 2>/dev/null | tr -d '+'` 30079543Sru if test -z "$dom" \ 30179543Sru || test "$dom" = '(none)'; then 30218099Spst dom=`(hostname) 2>/dev/null | grep '\.'` 30318099Spst fi 30418099Spst fi 30518099Spstchangequote(,)dnl 30618099Spst # If the top-level domain is two letters and it's not `us' or `ca' 30718099Spst # then they probably use A4 paper. 30818099Spst case "$dom" in 30918099Spst *.[Uu][Ss]|*.[Cc][Aa]) ;; 31018099Spst *.[A-Za-z][A-Za-z]) PAGE=A4 ;; 31118099Spst esac 31218099Spstchangequote([,])dnl 31318099Spstfi 31418099Spsttest -n "$PAGE" || PAGE=letter 315104862Sruif test "x$PAGE" = "xA4"; then 316104862Sru AC_DEFINE(PAGEA4, 1, 317104862Sru [Define if the printer's page size is A4.]) 318104862Srufi 31918099SpstAC_MSG_RESULT($PAGE) 32018099SpstAC_SUBST(PAGE)])dnl 32118099Spstdnl 32255839Sasmodaidnl 32318099SpstAC_DEFUN(GROFF_CXX_CHECK, 32469626Sru[AC_REQUIRE([AC_PROG_CXX]) 32579543SruAC_LANG_PUSH(C++) 32618099Spstif test "$cross_compiling" = no; then 32755839Sasmodai AC_MSG_CHECKING([that C++ compiler can compile simple program]) 32818099Spstfi 32918099SpstAC_TRY_RUN([int main() { return 0; }], 33018099SpstAC_MSG_RESULT(yes), 33155839SasmodaiAC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 33255839Sasmodai:) 33318099Spstif test "$cross_compiling" = no; then 33455839Sasmodai AC_MSG_CHECKING([that C++ static constructors and destructors are called]) 33518099Spstfi 33618099SpstAC_TRY_RUN([ 33718099Spstextern "C" { 33818099Spst void _exit(int); 33918099Spst} 34018099Spstint i; 34118099Spststruct A { 34218099Spst char dummy; 34318099Spst A() { i = 1; } 34418099Spst ~A() { if (i == 1) _exit(0); } 34518099Spst}; 34618099SpstA a; 34718099Spstint main() { return 1; } 34818099Spst], 34918099SpstAC_MSG_RESULT(yes), 35055839SasmodaiAC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]), 35155839Sasmodai:) 35218099SpstAC_MSG_CHECKING([that header files support C++]) 35318099SpstAC_TRY_LINK([#include <stdio.h>], 35455839Sasmodai[fopen(0, 0);], 35555839SasmodaiAC_MSG_RESULT(yes), 35655839SasmodaiAC_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++)])) 35779543SruAC_LANG_POP(C++)])dnl 35818099Spstdnl 35955839Sasmodaidnl 36018099SpstAC_DEFUN(GROFF_TMAC, 36155839Sasmodai[AC_MSG_CHECKING([for prefix of system macro packages]) 36218099Spstsys_tmac_prefix= 36318099Spstsys_tmac_file_prefix= 36455839Sasmodaifor d in /usr/share/lib/tmac /usr/lib/tmac; do 36555839Sasmodai for t in "" tmac.; do 36655839Sasmodai for m in an s m; do 36718099Spst f=$d/$t$m 36818099Spst if test -z "$sys_tmac_prefix" \ 36918099Spst && test -f $f \ 37055839Sasmodai && grep '^\.if' $f >/dev/null 2>&1; then 37118099Spst sys_tmac_prefix=$d/$t 37218099Spst sys_tmac_file_prefix=$t 37318099Spst fi 37418099Spst done 37518099Spst done 37618099Spstdone 37718099SpstAC_MSG_RESULT($sys_tmac_prefix) 37818099SpstAC_SUBST(sys_tmac_prefix) 37918099Spsttmac_wrap= 38018099SpstAC_MSG_CHECKING([which system macro packages should be made available]) 38155839Sasmodaiif test "x$sys_tmac_file_prefix" = "xtmac."; then 38255839Sasmodai for f in $sys_tmac_prefix*; do 38318099Spst suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 38418099Spst case "$suff" in 38555839Sasmodai e) ;; 38618099Spst *) 38755839Sasmodai grep "Copyright.*Free Software Foundation" $f >/dev/null \ 38855839Sasmodai || tmac_wrap="$tmac_wrap $suff" ;; 38918099Spst esac 39018099Spst done 39155839Sasmodaielif test -n "$sys_tmac_prefix"; then 39218099Spst files=`echo $sys_tmac_prefix*` 39318099Spst grep "\\.so" $files >conftest.sol 39455839Sasmodai for f in $files; do 39518099Spst case "$f" in 39655839Sasmodai ${sys_tmac_prefix}e) ;; 39718099Spst *.me) ;; 39818099Spst */ms.*) ;; 39918099Spst *) 40055839Sasmodai b=`basename $f` 40155839Sasmodai if grep "\\.so.*/$b\$" conftest.sol >/dev/null \ 40255839Sasmodai || grep -l "Copyright.*Free Software Foundation" $f >/dev/null; then 40355839Sasmodai : 40455839Sasmodai else 40555839Sasmodai suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"` 40655839Sasmodai case "$suff" in 40755839Sasmodai tmac.*) ;; 40855839Sasmodai *) tmac_wrap="$tmac_wrap $suff" ;; 40955839Sasmodai esac 41055839Sasmodai fi 41118099Spst esac 41218099Spst done 41318099Spst rm -f conftest.sol 41418099Spstfi 41518099SpstAC_MSG_RESULT([$tmac_wrap]) 41669626SruAC_SUBST(tmac_wrap)])dnl 41755839Sasmodaidnl 41855839Sasmodaidnl 41918099SpstAC_DEFUN(GROFF_G, 42018099Spst[AC_MSG_CHECKING([for existing troff installation]) 42155839Sasmodaiif test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then 42218099Spst AC_MSG_RESULT(yes) 42318099Spst g=g 42418099Spstelse 42518099Spst AC_MSG_RESULT(no) 42618099Spst g= 42718099Spstfi 42869626SruAC_SUBST(g)])dnl 42955839Sasmodaidnl 43055839Sasmodaidnl 43118099Spstdnl We need the path to install-sh to be absolute. 43255839Sasmodaidnl 43318099SpstAC_DEFUN(GROFF_INSTALL_SH, 43418099Spst[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 43518099Spstac_dir=`cd $ac_aux_dir; pwd` 43669626Sruac_install_sh="$ac_dir/install-sh -c"])dnl 43755839Sasmodaidnl 43855839Sasmodaidnl 439104862Srudnl Test whether install-info is available. 440104862Srudnl 441104862SruAC_DEFUN(GROFF_INSTALL_INFO, 442104862Sru[AC_CHECK_PROGS(INSTALL_INFO, install-info, :)])dnl 443104862Srudnl 444104862Srudnl 44555839Sasmodaidnl At least one UNIX system, Apple Macintosh Rhapsody 5.5, 44655839Sasmodaidnl does not have -lm. 44755839Sasmodaidnl 44855839SasmodaiAC_DEFUN(GROFF_LIBM, 44955839Sasmodai[AC_CHECK_LIB(m,sin,LIBM=-lm) 45069626SruAC_SUBST(LIBM)])dnl 45169626Srudnl 45269626Srudnl 45369626Srudnl We need top_srcdir to be absolute. 45469626Srudnl 45569626SruAC_DEFUN(GROFF_SRCDIR, 45669626Sru[ac_srcdir_defaulted=no 45769626Srusrcdir=`cd $srcdir; pwd`])dnl 45869626Srudnl 45969626Srudnl 46069626Srudnl This simplifies Makefile rules. 46169626Srudnl 46269626SruAC_DEFUN(GROFF_BUILDDIR, 463104862Sru[groff_top_builddir=`pwd` 464104862SruAC_SUBST(groff_top_builddir)])dnl 46569626Srudnl 46669626Srudnl 46769626Srudnl Check for EBCDIC - stolen from the OS390 Unix LYNX port 46869626Srudnl 46969626SruAC_DEFUN(GROFF_EBCDIC, 47069626Sru[AC_MSG_CHECKING([whether character set is EBCDIC]) 47169626SruAC_TRY_COMPILE(, 47269626Sru[/* Treat any failure as ASCII for compatibility with existing art. 47369626Sru Use compile-time rather than run-time tests for cross-compiler 47469626Sru tolerance. */ 47569626Sru#if '0' != 240 47669626Srumake an error "Character set is not EBCDIC" 47769626Sru#endif], 47869626Srugroff_cv_ebcdic="yes" 47969626Sru TTYDEVDIRS="font/devcp1047" 48069626Sru AC_MSG_RESULT(yes) 481104862Sru AC_DEFINE(IS_EBCDIC_HOST, 1, 482104862Sru [Define if the host's encoding is EBCDIC.]), 48369626Srugroff_cv_ebcdic="no" 484104862Sru TTYDEVDIRS="font/devascii font/devlatin1" 485104862Sru OTHERDEVDIRS="font/devlj4 font/devlbp" 48669626Sru AC_MSG_RESULT(no)) 487104862SruAC_SUBST(TTYDEVDIRS) 488104862SruAC_SUBST(OTHERDEVDIRS)])dnl 48969626Srudnl 49069626Srudnl 49169626Srudnl Check for OS/390 Unix. We test for EBCDIC also -- the Linux port (with 49269626Srudnl gcc) to OS/390 uses ASCII internally. 49369626Srudnl 49469626SruAC_DEFUN(GROFF_OS390, 49579543Sru[if test "$groff_cv_ebcdic" = "yes"; then 49669626Sru AC_MSG_CHECKING([for OS/390 Unix]) 49769626Sru case `uname` in 49869626Sru OS/390) 49969626Sru CFLAGS="$CFLAGS -D_ALL_SOURCE" 50069626Sru AC_MSG_RESULT(yes) ;; 50169626Sru *) 50269626Sru AC_MSG_RESULT(no) ;; 50369626Sru esac 50469626Srufi])dnl 50569626Srudnl 50669626Srudnl 50769626Srudnl Check whether we need a declaration for a function. 50869626Srudnl 50969626Srudnl Stolen from GNU bfd. 51069626Srudnl 51169626SruAC_DEFUN(GROFF_NEED_DECLARATION, 51269626Sru[AC_MSG_CHECKING([whether $1 must be declared]) 51379543SruAC_LANG_PUSH(C++) 51469626SruAC_CACHE_VAL(groff_cv_decl_needed_$1, 51569626Sru[AC_TRY_COMPILE([ 51669626Sru#include <stdio.h> 51769626Sru#ifdef HAVE_STRING_H 51869626Sru#include <string.h> 51979543Sru#endif 52069626Sru#ifdef HAVE_STRINGS_H 52169626Sru#include <strings.h> 52269626Sru#endif 52369626Sru#ifdef HAVE_STDLIB_H 52469626Sru#include <stdlib.h> 52569626Sru#endif 526104862Sru#ifdef HAVE_SYS_TIME_H 527104862Sru#include <sys/time.h> 528104862Sru#endif 52969626Sru#ifdef HAVE_UNISTD_H 53069626Sru#include <unistd.h> 53169626Sru#endif 53269626Sru#ifdef HAVE_MATH_H 53369626Sru#include <math.h> 53469626Sru#endif], 535104862Sru[#ifndef $1 536104862Sru char *p = (char *) $1; 537104862Sru#endif], 53869626Srugroff_cv_decl_needed_$1=no, 53969626Srugroff_cv_decl_needed_$1=yes)]) 54069626SruAC_MSG_RESULT($groff_cv_decl_needed_$1) 54169626Sruif test $groff_cv_decl_needed_$1 = yes; then 542104862Sru AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1, 543104862Sru [Define if your C++ doesn't declare ]$1[().]) 54469626Srufi 54579543SruAC_LANG_POP(C++)])dnl 54679543Srudnl 54779543Srudnl 548104862Srudnl If mkstemp() isn't available, use our own mkstemp.cc file. 54979543Srudnl 55079543SruAC_DEFUN(GROFF_MKSTEMP, 551104862Sru[AC_MSG_CHECKING([for mkstemp]) 552104862SruAC_LANG_PUSH(C++) 553104862SruAC_LIBSOURCE(mkstemp.cc) 554104862SruAC_TRY_LINK([#include <stdlib.h> 555104862Sru#include <unistd.h> 556104862Sruint (*f) (char *);], 557104862Sru[f = mkstemp;], 558104862SruAC_MSG_RESULT(yes);AC_DEFINE(HAVE_MKSTEMP, 1, 559104862Sru [Define if you have mkstemp().]), 560104862SruAC_MSG_RESULT(no);_AC_LIBOBJ(mkstemp)) 561104862SruAC_LANG_POP(C++)])dnl 562104862Srudnl 563104862Srudnl 564104862Srudnl Test whether <inttypes.h> exists, doesn't clash with <sys/types.h>, 565104862Srudnl and declares uintmax_t. Taken from the fileutils package. 566104862Srudnl 567104862SruAC_DEFUN(GROFF_INTTYPES_H, 568104862Sru[AC_LANG_PUSH(C++) 569104862SruAC_MSG_CHECKING([for inttypes.h]) 570104862SruAC_TRY_COMPILE([#include <sys/types.h> 571104862Sru#include <inttypes.h>], 572104862Sru[uintmax_t i = (uintmax_t)-1;], 573104862Srugroff_cv_header_inttypes_h=yes, 574104862Srugroff_cv_header_inttypes_h=no) 575104862SruAC_MSG_RESULT($groff_cv_header_inttypes_h) 576104862SruAC_LANG_POP(C++)])dnl 577104862Srudnl 578104862Srudnl 579104862Srudnl Test for working `unsigned long long'. Taken from the fileutils package. 580104862Srudnl 581104862SruAC_DEFUN(GROFF_UNSIGNED_LONG_LONG, 582104862Sru[AC_LANG_PUSH(C++) 583104862SruAC_MSG_CHECKING([for unsigned long long]) 584104862SruAC_TRY_LINK([unsigned long long ull = 1; int i = 63;], 585104862Sru[unsigned long long ullmax = (unsigned long long)-1; 586104862Srureturn ull << i | ull >> i | ullmax / ull | ullmax % ull;], 587104862Srugroff_cv_type_unsigned_long_long=yes, 588104862Srugroff_cv_type_unsigned_long_long=no) 589104862SruAC_MSG_RESULT($groff_cv_type_unsigned_long_long) 590104862SruAC_LANG_POP(C++)])dnl 591104862Srudnl 592104862Srudnl 593104862Srudnl Define uintmax_t to `unsigned long' or `unsigned long long' 594104862Srudnl if <inttypes.h> does not exist. Taken from the fileutils package. 595104862Srudnl 596104862SruAC_DEFUN(GROFF_UINTMAX_T, 597104862Sru[AC_REQUIRE([GROFF_INTTYPES_H]) 598104862Sruif test $groff_cv_header_inttypes_h = no; then 599104862Sru AC_REQUIRE([GROFF_UNSIGNED_LONG_LONG]) 600104862Sru test $groff_cv_type_unsigned_long_long = yes \ 601104862Sru && ac_type='unsigned long long' \ 602104862Sru || ac_type='unsigned long' 603104862Sru AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, 604104862Sru [Define uintmax_t to `unsigned long' or 605104862Sru `unsigned long long' if <inttypes.h> does not 606104862Sru exist.]) 607104862Srufi])dnl 608