[patch] fix building out-of-tree,
update docs for svn-access and build instructions
Bernhard Fischer
rep.nop at aon.at
Tue Oct 4 05:12:01 PDT 2005
On Thu, Sep 29, 2005 at 01:48:44PM +0200, Bernhard Fischer wrote:
>Hi,
>
>I will check the attached patch in tomorrow evening if nobody objects.
Vapier disliked how the subdirectories for the e2fsprogs were created.
This is fixed in this version (thanks vapier for the suggestion).
- fix building out-of-tree;
to test, checkout the source (let's assume /scratch/src/busybox), then
mkdir /tmp/bb ; cd /tmp/bb
make top_srcdir=/scratch/src/busybox O="$(pwd)" -f /scratch/src/busybox/Makefile allyesconfig ; make check
- default to O=$(pwd) if no O was specified. Now you can just specify
the top_srcdir (without O=/somewhere) to create the obj-tree in pwd.
- make "make configtarget buildtarget" work. Previously this didn't
work due to how HAVE_DOTCONFIG was evaluated. Two separate steps were
needed before, e.g. make config ; make busybox.
- remove some unneeded variables from Rules.mak (BB_SRC_DIR from Mr.
ldoolitt at recycle.lbl) which suggest that the stuff fixed above
didn't work.
- move selinux libraries to where they belong (from Makefile to Rules.mak)
- update the docs to mention svn instead of cvs and provide an example
for building out-of-tree.
Tested when building in tree. Tested building out of tree with and without
specifying the output-dir.
Ok?
Thanks,
Bernhard
-------------- next part --------------
diff -X excl -rduNp busybox.oorig/e2fsprogs/Makefile busybox/e2fsprogs/Makefile
--- busybox.oorig/e2fsprogs/Makefile 2005-09-26 15:54:22.000000000 +0200
+++ busybox/e2fsprogs/Makefile 2005-09-30 15:42:45.000000000 +0200
@@ -8,9 +8,9 @@ top_srcdir=..
top_builddir=..
srcdir=$(top_srcdir)/e2fsprogs
E2FSPROGS_DIR:=./
-include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include Makefile.in
+include $(top_builddir)/Rules.mak
all: $(libraries-y)
-include $(top_builddir)/.depend
diff -X excl -rduNp busybox.oorig/e2fsprogs/Makefile.in busybox/e2fsprogs/Makefile.in
--- busybox.oorig/e2fsprogs/Makefile.in 2005-10-04 13:50:47.000000000 +0200
+++ busybox/e2fsprogs/Makefile.in 2005-10-04 13:50:30.000000000 +0200
@@ -39,7 +39,18 @@ UUID_SRC := compare.c gen_uuid.c pack
UUID_SRCS := $(patsubst %,uuid/%, $(UUID_SRC))
UUID_OBJS := $(patsubst %.c,%.o, $(UUID_SRCS))
-E2FSPROGS-:=
+# for building out-of-tree we need to make sure that the directories to hold
+# the object tree are created
+$(patsubst %,$(E2FSPROGS_DIR)/%, blkid e2fsck e2p ext2fs uuid):
+ mkdir -p "$@"
+
+$(patsubst %,$(E2FSPROGS_DIR)/%, $(BLKID_OBJS)):$(E2FSPROGS_DIR)/blkid
+$(patsubst %,$(E2FSPROGS_DIR)/%, $(E2FSCK_OBJS)):$(E2FSPROGS_DIR)/e2fsck
+$(patsubst %,$(E2FSPROGS_DIR)/%, $(E2P_OBJS)):$(E2FSPROGS_DIR)/e2p
+$(patsubst %,$(E2FSPROGS_DIR)/%, $(EXT2FS_OBJS)):$(E2FSPROGS_DIR)/ext2fs
+$(patsubst %,$(E2FSPROGS_DIR)/%, $(UUID_OBJS)):$(E2FSPROGS_DIR)/uuid
+
+E2FSPROGS-y:=
E2FSPROGS-$(CONFIG_CHATTR) += chattr.o $(E2P_OBJS)
E2FSPROGS-$(CONFIG_E2FSCK) += e2fsck.o util.o $(BLKID_OBJS)
E2FSPROGS-$(CONFIG_FSCK) += fsck.o base_device.o
@@ -53,5 +64,6 @@ libraries-y+=$(E2FSPROGS_DIR)/$(E2FSPROG
$(E2FSPROGS_DIR)/$(E2FSPROGS_AR): $(patsubst %,$(E2FSPROGS_DIR)/%, $(E2FSPROGS-y))
$(AR) $(ARFLAGS) $@ $(patsubst %,$(E2FSPROGS_DIR)/%, $(E2FSPROGS-y))
-$(E2FSPROGS_DIR)/%.o: $(E2FSPROGS_DIR)/%.c
+$(E2FSPROGS_DIR)/%.o: $(subst $(top_builddir),$(top_srcdir),$(E2FSPROGS_DIR)/%.c)
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(E2FSPROGS_CFLAGS) -c -o $@ $<
+
diff -X excl -rduNp busybox.oorig/INSTALL busybox/INSTALL
--- busybox.oorig/INSTALL 2005-09-26 15:54:28.000000000 +0200
+++ busybox/INSTALL 2005-09-29 13:19:07.000000000 +0200
@@ -1,3 +1,15 @@
+Building:
+=========
+
+You will usually build in the source-tree.
+
+Alternatively you can build out-of-tree to have the object files separated
+from the source. This allows for building several different configurations
+from the same set of sources.
+
+A) Building in the source-tree:
+-------------------------------
+
1) Run 'make config' or 'make menuconfig' and select the
functionality that you wish to enable.
@@ -12,3 +24,27 @@
install busybox and all the needed links. Some people
will prefer to install using hardlinks and will instead
want to run 'make install-hardlinks'....
+
+B) Building out-of-tree:
+------------------------
+
+1) make the directory to hold the object files and chdir to it:
+ 'mkdir /tmp/bb ; cd /tmp/bb'
+ Then prepare the config giving the full path to the source in top_srcdir:
+ make top_srcdir=/path/busybox -f /path/busybox/Makefile O=$(pwd) allyesconfig
+
+ Proceed with step #A2 above.
+
+
+Installation:
+=============
+
+After the build is complete, a busybox.links file is generated. This is
+used by 'make install' to create symlinks to the BusyBox binary for all
+compiled in functions. By default, 'make install' will place the symlink
+forest into `pwd`/_install unless you have defined the PREFIX environment
+variable (i.e., 'make PREFIX=/tmp/foo install')
+
+If you wish to install hard links, rather than symlinks, you can use
+'make PREFIX=/tmp/foo install-hardlinks' instead.
+
diff -X excl -rduNp busybox.oorig/Makefile busybox/Makefile
--- busybox.oorig/Makefile 2005-09-29 10:17:48.000000000 +0200
+++ busybox/Makefile 2005-10-04 13:45:48.000000000 +0200
@@ -24,8 +24,6 @@ endif
export srctree=$(top_srcdir)
vpath %/Config.in $(srctree)
-include $(top_srcdir)/Rules.mak
-
DIRS:=applets archival archival/libunarchive coreutils console-tools \
debianutils editors findutils init miscutils modutils networking \
networking/libiproute networking/udhcp procps loginutils shell \
@@ -33,28 +31,36 @@ DIRS:=applets archival archival/libunarc
SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
-ifeq ($(strip $(CONFIG_SELINUX)),y)
-LIBRARIES += -lselinux
-endif
+# That's our default target when none is given on the command line
+.PHONY: _all
+_all:
+
+# All object directories.
+OBJ_DIRS = scripts/config include $(DIRS)
+$(OBJ_DIRS):
+ mkdir -p "$(patsubst %,$(top_builddir)/%,$@)"
+
+scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile
+ cp -v $< $@
+
+include $(top_srcdir)/Rules.mak
CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in
CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig
-ALL_DIRS:= $(DIRS) scripts/config
-ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS))
-
ifeq ($(KBUILD_SRC),)
ifdef O
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif
+else
+# If no alternate output-dir was specified, we build in cwd
+# We are using KBUILD_OUTPUT nevertheless to make sure that we create
+# Rules.mak and the toplevel Makefile, in case they don't exist.
+ KBUILD_OUTPUT := $(top_builddir)
endif
-# That's our default target when none is given on the command line
-.PHONY: _all
-_all:
-
ifneq ($(KBUILD_OUTPUT),)
# Invoke a second make in the output directory, passing relevant variables
# check that the output directory actually exists
@@ -63,24 +69,29 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUT
$(if $(wildcard $(KBUILD_OUTPUT)),, \
$(error output directory "$(saved-output)" does not exist))
+# We only need a copy of the Makefile for the config targets and reuse
+# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
+all_tree: $(OBJ_DIRS) $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile scripts/config/Makefile
+
.PHONY: $(MAKECMDGOALS)
-$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile
+$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree
+#all:
$(MAKE) -C $(KBUILD_OUTPUT) \
- top_srcdir=$(CURDIR) \
- top_builddir=$(KBUILD_OUTPUT) \
- KBUILD_SRC=$(CURDIR) \
+ top_srcdir=$(top_srcdir) \
+ top_builddir=$(top_builddir) \
+ KBUILD_SRC=$(top_srcdir) \
-f $(CURDIR)/Makefile $@
$(KBUILD_OUTPUT)/Rules.mak:
@echo > $@
- @echo top_srcdir=$(CURDIR) >> $@
+ @echo top_srcdir=$(top_srcdir) >> $@
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
@echo include $(top_srcdir)/Rules.mak >> $@
$(KBUILD_OUTPUT)/Makefile:
@echo > $@
- @echo top_srcdir=$(CURDIR) >> $@
+ @echo top_srcdir=$(top_srcdir) >> $@
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
@echo KBUILD_SRC='$$(top_srcdir)' >> $@
@echo include '$$(KBUILD_SRC)'/Makefile >> $@
@@ -124,21 +135,63 @@ help:
@echo ' sizes - show size of all enabled busybox symbols'
@echo
-ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
-all: busybox busybox.links doc
+ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
-all_tree: $(ALL_MAKEFILES)
+all: menuconfig
-$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
- [ -d $(@D) ] || mkdir -p $(@D); cp $< $@
+# configuration
+# ---------------------------------------------------------------------------
+
+scripts/config/conf: scripts/config/Makefile
+ $(MAKE) -C scripts/config conf
+ - at if [ ! -f .config ] ; then \
+ cp $(CONFIG_DEFCONFIG) .config; \
+ fi
+
+scripts/config/mconf: scripts/config/Makefile
+ $(MAKE) -C scripts/config ncurses conf mconf
+ - at if [ ! -f .config ] ; then \
+ cp $(CONFIG_DEFCONFIG) .config; \
+ fi
+
+menuconfig: scripts/config/mconf
+ @./scripts/config/mconf $(CONFIG_CONFIG_IN)
+
+config: scripts/config/conf
+ @./scripts/config/conf $(CONFIG_CONFIG_IN)
+
+oldconfig: scripts/config/conf
+ @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
+
+randconfig: scripts/config/conf
+ @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
+
+allyesconfig: scripts/config/conf
+ @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
+ sed -i -r -e "s/^(CONFIG_DEBUG|USING_CROSS_COMPILER|CONFIG_STATIC|CONFIG_SELINUX).*/# \1 is not set/" .config
+ @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
+
+allnoconfig: scripts/config/conf
+ @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
+
+defconfig: scripts/config/conf
+ @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
+
+else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
+
+all: busybox busybox.links doc
# In this section, we need .config
-include $(top_builddir)/.config.cmd
include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
-include $(top_builddir)/.depend
-busybox: $(ALL_MAKEFILES) .depend $(libraries-y)
+endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
+
+#vpath %/Makefile $(srctree)
+
+busybox: .depend $(libraries-y)
$(CC) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
$(STRIPCMD) $@
@@ -217,7 +270,7 @@ ifeq ($(strip $(CONFIG_BBCONFIG)),y)
DEP_INCLUDES += include/bbconfigopts.h
include/bbconfigopts.h: .config
- scripts/config/mkconfigs > $@
+ $(top_srcdir)/scripts/config/mkconfigs > $@
endif
depend dep $(top_builddir)/.depend: .depend
@@ -245,48 +298,6 @@ finished2:
$(SECHO) Finished installing...
$(SECHO)
-else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
-
-all: menuconfig
-
-# configuration
-# ---------------------------------------------------------------------------
-
-scripts/config/conf: scripts/config/Makefile $(top_srcdir)/Rules.mak
- $(MAKE) -C scripts/config conf
- - at if [ ! -f .config ] ; then \
- cp $(CONFIG_DEFCONFIG) .config; \
- fi
-
-scripts/config/mconf: scripts/config/Makefile $(top_srcdir)/Rules.mak
- $(MAKE) -C scripts/config ncurses conf mconf
- - at if [ ! -f .config ] ; then \
- cp $(CONFIG_DEFCONFIG) .config; \
- fi
-
-menuconfig: scripts/config/mconf
- @./scripts/config/mconf $(CONFIG_CONFIG_IN)
-
-config: scripts/config/conf
- @./scripts/config/conf $(CONFIG_CONFIG_IN)
-
-oldconfig: scripts/config/conf
- @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
-
-randconfig: scripts/config/conf
- @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
-
-allyesconfig: scripts/config/conf
- @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
- sed -i -r -e "s/^(CONFIG_DEBUG|USING_CROSS_COMPILER|CONFIG_STATIC|CONFIG_SELINUX).*/# \1 is not set/" .config
- @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
-
-allnoconfig: scripts/config/conf
- @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
-
-defconfig: scripts/config/conf
- @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
-
clean:
- $(MAKE) -C scripts/config $@
- rm -f docs/busybox.dvi docs/busybox.ps \
@@ -327,8 +338,6 @@ tags:
ctags -R .
-endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
-
endif # ifeq ($(skip-makefile),)
.PHONY: dummy subdirs release distclean clean config oldconfig \
diff -X excl -rduNp busybox.oorig/README busybox/README
--- busybox.oorig/README 2005-09-26 15:54:28.000000000 +0200
+++ busybox/README 2005-09-29 13:22:47.000000000 +0200
@@ -1,4 +1,5 @@
Please see the LICENSE file for details on copying and usage.
+Please refer to the INSTALL file for instructions on how to build.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for most of the utilities
@@ -15,17 +16,8 @@ BusyBox provides a fairly complete POSIX
system.
BusyBox is extremely configurable. This allows you to include only the
-components you need, thereby reducing binary size. Run 'make config' or
-'make menuconfig' to select the functionality that you wish to enable.
-
-After the build is complete, a busybox.links file is generated. This is
-used by 'make install' to create symlinks to the BusyBox binary for all
-compiled in functions. By default, 'make install' will place the symlink
-forest into `pwd`/_install unless you have defined the PREFIX environment
-variable (i.e., 'make PREFIX=/tmp/foo install')
-
-If you wish to install hard links, rather than symlinks, you can use
-'make PREFIX=/tmp/foo install-hardlinks' instead.
+components you need, thereby reducing binary size. See the file INSTALL
+for details.
----------------
@@ -110,14 +102,14 @@ be downloaded from
CVS:
-BusyBox now has its own publicly browsable CVS tree at:
- http://busybox.net/cgi-bin/cvsweb/busybox/
+BusyBox now has its own publicly browsable SVN tree at:
+ http://busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/
-Anonymous CVS access is available. For instructions, check out:
- http://busybox.net/cvs_anon.html
+Anonymous SVN access is available. For instructions, check out:
+ http://busybox.net/subversion.html
-For those that are actively contributing there is even CVS write access:
- http://busybox.net/cvs_write.html
+For those that are actively contributing there is even SVN write access:
+ http://busybox.net/developer.html
----------------
diff -X excl -rduNp busybox.oorig/Rules.mak busybox/Rules.mak
--- busybox.oorig/Rules.mak 2005-09-29 10:17:48.000000000 +0200
+++ busybox/Rules.mak 2005-10-04 10:17:54.000000000 +0200
@@ -27,7 +27,7 @@ BUILDTIME := $(shell TZ=UTC date -u "+%Y
# With a modern GNU make(1) (highly recommended, that's what all the
# developers use), all of the following configuration values can be
# overridden at the command line. For example:
-# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
+# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
#--------------------------------------------------------
# If you are running a cross compiler, you will want to set 'CROSS'
@@ -60,11 +60,6 @@ LC_ALL:= C
# For optimization overrides, it's better still to set OPTIMIZATION.
CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
-# If you have a "pristine" source directory, point BB_SRC_DIR to it.
-# Experimental and incomplete; tell the mailing list
-# <busybox at busybox.net> if you do or don't like it so far.
-BB_SRC_DIR=
-
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#
@@ -176,19 +171,20 @@ ifeq ($(strip $(CONFIG_STATIC)),y)
LDFLAGS += --static
endif
+ifeq ($(strip $(CONFIG_SELINUX)),y)
+ LIBRARIES += -lselinux
+endif
+
ifeq ($(strip $(PREFIX)),)
PREFIX:=`pwd`/_install
endif
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
-# the copy in BB_SRC_DIR, both during the compilation phase and the
+# the copy in top_srcdir, both during the compilation phase and the
# shell script that finds the list of object files.
# Work in progress by <ldoolitt at recycle.lbl.gov>.
-#
-ifneq ($(strip $(BB_SRC_DIR)),)
- VPATH:=$(BB_SRC_DIR)
-endif
+
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
More information about the busybox
mailing list