From aefad5317f2fd1645ace5a62b6b9643143093173 Mon Sep 17 00:00:00 2001 From: Yann E. MORIN Date: Sun, 26 Sep 2010 10:56:12 +0200 Subject: Makefile: generate a Makefile wrapper in $(O) If building out-of-tree, add a Makefile wrapper that calls-out to the real Makefile with proper args. Avoids having to pass -C and O= every time we call make. This is highly inspired from how the Linux kernel does it, and portions of it have been used. We can't use exactly the same implementation as the kernel does, because: - the script writing the wrapper has been expunged of the few lines that were too kernel-related: in buildroot we do not need the version string in the wrapper, and we do not have a patchlevel version; - "in-tree build" does not have the same meaning for the kernel and for buildroot: for the kernel, $(O) point to the $(TOPDIR), while for buildroot $(O) points to $(TOPDIR)/output. For more complete explanations, see: http://lists.busybox.net/pipermail/buildroot/2010-September/037815.html [Peter: minor tweaks] Signed-off-by: "Yann E. MORIN" Signed-off-by: Peter Korsgaard --- Makefile | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index faa802bb7..aab346e94 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ space:=$(empty) $(empty) ifneq ("$(origin O)", "command line") O:=output CONFIG_DIR:=$(TOPDIR) +NEED_WRAPPER= else # other packages might also support Linux-style out of tree builds # with the O= syntax (E.G. Busybox does). As make automatically @@ -60,6 +61,7 @@ override O:=$(O) CONFIG_DIR:=$(O) # we need to pass O= everywhere we call back into the toplevel makefile EXTRAMAKEARGS = O=$(O) +NEED_WRAPPER=y endif # $(shell find . -name *_defconfig |sed 's/.*\///') @@ -324,7 +326,7 @@ prepare: $(BUILD_DIR)/buildroot-config/auto.conf world: prepare dependencies dirs $(BASE_TARGETS) $(TARGETS_ALL) -.PHONY: all world dirs clean distclean source \ +.PHONY: all world dirs clean distclean source outputmakefile \ $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \ $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \ $(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \ @@ -463,52 +465,52 @@ COMMON_CONFIG_ENV = \ KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \ BUILDROOT_CONFIG=$(CONFIG_DIR)/.config -xconfig: $(BUILD_DIR)/buildroot-config/qconf +xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @if ! $(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN); then \ test -f $(CONFIG_DIR)/.config.cmd || rm -f $(CONFIG_DIR)/.config; \ fi -gconfig: $(BUILD_DIR)/buildroot-config/gconf +gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @if ! $(COMMON_CONFIG_ENV) srctree=$(TOPDIR) \ $< $(CONFIG_CONFIG_IN); then \ test -f $(CONFIG_DIR)/.config.cmd || rm -f $(CONFIG_DIR)/.config; \ fi -menuconfig: $(BUILD_DIR)/buildroot-config/mconf +menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @if ! $(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN); then \ test -f $(CONFIG_DIR)/.config.cmd || rm -f $(CONFIG_DIR)/.config; \ fi -nconfig: $(BUILD_DIR)/buildroot-config/nconf +nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @if ! $(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN); then \ test -f $(CONFIG_DIR)/.config.cmd || rm -f $(CONFIG_DIR)/.config; \ fi -config: $(BUILD_DIR)/buildroot-config/conf +config: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN) -oldconfig: $(BUILD_DIR)/buildroot-config/conf +oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN) -randconfig: $(BUILD_DIR)/buildroot-config/conf +randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN) -allyesconfig: $(BUILD_DIR)/buildroot-config/conf +allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN) -allnoconfig: $(BUILD_DIR)/buildroot-config/conf +allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN) -randpackageconfig: $(BUILD_DIR)/buildroot-config/conf +randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @grep -v BR2_PACKAGE_ $(CONFIG_DIR)/.config > $(CONFIG_DIR)/.config.nopkg @$(COMMON_CONFIG_ENV) \ @@ -516,7 +518,7 @@ randpackageconfig: $(BUILD_DIR)/buildroot-config/conf $< --randconfig $(CONFIG_CONFIG_IN) @rm -f $(CONFIG_DIR)/.config.nopkg -allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf +allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @grep -v BR2_PACKAGE_ $(CONFIG_DIR)/.config > $(CONFIG_DIR)/.config.nopkg @$(COMMON_CONFIG_ENV) \ @@ -524,7 +526,7 @@ allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf $< --allyesconfig $(CONFIG_CONFIG_IN) @rm -f $(CONFIG_DIR)/.config.nopkg -allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf +allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @grep -v BR2_PACKAGE_ $(CONFIG_DIR)/.config > $(CONFIG_DIR)/.config.nopkg @$(COMMON_CONFIG_ENV) \ @@ -532,19 +534,19 @@ allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf $< --allnoconfig $(CONFIG_CONFIG_IN) @rm -f $(CONFIG_DIR)/.config.nopkg -silentoldconfig: $(BUILD_DIR)/buildroot-config/conf +silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN) -defconfig: $(BUILD_DIR)/buildroot-config/conf +defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< --defconfig $(CONFIG_CONFIG_IN) -%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig +%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN) -savedefconfig: $(BUILD_DIR)/buildroot-config/conf +savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile @mkdir -p $(BUILD_DIR)/buildroot-config @$(COMMON_CONFIG_ENV) $< --savedefconfig=$(TOPDIR)/defconfig $(CONFIG_CONFIG_IN) @@ -559,6 +561,15 @@ endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y) # Cleanup and misc junk # ############################################################# + +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +outputmakefile: +ifeq ($(NEED_WRAPPER),y) + $(Q)$(TOPDIR)/scripts/mkmakefile $(TOPDIR) $(O) +endif + clean: rm -rf $(STAGING_DIR) $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \ $(STAMP_DIR) $(BUILD_DIR) $(TOOLCHAIN_DIR) -- cgit v1.2.3-55-g7522