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 \ |
| 15 | | grep -v ^IF_FEATURE_ \ |
| 16 | | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 17 | | sort | uniq |
| 18 | `" |
| 19 | |
| 20 | # Take existing config |
| 21 | test -f .config || { echo "No .config file"; exit 1; } |
| 22 | cfg="`cat .config`" |
| 23 | |
| 24 | # Make a config with all applet symbols off |
| 25 | allno="$cfg" |
| 26 | for app in $apps; do |
| 27 | allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`" |
| 28 | done |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 29 | #echo "$allno" >.config_allno |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 30 | |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame^] | 31 | trap 'test -f .config.SV && mv .config.SV .config && touch .config' EXIT |
| 32 | |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 33 | # Turn on each applet individually and build single-applet executable |
| 34 | fail=0 |
| 35 | for app in $apps; do |
| 36 | # Only if it was indeed originally enabled... |
| 37 | { echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue |
| 38 | |
| 39 | echo "Making ${app}..." |
| 40 | mv .config .config.SV |
| 41 | echo "CONFIG_${app}=y" >.config |
| 42 | echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 43 | |
Denys Vlasenko | 7d5c881 | 2016-12-23 19:42:53 +0100 | [diff] [blame] | 44 | if test x"${app}" != x"SH_IS_ASH" && test x"${app}" != x"SH_IS_HUSH"; then |
| 45 | # $allno has all choices for "sh" aliasing set to off. |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 46 | # "sh" aliasing defaults to "ash", not none. |
| 47 | # without this fix, "make oldconfig" sets it wrong, |
Denys Vlasenko | 7d5c881 | 2016-12-23 19:42:53 +0100 | [diff] [blame] | 48 | # resulting in NUM_APPLETS = 2 (the second applet is "sh") |
Denys Vlasenko | 0b88358 | 2016-12-23 16:49:07 +0100 | [diff] [blame] | 49 | sed '/CONFIG_SH_IS_NONE/d' -i .config |
| 50 | echo "CONFIG_SH_IS_NONE=y" >>.config |
| 51 | fi |
| 52 | |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 53 | if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then |
| 54 | : $((fail++)) |
| 55 | echo "Config error for ${app}" |
| 56 | mv .config busybox_config_${app} |
Denys Vlasenko | 7d5c881 | 2016-12-23 19:42:53 +0100 | [diff] [blame] | 57 | elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 58 | : $((fail++)) |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame^] | 59 | grep -i -e error: -e warning: busybox_make_${app}.log |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 60 | echo "Build error for ${app}" |
| 61 | mv .config busybox_config_${app} |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 62 | elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame^] | 63 | grep -i -e error: -e warning: busybox_make_${app}.log |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 64 | mv busybox busybox_${app} |
| 65 | : $((fail++)) |
| 66 | echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`" |
| 67 | mv .config busybox_config_${app} |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 68 | else |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame^] | 69 | grep -i -e error: -e warning: busybox_make_${app}.log \ |
| 70 | || rm busybox_make_${app}.log |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 71 | mv busybox busybox_${app} |
Denys Vlasenko | e7b54d0 | 2017-01-09 16:31:21 +0100 | [diff] [blame^] | 72 | #mv .config busybox_config_${app} |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 73 | fi |
| 74 | mv .config.SV .config |
| 75 | #exit |
| 76 | done |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 77 | touch .config # or else next "make" can be confused |
Denys Vlasenko | 10c01a7 | 2016-12-23 13:39:22 +0100 | [diff] [blame] | 78 | echo "Failures: $fail" |
| 79 | test $fail = 0 # set exitcode |