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 |
Denys Vlasenko | 3e5fa43 | 2010-07-06 02:26:35 +0200 | [diff] [blame] | 46 | echo '# CONFIG_SELINUX is not set' >>.config |
| 47 | echo '# CONFIG_EFENCE is not set' >>.config |
| 48 | echo '# CONFIG_DMALLOC is not set' >>.config |
| 49 | echo '# CONFIG_RFKILL is not set' >>.config |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 50 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 51 | # If glibc, don't build static |
| 52 | if test x"$LIBC" = x"glibc"; then |
| 53 | cat .config \ |
| 54 | | grep -v CONFIG_STATIC \ |
Denys Vlasenko | 9c9a742 | 2017-12-31 20:31:05 +0100 | [diff] [blame] | 55 | | grep -v CONFIG_FEATURE_LIBBUSYBOX_STATIC \ |
Denys Vlasenko | 015db58 | 2016-06-19 18:15:33 +0200 | [diff] [blame] | 56 | \ |
| 57 | | grep -v CONFIG_FEATURE_2_4_MODULES \ |
| 58 | | grep -v CONFIG_FEATURE_USE_BSS_TAIL \ |
| 59 | | grep -v CONFIG_DEBUG_SANITIZE \ |
Denys Vlasenko | 5f5119b | 2018-06-26 16:01:05 +0200 | [diff] [blame] | 60 | | grep -v CONFIG_FEATURE_MOUNT_NFS \ |
Denys Vlasenko | 1853266 | 2018-06-26 16:08:22 +0200 | [diff] [blame] | 61 | | grep -v CONFIG_FEATURE_INETD_RPC \ |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 62 | >.config.new |
| 63 | mv .config.new .config |
| 64 | echo '# CONFIG_STATIC is not set' >>.config |
Denys Vlasenko | 9c9a742 | 2017-12-31 20:31:05 +0100 | [diff] [blame] | 65 | echo '# CONFIG_FEATURE_LIBBUSYBOX_STATIC is not set' >>.config |
Denys Vlasenko | 015db58 | 2016-06-19 18:15:33 +0200 | [diff] [blame] | 66 | # newer glibc (at least 2.23) no longer supply query_module() ABI. |
| 67 | # People who target 2.4 kernels would likely use older glibc (and older bbox). |
| 68 | echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config |
| 69 | echo '# CONFIG_FEATURE_USE_BSS_TAIL is not set' >>.config |
| 70 | echo '# CONFIG_DEBUG_SANITIZE is not set' >>.config |
Denys Vlasenko | 5f5119b | 2018-06-26 16:01:05 +0200 | [diff] [blame] | 71 | # 2018: current glibc versions no longer include rpc/rpc.h |
| 72 | echo '# CONFIG_FEATURE_MOUNT_NFS is not set' >>.config |
Denys Vlasenko | 1853266 | 2018-06-26 16:08:22 +0200 | [diff] [blame] | 73 | echo '# CONFIG_FEATURE_INETD_RPC is not set' >>.config |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 74 | fi |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 75 | |
Denys Vlasenko | 3e5fa43 | 2010-07-06 02:26:35 +0200 | [diff] [blame] | 76 | # If uclibc, build static, and remove some things |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 77 | # likely to not work on uclibc. |
| 78 | if test x"$LIBC" = x"uclibc"; then |
| 79 | cat .config \ |
| 80 | | grep -v CONFIG_STATIC \ |
| 81 | | grep -v CONFIG_BUILD_LIBBUSYBOX \ |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 82 | | grep -v CONFIG_PIE \ |
Denys Vlasenko | 3e5fa43 | 2010-07-06 02:26:35 +0200 | [diff] [blame] | 83 | \ |
| 84 | | grep -v CONFIG_FEATURE_2_4_MODULES \ |
Denys Vlasenko | 69c8c69 | 2015-10-11 16:27:55 +0200 | [diff] [blame] | 85 | | grep -v CONFIG_FEATURE_SYNC_FANCY \ |
| 86 | | grep -v CONFIG_FEATURE_TOUCH_NODEREF \ |
Denys Vlasenko | 015db58 | 2016-06-19 18:15:33 +0200 | [diff] [blame] | 87 | | grep -v CONFIG_NANDWRITE \ |
| 88 | | grep -v CONFIG_NANDDUMP \ |
| 89 | | grep -v CONFIG_BLKDISCARD \ |
| 90 | | grep -v CONFIG_NSENTER \ |
| 91 | | grep -v CONFIG_UNSHARE \ |
Denys Vlasenko | 7fdb764 | 2017-07-03 02:33:08 +0200 | [diff] [blame] | 92 | | grep -v CONFIG_FALLOCATE \ |
| 93 | | grep -v CONFIG_UDHCPC6 \ |
Denys Vlasenko | 762440b | 2018-06-26 17:22:35 +0200 | [diff] [blame] | 94 | | grep -v CONFIG_NSLOOKUP \ |
Denys Vlasenko | 7fdb764 | 2017-07-03 02:33:08 +0200 | [diff] [blame] | 95 | | grep -v CONFIG_ASH_INTERNAL_GLOB \ |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 96 | >.config.new |
| 97 | mv .config.new .config |
| 98 | echo 'CONFIG_STATIC=y' >>.config |
Denys Vlasenko | 3e5fa43 | 2010-07-06 02:26:35 +0200 | [diff] [blame] | 99 | echo '# CONFIG_BUILD_LIBBUSYBOX is not set' >>.config |
| 100 | echo '# CONFIG_PIE is not set' >>.config |
| 101 | echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config |
Denys Vlasenko | 69c8c69 | 2015-10-11 16:27:55 +0200 | [diff] [blame] | 102 | echo '# CONFIG_FEATURE_SYNC_FANCY is not set' >>.config |
Denys Vlasenko | 198b02f | 2013-12-31 23:22:36 +0100 | [diff] [blame] | 103 | echo '# CONFIG_FEATURE_TOUCH_NODEREF is not set' >>.config |
Denys Vlasenko | 015db58 | 2016-06-19 18:15:33 +0200 | [diff] [blame] | 104 | # My uclibc installation does not support some needed APIs... |
| 105 | echo '# CONFIG_NANDWRITE is not set' >>.config |
| 106 | echo '# CONFIG_NANDDUMP is not set' >>.config |
| 107 | echo '# CONFIG_BLKDISCARD is not set' >>.config |
| 108 | echo '# CONFIG_NSENTER is not set' >>.config |
| 109 | echo '# CONFIG_UNSHARE is not set' >>.config |
Denys Vlasenko | 7fdb764 | 2017-07-03 02:33:08 +0200 | [diff] [blame] | 110 | echo '# CONFIG_FALLOCATE is not set' >>.config |
| 111 | echo '# CONFIG_UDHCPC6 is not set' >>.config |
Denys Vlasenko | 762440b | 2018-06-26 17:22:35 +0200 | [diff] [blame] | 112 | echo '# CONFIG_NSLOOKUP is not set' >>.config |
Denys Vlasenko | 7fdb764 | 2017-07-03 02:33:08 +0200 | [diff] [blame] | 113 | echo 'CONFIG_ASH_INTERNAL_GLOB=y' >>.config |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 114 | fi |
| 115 | |
| 116 | # If STATIC, remove some things. |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 117 | # PAM with static linking is probably pointless |
| 118 | # (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] | 119 | if grep -q "^CONFIG_STATIC=y" .config; then |
| 120 | cat .config \ |
| 121 | | grep -v CONFIG_PAM \ |
| 122 | >.config.new |
| 123 | mv .config.new .config |
Denys Vlasenko | 3e5fa43 | 2010-07-06 02:26:35 +0200 | [diff] [blame] | 124 | echo '# CONFIG_PAM is not set' >>.config |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 125 | fi |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 126 | |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 127 | # Regenerate .config with default answers for yanked-off options |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 128 | # (most of default answers are "no"). |
| 129 | { yes "" | make oldconfig >/dev/null; } || { echo "oldconfig error"; exit 1; } |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 130 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 131 | # Build! |
| 132 | nice -n 10 make $MAKEOPTS 2>&1 | tee make.log |
Denys Vlasenko | bb0bf28 | 2016-06-19 21:54:04 +0200 | [diff] [blame] | 133 | grep 'Rerun make' make.log \ |
| 134 | && nice -n 10 make $MAKEOPTS 2>&1 | tee -a make.log |
Denis Vlasenko | 27e1501 | 2008-09-28 17:19:02 +0000 | [diff] [blame] | 135 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 136 | # Return exitcode 1 if busybox executable does not exist |
| 137 | test -x busybox |