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/' \ |
| 17 | | grep -v ^MODPROBE_SMALL \ |
| 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 |
| 30 | |
| 31 | # Turn on each applet individually and build single-applet executable |
| 32 | fail=0 |
| 33 | for app in $apps; do |
| 34 | # Only if it was indeed originally enabled... |
| 35 | { echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue |
| 36 | |
| 37 | echo "Making ${app}..." |
| 38 | mv .config .config.SV |
| 39 | echo "CONFIG_${app}=y" >.config |
| 40 | echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config |
| 41 | if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then |
| 42 | : $((fail++)) |
| 43 | echo "Config error for ${app}" |
| 44 | mv .config busybox_config_${app} |
| 45 | elif ! make $makeopts >busybox_make_${app}.log 2>&1; then |
| 46 | : $((fail++)) |
| 47 | echo "Build error for ${app}" |
| 48 | mv .config busybox_config_${app} |
| 49 | else |
| 50 | mv busybox busybox_${app} |
| 51 | rm busybox_make_${app}.log |
| 52 | fi |
| 53 | mv .config.SV .config |
| 54 | #exit |
| 55 | done |
| 56 | echo "Failures: $fail" |
| 57 | test $fail = 0 # set exitcode |