X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=Makefile;h=7f29037f538214f45cc143e4f5144a7b91c5e550;hb=d1b6078e5d614993de2a858e85f1dc06cfe5539b;hp=c3b54ad2f0d047976db3744be98ed91122212355;hpb=d24eaac9e66d1f725a7b3c8e8d472845c3f63c39;p=oweals%2Fbusybox.git diff --git a/Makefile b/Makefile index c3b54ad2f..7f29037f5 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,11 @@ noconfig_targets := menuconfig config oldconfig randconfig \ defconfig allyesconfig allnoconfig clean distclean \ release tags -ifndef TOPDIR -TOPDIR=$(CURDIR)/ -endif +# the toplevel sourcedir ifndef top_srcdir top_srcdir=$(CURDIR) endif +# toplevel directory of the object-tree ifndef top_builddir top_builddir=$(CURDIR) endif @@ -25,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 \ @@ -34,28 +31,36 @@ DIRS:=applets archival archival/libunarchive coreutils console-tools \ 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 @@ -64,25 +69,29 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) $(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) \ - TOPDIR=$(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 >> $@ @@ -126,22 +135,62 @@ 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: menuconfig + +# configuration +# --------------------------------------------------------------------------- + +scripts/config/conf: scripts/config/Makefile + $(MAKE) -C scripts/config conf + -@if [ ! -f .config ] ; then \ + cp $(CONFIG_DEFCONFIG) .config; \ + fi + +scripts/config/mconf: scripts/config/Makefile + $(MAKE) -C scripts/config ncurses conf mconf + -@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) -all_tree: $(ALL_MAKEFILES) +allnoconfig: scripts/config/conf + @./scripts/config/conf -n $(CONFIG_CONFIG_IN) -$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile - [ -d $(@D) ] || mkdir -p $(@D); cp $< $@ +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) - $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group +endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) + +busybox: .depend $(libraries-y) + $(CC) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group $(STRIPCMD) $@ busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h @@ -219,7 +268,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 @@ -247,48 +296,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 - -@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 - -@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 \ @@ -329,8 +336,6 @@ tags: ctags -R . -endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) - endif # ifeq ($(skip-makefile),) .PHONY: dummy subdirs release distclean clean config oldconfig \