home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / groff-1.09-src.lha / src / amiga / groff-1.09 / acgroff.m4 next >
M4 Source File  |  1994-02-12  |  10KB  |  404 lines

  1. dnl Autoconf macros for groff.
  2. dnl Copyright (C) 1989, 1990, 1991, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA.
  19. dnl
  20. define(GROFF_EXIT,[rm -f conftest* core; exit 1])dnl
  21. define(GROFF_PREFIX,[AC_PROVIDE([$0])AC_PREFIX(grops)AC_PREFIX(gcc)])dnl
  22. define(GROFF_PROG_CCC,
  23. [AC_PROVIDE([$0])AC_REQUIRE([AC_PROG_CC])dnl
  24. cc_compile='$CCC conftest.cc -o conftest $CCLIBS $LIBS >/dev/null 2>&1'
  25. AC_SUBST(CCLIBS)
  26. if test -z "$CCC"; then
  27. # See whether the C compiler is also a C++ compiler.
  28. echo checking if C compiler is also a C++ compiler
  29. cat <<EOF > conftest.cc
  30. #ifdef __cplusplus
  31.   yes
  32. #endif
  33. EOF
  34. $CC -E conftest.cc >conftest.out 2>&1
  35. if egrep yes conftest.out >/dev/null 2>&1; then
  36.   CCC="$CC"
  37. fi
  38. fi
  39. AC_PROGRAM_CHECK(CCC,g++,g++,)
  40. AC_PROGRAM_CHECK(CCC,CC,CC,)
  41. AC_PROGRAM_CHECK(CCC,cc++,cc++,)
  42. if test -z "$CCC"; then
  43. cat <<EOM
  44. This package requires a C++ compiler, but I couldn't find one.
  45. Set the environment variable CCC to the name of your C++ compiler.
  46. EOM
  47. GROFF_EXIT
  48. fi
  49. echo checking that C++ compiler can compile very simple C++ program
  50. GROFF_CC_TEST_PROGRAM([
  51. int main() { return 0; }
  52. ],,
  53. cat <<EOM
  54. $CCC was unable successfully to compile a very simple C++ program
  55. (the C++ program was in a file with a suffix of .cc)
  56. EOM
  57. GROFF_EXIT
  58. ,)
  59. echo checking that C++ static constructors and destructors are called
  60. GROFF_CC_TEST_PROGRAM([
  61. extern "C" {
  62.   void _exit(int);
  63. }
  64. int i;
  65. struct A {
  66.   char dummy;
  67.   A() { i = 1; }
  68.   ~A() { if (i == 1) _exit(0); }
  69. };
  70. A a;
  71. int main() { return 1; }
  72. ],,
  73. cat <<EOM
  74. $CCC is not installed correctly: static constructors and destructors do not work
  75. EOM
  76. GROFF_EXIT
  77. ,)
  78. GROFF_CC_COMPILE_CHECK([C++ header files],[#include <stdio.h>],
  79. [fopen(0, 0);],,
  80. [cat <<\EOF
  81. Your header files do not appear to support C++.
  82. I was unable to compile and link a simple C++ program that used a function
  83. declared in <stdio.h>.
  84. If you're using a version of gcc/g++ earlier than 2.5,
  85. you should install libg++.
  86. EOF
  87. GROFF_EXIT])])dnl
  88. define(GROFF_CC_COMPILE_CHECK,
  89. [AC_PROVIDE([$0])AC_REQUIRE([GROFF_PROG_CCC])echo checking for $1
  90. cat <<EOF >conftest.cc
  91. [$2]
  92. int main() { return 0; } void t() { [$3] }
  93. EOF
  94. dnl Don't try to run the program, which would prevent cross-configuring.
  95. if eval $cc_compile; then
  96.   ifelse([$4], , :, [$4])
  97. ifelse([$5], , , [else
  98.   $5
  99. ])dnl
  100. fi
  101. rm -f conftest*])dnl
  102. dnl
  103. define(GROFF_CC_TEST_PROGRAM,
  104. [AC_PROVIDE([$0])AC_REQUIRE([GROFF_PROG_CCC])ifelse([$4], , ,
  105. [AC_REQUIRE([AC_CROSS_CHECK])if $cross_compiling
  106. then
  107.   $4
  108. else
  109. ])dnl
  110. cat <<EOF > conftest.cc
  111. [$1]
  112. EOF
  113. rm -f conftest
  114. eval $cc_compile
  115. if test -s conftest && (./conftest) 2>/dev/null; then
  116.   ifelse([$2], , :, [$2])
  117. ifelse([$3], , , [else
  118.   $3
  119. ])dnl
  120. fi
  121. ifelse([$4], , , fi
  122. )dnl
  123. rm -f conftest*])dnl
  124. dnl
  125. define(GROFF_PAGE,
  126. [AC_REQUIRE([GROFF_PREFIX])
  127. if test -z "$PAGE" && test -r $prefix/lib/groff/font/devps/DESC
  128. then
  129.     if grep "^paperlength 841890" \
  130.         $prefix/lib/groff/font/devps/DESC >/dev/null 2>&1
  131.     then
  132.         PAGE=A4
  133.     else
  134.         PAGE=letter
  135.     fi
  136. fi
  137. if test -z "$PAGE"
  138. then
  139.     dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
  140.         /etc/resolv.conf 2>/dev/null`
  141.  
  142.     if test -z "$dom"
  143.     then
  144.         dom=`(domainname) 2>/dev/null | tr -d '+'`
  145.         if test -z "$dom"
  146.         then
  147.             dom=`(hostname) 2>/dev/null | grep '\.'`
  148.         fi
  149.     fi
  150.  
  151. changequote(,)dnl
  152.     # If the top-level domain is two letters and it's not `us' or `ca'
  153.     # then they probably use A4 paper.
  154.     case "$dom" in
  155.     *.[Uu][Ss]|*.[Cc][Aa]) ;;
  156.     *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
  157.     esac
  158. changequote([,])dnl
  159. fi
  160. test -n "$PAGE" || PAGE=letter
  161. echo guessing $PAGE size paper
  162. AC_SUBST(PAGE)])dnl
  163. dnl
  164. define(GROFF_PERL_PATH,
  165. [echo checking for perl
  166. PERLPATH=
  167. saveifs="$IFS"; IFS="${IFS}:"
  168. for dir in $PATH; do
  169.   test -z "$dir" && dir=.
  170.   if test -f $dir/perl; then
  171.      PERLPATH="$dir/perl"
  172.      break
  173.   fi
  174. done
  175. IFS="$saveifs"
  176. AC_SUBST(PERLPATH)])dnl
  177. dnl
  178. define(GROFF_WCOREFLAG,
  179. [echo checking for w_coredump
  180. AC_TEST_PROGRAM([
  181. #include <sys/types.h>
  182. #include <sys/wait.h>
  183. main()
  184. {
  185. #ifdef WCOREFLAG
  186.   exit(1);
  187. #else
  188.   int i = 0;
  189.   ((union wait *)&i)->w_coredump = 1;
  190.   exit(i != 0200);
  191. #endif
  192. }
  193. ],AC_DEFINE(WCOREFLAG,0200),,)])dnl
  194. dnl
  195. define(GROFF_MMAP,
  196. [AC_COMPILE_CHECK([mmap],[#include <sys/types.h>
  197. #include <sys/mman.h>],
  198. [char *p = mmap(0, 0, PROT_READ, MAP_PRIVATE, 0, 0); munmap(p, 0);],
  199. AC_DEFINE(HAVE_MMAP))])dnl
  200. dnl;
  201. define(GROFF_SYS_SIGLIST,
  202. [AC_COMPILE_CHECK([sys_siglist],,changequote(,)dnl
  203. extern char *sys_siglist[]; sys_siglist[0] = 0;,changequote([,])dnl
  204. AC_DEFINE(HAVE_SYS_SIGLIST))])dnl
  205. dnl
  206. define(GROFF_STRUCT_EXCEPTION,
  207. [AC_COMPILE_CHECK([struct exception],[#include <math.h>],
  208. [struct exception e;],
  209. AC_DEFINE(HAVE_STRUCT_EXCEPTION))])dnl
  210. define(GROFF_COOKIE_BUG,
  211. [echo checking for gcc/g++ delete bug
  212. GROFF_CC_TEST_PROGRAM([
  213. #include <stdlib.h>
  214. #include <stddef.h>
  215.  
  216. int testit = 0;
  217.  
  218. int main()
  219. {
  220.   testit = 1;
  221.   int *p = new int;
  222.   delete p;
  223.   testit = 0;
  224.   return 1;
  225. }
  226.  
  227. static unsigned dummy[3];
  228.  
  229. void *operator new(size_t n)
  230. {
  231.   if (testit) {
  232.     dummy[1] = -(unsigned)(dummy + 2);
  233.     return dummy + 2;
  234.   }
  235.   else
  236.     return (void *)malloc(n);
  237. }
  238.  
  239. void operator delete(void *p)
  240. {
  241.   if (testit) {
  242.     if (p == dummy)
  243.       exit(0);
  244.   }
  245.   else
  246.     free(p);
  247. }
  248. ],AC_DEFINE(COOKIE_BUG),,)])dnl
  249. dnl
  250. define(GROFF_CFRONT_ANSI_BUG,
  251. [AC_REQUIRE([GROFF_LIMITS_H])echo checking for cfront ANSI C INT_MIN bug
  252. GROFF_CC_TEST_PROGRAM([#include <stdlib.h>
  253. #ifdef HAVE_CC_LIMITS_H
  254. #include <limits.h>
  255. #else
  256. #define INT_MAX 2147483647
  257. #endif
  258.  
  259. #undef INT_MIN
  260. #define INT_MIN (-INT_MAX-1)
  261.  
  262. int main()
  263. {
  264.   int z = 0;
  265.   return INT_MIN < z;
  266. }
  267. ],AC_DEFINE(CFRONT_ANSI_BUG),,)])dnl
  268. dnl
  269. define(GROFF_ARRAY_DELETE,
  270. [GROFF_CC_COMPILE_CHECK(new array delete syntax,,
  271. changequote(,)dnl
  272. char *p = new char[5]; delete [] p;changequote([,]),
  273. ,AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))])dnl
  274. dnl
  275. define(GROFF_BROKEN_SPOOLER_FLAGS,
  276. [test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
  277. echo using default value of ${BROKEN_SPOOLER_FLAGS} for grops -b option
  278. AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
  279. dnl
  280. define(GROFF_PRINT,
  281. [if test -z "$PSPRINT"
  282. then
  283.     AC_PROGRAMS_CHECK(LPR,lpr)
  284.     AC_PROGRAMS_CHECK(LP,lp)
  285.     if test -n "$LPR" && test -n "$LP"
  286.     then
  287.         # HP-UX provides an lpr command that emulates lpr using lp,
  288.         # but it doesn't have lpq; in this case we want to use lp
  289.         # rather than lpr.
  290.         AC_PROGRAMS_CHECK(LPQ,lpq)
  291.         test -n "$LPQ" || LPR=
  292.     fi
  293.     if test -n "$LPR"
  294.     then
  295.         PSPRINT="$LPR"
  296.     elif test -n "$LP"
  297.     then
  298.         PSPRINT="$LP"
  299.     fi
  300. fi
  301. AC_SUBST(PSPRINT)
  302. # Figure out DVIPRINT from PSPRINT.
  303. if test -n "$PSPRINT" && test -z "$DVIPRINT"
  304. then
  305.     if test "X$PSPRINT" = "Xlpr"
  306.     then
  307.         DVIPRINT="lpr -d"
  308.     else
  309.         DVIPRINT="$PSPRINT"
  310.     fi
  311. fi
  312. AC_SUBST(DVIPRINT)])dnl
  313. define(GROFF_GETOPT,
  314. [GROFF_CC_COMPILE_CHECK([declaration of getopt in stdlib.h],
  315. [#include <stdlib.h>
  316. extern "C" { void getopt(int); }],,,
  317. AC_DEFINE(STDLIB_H_DECLARES_GETOPT))
  318. GROFF_CC_COMPILE_CHECK([declaration of getopt in unistd.h],
  319. [#include <sys/types.h>
  320. #include <unistd.h>
  321. extern "C" { void getopt(int); }],,,
  322. AC_DEFINE(UNISTD_H_DECLARES_GETOPT))
  323. ])dnl
  324. define(GROFF_PUTENV,
  325. [GROFF_CC_COMPILE_CHECK([declaration of putenv],
  326. [#include <stdlib.h>
  327. extern "C" { void putenv(int); }],,,
  328. AC_DEFINE(STDLIB_H_DECLARES_PUTENV))])dnl
  329. define(GROFF_POPEN,
  330. [GROFF_CC_COMPILE_CHECK([declaration of popen],
  331. [#include <stdio.h>
  332. extern "C" { void popen(int); }],,,
  333. AC_DEFINE(STDIO_H_DECLARES_POPEN))])dnl
  334. define(GROFF_PCLOSE,
  335. [GROFF_CC_COMPILE_CHECK([declaration of pclose],
  336. [#include <stdio.h>
  337. extern "C" { void pclose(int); }],,,
  338. AC_DEFINE(STDIO_H_DECLARES_PCLOSE))])dnl
  339. define(GROFF_ETAGSCCFLAG,
  340. [echo checking for etags C++ option
  341. for flag in p C
  342. do
  343.     test -z "$ETAGSCCFLAG" || break
  344.     >conftest.c
  345.     (etags -$flag -o /dev/null conftest.c >/dev/null 2>&1) 2>/dev/null &&
  346.         ETAGSCCFLAG="-$flag"
  347.     rm -f conftest.c
  348. done
  349. AC_SUBST(ETAGSCCFLAG)])dnl
  350. define(GROFF_LIMITS_H,
  351. [AC_PROVIDE([$0])GROFF_CC_COMPILE_CHECK(['C++ <limits.h>'],
  352. [#include <limits.h>],
  353. [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
  354. AC_DEFINE(HAVE_CC_LIMITS_H))])dnl
  355. define(GROFF_TRADITIONAL_CPP,
  356. [GROFF_CC_COMPILE_CHECK([traditional preprocessor],
  357. [#define name2(a,b) a/**/b],[int name2(foo,bar);],
  358. AC_DEFINE(TRADITIONAL_CPP))])dnl
  359. define(GROFF_TIME_T,
  360. [GROFF_CC_COMPILE_CHECK([time_t],[#include <time.h>],
  361. [time_t t = time(0); struct tm *p = localtime(&t);],,
  362. AC_DEFINE(LONG_FOR_TIME_T))])dnl
  363. define(GROFF_OSFCN_H,
  364. [GROFF_CC_COMPILE_CHECK(['C++ <osfcn.h>'],[#include <osfcn.h>],
  365. [read(0, 0, 0); open(0, 0);],AC_DEFINE(HAVE_CC_OSFCN_H))])dnl
  366. dnl Bison generated parsers have problems with C++ compilers other than g++.
  367. dnl So byacc is preferred over bison.
  368. define(GROFF_PROG_YACC,
  369. [AC_PROGRAM_CHECK(YACC, byacc, byacc, )
  370. AC_PROGRAM_CHECK(YACC, bison, bison -y, yacc)
  371. ])dnl
  372. dnl GROFF_CSH_HACK(if hack present, if not present)
  373. define(GROFF_CSH_HACK,
  374. [echo 'checking for csh # hack'
  375. cat <<EOF >conftest.sh
  376. #!/bin/sh
  377. true || exit 0
  378. export PATH || exit 0
  379. exit 1
  380. EOF
  381. chmod +x conftest.sh
  382. if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1
  383. then
  384.     :; $1
  385. else
  386.     :; $2
  387. fi
  388. rm -f conftest.sh
  389. ])dnl
  390. define(GROFF_POSIX,
  391. [GROFF_CC_COMPILE_CHECK(whether -D_POSIX_SOURCE is necessary,
  392. [#include <stdio.h>],
  393. [(void)fileno(stdin);],,
  394. AC_DEFINE(_POSIX_SOURCE))])dnl
  395. dnl From udodo!hans@relay.NL.net (Hans Zuidam)
  396. define(GROFF_ISC_SYSV3,
  397. [echo 'checking for ISC 3.x or 4.x'
  398. changequote(,)dnl
  399. if grep '[34]\.' /usr/options/cb.name >/dev/null 2>&1
  400. changequote([,])dnl
  401. then
  402.     AC_DEFINE(_SYSV3)
  403. fi])dnl
  404.