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