home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / crypl200.zip / BNLIB / CONFIGUR.IN < prev    next >
Text File  |  1996-01-28  |  10KB  |  313 lines

  1. dnl This file in input to autoconf.  It consists of a series of m4
  2. dnl macros which expand to produce the shell script "configure".
  3. dnl Anything which is not an m4 macro is copied directly to the output.
  4. dnl
  5. dnl Start things up.  If the specified file doesn't exist, configure
  6. dnl will complain.
  7. AC_INIT(lbn16.c)
  8.  
  9. dnl The following tests need to know that we intend to produce a config.h
  10. dnl file, even though this won't expand to any shell script code until
  11. dnl AC_OUTPUT time.  Name it config.hin to avoid MS-LOSS.
  12. AC_CONFIG_HEADER(config.h:config.hin)
  13.  
  14. dnl Checks for programs.
  15.  
  16. # Find a compiler to use.
  17. # Check 1) The $CC environment varaible, 2) gcc, 3) acc, and 4) cc.
  18. dnl This used to be just AC-CHECK-PROGS(CC, gcc acc, cc), but...
  19. # This deals with brain-damaged Sun systems that place a bogus cc or
  20. # acc executable in the $PATH, which just prints an error and exit.
  21. # We deal with this by actually trying to compile a trivial test program.
  22. if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
  23.   AC_MSG_CHECKING(For C compiler (cached))
  24.   CC="$ac_cv_prog_CC"
  25.   AC_MSG_RESULT($CC)
  26. elif test -n "$CC"; then
  27.   ac_cv_prog_CC="$CC" # Let the user override the test.
  28.   AC_MSG_CHECKING(For C compiler)
  29.   AC_MSG_RESULT($CC)
  30. else
  31.   IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  32.   echo 'main(){return 0;}' > conftest.$ac_ext
  33.   for ac_prog in gcc acc cc; do
  34. # Extract the first word of "$ac_prog", so it can be a program name with args.
  35.     set dummy $ac_prog; ac_word=$2
  36.     AC_MSG_CHECKING(for $ac_word)
  37.     for ac_dir in $PATH; do
  38.       test -z "$ac_dir" && ac_dir=.
  39.       if test -x "$ac_dir/$ac_word"; then
  40.         CC="$ac_prog"
  41.         if eval $ac_compile; then
  42.           ac_cv_prog_CC="$ac_prog"
  43.         fi
  44.         break
  45.       fi
  46.     done
  47.     CC="$ac_cv_prog_CC"
  48.     if test -n "$CC"; then
  49.       AC_MSG_RESULT($ac_dir/$CC)
  50.       break;
  51.     fi
  52.     AC_MSG_RESULT(no)
  53.   done
  54.   if test ! -n "$CC"; then
  55.     AC_MSG_ERROR(no C compiler found)
  56.   fi
  57.   IFS="$ac_save_ifs"
  58.   rm -f conftest*
  59. fi
  60. AC_SUBST(CC)
  61.  
  62. AC_CACHE_CHECK(whether we are using GNU CC, ac_cv_prog_gcc,
  63. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  64. cat > conftest.c <<EOF
  65. #ifdef __GNUC__
  66.   yes;
  67. #endif
  68. EOF
  69. if ${CC-cc} -E conftest.c 2>&AC_FD_CC | egrep yes >/dev/null 2>&1; then
  70.   ac_cv_prog_gcc=yes
  71. else
  72.   ac_cv_prog_gcc=no
  73. fi])
  74.  
  75. if test $ac_cv_prog_gcc = yes; then
  76.   if test "${CFLAGS+set}" != set; then
  77. AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_gcc_g,
  78. [echo 'void f(){}' > conftest.c
  79. if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
  80.   ac_cv_prog_gcc_g=yes
  81. else
  82.   ac_cv_prog_gcc_g=no
  83. fi
  84. rm -f conftest*
  85. ])
  86.   fi
  87.  
  88.   # If we're using GCC, perform some Deep Magic to enable the result to
  89.   # link cleanly with code compiled with a compiler that doesn't understand
  90.   # GCC's support library (-lgcc).  Do a link, to relocatable object form,
  91.   # with just -lgcc.  If it's not GCC, do the normal -c thing.
  92.   # These substitutions are used in the Makefile to force that behaviour.
  93.   GCCMAGIC1='-Wl,-r -nostdlib'
  94.   GCCMAGIC2=-lgcc
  95. else
  96.   GCCMAGIC1=-c
  97.   GCCMAGIC2=
  98. fi
  99. AC_SUBST(GCCMAGIC1)
  100. AC_SUBST(GCCMAGIC2)
  101.  
  102. # Now, figure out the CFLAGS we want.  If the user didn't *ask*
  103. # for CFLAGS, we're going to use some ideas of our own.
  104. if test "$(CFLAGS+set)" != set; then
  105.  
  106. # First, remember one useful thing that was just figured out,
  107. # namely whether the compiler can take -g with -O.  (Most compilers
  108. # seem to do the opposite of what I want here - if you give both, -g
  109. # overrides and disables optimization.)  This is only done for
  110. # gcc at the moment, and the no/yes combination is possible but
  111. # misleading
  112. if test $ac_cv_prog_gcc$ac_cv_prog_gcc_g = yesyes; then
  113.   CFLAGS=-g
  114. else
  115.   CFLAGS=""
  116. fi
  117.  
  118. # Now, the whole raison d'e^tre of this library is that it's *fast*.
  119. # So we are *not* happy with autoconf's normal conservative compilation
  120. # flags.  Try to figure out what kind the compiler we're using and soup
  121. # things up a bit.  Also turn on warnings if possible.
  122. # If it's GCC, crank up optimization to -O6, and try to add some
  123. # -m options, too.
  124. # Otherwise, it gets even more ad-hoc, but the test below works for the
  125. # SunPro C compiler and cranks it up to maximum optimization.
  126. dnl
  127. dnl Note that the situation here is actually *worse* than the usual
  128. dnl CPU-COMPANY-SYSTEM system type can detect, because it depends on
  129. dnl the C compiler.  For example, all of the options below (as of the
  130. dnl time this is written) are available on a single machine!
  131. dnl Using compiler-specific checks rather than config.guess seems
  132. dnl entirely appropriate here.
  133. AC_MSG_CHECKING(for useful tuning options (\$TUNE))
  134. if test $ac_cv_prog_gcc = yes; then
  135.   : ${WARN="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"}
  136.   if test "${TUNE+set}" != set; then
  137.     TUNE=-O6
  138.     case `$CC -v 2>&1` in
  139.     *gcc-lib/sparc-*)
  140.     # Try to use the architecture-detecting tool with SunPro CC.
  141.     if bn_tune=`(fpversion -foption) 2>/dev/null`; then
  142.       if test "$bn_tune" = xcg92 || test "$bn_tune" = cg92; then
  143.         TUNE="$TUNE -mv8"
  144.       elif test "$bn_tune" != xcg89 && test "$bn_tune" != cg89; then
  145.         TUNE="$TUNE -mv8"
  146.         bn_tune_guess=yes
  147.       fi
  148.     else
  149.       TUNE="$TUNE -mv8"
  150.       bn_tune_guess=yes
  151.     fi
  152.     esac
  153.   fi
  154. elif $CC -flags 2>&1 | grep SunSoft >/dev/null 2>&1; then
  155.   if test "${WARN+set}" != set; then
  156.     if $CC -flags 2>&1 | grep 'checking' | grep '^-vc' > /dev/null 2>&1; then
  157.       WARN=-vc
  158.     elif $CC -flags 2>&1 | grep 'checking' | grep '^-v ' > /dev/null 2>&1; then
  159.       WARN=-v
  160.     fi
  161.     if $CC -flags 2>&1 | grep '^-xstrconst' > /dev/null 2>&1; then
  162.       WARN="${WARN}${WARN+ }-xstrconst"
  163.     fi
  164.   fi
  165.   # SunPro C compiler - now grok version and platform
  166.   if test "${TUNE+set}" != set; then
  167.     if $CC -flags 2>&1 | grep '^-xO.*5' >/dev/null 2>&1; then
  168.       TUNE=-xO5
  169.     else
  170.       TUNE=-xO4
  171.     fi
  172.     # Architecture: -native iv avail., else as fpversion says, else guess -mv8
  173.     if $CC -flags 2>&1 | grep '^-native' >/dev/null 2>&1; then
  174.       TUNE="$TUNE -native"
  175.     elif bn_tune=`(fpversion -foption) 2>/dev/null`; then
  176.       TUNE="$TUNE -$bn_tune"
  177.     elif $CC -flags 2>&1 | grep '^-xcg92' >/dev/null 2>&1; then
  178.       TUNE="$TUNE -xcg92"
  179.       bn_tune_guess=yes
  180.     fi
  181.   fi
  182. fi
  183. bn_tune_set=${TUNE+set}
  184. # If nothing better is available, turn on -O
  185. : ${TUNE=-O}
  186. AC_MSG_RESULT(${TUNE-none})
  187. if test "$bn_tune_set" != set; then
  188.   AC_MSG_WARN(not optimizing heavily - try setting \$CFLAGS)
  189. elif test "$bn_tune_guess" = yes; then
  190.   AC_MSG_WARN([architecture guessed.  If incorrect, use explicit \$TUNE.])
  191. fi
  192. AC_MSG_CHECKING(for useful warning options (\$WARN))
  193. AC_MSG_RESULT(${WARN-none})
  194. fi 
  195. # ^^ End of "$(CFLAGS+set)" != set condition
  196. AC_SUBST(TUNE)
  197. AC_SUBST(WARN)
  198.  
  199. # Find "ranlib".  Sone systems don't have or need ranlib.  If so,
  200. # ":" (do nothing) is used instead.
  201. AC_PROG_RANLIB
  202.  
  203. dnl Checks for libraries.
  204. dnl (we don't have any)
  205.  
  206. dnl Checks for header files.
  207. AC_HEADER_STDC
  208.  
  209. if test $ac_cv_header_stdc = yes; then
  210.   AC_DEFINE(HAVE_ASSERT_H)
  211.   AC_DEFINE(HAVE_LIMITS_H)
  212.   AC_DEFINE(HAVE_STDLIB_H)
  213.   AC_DEFINE(HAVE_STRING_H)
  214.  
  215. else    # If non-ANSI, check for other brokenness.
  216.  
  217. AC_CHECK_HEADERS(assert.h limits.h stdlib.h string.h)
  218.  
  219. # Do we want to include memory.h?
  220. if test $ac_cv_header_string_h = no; then
  221. AC_CHECK_HEADERS(strings.h)
  222. ac_found=no
  223. else
  224. AC_MSG_CHECKING(whether string.h declares mem functions)
  225. AC_EGREP_HEADER(memset, string.h, ac_found=yes, ac_found=no)
  226. AC_MSG_RESULT($ac_found)
  227. fi
  228. # ac_found is now "yes" if string.h exists and declares the mem*
  229. # functions.  If not, see if memory.h exists and include that
  230. # as well.
  231. if test $ac_found = no; then
  232. AC_CHECK_HEADER(memory,h. [AC_DEFINE(NEED_MEMORY_H)])
  233. fi
  234.  
  235. AC_CACHE_CHECK(whether <stdio.h> provides prototypes,
  236. bn_cv_header_stdio_protos,
  237. [AC_EGREP_HEADER(printf, stdio.h, bn_cv_header_stdio_protos=yes, bn_cv_header_stdio_protos=no)
  238. ])
  239. if test $bn_cv_header_stdio_protos = no; then
  240.   AC_DEFINE(NO_STDIO_PROTOS)
  241. fi
  242.  
  243. fi
  244. # ^^ End of non-ANSI header brokenness tests (first part)
  245.  
  246. AC_CACHE_CHECK(whether <string.h> declares mem* wrong.,
  247. bn_cv_header_mem_broken,
  248. [AC_EGREP_HEADER(memcpy.*char, string.h, bn_cv_header_mem_broken=yes, bn_cv_header_mem_broken=no)
  249. ])
  250. if test $bn_cv_header_mem_broken = yes; then
  251.   AC_DEFINE(MEM_PROTOS_BROKEN)
  252. fi
  253.  
  254. # SunOS 4.1.x acc's <assert.h> is broken
  255. AC_CACHE_CHECK(whether <assert.h> is broken and needs <stdio.h>,
  256. bn_cv_header_assert_needs_stdio,
  257. [AC_EGREP_CPP(stderr,
  258. [#include <assert.h>
  259. assert(foo)
  260. ], bn_cv_header_assert_needs_stdio=yes, bn_cv_header_assert_needs_stdio=no)
  261. ])
  262. if test $bn_cv_header_assert_needs_stdio = yes; then
  263.   AC_DEFINE(ASSERT_NEEDS_STDIO)
  264. fi
  265.  
  266. AC_CACHE_CHECK(whether <assert.h> is broken and needs <stdlib.h>,
  267. bn_cv_header_assert_needs_stdlib,
  268. [AC_EGREP_CPP(exit,
  269. [#include <assert.h>
  270. assert(foo)
  271. ], bn_cv_header_assert_needs_stdlib=yes, bn_cv_header_assert_needs_stdlib=no)
  272. ])
  273. if test $bn_cv_header_assert_needs_stdlib = yes; then
  274.   AC_DEFINE(ASSERT_NEEDS_STDLIB)
  275. fi
  276.  
  277. # Check that we have <sys/time.h> explicitly.
  278. AC_CHECK_HEADERS(sys/time.h)
  279. AC_HEADER_TIME
  280.  
  281. dnl Checks for typedefs, structures, and compiler characteristics.
  282. # Verify that the compiler supports const, and that it works.
  283. # A number of compilers sort of support const, but they have bugs
  284. # that will prevent valid programs from compiling.
  285. AC_C_CONST
  286.  
  287. # See if we have size_t.  (If not, define it as unsigned.)
  288. AC_TYPE_SIZE_T
  289.  
  290. dnl Checks for library functions.
  291. AC_CHECK_FUNCS(clock_gettime gethrvtime getrusage)
  292. dnl The following are for real-time clocks only as of yet.
  293. dnl AC_CHECK_FUNCS(clock_getres gethrtime gettimeofday getitimer setitimer ftime)
  294.  
  295. # If we don't have ANSI C, see if a few functions are missing that
  296. # we've noticed the lack of before.
  297. if test $ac_cv_header_stdc = yes; then
  298.   AC_DEFINE(HAVE_CLOCK)
  299.   AC_DEFINE(HAVE_TIME)
  300.   AC_DEFINE(HAVE_MEMMOVE)
  301.   AC_DEFINE(HAVE_MEMCPY)
  302. else
  303. AC_CHECK_FUNCS(clock time memmove memcpy)
  304. fi
  305. # ^^ End of non-ANSI header brokenness tests (second part)
  306.  
  307. # The big bang!  Produce the output files.  This is config.cache, and
  308. # config.status, which builds the config.h file and a long list of
  309. # Makefiles.
  310. dnl The value specified to AC_CONFIG_HEADER at the top if the file is
  311. dnl used here to produce config.h.
  312. AC_OUTPUT(Makefile)
  313.