[BusyBox] Building individual applets standalone.

Bernhard Fischer rep.nop at aon.at
Tue May 31 17:39:05 MDT 2005


On Thu, Mar 17, 2005 at 02:17:21AM -0500, Rob Landley wrote:
>I got bored, so here's a script and a .c file that builds a dozen or so 
>busybox applets standalone.  Proof of concept, as it were...

I also sometimes wanted to have standalone applets, fwiw.

Let's start building a libbb.so. If this is ok, then i'll cover the
other libs too.

- If CONFIG_STATIC is not selected, build the helper-libs as shared
  objects and dynamically link to them.
- If CONFIG_BUILD_LIBRARIES is selected then build all libraries static
  as well as dynamic. This makes reusing the libraries of busybox
  easier.

Does someone know how to allow for tristate to work? I'd be glad to hear
about it as it's not obvious to me how to "enable" it, from a short
glance.

>If anybody wants to teach the actual makefiles how to do this, I'm interested 
>in collaborating.

get_terminal_width_height.c is specified more than once in the Makefile.
Please apply the second snippet of the attached patch
(busybox/libbb/Makefile.in).

I can split that fix off the rest if needed.
-------------- next part --------------
diff -X excl.busybox -rduNp busybox.oorig/libbb/Makefile busybox/libbb/Makefile
--- busybox.oorig/libbb/Makefile	2005-04-01 22:05:47.000000000 +0200
+++ busybox/libbb/Makefile	2005-06-01 01:39:10.443449136 +0200
@@ -28,5 +28,5 @@ all: $(libraries-y)
 -include $(top_builddir)/.depend
 
 clean:
-	rm -f *.o *.a $(AR_TARGET)
+	rm -f *.o *.a *.so $(AR_TARGET) $(SO_TARGET)
 
diff -X excl.busybox -rduNp busybox.oorig/libbb/Makefile.in busybox/libbb/Makefile.in
--- busybox.oorig/libbb/Makefile.in	2005-04-16 21:35:20.000000000 +0200
+++ busybox/libbb/Makefile.in	2005-06-01 01:39:10.445448832 +0200
@@ -17,6 +17,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 LIBBB_AR:=libbb.a
+LIBBB_LD:=libbb.so
 ifndef $(LIBBB_DIR)
 LIBBB_DIR:=$(top_builddir)/libbb/
 endif
@@ -29,7 +30,7 @@ LIBBB_SRC:= \
 	device_open.c dump.c error_msg.c error_msg_and_die.c find_mount_point.c \
 	find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \
 	full_write.c get_last_path_component.c get_line_from_file.c get_ug_id.c \
-	get_terminal_width_height.c hash_fd.c herror_msg.c herror_msg_and_die.c \
+	hash_fd.c herror_msg.c herror_msg_and_die.c \
 	human_readable.c inet_common.c inode_hash.c interface.c isdirectory.c \
 	kernel_version.c last_char_is.c llist_add_to.c login.c loop.c \
 	make_directory.c mode_string.c module_syscalls.c mtab.c mtab_file.c \
@@ -80,13 +81,17 @@ LIBBB_MOBJS2=$(patsubst %,$(LIBBB_DIR)%,
 LIBBB_MOBJS3=$(patsubst %,$(LIBBB_DIR)%, $(LIBBB_MOBJ3))
 LIBBB_MOBJS4=$(patsubst %,$(LIBBB_DIR)%, $(LIBBB_MOBJ4))
 
-libraries-y+=$(LIBBB_DIR)$(LIBBB_AR)
 
 $(LIBBB_DIR)$(LIBBB_AR): $(LIBBB_OBJS) $(LIBBB_MOBJS0) $(LIBBB_MOBJS1) \
 	$(LIBBB_MOBJS2) $(LIBBB_MOBJS3) $(LIBBB_MOBJS4)
 	$(AR) -ro $@ $(LIBBB_OBJS) $(LIBBB_MOBJS0) $(LIBBB_MOBJS1) \
 		$(LIBBB_MOBJS2) $(LIBBB_MOBJS3) $(LIBBB_MOBJS4)
 
+$(LIBBB_DIR)$(LIBBB_LD): $(LIBBB_OBJS) $(LIBBB_MOBJS0) $(LIBBB_MOBJS1) \
+	$(LIBBB_MOBJS2) $(LIBBB_MOBJS3) $(LIBBB_MOBJS4)
+	$(CC) -shared -o $@ $(LIBBB_OBJS) $(LIBBB_MOBJS0) $(LIBBB_MOBJS1) \
+		$(LIBBB_MOBJS2) $(LIBBB_MOBJS3) $(LIBBB_MOBJS4)
+
 $(LIBBB_DIR)%.o: $(srcdir)/%.c
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
 
@@ -105,3 +110,14 @@ $(LIBBB_MOBJS3): $(LIBBB_MSRC3)
 $(LIBBB_MOBJS4): $(LIBBB_MSRC4)
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DL_$(notdir $*) -c $< -o $@
 
+ifeq ($(CONFIG_STATIC),y)
+libraries-y+=$(LIBBB_DIR)$(LIBBB_AR)
+libraries-m+=$(LIBBB_DIR)$(LIBBB_LD)
+else
+libraries-y+=$(LIBBB_DIR)$(LIBBB_LD)
+libraries-m+=$(LIBBB_DIR)$(LIBBB_AR)
+endif
+
+ifeq ($(CONFIG_BUILD_LIBRARIES),y)
+all: $(libraries-y) $(libraries-m)
+endif
diff -X excl.busybox -rduNp busybox.oorig/sysdeps/linux/Config.in busybox/sysdeps/linux/Config.in
--- busybox.oorig/sysdeps/linux/Config.in	2005-05-01 03:10:24.000000000 +0200
+++ busybox/sysdeps/linux/Config.in	2005-06-01 01:39:10.448448376 +0200
@@ -164,6 +164,17 @@ config CONFIG_STATIC
 
 	  Most people will leave this set to 'N'.
 
+config CONFIG_BUILD_LIBRARIES
+	bool "Build libraries"
+	default y
+	help
+	  Build static as well as shared libs. If you disable this,
+	  you will not be able to peruse the BusyBox libraries for
+	  your applications.
+	  
+	  Unless you have a really slow compile environment, setting
+	  this to 'Y' won't hurt noticeably.
+
 config CONFIG_LFS
 	bool "Build with Large File Support (for accessing files > 2 GB)"
 	default n


More information about the busybox mailing list