1# sourced to find alternate names for things 2 3source ./configure 4 5if [ -z "$(command -v "${CROSS_COMPILE}${CC}")" ] 6then 7 echo "No ${CROSS_COMPILE}${CC} found" >&2 8 exit 1 9fi 10 11if [ -z "$SED" ] 12then 13 [ ! -z "$(command -v gsed 2>/dev/null)" ] && SED=gsed || SED=sed 14fi 15 16# Tell linker to do dead code elimination at function level 17if [ "$(uname)" == "Darwin" ] 18then 19 CFLAGS+=" -Wno-deprecated-declarations" 20 : ${LDOPTIMIZE:=-Wl,-dead_strip} ${STRIP:=strip} 21else 22 : ${LDOPTIMIZE:=-Wl,--gc-sections -Wl,--as-needed} ${STRIP:=strip -s -R .note* -R .comment} 23fi 24 25# Address Sanitizer 26if [ ! -z "$ASAN" ]; then 27 # Turn ASan on and disable most optimization to get more readable backtraces. 28 # (Technically ASAN is just "-fsanitize=address" and the rest is optional.) 29 ASAN_FLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls" 30 CFLAGS="$CFLAGS $ASAN_FLAGS" 31 HOSTCC="$HOSTCC $ASAN_FLAGS" 32 NOSTRIP=1 33 # Ignore leaks on exit. TODO 34 export ASAN_OPTIONS="detect_leaks=0" 35 unset ASAN 36fi 37 38# Probe number of available processors, and add one. 39: ${CPUS:=$(($(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)+1))} 40 41# Centos 7 bug workaround, EOL June 30 2024. TODO 42DASHN=-n; wait -n 2>/dev/null; [ $? -eq 2 ] && unset DASHN 43 44# If the build is using gnu tools, make them behave less randomly. 45export LANG=c 46export LC_ALL=C 47