Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # This script expects that the tree was built with the desired .config: |
| 3 | # in particular, it expects that include/applets.h is generated already. |
| 4 | # |
| 5 | # The script will try to rebuild each enabled applet in isolation. |
| 6 | # All other options which chose general bbox config, applet features, etc, |
| 7 | # are not modified for the builds. |
| 8 | |
| 9 | makeopts="-j9" |
| 10 | |
| 11 | # The list of all applet config symbols |
| 12 | test -f include/applets.h || { echo "No include/applets.h file"; exit 1; } |
| 13 | apps="` |
| 14 | grep ^IF_ include/applets.h \ |
Denys Vlasenko | 82d1c1f | 2017-12-31 17:30:02 +0100 | [diff] [blame] | 15 | | grep -v '^IF_FEATURE_' \ |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 16 | | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ |
Denys Vlasenko | 82d1c1f | 2017-12-31 17:30:02 +0100 | [diff] [blame] | 17 | | grep -v '^BUSYBOX$' \ |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 18 | | sort | uniq |
| 19 | `" |
| 20 | |
| 21 | # Take existing config |
| 22 | test -f .config || { echo "No .config file"; exit 1; } |
| 23 | cfg="`cat .config`" |
| 24 | |
| 25 | # Make a config with all applet symbols off |
| 26 | allno="$cfg" |
| 27 | for app in $apps; do |
| 28 | allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`" |
| 29 | done |
Denys Vlasenko | 52c2105 | 2018-12-06 14:10:10 +0100 | [diff] [blame] | 30 | # remove "busybox" as well |
| 31 | allno="`echo "$allno" | sed "s/^CONFIG_BUSYBOX=y\$/# CONFIG_BUSYBOX is not set/"`" |
Denys Vlasenko | b02f8ca | 2020-06-24 16:36:44 +0200 | [diff] [blame] | 32 | # disable any CONFIG_script_DEPENDENCIES as well |
| 33 | allno="`echo "$allno" | sed "s/^\(CONFIG_.*_DEPENDENCIES\)=y\$/# \1 is not set/"`" |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 34 | #echo "$allno" >.config_allno |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 35 | |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame] | 36 | trap 'test -f .config.SV && mv .config.SV .config && touch .config' EXIT |
| 37 | |
Denys Vlasenko | b8935d0 | 2017-01-15 20:16:27 +0100 | [diff] [blame] | 38 | |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 39 | # Turn on each applet individually and build single-applet executable |
Denys Vlasenko | b8935d0 | 2017-01-15 20:16:27 +0100 | [diff] [blame] | 40 | # (give config names on command line to build only those) |
| 41 | test $# = 0 && set -- $apps |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 42 | fail=0 |
Denys Vlasenko | b8935d0 | 2017-01-15 20:16:27 +0100 | [diff] [blame] | 43 | for app; do |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 44 | # Only if it was indeed originally enabled... |
| 45 | { echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue |
| 46 | |
| 47 | echo "Making ${app}..." |
| 48 | mv .config .config.SV |
| 49 | echo "CONFIG_${app}=y" >.config |
| 50 | echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 51 | |
Denys Vlasenko | 7d5c881 | 2016-12-23 19:42:53 +0100 | [diff] [blame] | 52 | if test x"${app}" != x"SH_IS_ASH" && test x"${app}" != x"SH_IS_HUSH"; then |
| 53 | # $allno has all choices for "sh" aliasing set to off. |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 54 | # "sh" aliasing defaults to "ash", not none. |
| 55 | # without this fix, "make oldconfig" sets it wrong, |
Denys Vlasenko | 7d5c881 | 2016-12-23 19:42:53 +0100 | [diff] [blame] | 56 | # resulting in NUM_APPLETS = 2 (the second applet is "sh") |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 57 | sed '/CONFIG_SH_IS_NONE/d' -i .config |
| 58 | echo "CONFIG_SH_IS_NONE=y" >>.config |
| 59 | fi |
| 60 | |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 61 | if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then |
Kang-Che Sung | ed2b922 | 2017-07-15 11:38:58 +0800 | [diff] [blame] | 62 | fail=$((fail+1)) |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 63 | echo "Config error for ${app}" |
| 64 | mv .config busybox_config_${app} |
Denys Vlasenko | 7d5c881 | 2016-12-23 19:42:53 +0100 | [diff] [blame] | 65 | elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then |
Kang-Che Sung | ed2b922 | 2017-07-15 11:38:58 +0800 | [diff] [blame] | 66 | fail=$((fail+1)) |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame] | 67 | grep -i -e error: -e warning: busybox_make_${app}.log |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 68 | echo "Build error for ${app}" |
| 69 | mv .config busybox_config_${app} |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 70 | elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame] | 71 | grep -i -e error: -e warning: busybox_make_${app}.log |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 72 | mv busybox busybox_${app} |
Kang-Che Sung | ed2b922 | 2017-07-15 11:38:58 +0800 | [diff] [blame] | 73 | fail=$((fail+1)) |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 74 | echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`" |
| 75 | mv .config busybox_config_${app} |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 76 | else |
Denys Vlasenko | 8b710ef | 2018-12-30 20:07:54 +0100 | [diff] [blame] | 77 | if grep -q 'use larger COMMON_BUFSIZE' busybox_make_${app}.log; then |
| 78 | # FEATURE_USE_BSS_TAIL=y is selected, and build system |
| 79 | # recommends rebuilding. Do so, and print some |
| 80 | # debug info to see whether it works right: |
| 81 | tail -n1 busybox_make_${app}.log |
| 82 | nm busybox_unstripped | grep ' _end' |
| 83 | make >/dev/null 2>&1 |
| 84 | nm busybox_unstripped | grep ' _end' |
| 85 | grep ^bb_common_bufsiz1 busybox_unstripped.map |
| 86 | fi |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame] | 87 | grep -i -e error: -e warning: busybox_make_${app}.log \ |
| 88 | || rm busybox_make_${app}.log |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 89 | mv busybox busybox_${app} |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame] | 90 | #mv .config busybox_config_${app} |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 91 | fi |
| 92 | mv .config.SV .config |
| 93 | #exit |
| 94 | done |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 95 | touch .config # or else next "make" can be confused |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 96 | echo "Failures: $fail" |
| 97 | test $fail = 0 # set exitcode |