3 # Compile individual versions of each busybox applet.
8 # Clear out the build directory. (Make clean should do this instead of here.)
13 # Make our prerequisites.
15 make busybox.links include/bb_config.h $(pwd)/{libbb/libbb.a,archival/libunarchive/libunarchive.a,coreutils/libcoreutils/libcoreutils.a,networking/libiproute/libiproute.a}
18 # Could very well be that we want to build an individual applet but have no
21 test -d ./build || mkdir build
25 # About 3/5 of the applets build from one .c file (with the same name as the
26 # corresponding applet), and all it needs to link against. However, to build
27 # them all we need more than that.
29 # Figure out which applets need extra libraries added to their command line.
31 function substithing()
33 if [ "${1/ $3 //}" != "$1" ]
39 function extra_libraries()
41 # gzip needs gunzip.c (when gunzip is enabled, anyway).
42 substithing " gzip " "archival/gunzip.c archival/uncompress.c" "$1"
44 # init needs init_shared.c
45 substithing " init " "init/init_shared.c" "$1"
47 # ifconfig needs interface.c
48 substithing " ifconfig " "networking/interface.c" "$1"
50 # Applets that need libunarchive.a
51 substithing " ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip " "archival/libunarchive/libunarchive.a" "$1"
53 # Applets that need libcoreutils.a
54 substithing " cp mv " "coreutils/libcoreutils/libcoreutils.a" "$1"
56 # Applets that need libiproute.a
57 substithing " ip " "networking/libiproute/libiproute.a" "$1"
60 substithing " awk dc " "-lm" "$1"
63 substithing " httpd vlock " "-lcrypt" "$1"
66 # Query applets.h to figure out which applets need special treatment
68 strange_names=`sed -rn -e 's/\#.*//' -e 's/.*APPLET_NOUSAGE\(([^,]*),([^,]*),.*/\1 \2/p' -e 's/.*APPLET_ODDNAME\(([^,]*),([^,]*),.*, *([^)]*).*/\1 \2@\3/p' include/applets.h`
74 if [ "$APPLET" == "$1" ]
77 if [ "${APPFILT}" == "$2" ]
79 HELPNAME='"nousage\n"' # These should be _fixed_.
81 HELPNAME="${2/*@/}"_full_usage
87 #echo APPLET=${APPLET} APPFILT=${APPFILT} HELPNAME=${HELPNAME} 2=${2}
90 # Iterate through every name in busybox.links
95 export APPFILT=${APPLET}
96 export HELPNAME=${APPLET}_full_usage
98 bonkname $strange_names
100 j=`find archival console-tools coreutils debianutils editors findutils init loginutils miscutils modutils networking procps shell sysklogd util-linux -name "${APPFILT}.c"`
103 echo no file for $APPLET
105 echo "Building $APPLET"
106 gcc -Os -o build/$APPLET applets/individual.c $j \
107 `extra_libraries $APPFILT` libbb/libbb.a -Iinclude \
109 '-Drun_applet_and_exit(...)' '-Dfind_applet_by_name(...)=0' \
110 -DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${HELPNAME}
113 echo "Failed $APPLET"
120 for APPLET in `sed 's .*/ ' busybox.links`