home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / gnu / groff_src.lha / groff-1.10src / aclocal.m4 next >
M4 Source File  |  1995-11-20  |  10KB  |  386 lines

  1. dnl Autoconf macros for groff.
  2. dnl Copyright (C) 1989, 1990, 1991, 1992, 1995 Free Software Foundation, Inc.
  3. dnl 
  4. dnl This file is part of groff.
  5. dnl 
  6. dnl groff is free software; you can redistribute it and/or modify it under
  7. dnl the terms of the GNU General Public License as published by the Free
  8. dnl Software Foundation; either version 2, or (at your option) any later
  9. dnl version.
  10. dnl 
  11. dnl groff is distributed in the hope that it will be useful, but WITHOUT ANY
  12. dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. dnl FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14. dnl for more details.
  15. dnl 
  16. dnl You should have received a copy of the GNU General Public License along
  17. dnl with groff; see the file COPYING.  If not, write to the Free Software
  18. dnl Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. dnl
  20. AC_DEFUN(GROFF_PRINT,
  21. [if test -z "$PSPRINT"
  22. then
  23.     AC_CHECK_PROGS(LPR,lpr)
  24.     AC_CHECK_PROGS(LP,lp)
  25.     if test -n "$LPR" && test -n "$LP"
  26.     then
  27.         # HP-UX provides an lpr command that emulates lpr using lp,
  28.         # but it doesn't have lpq; in this case we want to use lp
  29.         # rather than lpr.
  30.         AC_CHECK_PROGS(LPQ,lpq)
  31.         test -n "$LPQ" || LPR=
  32.     fi
  33.     if test -n "$LPR"
  34.     then
  35.         PSPRINT="$LPR"
  36.     elif test -n "$LP"
  37.     then
  38.         PSPRINT="$LP"
  39.     fi
  40. fi
  41. AC_SUBST(PSPRINT)
  42. AC_MSG_CHECKING([for command to use for printing PostScript files])
  43. AC_MSG_RESULT($PSPRINT)
  44. # Figure out DVIPRINT from PSPRINT.
  45. AC_MSG_CHECKING([for command to use for printing dvi files])
  46. if test -n "$PSPRINT" && test -z "$DVIPRINT"
  47. then
  48.     if test "X$PSPRINT" = "Xlpr"
  49.     then
  50.         DVIPRINT="lpr -d"
  51.     else
  52.         DVIPRINT="$PSPRINT"
  53.     fi
  54. fi
  55. AC_SUBST(DVIPRINT)
  56. AC_MSG_RESULT($DVIPRINT)])dnl
  57. dnl Bison generated parsers have problems with C++ compilers other than g++.
  58. dnl So byacc is preferred over bison.
  59. AC_DEFUN(GROFF_PROG_YACC,
  60. [AC_CHECK_PROGS(YACC, byacc 'bison -y', yacc)])
  61. dnl GROFF_CSH_HACK(if hack present, if not present)
  62. AC_DEFUN(GROFF_CSH_HACK,
  63. [AC_MSG_CHECKING([for csh hash hack])
  64. cat <<EOF >conftest.sh
  65. #!/bin/sh
  66. true || exit 0
  67. export PATH || exit 0
  68. exit 1
  69. EOF
  70. chmod +x conftest.sh
  71. if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1
  72. then
  73.     AC_MSG_RESULT(yes); $1
  74. else
  75.     AC_MSG_RESULT(no); $2
  76. fi
  77. rm -f conftest.sh
  78. ])dnl
  79. dnl From udodo!hans@relay.NL.net (Hans Zuidam)
  80. AC_DEFUN(GROFF_ISC_SYSV3,
  81. [AC_MSG_CHECKING([for ISC 3.x or 4.x])
  82. changequote(,)dnl
  83. if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
  84. changequote([,])dnl
  85. then
  86.     AC_MSG_RESULT(yes)
  87.     AC_DEFINE(_SYSV3)
  88. else
  89.     AC_MSG_RESULT(no)
  90. fi])dnl
  91. AC_DEFUN(GROFF_POSIX,
  92. [AC_MSG_CHECKING([whether -D_POSIX_SOURCE is necessary])
  93. AC_LANG_SAVE
  94. AC_LANG_CPLUSPLUS
  95. AC_TRY_COMPILE([#include <stdio.h>
  96. extern "C" { void fileno(int); }],,
  97. AC_MSG_RESULT(yes);AC_DEFINE(_POSIX_SOURCE),
  98. AC_MSG_RESULT(no))
  99. AC_LANG_RESTORE])dnl
  100. AC_DEFUN(GROFF_GETOPT,
  101. [AC_LANG_SAVE
  102. AC_LANG_CPLUSPLUS
  103. AC_MSG_CHECKING([declaration of getopt in stdlib.h])
  104. AC_TRY_COMPILE(
  105. [#include <stdlib.h>
  106. extern "C" { void getopt(int); }],,AC_MSG_RESULT(no),
  107. AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_GETOPT))
  108. AC_MSG_CHECKING([declaration of getopt in unistd.h])
  109. AC_TRY_COMPILE([#include <sys/types.h>
  110. #include <unistd.h>
  111. extern "C" { void getopt(int); }],,AC_MSG_RESULT(no),
  112. AC_MSG_RESULT(yes);AC_DEFINE(UNISTD_H_DECLARES_GETOPT))
  113. AC_LANG_RESTORE])dnl
  114. AC_DEFUN(GROFF_PUTENV,
  115. [AC_LANG_SAVE
  116. AC_LANG_CPLUSPLUS
  117. AC_MSG_CHECKING([declaration of putenv])
  118. AC_TRY_COMPILE([#include <stdlib.h>
  119. extern "C" { void putenv(int); }],,AC_MSG_RESULT(no),
  120. AC_MSG_RESULT(yes)
  121. AC_DEFINE(STDLIB_H_DECLARES_PUTENV))
  122. AC_LANG_RESTORE])dnl
  123. AC_DEFUN(GROFF_POPEN,
  124. [AC_LANG_SAVE
  125. AC_LANG_CPLUSPLUS
  126. AC_MSG_CHECKING([declaration of popen])
  127. AC_TRY_COMPILE([#include <stdio.h>
  128. extern "C" { void popen(int); }],,AC_MSG_RESULT(no),
  129. AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_POPEN))
  130. AC_LANG_RESTORE])dnl
  131. AC_DEFUN(GROFF_PCLOSE,
  132. [AC_LANG_SAVE
  133. AC_LANG_CPLUSPLUS
  134. AC_MSG_CHECKING([declaration of pclose])
  135. AC_TRY_COMPILE([#include <stdio.h>
  136. extern "C" { void pclose(int); }],,AC_MSG_RESULT(no),
  137. AC_MSG_RESULT(yes);AC_DEFINE(STDIO_H_DECLARES_PCLOSE))
  138. AC_LANG_RESTORE])dnl
  139. AC_DEFUN(GROFF_OSFCN_H,
  140. [AC_LANG_SAVE
  141. AC_LANG_CPLUSPLUS
  142. AC_MSG_CHECKING([C++ <osfcn.h>])
  143. AC_TRY_COMPILE([#include <osfcn.h>],
  144. [read(0, 0, 0); open(0, 0);],AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_OSFCN_H),
  145. AC_MSG_RESULT(no))
  146. AC_LANG_RESTORE])dnl
  147. AC_DEFUN(GROFF_LIMITS_H,
  148. [AC_LANG_SAVE
  149. AC_LANG_CPLUSPLUS
  150. AC_MSG_CHECKING([C++ <limits.h>])
  151. AC_TRY_COMPILE([#include <limits.h>],
  152. [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
  153. AC_MSG_RESULT(yes);AC_DEFINE(HAVE_CC_LIMITS_H),AC_MSG_RESULT(no))
  154. AC_LANG_RESTORE])dnl
  155. AC_DEFUN(GROFF_TIME_T,
  156. [AC_LANG_SAVE
  157. AC_LANG_CPLUSPLUS
  158. AC_MSG_CHECKING([for declaration of time_t])
  159. AC_TRY_COMPILE([#include <time.h>],
  160. [time_t t = time(0); struct tm *p = localtime(&t);],AC_MSG_RESULT(yes),
  161. AC_MSG_RESULT(no);AC_DEFINE(LONG_FOR_TIME_T))
  162. AC_LANG_RESTORE])dnl
  163. AC_DEFUN(GROFF_STRUCT_EXCEPTION,
  164. [AC_MSG_CHECKING([struct exception])
  165. AC_TRY_COMPILE([#include <math.h>],
  166. [struct exception e;],
  167. AC_MSG_RESULT(yes);AC_DEFINE(HAVE_STRUCT_EXCEPTION),
  168. AC_MSG_RESULT(no))])dnl
  169. AC_DEFUN(GROFF_ARRAY_DELETE,
  170. [AC_LANG_SAVE
  171. AC_LANG_CPLUSPLUS
  172. AC_MSG_CHECKING([whether ANSI array delete syntax supported])
  173. AC_TRY_COMPILE(,
  174. changequote(,)dnl
  175. char *p = new char[5]; delete [] p;changequote([,]),
  176. AC_MSG_RESULT(yes),AC_MSG_RESULT(no);AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))
  177. AC_LANG_RESTORE])dnl
  178. dnl
  179. AC_DEFUN(GROFF_TRADITIONAL_CPP,
  180. [AC_LANG_SAVE
  181. AC_LANG_CPLUSPLUS
  182. AC_MSG_CHECKING([traditional preprocessor])
  183. AC_TRY_COMPILE([#define name2(a,b) a/**/b],[int name2(foo,bar);],
  184. AC_MSG_RESULT(yes);AC_DEFINE(TRADITIONAL_CPP),
  185. AC_MSG_RESULT(no))
  186. AC_LANG_RESTORE])dnl
  187.  
  188. AC_DEFUN(GROFF_WCOREFLAG,
  189. [AC_MSG_CHECKING([w_coredump])
  190. AC_TRY_RUN([
  191. #include <sys/types.h>
  192. #include <sys/wait.h>
  193. main()
  194. {
  195. #ifdef WCOREFLAG
  196.   exit(1);
  197. #else
  198.   int i = 0;
  199.   ((union wait *)&i)->w_coredump = 1;
  200.   exit(i != 0200);
  201. #endif
  202. }
  203. ],AC_MSG_RESULT(yes);AC_DEFINE(WCOREFLAG,0200),AC_MSG_RESULT(no),
  204. AC_MSG_RESULT(no))])dnl
  205. dnl
  206. AC_DEFUN(GROFF_BROKEN_SPOOLER_FLAGS,
  207. [AC_MSG_CHECKING([default value for grops -b option])
  208. test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
  209. AC_MSG_RESULT($BROKEN_SPOOLER_FLAGS)
  210. AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
  211. dnl
  212. AC_DEFUN(GROFF_PAGE,
  213. [AC_MSG_CHECKING([default paper size])
  214. if test -z "$PAGE"
  215. then
  216.     descfile=
  217.     if test -r $prefix/share/groff/font/devps/DESC
  218.     then
  219.         descfile=$prefix/share/groff/font/devps/DESC
  220.     elif test -r $prefix/lib/groff/font/devps/DESC
  221.     then
  222.         descfile=$prefix/lib/groff/font/devps/DESC
  223.     fi
  224.     if test -n "$descfile" \
  225.       && grep "^paperlength 841890" $descfile >/dev/null 2>&1
  226.     then
  227.         PAGE=A4
  228.     else
  229.         PAGE=letter
  230.     fi
  231. fi
  232. if test -z "$PAGE"
  233. then
  234.     dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
  235.         /etc/resolv.conf 2>/dev/null`
  236.  
  237.     if test -z "$dom"
  238.     then
  239.         dom=`(domainname) 2>/dev/null | tr -d '+'`
  240.         if test -z "$dom"
  241.         then
  242.             dom=`(hostname) 2>/dev/null | grep '\.'`
  243.         fi
  244.     fi
  245.  
  246. changequote(,)dnl
  247.     # If the top-level domain is two letters and it's not `us' or `ca'
  248.     # then they probably use A4 paper.
  249.     case "$dom" in
  250.     *.[Uu][Ss]|*.[Cc][Aa]) ;;
  251.     *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
  252.     esac
  253. changequote([,])dnl
  254. fi
  255. test -n "$PAGE" || PAGE=letter
  256. AC_MSG_RESULT($PAGE)
  257. AC_SUBST(PAGE)])dnl
  258. dnl
  259. AC_DEFUN(GROFF_CXX_CHECK,
  260. [AC_REQUIRE([AC_C_CROSS])
  261. AC_REQUIRE([AC_PROG_CXX])
  262. AC_LANG_SAVE
  263. AC_LANG_CPLUSPLUS
  264. if test "$cross_compiling" = no; then
  265. AC_MSG_CHECKING([that C++ compiler can compile simple program])
  266. fi
  267. AC_TRY_RUN([int main() { return 0; }],
  268. AC_MSG_RESULT(yes),
  269. AC_MSG_RESULT(no)
  270. AC_MSG_ERROR([a working C++ compiler is required]),:)
  271. if test "$cross_compiling" = no; then
  272. AC_MSG_CHECKING([that C++ static constructors and destructors are called])
  273. fi
  274. AC_TRY_RUN([
  275. extern "C" {
  276.   void _exit(int);
  277. }
  278. int i;
  279. struct A {
  280.   char dummy;
  281.   A() { i = 1; }
  282.   ~A() { if (i == 1) _exit(0); }
  283. };
  284. A a;
  285. int main() { return 1; }
  286. ],
  287. AC_MSG_RESULT(yes),
  288. AC_MSG_RESULT(no)
  289. AC_MSG_ERROR([a working C++ compiler is required]),:)
  290. AC_MSG_CHECKING([that header files support C++])
  291. AC_TRY_LINK([#include <stdio.h>],
  292. [fopen(0, 0);],AC_MSG_RESULT(yes),
  293. AC_MSG_RESULT(no)
  294. 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++)]))
  295. AC_LANG_RESTORE
  296. ])dnl
  297. dnl
  298. AC_DEFUN(GROFF_TMAC,
  299. [
  300. AC_MSG_CHECKING([for prefix of system macro packages])
  301. sys_tmac_prefix=
  302. sys_tmac_file_prefix=
  303. for d in /usr/share/lib/tmac /usr/lib/tmac
  304. do
  305.     for t in "" tmac.
  306.     do
  307.         for m in an s m
  308.         do
  309.             f=$d/$t$m
  310.             if test -z "$sys_tmac_prefix" \
  311.               && test -f $f \
  312.               && grep '^\.if' $f >/dev/null 2>&1
  313.             then
  314.                 sys_tmac_prefix=$d/$t
  315.                 sys_tmac_file_prefix=$t
  316.             fi
  317.         done
  318.     done
  319. done
  320. AC_MSG_RESULT($sys_tmac_prefix)
  321. AC_SUBST(sys_tmac_prefix)
  322. tmac_wrap=
  323. AC_MSG_CHECKING([which system macro packages should be made available])
  324. if test "x$sys_tmac_file_prefix" = "xtmac."
  325. then
  326.     for f in $sys_tmac_prefix*
  327.     do
  328.         suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
  329.         case "$suff" in
  330.         e);;
  331.         *)
  332.         grep "Copyright.*Free Software Foundation" $f >/dev/null \
  333.           || tmac_wrap="$tmac_wrap $suff"
  334.         ;;
  335.         esac 
  336.     done
  337. elif test -n "$sys_tmac_prefix"
  338. then
  339.     files=`echo $sys_tmac_prefix*`
  340.     grep "\\.so" $files >conftest.sol
  341.     for f in $files
  342.     do
  343.         case "$f" in
  344.         ${sys_tmac_prefix}e) ;;
  345.         *.me) ;;
  346.         */ms.*) ;;
  347.         *)
  348.         b=`basename $f`
  349.         if grep "\\.so.*/$b\$" conftest.sol >/dev/null \
  350.           || grep -l "Copyright.*Free Software Foundation" $f >/dev/null
  351.         then
  352.             :
  353.         else
  354.             suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
  355.             case "$suff" in
  356.             tmac.*);;
  357.             *) tmac_wrap="$tmac_wrap $suff" ;;
  358.             esac
  359.         fi
  360.         esac
  361.     done
  362.     rm -f conftest.sol
  363. fi
  364. AC_MSG_RESULT([$tmac_wrap])
  365. AC_SUBST(tmac_wrap)
  366. ])dnl
  367. AC_DEFUN(GROFF_G,
  368. [AC_MSG_CHECKING([for existing troff installation])
  369. if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" \
  370.   = x0
  371. then
  372.     AC_MSG_RESULT(yes)
  373.     g=g
  374. else
  375.     AC_MSG_RESULT(no)
  376.     g=
  377. fi
  378. AC_SUBST(g)
  379. ])dnl
  380. dnl We need the path to install-sh to be absolute.
  381. AC_DEFUN(GROFF_INSTALL_SH,
  382. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  383. ac_dir=`cd $ac_aux_dir; pwd`
  384. ac_install_sh="$ac_dir/install-sh -c"
  385. ])
  386.