2008-09-28 22:49:02 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
# If not specified in environment...
|
|
|
|
if ! test "$LIBC"; then
|
|
|
|
# Select which libc to build against
|
|
|
|
LIBC="glibc"
|
|
|
|
LIBC="uclibc"
|
|
|
|
fi
|
2008-11-09 21:38:31 +05:30
|
|
|
# x86 32-bit:
|
2010-05-10 07:46:43 +05:30
|
|
|
#CROSS_COMPILER_PREFIX="i486-linux-uclibc-"
|
2008-11-09 21:38:31 +05:30
|
|
|
# My system has strange prefix for x86 64-bit uclibc:
|
2010-05-10 07:46:43 +05:30
|
|
|
#CROSS_COMPILER_PREFIX="x86_64-pc-linux-gnu-"
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
if test $# -lt 2 || ! test -d "$1" || test -e "$2"; then
|
|
|
|
echo "Usage: $0 SRC_DIR TMP_DIR"
|
|
|
|
echo
|
|
|
|
echo "SRC_DIR will be copied to TMP_DIR directory."
|
|
|
|
echo "Then a random build will be performed."
|
|
|
|
echo
|
|
|
|
echo "Useful variables:"
|
|
|
|
echo "\$LIBC, \$CROSS_COMPILER_PREFIX, \$MAKEOPTS"
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
cp -dpr -- "$1" "$2" || { echo "copy error"; exit 1; }
|
|
|
|
cd -- "$2" || { echo "cd $dir error"; exit 1; }
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
# Generate random config
|
|
|
|
make randconfig >/dev/null || { echo "randconfig error"; exit 1; }
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
# Tweak resulting config
|
2008-09-28 22:49:02 +05:30
|
|
|
cat .config \
|
2010-05-10 07:46:43 +05:30
|
|
|
| grep -v CONFIG_DEBUG_PESSIMIZE \
|
2008-09-28 22:49:02 +05:30
|
|
|
| grep -v CONFIG_WERROR \
|
2010-05-10 07:46:43 +05:30
|
|
|
| grep -v CONFIG_CROSS_COMPILER_PREFIX \
|
2010-01-25 04:03:06 +05:30
|
|
|
| grep -v CONFIG_SELINUX \
|
|
|
|
| grep -v CONFIG_EFENCE \
|
|
|
|
| grep -v CONFIG_DMALLOC \
|
2010-05-10 07:46:43 +05:30
|
|
|
\
|
|
|
|
| grep -v CONFIG_RFKILL \
|
|
|
|
>.config.new
|
2008-09-28 22:49:02 +05:30
|
|
|
mv .config.new .config
|
2010-05-10 07:46:43 +05:30
|
|
|
echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config
|
|
|
|
echo '# CONFIG_WERROR is not set' >>.config
|
|
|
|
echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config
|
2010-07-06 05:56:35 +05:30
|
|
|
echo '# CONFIG_SELINUX is not set' >>.config
|
|
|
|
echo '# CONFIG_EFENCE is not set' >>.config
|
|
|
|
echo '# CONFIG_DMALLOC is not set' >>.config
|
|
|
|
echo '# CONFIG_RFKILL is not set' >>.config
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
# If glibc, don't build static
|
|
|
|
if test x"$LIBC" = x"glibc"; then
|
|
|
|
cat .config \
|
|
|
|
| grep -v CONFIG_STATIC \
|
2016-06-19 21:45:33 +05:30
|
|
|
\
|
|
|
|
| grep -v CONFIG_FEATURE_2_4_MODULES \
|
|
|
|
| grep -v CONFIG_FEATURE_USE_BSS_TAIL \
|
|
|
|
| grep -v CONFIG_DEBUG_SANITIZE \
|
2010-05-10 07:46:43 +05:30
|
|
|
>.config.new
|
|
|
|
mv .config.new .config
|
|
|
|
echo '# CONFIG_STATIC is not set' >>.config
|
2016-06-19 21:45:33 +05:30
|
|
|
# newer glibc (at least 2.23) no longer supply query_module() ABI.
|
|
|
|
# People who target 2.4 kernels would likely use older glibc (and older bbox).
|
|
|
|
echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config
|
|
|
|
echo '# CONFIG_FEATURE_USE_BSS_TAIL is not set' >>.config
|
|
|
|
echo '# CONFIG_DEBUG_SANITIZE is not set' >>.config
|
2010-05-10 07:46:43 +05:30
|
|
|
fi
|
|
|
|
|
2010-07-06 05:56:35 +05:30
|
|
|
# If uclibc, build static, and remove some things
|
2010-05-10 07:46:43 +05:30
|
|
|
# likely to not work on uclibc.
|
|
|
|
if test x"$LIBC" = x"uclibc"; then
|
|
|
|
cat .config \
|
|
|
|
| grep -v CONFIG_STATIC \
|
|
|
|
| grep -v CONFIG_BUILD_LIBBUSYBOX \
|
|
|
|
| grep -v CONFIG_PIE \
|
2010-07-06 05:56:35 +05:30
|
|
|
\
|
|
|
|
| grep -v CONFIG_FEATURE_2_4_MODULES \
|
2015-10-11 19:57:55 +05:30
|
|
|
| grep -v CONFIG_FEATURE_SYNC_FANCY \
|
|
|
|
| grep -v CONFIG_FEATURE_TOUCH_NODEREF \
|
2016-06-19 21:45:33 +05:30
|
|
|
| grep -v CONFIG_NANDWRITE \
|
|
|
|
| grep -v CONFIG_NANDDUMP \
|
|
|
|
| grep -v CONFIG_BLKDISCARD \
|
|
|
|
| grep -v CONFIG_NSENTER \
|
|
|
|
| grep -v CONFIG_UNSHARE \
|
2017-07-03 06:03:08 +05:30
|
|
|
| grep -v CONFIG_FALLOCATE \
|
|
|
|
| grep -v CONFIG_UDHCPC6 \
|
|
|
|
| grep -v CONFIG_ASH_INTERNAL_GLOB \
|
2010-05-10 07:46:43 +05:30
|
|
|
>.config.new
|
|
|
|
mv .config.new .config
|
|
|
|
echo 'CONFIG_STATIC=y' >>.config
|
2010-07-06 05:56:35 +05:30
|
|
|
echo '# CONFIG_BUILD_LIBBUSYBOX is not set' >>.config
|
|
|
|
echo '# CONFIG_PIE is not set' >>.config
|
|
|
|
echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config
|
2015-10-11 19:57:55 +05:30
|
|
|
echo '# CONFIG_FEATURE_SYNC_FANCY is not set' >>.config
|
2014-01-01 03:52:36 +05:30
|
|
|
echo '# CONFIG_FEATURE_TOUCH_NODEREF is not set' >>.config
|
2016-06-19 21:45:33 +05:30
|
|
|
# My uclibc installation does not support some needed APIs...
|
|
|
|
echo '# CONFIG_NANDWRITE is not set' >>.config
|
|
|
|
echo '# CONFIG_NANDDUMP is not set' >>.config
|
|
|
|
echo '# CONFIG_BLKDISCARD is not set' >>.config
|
|
|
|
echo '# CONFIG_NSENTER is not set' >>.config
|
|
|
|
echo '# CONFIG_UNSHARE is not set' >>.config
|
2017-07-03 06:03:08 +05:30
|
|
|
echo '# CONFIG_FALLOCATE is not set' >>.config
|
|
|
|
echo '# CONFIG_UDHCPC6 is not set' >>.config
|
|
|
|
echo 'CONFIG_ASH_INTERNAL_GLOB=y' >>.config
|
2010-05-10 07:46:43 +05:30
|
|
|
fi
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
# If STATIC, remove some things.
|
2008-09-28 22:49:02 +05:30
|
|
|
# PAM with static linking is probably pointless
|
|
|
|
# (but I need to try - now I don't have libpam.a on my system, only libpam.so)
|
2010-05-10 07:46:43 +05:30
|
|
|
if grep -q "^CONFIG_STATIC=y" .config; then
|
|
|
|
cat .config \
|
|
|
|
| grep -v CONFIG_PAM \
|
|
|
|
>.config.new
|
|
|
|
mv .config.new .config
|
2010-07-06 05:56:35 +05:30
|
|
|
echo '# CONFIG_PAM is not set' >>.config
|
2010-05-10 07:46:43 +05:30
|
|
|
fi
|
2008-09-28 22:49:02 +05:30
|
|
|
|
|
|
|
# Regenerate .config with default answers for yanked-off options
|
2010-05-10 07:46:43 +05:30
|
|
|
# (most of default answers are "no").
|
|
|
|
{ yes "" | make oldconfig >/dev/null; } || { echo "oldconfig error"; exit 1; }
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
# Build!
|
|
|
|
nice -n 10 make $MAKEOPTS 2>&1 | tee make.log
|
2016-06-20 01:24:04 +05:30
|
|
|
grep 'Rerun make' make.log \
|
|
|
|
&& nice -n 10 make $MAKEOPTS 2>&1 | tee -a make.log
|
2008-09-28 22:49:02 +05:30
|
|
|
|
2010-05-10 07:46:43 +05:30
|
|
|
# Return exitcode 1 if busybox executable does not exist
|
|
|
|
test -x busybox
|