|
@@ -1,86 +1,88 @@
|
|
|
#!/bin/sh
|
|
|
|
|
|
-# Select which libc to build against
|
|
|
-libc="glibc" # assumed native
|
|
|
-# static, cross-compilation
|
|
|
-libc="uclibc"
|
|
|
+# If not specified in environment...
|
|
|
+if ! test "$LIBC"; then
|
|
|
+ # Select which libc to build against
|
|
|
+ LIBC="glibc"
|
|
|
+ LIBC="uclibc"
|
|
|
+fi
|
|
|
# x86 32-bit:
|
|
|
-uclibc_cross="i486-linux-uclibc-"
|
|
|
+#CROSS_COMPILER_PREFIX="i486-linux-uclibc-"
|
|
|
# My system has strange prefix for x86 64-bit uclibc:
|
|
|
-#uclibc_cross="x86_64-pc-linux-gnu-"
|
|
|
+#CROSS_COMPILER_PREFIX="x86_64-pc-linux-gnu-"
|
|
|
|
|
|
-test -d tree || exit 1
|
|
|
+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
|
|
|
|
|
|
-dir=test.$$
|
|
|
-while test -e "$dir" -o -e failed."$dir"; do
|
|
|
- dir=test."$RANDOM"
|
|
|
-done
|
|
|
+cp -dpr -- "$1" "$2" || { echo "copy error"; exit 1; }
|
|
|
+cd -- "$2" || { echo "cd $dir error"; exit 1; }
|
|
|
|
|
|
-cp -dpr tree "$dir" || exit 1
|
|
|
-cd "$dir" || exit 1
|
|
|
-
|
|
|
-echo "Running randconfig test in $dir..." >&2
|
|
|
-
|
|
|
-make randconfig >/dev/null || exit 1
|
|
|
+# Generate random config
|
|
|
+make randconfig >/dev/null || { echo "randconfig error"; exit 1; }
|
|
|
|
|
|
+# Tweak resulting config
|
|
|
cat .config \
|
|
|
-| grep -v ^CONFIG_DEBUG_PESSIMIZE= \
|
|
|
+| grep -v CONFIG_DEBUG_PESSIMIZE \
|
|
|
| grep -v CONFIG_WERROR \
|
|
|
-| cat >.config.new
|
|
|
-mv .config.new .config
|
|
|
-#echo CONFIG_WERROR=y >>.config
|
|
|
-echo '# CONFIG_WERROR is not set' >>.config
|
|
|
-
|
|
|
-test "$libc" = glibc && {
|
|
|
-cat .config \
|
|
|
-| grep -v CONFIG_STATIC \
|
|
|
+| grep -v CONFIG_CROSS_COMPILER_PREFIX \
|
|
|
| grep -v CONFIG_SELINUX \
|
|
|
| grep -v CONFIG_EFENCE \
|
|
|
| grep -v CONFIG_DMALLOC \
|
|
|
-| cat >.config.new
|
|
|
+\
|
|
|
+| grep -v CONFIG_RFKILL \
|
|
|
+>.config.new
|
|
|
mv .config.new .config
|
|
|
-echo '# CONFIG_STATIC is not set' >>.config
|
|
|
-}
|
|
|
+echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config
|
|
|
+echo '# CONFIG_WERROR is not set' >>.config
|
|
|
+echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config
|
|
|
|
|
|
-test "$libc" = uclibc && {
|
|
|
-cat .config \
|
|
|
-| grep -v ^CONFIG_SELINUX= \
|
|
|
-| grep -v ^CONFIG_EFENCE= \
|
|
|
-| grep -v ^CONFIG_DMALLOC= \
|
|
|
-| grep -v ^CONFIG_BUILD_LIBBUSYBOX= \
|
|
|
-| grep -v ^CONFIG_PAM= \
|
|
|
-| grep -v ^CONFIG_TASKSET= \
|
|
|
-| grep -v ^CONFIG_UNICODE_SUPPORT= \
|
|
|
-| grep -v ^CONFIG_PIE= \
|
|
|
-| grep -v CONFIG_STATIC \
|
|
|
-| grep -v CONFIG_CROSS_COMPILER_PREFIX \
|
|
|
-| cat >.config.new
|
|
|
-mv .config.new .config
|
|
|
-echo 'CONFIG_CROSS_COMPILER_PREFIX="'"$uclibc_cross"'"' >>.config
|
|
|
-echo 'CONFIG_STATIC=y' >>.config
|
|
|
-}
|
|
|
+# If glibc, don't build static
|
|
|
+if test x"$LIBC" = x"glibc"; then
|
|
|
+ cat .config \
|
|
|
+ | grep -v CONFIG_STATIC \
|
|
|
+ >.config.new
|
|
|
+ mv .config.new .config
|
|
|
+ echo '# CONFIG_STATIC is not set' >>.config
|
|
|
+fi
|
|
|
+
|
|
|
+# If glibc, build static, and remove some things
|
|
|
+# 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_TASKSET \
|
|
|
+ | grep -v CONFIG_UNICODE_SUPPORT \
|
|
|
+ | grep -v CONFIG_PIE \
|
|
|
+ >.config.new
|
|
|
+ mv .config.new .config
|
|
|
+ echo 'CONFIG_STATIC=y' >>.config
|
|
|
+fi
|
|
|
|
|
|
-# If STATIC, remove some things
|
|
|
+# If STATIC, remove some things.
|
|
|
# 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)
|
|
|
-grep -q ^CONFIG_STATIC= .config && {
|
|
|
-cat .config \
|
|
|
-| grep -v ^CONFIG_PAM= \
|
|
|
-| cat >.config.new
|
|
|
-mv .config.new .config
|
|
|
-}
|
|
|
+if grep -q "^CONFIG_STATIC=y" .config; then
|
|
|
+ cat .config \
|
|
|
+ | grep -v CONFIG_PAM \
|
|
|
+ >.config.new
|
|
|
+ mv .config.new .config
|
|
|
+fi
|
|
|
|
|
|
# Regenerate .config with default answers for yanked-off options
|
|
|
-{ yes "" | make oldconfig >/dev/null; } || exit 1
|
|
|
-
|
|
|
-nice -n 10 make $MAKEOPTS 2>&1 | tee -a make.log
|
|
|
+# (most of default answers are "no").
|
|
|
+{ yes "" | make oldconfig >/dev/null; } || { echo "oldconfig error"; exit 1; }
|
|
|
|
|
|
-test -x busybox && {
|
|
|
- cd ..
|
|
|
- rm -rf "$dir"
|
|
|
- exit 0
|
|
|
-}
|
|
|
+# Build!
|
|
|
+nice -n 10 make $MAKEOPTS 2>&1 | tee make.log
|
|
|
|
|
|
-cd ..
|
|
|
-mv "$dir" "failed.$dir"
|
|
|
-exit 1
|
|
|
+# Return exitcode 1 if busybox executable does not exist
|
|
|
+test -x busybox
|