Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 3 | # If not specified in environment... |
| 4 | if ! test "$LIBC"; then |
| 5 | # Select which libc to build against |
| 6 | LIBC="glibc" |
| 7 | LIBC="uclibc" |
| 8 | fi |
Denis Vlasenko | 62e0dc2 | 2008-11-09 16:08:31 +0000 | [diff] [blame] | 9 | # x86 32-bit: |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 10 | #CROSS_COMPILER_PREFIX="i486-linux-uclibc-" |
Denis Vlasenko | 62e0dc2 | 2008-11-09 16:08:31 +0000 | [diff] [blame] | 11 | # My system has strange prefix for x86 64-bit uclibc: |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 12 | #CROSS_COMPILER_PREFIX="x86_64-pc-linux-gnu-" |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 13 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 14 | if test $# -lt 2 || ! test -d "$1" || test -e "$2"; then |
| 15 | echo "Usage: $0 SRC_DIR TMP_DIR" |
| 16 | echo |
| 17 | echo "SRC_DIR will be copied to TMP_DIR directory." |
| 18 | echo "Then a random build will be performed." |
| 19 | echo |
| 20 | echo "Useful variables:" |
| 21 | echo "\$LIBC, \$CROSS_COMPILER_PREFIX, \$MAKEOPTS" |
| 22 | exit 1 |
| 23 | fi |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 24 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 25 | cp -dpr -- "$1" "$2" || { echo "copy error"; exit 1; } |
| 26 | cd -- "$2" || { echo "cd $dir error"; exit 1; } |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 27 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 28 | # Generate random config |
| 29 | make randconfig >/dev/null || { echo "randconfig error"; exit 1; } |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 30 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 31 | # Tweak resulting config |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 32 | cat .config \ |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 33 | | grep -v CONFIG_DEBUG_PESSIMIZE \ |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 34 | | grep -v CONFIG_WERROR \ |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 35 | | grep -v CONFIG_CROSS_COMPILER_PREFIX \ |
Denys Vlasenko | 2315c88 | 2010-01-24 23:33:06 +0100 | [diff] [blame] | 36 | | grep -v CONFIG_SELINUX \ |
| 37 | | grep -v CONFIG_EFENCE \ |
| 38 | | grep -v CONFIG_DMALLOC \ |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 39 | \ |
| 40 | | grep -v CONFIG_RFKILL \ |
| 41 | >.config.new |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 42 | mv .config.new .config |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 43 | echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config |
| 44 | echo '# CONFIG_WERROR is not set' >>.config |
| 45 | echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 46 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 47 | # If glibc, don't build static |
| 48 | if test x"$LIBC" = x"glibc"; then |
| 49 | cat .config \ |
| 50 | | grep -v CONFIG_STATIC \ |
| 51 | >.config.new |
| 52 | mv .config.new .config |
| 53 | echo '# CONFIG_STATIC is not set' >>.config |
| 54 | fi |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 55 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 56 | # If glibc, build static, and remove some things |
| 57 | # likely to not work on uclibc. |
| 58 | if test x"$LIBC" = x"uclibc"; then |
| 59 | cat .config \ |
| 60 | | grep -v CONFIG_STATIC \ |
| 61 | | grep -v CONFIG_BUILD_LIBBUSYBOX \ |
| 62 | | grep -v CONFIG_TASKSET \ |
| 63 | | grep -v CONFIG_UNICODE_SUPPORT \ |
| 64 | | grep -v CONFIG_PIE \ |
| 65 | >.config.new |
| 66 | mv .config.new .config |
| 67 | echo 'CONFIG_STATIC=y' >>.config |
| 68 | fi |
| 69 | |
| 70 | # If STATIC, remove some things. |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 71 | # PAM with static linking is probably pointless |
| 72 | # (but I need to try - now I don't have libpam.a on my system, only libpam.so) |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 73 | if grep -q "^CONFIG_STATIC=y" .config; then |
| 74 | cat .config \ |
| 75 | | grep -v CONFIG_PAM \ |
| 76 | >.config.new |
| 77 | mv .config.new .config |
| 78 | fi |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 79 | |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 80 | # Regenerate .config with default answers for yanked-off options |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 81 | # (most of default answers are "no"). |
| 82 | { yes "" | make oldconfig >/dev/null; } || { echo "oldconfig error"; exit 1; } |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 83 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 84 | # Build! |
| 85 | nice -n 10 make $MAKEOPTS 2>&1 | tee make.log |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 86 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 87 | # Return exitcode 1 if busybox executable does not exist |
| 88 | test -x busybox |