-
Notifications
You must be signed in to change notification settings - Fork 18
/
make_single_applets.sh
executable file
·73 lines (65 loc) · 2.28 KB
/
make_single_applets.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
# This script expects that the tree was built with the desired .config:
# in particular, it expects that include/applets.h is generated already.
#
# The script will try to rebuild each enabled applet in isolation.
# All other options which chose general bbox config, applet features, etc,
# are not modified for the builds.
makeopts="-j9"
# The list of all applet config symbols
test -f include/applets.h || { echo "No include/applets.h file"; exit 1; }
apps="`
grep ^IF_ include/applets.h \
| grep -v ^IF_FEATURE_ \
| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
| sort | uniq
`"
# Take existing config
test -f .config || { echo "No .config file"; exit 1; }
cfg="`cat .config`"
# Make a config with all applet symbols off
allno="$cfg"
for app in $apps; do
allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
done
#echo "$allno" >.config_allno
# Turn on each applet individually and build single-applet executable
fail=0
for app in $apps; do
# Only if it was indeed originally enabled...
{ echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue
echo "Making ${app}..."
mv .config .config.SV
echo "CONFIG_${app}=y" >.config
echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config
if test x"${app}" != x"SH_IS_ASH" && test x"${app}" != x"SH_IS_HUSH"; then
# $allno has all choices for "sh" aliasing set to off.
# "sh" aliasing defaults to "ash", not none.
# without this fix, "make oldconfig" sets it wrong,
# resulting in NUM_APPLETS = 2 (the second applet is "sh")
sed '/CONFIG_SH_IS_NONE/d' -i .config
echo "CONFIG_SH_IS_NONE=y" >>.config
fi
if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
: $((fail++))
echo "Config error for ${app}"
mv .config busybox_config_${app}
elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then
: $((fail++))
echo "Build error for ${app}"
mv .config busybox_config_${app}
elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then
mv busybox busybox_${app}
: $((fail++))
echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`"
mv .config busybox_config_${app}
else
mv busybox busybox_${app}
rm busybox_make_${app}.log
fi
mv .config.SV .config
#exit
done
touch .config # or else next "make" can be confused
echo "Failures: $fail"
test $fail = 0 # set exitcode