2
0

configure.ac 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. dnl Copyright (c) 1995 Colin Plumb. All rights reserved.
  2. dnl For licensing and other legal details, see the file legal.c.
  3. dnl
  4. dnl This file in input to autoconf. It consists of a series of m4
  5. dnl macros which expand to produce the shell script "configure".
  6. dnl Anything which is not an m4 macro is copied directly to the output.
  7. dnl
  8. dnl Start things up. If the specified file doesn't exist, configure
  9. dnl will complain.
  10. AC_INIT([libbn], [0.1])
  11. dnl The following tests need to know that we intend to produce a config.h
  12. dnl file, even though this won't expand to any shell script code until
  13. dnl AC_OUTPUT time. Name it bnconfig.hin to avoid MS-LOSS.
  14. AC_CONFIG_HEADER(bnconfig.h:bnconfig.hin)
  15. dnl Checks for programs.
  16. # Find a compiler to use.
  17. # Check 1) The $CC environment varaible, 2) egcc, 3) gcc, 4) acc, and 5) 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 egcc 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. AC_CACHE_CHECK(whether we are using GNU CC, ac_cv_prog_gcc,
  62. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  63. cat > conftest.c <<EOF
  64. #ifdef __GNUC__
  65. yes;
  66. #endif
  67. EOF
  68. if ${CC-cc} -E conftest.c 2>&AC_FD_CC | egrep yes >/dev/null 2>&1; then
  69. ac_cv_prog_gcc=yes
  70. else
  71. ac_cv_prog_gcc=no
  72. fi])
  73. if test $ac_cv_prog_gcc = yes; then
  74. if test "${CFLAGS+set}" != set; then
  75. AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_gcc_g,
  76. [echo 'void f(){}' > conftest.c
  77. if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
  78. ac_cv_prog_gcc_g=yes
  79. else
  80. ac_cv_prog_gcc_g=no
  81. fi
  82. rm -f conftest*
  83. ])
  84. fi
  85. # If we're using GCC, perform some Deep Magic to enable the result to
  86. # link cleanly with code compiled with a compiler that doesn't understand
  87. # GCC's support library (-lgcc). Do a link, to relocatable object form,
  88. # with just -lgcc. If it's not GCC, do the normal -c thing.
  89. # These substitutions are used in the Makefile to force that behaviour.
  90. GCCMAGIC1='-Wl,-r -nostdlib'
  91. GCCMAGIC2=-lgcc
  92. else
  93. GCCMAGIC1=-c
  94. GCCMAGIC2=
  95. fi
  96. AC_SUBST(GCCMAGIC1)
  97. AC_SUBST(GCCMAGIC2)
  98. # Now, figure out the CFLAGS we want. If the user didn't *ask*
  99. # for CFLAGS, we're going to use some ideas of our own.
  100. if test "${CFLAGS+set}" != set; then
  101. # First, remember one useful thing that was just figured out,
  102. # namely whether the compiler can take -g with -O. (Most compilers
  103. # seem to do the opposite of what I want here - if you give both, -g
  104. # overrides and disables optimization.) This is only done for
  105. # gcc at the moment, and the no/yes combination is possible but
  106. # misleading
  107. if test $ac_cv_prog_gcc$ac_cv_prog_gcc_g = yesyes; then
  108. CFLAGS=-g
  109. else
  110. CFLAGS=""
  111. fi
  112. # Now, the whole raison d'e^tre of this library is that it's *fast*.
  113. # So we are *not* happy with autoconf's normal conservative compilation
  114. # flags. Try to figure out what kind the compiler we're using and soup
  115. # things up a bit. Also turn on warnings if possible.
  116. # If it's GCC, crank up optimization to -O6, and try to add some
  117. # -m options, too.
  118. # Otherwise, it gets even more ad-hoc, but the test below works for the
  119. # SunPro C compiler and cranks it up to maximum optimization.
  120. dnl
  121. dnl Note that the situation here is actually *worse* than the usual
  122. dnl CPU-COMPANY-SYSTEM system type can detect, because it depends on
  123. dnl the C compiler. For example, all of the options below (as of the
  124. dnl time this is written) are available on a single machine!
  125. dnl Using compiler-specific checks rather than config.guess seems
  126. dnl entirely appropriate here.
  127. AC_MSG_CHECKING(for useful tuning options (\$TUNE))
  128. if test $ac_cv_prog_gcc = yes; then
  129. : ${WARN="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"}
  130. if test "${TUNE+set}" != set; then
  131. TUNE=-O6
  132. case `$CC -v 2>&1` in
  133. *gcc-lib/sparc-*)
  134. # Try to use the architecture-detecting tool with SunPro CC.
  135. if bn_tune=`(fpversion -foption) 2>/dev/null`; then
  136. if test "$bn_tune" = xcg92 || test "$bn_tune" = cg92; then
  137. TUNE="$TUNE -mv8"
  138. elif test "$bn_tune" != xcg89 && test "$bn_tune" != cg89; then
  139. TUNE="$TUNE -mv8"
  140. bn_tune_guess=yes
  141. fi
  142. else
  143. TUNE="$TUNE -mv8"
  144. bn_tune_guess=yes
  145. fi
  146. esac
  147. fi
  148. elif $CC -flags 2>&1 | grep SunSoft >/dev/null 2>&1; then
  149. if test "${WARN+set}" != set; then
  150. if $CC -flags 2>&1 | grep 'checking' | grep '^-vc' > /dev/null 2>&1; then
  151. WARN=-vc
  152. elif $CC -flags 2>&1 | grep 'checking' | grep '^-v ' > /dev/null 2>&1; then
  153. WARN=-v
  154. fi
  155. if $CC -flags 2>&1 | grep '^-xstrconst' > /dev/null 2>&1; then
  156. WARN="${WARN}${WARN+ }-xstrconst"
  157. fi
  158. fi
  159. # SunPro C compiler - now grok version and platform
  160. if test "${TUNE+set}" != set; then
  161. if $CC -flags 2>&1 | grep '^-xO.*5' >/dev/null 2>&1; then
  162. TUNE=-xO5
  163. else
  164. TUNE=-xO4
  165. fi
  166. # Architecture: -native iv avail., else as fpversion says, else guess -mv8
  167. if $CC -flags 2>&1 | grep '^-native' >/dev/null 2>&1; then
  168. TUNE="$TUNE -native"
  169. elif bn_tune=`(fpversion -foption) 2>/dev/null`; then
  170. TUNE="$TUNE -$bn_tune"
  171. elif $CC -flags 2>&1 | grep '^-xcg92' >/dev/null 2>&1; then
  172. TUNE="$TUNE -xcg92"
  173. bn_tune_guess=yes
  174. fi
  175. fi
  176. fi
  177. bn_tune_set=${TUNE+set}
  178. # If nothing better is available, turn on -O
  179. : ${TUNE=-O}
  180. AC_MSG_RESULT(${TUNE-none})
  181. if test "$bn_tune_set" != set; then
  182. AC_MSG_WARN(not optimizing heavily - try setting \$CFLAGS)
  183. elif test "$bn_tune_guess" = yes; then
  184. AC_MSG_WARN([architecture guessed. If incorrect, use explicit \$TUNE.])
  185. fi
  186. AC_MSG_CHECKING(for useful warning options (\$WARN))
  187. AC_MSG_RESULT(${WARN-none})
  188. fi
  189. # ^^ End of "$(CFLAGS+set)" != set condition
  190. AC_SUBST(TUNE)
  191. AC_SUBST(WARN)
  192. # Find "ranlib". Sone systems don't have or need ranlib. If so,
  193. # ":" (do nothing) is used instead.
  194. AC_PROG_RANLIB
  195. dnl Checks for libraries.
  196. dnl (we don't have any)
  197. dnl Checks for header files.
  198. AC_HEADER_STDC
  199. if test $ac_cv_header_stdc = yes; then
  200. AC_DEFINE(HAVE_ASSERT_H)
  201. AC_DEFINE(HAVE_LIMITS_H)
  202. AC_DEFINE(HAVE_STDLIB_H)
  203. AC_DEFINE(HAVE_STRING_H)
  204. else # If non-ANSI, check for other brokenness.
  205. AC_CHECK_HEADERS(assert.h limits.h stdlib.h string.h)
  206. fi
  207. # ^^ End of non-ANSI header brokenness tests (first part)
  208. # Check that we have <sys/time.h> explicitly.
  209. AC_CHECK_HEADERS(sys/time.h)
  210. AC_HEADER_TIME
  211. dnl Checks for typedefs, structures, and compiler characteristics.
  212. # Verify that the compiler supports const, and that it works.
  213. # A number of compilers sort of support const, but they have bugs
  214. # that will prevent valid programs from compiling.
  215. AC_C_CONST
  216. # See if we have size_t. (If not, define it as unsigned.)
  217. AC_TYPE_SIZE_T
  218. dnl Checks for library functions.
  219. AC_CHECK_FUNCS(clock_gettime gethrvtime getrusage)
  220. dnl The following are for real-time clocks only as of yet.
  221. dnl AC_CHECK_FUNCS(clock_getres gethrtime gettimeofday getitimer setitimer ftime)
  222. # If we don't have ANSI C, see if a few functions are missing that
  223. # we've noticed the lack of before.
  224. if test $ac_cv_header_stdc = yes; then
  225. AC_DEFINE(HAVE_CLOCK)
  226. AC_DEFINE(HAVE_TIME)
  227. AC_DEFINE(HAVE_MEMMOVE)
  228. AC_DEFINE(HAVE_MEMCPY)
  229. else
  230. AC_CHECK_FUNCS(clock time memmove memcpy)
  231. fi
  232. # ^^ End of non-ANSI header brokenness tests (second part)
  233. # libzrtp - fix it back
  234. #AC_OUTPUT_SUBDIRS(test)
  235. # The big bang! Produce the output files. This is config.cache, and
  236. # config.status, which builds the config.h file and a long list of
  237. # Makefiles.
  238. dnl The value specified to AC_CONFIG_HEADER at the top if the file is
  239. dnl used here to produce bnconfig.h.
  240. AC_OUTPUT(Makefile)
  241. echo
  242. echo bnlib is now configured for a generic installation.
  243. echo If you with assembly-language support, edit the Makefile according
  244. echo to the instructions in README.bn.