aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-09 20:56:23 +0000
committerRob Landley <rob@landley.net>2006-08-09 20:56:23 +0000
commit519d7df930d2ac14b7a833c0255a4a5abd5a329b (patch)
treead8d4242826335c7e418648d60d82a55095f11e1
parente55a73c7a89d9437bda82d317ee980989a5949db (diff)
downloadbusybox-519d7df930d2ac14b7a833c0255a4a5abd5a329b.tar.gz
Another whack at scripts/individual. Now builds 212 applets.
-rw-r--r--applets/Makefile.in2
-rw-r--r--applets/version.c17
-rw-r--r--coreutils/install.c10
-rw-r--r--include/libbb.h2
-rw-r--r--include/platform.h1
-rw-r--r--libbb/messages.c8
-rw-r--r--libbb/xfuncs.c2
-rw-r--r--modutils/insmod.c1
-rwxr-xr-xscripts/individual85
9 files changed, 81 insertions, 47 deletions
diff --git a/applets/Makefile.in b/applets/Makefile.in
index 02bcda93b..a4890c2fb 100644
--- a/applets/Makefile.in
+++ b/applets/Makefile.in
@@ -10,7 +10,7 @@ APPLETS_DIR:=$(top_builddir)/applets/
endif
srcdir=$(top_srcdir)/applets
-APPLET_SRC:= $(patsubst %,$(srcdir)/%,applets.c busybox.c version.c)
+APPLET_SRC:= $(patsubst %,$(srcdir)/%,applets.c busybox.c)
APPLET_OBJ:= $(patsubst $(srcdir)/%.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
APPLET_SRC-y+=$(APPLET_SRC)
diff --git a/applets/version.c b/applets/version.c
deleted file mode 100644
index ce75f1ff9..000000000
--- a/applets/version.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Version stuff.
- *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
- */
-
-#include "busybox.h"
-
-#ifndef BB_EXTRA_VERSION
-#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
-#else
-#define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
-#endif
-
-const char BB_BANNER[]=BANNER;
-const char * const bb_msg_full_version = BANNER " multi-call binary";
diff --git a/coreutils/install.c b/coreutils/install.c
index f6d84c15f..d3d6a58a1 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -8,16 +8,10 @@
* owner/group, will probably modify bb_make_directory(...)
*/
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h> /* struct option */
-
#include "busybox.h"
#include "libcoreutils/coreutils.h"
+#include <libgen.h>
+#include <getopt.h> /* struct option */
#define INSTALL_OPT_CMD 1
#define INSTALL_OPT_DIRECTORY 2
diff --git a/include/libbb.h b/include/libbb.h
index 963a0290c..67d4eb170 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -222,8 +222,10 @@ extern void chomp(char *s);
extern void trim(char *s);
extern char *skip_whitespace(const char *);
+#ifndef BUILD_INDIVIDUAL
extern struct BB_applet *find_applet_by_name(const char *name);
void run_applet_by_name(const char *name, int argc, char **argv);
+#endif
/* dmalloc will redefine these to it's own implementation. It is safe
* to have the prototypes here unconditionally. */
diff --git a/include/platform.h b/include/platform.h
index ca6f3634f..a4ff9b8d7 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -154,6 +154,7 @@ __extension__ typedef unsigned long long __u64;
#if defined __GLIBC__ || defined __UCLIBC__ \
|| defined __dietlibc__ || defined _NEWLIB_VERSION
+#define _XOPEN_SOURCE
#include <features.h>
#define HAVE_FEATURES_H
#include <stdint.h>
diff --git a/libbb/messages.c b/libbb/messages.c
index 2feb6a970..b6755058e 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -9,12 +9,14 @@
#ifdef L_full_version
#ifndef BB_EXTRA_VERSION
-#define LIBBB_BANNER "BusyBox's library v" BB_VER " (" BB_BT ")"
+#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
#else
-#define LIBBB_BANNER "BusyBox's library v" BB_VER " (" BB_EXTRA_VERSION ")"
+#define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
#endif
- const char * const libbb_msg_full_version = LIBBB_BANNER;
+const char BB_BANNER[]=BANNER;
+const char * const bb_msg_full_version = BANNER " multi-call binary";
#endif
+
#ifdef L_memory_exhausted
const char * const bb_msg_memory_exhausted = "memory exhausted";
#endif
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index cfb1c29ac..4d81fdc28 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -208,7 +208,7 @@ pid_t spawn(char **argv)
{
static int failed;
pid_t pid;
- void *app = find_applet_by_name(argv[0]);
+ void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0;
// Be nice to nommu machines.
failed = 0;
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 614eb2f6b..e09275e11 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -59,6 +59,7 @@
*/
#include "busybox.h"
+#include <libgen.h>
#include <sys/utsname.h>
#if !defined(CONFIG_FEATURE_2_4_MODULES) && \
diff --git a/scripts/individual b/scripts/individual
index 35c44e87e..1463e0fc4 100755
--- a/scripts/individual
+++ b/scripts/individual
@@ -1,5 +1,10 @@
#!/bin/sh
+# Compile individual versions of each busybox applet.
+
+if [ $# -eq 0 ]
+then
+
# Clear out the build directory. (Make clean should do this instead of here.)
rm -rf build
@@ -23,30 +28,62 @@ cd archival/libunarchive
make
cd ../..
+# And again
+
+cd coreutils/libcoreutils
+make
+cd ../..
+
+# Sensing a pattern here?
+
+#cd networking/libiproute
+#make
+#cd ../..
+
+fi
+
# 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.
-function extra_libraries()
+function substithing()
{
- archival="ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip "
- if [ "${archival/$1 //}" != "${archival}" ]
+ if [ "${1/ $3 //}" != "$1" ]
then
- echo "archival/libunarchive/libunarchive.a"
+ echo $2
fi
+}
+
+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"
# What needs -libm?
+ substithing " awk dc " "-lm" "$1"
- libm="awk dc "
- if [ "${libm/$1 //}" != "${libm}" ]
- then
- echo "-lm"
- fi
+ # What needs -lcrypt?
+ substithing " httpd vlock " "-lcrypt" "$1"
}
-# Query applets.h to figure out which need something funky
+# Query applets.h to figure out which applets need special treatment
strange_names=`sed -rn -e 's/\#.*//' -e 's/.*APPLET_NOUSAGE\(([^,]*),([^,]*),.*/\1 \2/p' -e 's/.*APPLET_ODDNAME\(([^,]*),([^,]*),.*, *([^)]*).*/\1 \2@\3/p' include/applets.h`
@@ -59,7 +96,7 @@ function bonkname()
APPFILT="${2/@*/}"
if [ "${APPFILT}" == "$2" ]
then
- HELPNAME='"nousage\n"'
+ HELPNAME='"nousage\n"' # These should be _fixed_.
else
HELPNAME="${2/*@/}"_full_usage
fi
@@ -70,14 +107,17 @@ function bonkname()
#echo APPLET=${APPLET} APPFILT=${APPFILT} HELPNAME=${HELPNAME} 2=${2}
}
-for APPLET in `sed 's .*/ ' busybox.links`
-do
- export APPLET
+# Iterate through every name in busybox.links
+
+function buildit ()
+{
+ export APPLET="$1"
export APPFILT=${APPLET}
export HELPNAME=${APPLET}_full_usage
+
bonkname $strange_names
- j=`find . -name "${APPFILT}.c"`
+ j=`find archival console-tools coreutils debianutils editors findutils init loginutils miscutils modutils networking procps shell sysklogd util-linux -name "${APPFILT}.c"`
if [ -z "$j" ]
then
echo no file for $APPLET
@@ -86,13 +126,24 @@ do
gcc -Os -o build/$APPLET applets/individual.c $j \
`extra_libraries $APPFILT` libbb/libbb.a -Iinclude \
-DBUILD_INDIVIDUAL \
- "-Drun_applet_by_name(...)" "-Dfind_applet_by_name(...) 0" \
+ '-Drun_applet_by_name(...)' '-Dfind_applet_by_name(...)=0' \
-DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${HELPNAME}
if [ $? -ne 0 ];
then
echo "Failed $APPLET"
fi
fi
-done
+}
+
+if [ $# -eq 0 ]
+then
+ for APPLET in `sed 's .*/ ' busybox.links`
+ do
+ buildit "$APPLET"
+ done
+else
+ buildit "$1"
+fi
+
strip build/*