2018-02-04 18:07:12 -08:00
|
|
|
#!/bin/bash
|
2008-01-19 15:08:39 -08:00
|
|
|
|
2022-03-04 02:11:01 -08:00
|
|
|
# set environment variables used by scripts/make.sh
|
2008-01-19 15:08:39 -08:00
|
|
|
|
2018-02-04 18:07:12 -08:00
|
|
|
# People run ./configure out of habit, so do "defconfig" for them.
|
|
|
|
|
|
|
|
if [ "$(basename "$0")" == configure ]
|
|
|
|
then
|
|
|
|
echo "Assuming you want 'make defconfig', but you should probably check the README."
|
|
|
|
make defconfig
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
|
2022-03-04 02:11:01 -08:00
|
|
|
# Warn about stuff, disable stupid warnings, be 8-bit clean for utf8.
|
|
|
|
CFLAGS="$CFLAGS -Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-declaration -Wno-char-subscripts -Wno-pointer-sign -Wno-string-plus-int -funsigned-char"
|
|
|
|
|
|
|
|
# Set default values if variable not already set
|
2022-03-22 12:21:08 -07:00
|
|
|
: ${CC:=cc} ${HOSTCC:=cc} ${GENDIR:=generated} ${KCONFIG_CONFIG:=.config}
|
2022-03-04 02:11:01 -08:00
|
|
|
: ${OUTNAME:=toybox${TARGET:+-$TARGET}}
|
|
|
|
: ${OPTIMIZE:=-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing}
|
|
|
|
|
2019-08-27 10:45:25 -07:00
|
|
|
# set ASAN=1 to enable "address sanitizer" and debuggable backtraces
|
2019-09-20 12:38:52 -07:00
|
|
|
[ -z "$ASAN" ] || { CFLAGS="$CFLAGS -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address"; NOSTRIP=1; }
|
2015-02-28 10:39:16 -08:00
|
|
|
|
|
|
|
# We accept LDFLAGS, but by default don't have anything in it
|
2021-09-30 19:21:25 -07:00
|
|
|
if [ "$(uname)" == "Darwin" ]
|
2018-11-30 13:47:05 -08:00
|
|
|
then
|
2022-03-04 02:11:01 -08:00
|
|
|
: ${LDOPTIMIZE:=-Wl,-dead_strip} ${STRIP:=strip}
|
2021-09-30 19:21:25 -07:00
|
|
|
else
|
2022-03-04 02:11:01 -08:00
|
|
|
: ${LDOPTIMIZE:=-Wl,--gc-sections -Wl,--as-needed} ${STRIP:=strip -s -R .note* -R .comment}
|
|
|
|
# LDASNEEDED="-Wl,--as-needed" # must go at end of compiler command line
|
2018-11-30 13:47:05 -08:00
|
|
|
fi
|