blob: 2075cb9a7e66094266ed30ff0326b8f7c9b887a9 [file] [log] [blame]
Denys Vlasenko10c01a72016-12-23 13:39:22 +01001#!/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
9makeopts="-j9"
10
11# The list of all applet config symbols
12test -f include/applets.h || { echo "No include/applets.h file"; exit 1; }
13apps="`
14grep ^IF_ include/applets.h \
Denys Vlasenko82d1c1f2017-12-31 17:30:02 +010015| grep -v '^IF_FEATURE_' \
Denys Vlasenko10c01a72016-12-23 13:39:22 +010016| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
Denys Vlasenko82d1c1f2017-12-31 17:30:02 +010017| grep -v '^BUSYBOX$' \
Denys Vlasenko10c01a72016-12-23 13:39:22 +010018| sort | uniq
19`"
20
21# Take existing config
22test -f .config || { echo "No .config file"; exit 1; }
23cfg="`cat .config`"
24
25# Make a config with all applet symbols off
26allno="$cfg"
27for app in $apps; do
28 allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
29done
Denys Vlasenko52c21052018-12-06 14:10:10 +010030# remove "busybox" as well
31allno="`echo "$allno" | sed "s/^CONFIG_BUSYBOX=y\$/# CONFIG_BUSYBOX is not set/"`"
Denys Vlasenko0b883582016-12-23 16:49:07 +010032#echo "$allno" >.config_allno
Denys Vlasenko10c01a72016-12-23 13:39:22 +010033
Denys Vlasenkoe7b54d02017-01-09 16:31:21 +010034trap 'test -f .config.SV && mv .config.SV .config && touch .config' EXIT
35
Denys Vlasenkob8935d02017-01-15 20:16:27 +010036
Denys Vlasenko10c01a72016-12-23 13:39:22 +010037# Turn on each applet individually and build single-applet executable
Denys Vlasenkob8935d02017-01-15 20:16:27 +010038# (give config names on command line to build only those)
39test $# = 0 && set -- $apps
Denys Vlasenko10c01a72016-12-23 13:39:22 +010040fail=0
Denys Vlasenkob8935d02017-01-15 20:16:27 +010041for app; do
Denys Vlasenko10c01a72016-12-23 13:39:22 +010042 # Only if it was indeed originally enabled...
43 { echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue
44
45 echo "Making ${app}..."
46 mv .config .config.SV
47 echo "CONFIG_${app}=y" >.config
48 echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config
Denys Vlasenko0b883582016-12-23 16:49:07 +010049
Denys Vlasenko7d5c8812016-12-23 19:42:53 +010050 if test x"${app}" != x"SH_IS_ASH" && test x"${app}" != x"SH_IS_HUSH"; then
51 # $allno has all choices for "sh" aliasing set to off.
Denys Vlasenko0b883582016-12-23 16:49:07 +010052 # "sh" aliasing defaults to "ash", not none.
53 # without this fix, "make oldconfig" sets it wrong,
Denys Vlasenko7d5c8812016-12-23 19:42:53 +010054 # resulting in NUM_APPLETS = 2 (the second applet is "sh")
Denys Vlasenko0b883582016-12-23 16:49:07 +010055 sed '/CONFIG_SH_IS_NONE/d' -i .config
56 echo "CONFIG_SH_IS_NONE=y" >>.config
57 fi
58
Denys Vlasenko10c01a72016-12-23 13:39:22 +010059 if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
Kang-Che Sunged2b9222017-07-15 11:38:58 +080060 fail=$((fail+1))
Denys Vlasenko10c01a72016-12-23 13:39:22 +010061 echo "Config error for ${app}"
62 mv .config busybox_config_${app}
Denys Vlasenko7d5c8812016-12-23 19:42:53 +010063 elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then
Kang-Che Sunged2b9222017-07-15 11:38:58 +080064 fail=$((fail+1))
Denys Vlasenkoe7b54d02017-01-09 16:31:21 +010065 grep -i -e error: -e warning: busybox_make_${app}.log
Denys Vlasenko10c01a72016-12-23 13:39:22 +010066 echo "Build error for ${app}"
67 mv .config busybox_config_${app}
Denys Vlasenkoa1cd0d92016-12-23 15:12:27 +010068 elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then
Denys Vlasenkoe7b54d02017-01-09 16:31:21 +010069 grep -i -e error: -e warning: busybox_make_${app}.log
Denys Vlasenkoa1cd0d92016-12-23 15:12:27 +010070 mv busybox busybox_${app}
Kang-Che Sunged2b9222017-07-15 11:38:58 +080071 fail=$((fail+1))
Denys Vlasenkoa1cd0d92016-12-23 15:12:27 +010072 echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`"
73 mv .config busybox_config_${app}
Denys Vlasenko10c01a72016-12-23 13:39:22 +010074 else
Denys Vlasenkoe7b54d02017-01-09 16:31:21 +010075 grep -i -e error: -e warning: busybox_make_${app}.log \
76 || rm busybox_make_${app}.log
Denys Vlasenko10c01a72016-12-23 13:39:22 +010077 mv busybox busybox_${app}
Denys Vlasenkoe7b54d02017-01-09 16:31:21 +010078 #mv .config busybox_config_${app}
Denys Vlasenko10c01a72016-12-23 13:39:22 +010079 fi
80 mv .config.SV .config
81 #exit
82done
Denys Vlasenkoa1cd0d92016-12-23 15:12:27 +010083touch .config # or else next "make" can be confused
Denys Vlasenko10c01a72016-12-23 13:39:22 +010084echo "Failures: $fail"
85test $fail = 0 # set exitcode