summaryrefslogtreecommitdiff
path: root/make_single_applets.sh (plain)
blob: 6473e4dddb98cd510251b65d334b788a4a990eef
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
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 \
15| grep -v ^IF_FEATURE_ \
16| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
17| sort | uniq
18`"
19
20# Take existing config
21test -f .config || { echo "No .config file"; exit 1; }
22cfg="`cat .config`"
23
24# Make a config with all applet symbols off
25allno="$cfg"
26for app in $apps; do
27 allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
28done
29
30# Turn on each applet individually and build single-applet executable
31fail=0
32for app in $apps; do
33 # Only if it was indeed originally enabled...
34 { echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue
35
36 echo "Making ${app}..."
37 mv .config .config.SV
38 echo "CONFIG_${app}=y" >.config
39 echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config
40 if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
41 : $((fail++))
42 echo "Config error for ${app}"
43 mv .config busybox_config_${app}
44 elif ! make $makeopts >busybox_make_${app}.log 2>&1; then
45 : $((fail++))
46 echo "Build error for ${app}"
47 mv .config busybox_config_${app}
48 elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then
49 mv busybox busybox_${app}
50 : $((fail++))
51 echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`"
52 mv .config busybox_config_${app}
53 else
54 mv busybox busybox_${app}
55 rm busybox_make_${app}.log
56 fi
57 mv .config.SV .config
58 #exit
59done
60touch .config # or else next "make" can be confused
61echo "Failures: $fail"
62test $fail = 0 # set exitcode
63