2006-08-04 21:05:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2006-08-09 20:56:23 +00:00
|
|
|
# Compile individual versions of each busybox applet.
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
|
2006-08-06 02:13:36 +00:00
|
|
|
# Clear out the build directory. (Make clean should do this instead of here.)
|
|
|
|
|
|
|
|
rm -rf build
|
|
|
|
mkdir build
|
|
|
|
|
2006-08-04 21:05:33 +00:00
|
|
|
# Make our prerequisites.
|
|
|
|
|
|
|
|
make busybox.links include/bb_config.h
|
|
|
|
|
|
|
|
# Adding "libbb/libbb.a" to the previous line doesn't work, nor does going
|
|
|
|
# "make libbb.a" in the libb directory. The busybox makefile has layers and
|
|
|
|
# layers of overcomplicated brokenness...
|
|
|
|
|
|
|
|
cd libbb
|
|
|
|
make
|
|
|
|
cd ..
|
|
|
|
|
2006-08-06 02:13:36 +00:00
|
|
|
# Same problem.
|
|
|
|
|
2006-08-05 00:41:39 +00:00
|
|
|
cd archival/libunarchive
|
|
|
|
make
|
|
|
|
cd ../..
|
|
|
|
|
2006-08-09 20:56:23 +00:00
|
|
|
# And again
|
|
|
|
|
|
|
|
cd coreutils/libcoreutils
|
|
|
|
make
|
|
|
|
cd ../..
|
|
|
|
|
|
|
|
# Sensing a pattern here?
|
|
|
|
|
|
|
|
#cd networking/libiproute
|
|
|
|
#make
|
|
|
|
#cd ../..
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2006-08-06 02:13:36 +00:00
|
|
|
# About 3/5 of the applets build from one .c file (with the same name as the
|
|
|
|
# corresponding applet), and all it needs to link against. However, to build
|
|
|
|
# them all we need more than that.
|
|
|
|
|
|
|
|
# Figure out which applets need extra libraries added to their command line.
|
2006-08-05 00:41:39 +00:00
|
|
|
|
2006-08-09 20:56:23 +00:00
|
|
|
function substithing()
|
2006-08-05 00:41:39 +00:00
|
|
|
{
|
2006-08-09 20:56:23 +00:00
|
|
|
if [ "${1/ $3 //}" != "$1" ]
|
2006-08-05 00:41:39 +00:00
|
|
|
then
|
2006-08-09 20:56:23 +00:00
|
|
|
echo $2
|
2006-08-05 00:41:39 +00:00
|
|
|
fi
|
2006-08-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function extra_libraries()
|
|
|
|
{
|
|
|
|
# gzip needs gunzip.c (when gunzip is enabled, anyway).
|
|
|
|
substithing " gzip " "archival/gunzip.c archival/uncompress.c" "$1"
|
|
|
|
|
|
|
|
# init needs init_shared.c
|
|
|
|
substithing " init " "init/init_shared.c" "$1"
|
|
|
|
|
|
|
|
# ifconfig needs interface.c
|
|
|
|
substithing " ifconfig " "networking/interface.c" "$1"
|
|
|
|
|
|
|
|
# Applets that need libunarchive.a
|
|
|
|
substithing " ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip " "archival/libunarchive/libunarchive.a" "$1"
|
|
|
|
|
|
|
|
# Applets that need libcoreutils.a
|
|
|
|
substithing " cp mv " "coreutils/libcoreutils/libcoreutils.a" "$1"
|
|
|
|
|
|
|
|
# Applets that need libiproute.a
|
|
|
|
substithing " ip " "networking/libiproute/libiproute.a" "$1"
|
2006-08-06 02:13:36 +00:00
|
|
|
|
|
|
|
# What needs -libm?
|
2006-08-09 20:56:23 +00:00
|
|
|
substithing " awk dc " "-lm" "$1"
|
2006-08-06 02:13:36 +00:00
|
|
|
|
2006-08-09 20:56:23 +00:00
|
|
|
# What needs -lcrypt?
|
|
|
|
substithing " httpd vlock " "-lcrypt" "$1"
|
2006-08-05 00:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-08-09 20:56:23 +00:00
|
|
|
# Query applets.h to figure out which applets need special treatment
|
2006-08-04 21:05:33 +00:00
|
|
|
|
2006-08-06 02:13:36 +00:00
|
|
|
strange_names=`sed -rn -e 's/\#.*//' -e 's/.*APPLET_NOUSAGE\(([^,]*),([^,]*),.*/\1 \2/p' -e 's/.*APPLET_ODDNAME\(([^,]*),([^,]*),.*, *([^)]*).*/\1 \2@\3/p' include/applets.h`
|
|
|
|
|
|
|
|
function bonkname()
|
|
|
|
{
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
if [ "$APPLET" == "$1" ]
|
|
|
|
then
|
|
|
|
APPFILT="${2/@*/}"
|
|
|
|
if [ "${APPFILT}" == "$2" ]
|
|
|
|
then
|
2006-08-09 20:56:23 +00:00
|
|
|
HELPNAME='"nousage\n"' # These should be _fixed_.
|
2006-08-06 02:13:36 +00:00
|
|
|
else
|
|
|
|
HELPNAME="${2/*@/}"_full_usage
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
shift 2
|
|
|
|
done
|
|
|
|
#echo APPLET=${APPLET} APPFILT=${APPFILT} HELPNAME=${HELPNAME} 2=${2}
|
|
|
|
}
|
2006-08-05 00:41:39 +00:00
|
|
|
|
2006-08-09 20:56:23 +00:00
|
|
|
# Iterate through every name in busybox.links
|
|
|
|
|
|
|
|
function buildit ()
|
|
|
|
{
|
|
|
|
export APPLET="$1"
|
2006-08-06 02:13:36 +00:00
|
|
|
export APPFILT=${APPLET}
|
|
|
|
export HELPNAME=${APPLET}_full_usage
|
2006-08-09 20:56:23 +00:00
|
|
|
|
2006-08-06 02:13:36 +00:00
|
|
|
bonkname $strange_names
|
|
|
|
|
2006-08-09 20:56:23 +00:00
|
|
|
j=`find archival console-tools coreutils debianutils editors findutils init loginutils miscutils modutils networking procps shell sysklogd util-linux -name "${APPFILT}.c"`
|
2006-08-04 21:05:33 +00:00
|
|
|
if [ -z "$j" ]
|
|
|
|
then
|
|
|
|
echo no file for $APPLET
|
|
|
|
else
|
2006-08-06 02:13:36 +00:00
|
|
|
echo "Building $APPLET"
|
2006-08-05 00:41:39 +00:00
|
|
|
gcc -Os -o build/$APPLET applets/individual.c $j \
|
|
|
|
`extra_libraries $APPFILT` libbb/libbb.a -Iinclude \
|
|
|
|
-DBUILD_INDIVIDUAL \
|
2006-08-09 20:56:23 +00:00
|
|
|
'-Drun_applet_by_name(...)' '-Dfind_applet_by_name(...)=0' \
|
2006-08-06 02:13:36 +00:00
|
|
|
-DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${HELPNAME}
|
2006-08-04 21:05:33 +00:00
|
|
|
if [ $? -ne 0 ];
|
|
|
|
then
|
2006-08-06 02:13:36 +00:00
|
|
|
echo "Failed $APPLET"
|
2006-08-04 21:05:33 +00:00
|
|
|
fi
|
|
|
|
fi
|
2006-08-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
for APPLET in `sed 's .*/ ' busybox.links`
|
|
|
|
do
|
|
|
|
buildit "$APPLET"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
buildit "$1"
|
|
|
|
fi
|
|
|
|
|
2006-08-04 21:05:33 +00:00
|
|
|
|
|
|
|
strip build/*
|