All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2] Add target to create a project directory
Date: Sun, 14 Oct 2012 01:21:03 +0200	[thread overview]
Message-ID: <20121013232039.19428.5883.stgit@localhost> (raw)
In-Reply-To: <20121013231443.17317.60675.stgit@localhost>

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
v2: Removed accidental changes to busybox.config and uClibc.config
---
 Makefile              |   30 ++++++++++++++++++++++++++++++
 Makefile.project.tmpl |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 Makefile.project.tmpl

diff --git a/Makefile b/Makefile
index 0e5b28e..a3b88f7 100644
--- a/Makefile
+++ b/Makefile
@@ -698,6 +698,33 @@ endif
 
 cross: $(BASE_TARGETS)
 
+ifneq ($(PROJECT_DIR),)
+ifeq ($(findstring -git,$(BR2_VERSION)),)
+BUILDROOT_VERSION = $(BR2_VERSION)
+else
+BUILDROOT_VERSION = snapshot
+endif
+
+# Write a buildroot config in the project dir, then use that defconfig to
+# re-generate the .config.  This replaces the config file paths with paths
+# pointing into PROJECT_DIR (unless they have been changed from their
+# default values).  The subsequent update-all-config writes all the config
+# files into the PROJECT_DIR.  That last step doesn't need to set PROJECT_DIR
+# or DEFCONFIG anymore, because they're already set in the new .config.
+projectdir:
+	mkdir -p $(PROJECT_DIR)
+	sed s/@BUILDROOT_VERSION@/$(BUILDROOT_VERSION)/g \
+		Makefile.project.tmpl > $(PROJECT_DIR)/Makefile
+	$(MAKE1) $(EXTRAMAKEARGS) \
+		DEFCONFIG=$(PROJECT_DIR)/buildroot.config \
+		savedefconfig
+	$(MAKE1) $(EXTRAMAKEARGS) \
+		PROJECT_DIR=$(PROJECT_DIR) \
+		DEFCONFIG=$(PROJECT_DIR)/buildroot.config \
+		defconfig
+	$(MAKE1) $(EXTRAMAKEARGS) update-all-config
+endif
+
 help:
 	@echo 'Cleaning:'
 	@echo '  clean                  - delete all files created by build'
@@ -756,6 +783,9 @@ endif
 	@echo '  source-check           - check selected packages for valid download URLs'
 	@echo '  external-deps          - list external packages used'
 	@echo '  legal-info             - generate info about license compliance'
+ifneq ($(PROJECT_DIR),)
+	@echo '  projectdir             - Prepare project directory with a Makefile.'
+endif
 	@echo
 	@echo '  make V=0|1             - 0 => quiet build (default), 1 => verbose build'
 	@echo '  make O=dir             - Locate all output files in "dir", including .config'
diff --git a/Makefile.project.tmpl b/Makefile.project.tmpl
new file mode 100644
index 0000000..b41180a
--- /dev/null
+++ b/Makefile.project.tmpl
@@ -0,0 +1,40 @@
+# This Makefile creates a build environment using the directory containing
+# this Makefile as the project directory.
+# If called from a different directory using 'make -f ...', the current
+# directory is used as the output directory.
+
+lastword = $(word $(words $(1)),$(1))
+makedir  = $(dir $(call lastword,$(MAKEFILE_LIST)))
+
+BR2_PROJECT_DIR = $(realpath $(makedir))
+BUILDROOT_DIR   = $(BR2_PROJECT_DIR)/buildroot
+BUILDROOT_VERSION = @BUILDROOT_VERSION@
+BUILDROOT_SITE    = http://buildroot.net/downloads
+BUILDROOT_SOURCE  = buildroot-$(BUILDROOT_VERSION).tar.bz2
+
+ifeq ($(O),)
+ifeq ($(makedir),./)
+# Building in project dir => create output dir
+O = $(CURDIR)/output
+else
+# Building from some other dir => use this dir as output dir
+O = $(CURDIR)
+endif
+endif
+
+.PHONY: all $(MAKECMDGOALS)
+
+all: $(BUILDROOT_DIR)
+	@$(MAKE) -C buildroot O=$(O) BR2_PROJECT_DIR=$(BR2_PROJECT_DIR) $(all)
+
+all     := $(filter-out all,$(MAKECMDGOALS))
+$(all): all
+        @:
+
+$(BUILDROOT_DIR):
+	mkdir -p $@
+	wget -O - $(BUILDROOT_SITE)/$(BUILDROOT_SOURCE) | \
+		tar -xjf - -C $@ --strip-components=1
+	for p in `ls $(makedir)/patches/buildroot/buildroot-* 2>/dev/null`; do \
+		patch -d $@ -p1 -i $$p; \
+	done

  reply	other threads:[~2012-10-13 23:21 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-13 23:13 [Buildroot] [PATCH 00/13] Add support for a project directory Arnout Vandecappelle
2012-10-13 23:13 ` [Buildroot] [PATCH 01/13] Add BR2_PROJECT_DIR config option Arnout Vandecappelle
2012-10-13 23:13 ` [Buildroot] [PATCH 02/13] Set default BR2_PACKAGE_OVERRIDE_FILE based on BR2_PROJECT_DIR Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 03/13] linux: get default paths from BR2_PROJECT_DIR Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 04/13] busybox: " Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 05/13] target/generic: " Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 06/13] toolchain-crosstool-ng: " Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 07/13] uClibc: " Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 08/13] Store BR2_DEFCONFIG in .config, and use it to update the original input Arnout Vandecappelle
2012-10-14 18:37   ` Thomas De Schampheleire
2012-10-13 23:14 ` [Buildroot] [PATCH 09/13] Skip menuconfig if BR2_DEFCONFIG or BR2_PROJECT_DIR is given Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 10/13] Add update-all-config target Arnout Vandecappelle
2012-10-14 18:45   ` Thomas De Schampheleire
2012-10-20 16:47     ` Arnout Vandecappelle
2012-10-20 16:52       ` Arnout Vandecappelle
2012-12-03 14:18     ` Stephan Hoffmann
2012-12-03 16:41       ` Thomas Petazzoni
2012-10-13 23:14 ` [Buildroot] [PATCH 11/13] Add target to create a project directory Arnout Vandecappelle
2012-10-13 23:21   ` Arnout Vandecappelle [this message]
2012-10-13 23:35     ` [Buildroot] [PATCH v2] " Valentine Barshak
2012-10-14 12:50       ` Arnout Vandecappelle
2012-10-16 17:36         ` Valentine Barshak
2012-10-13 23:14 ` [Buildroot] [PATCH 12/13] target/generic: add filesystem overlay option Arnout Vandecappelle
2012-10-14  0:39   ` Danomi Manchego
2012-10-14 12:53     ` Arnout Vandecappelle
2012-10-14 16:12       ` Danomi Manchego
2012-10-14 18:50   ` Thomas De Schampheleire
2012-10-20 16:15     ` Arnout Vandecappelle
2012-10-13 23:14 ` [Buildroot] [PATCH 13/13] Document BR2_PROJECT_DIR in the manual Arnout Vandecappelle
2012-10-14  8:35 ` [Buildroot] [PATCH 00/13] Add support for a project directory Thomas Petazzoni
2012-10-14  8:46   ` Thomas Petazzoni
2012-10-14 10:43     ` Arnout Vandecappelle
2012-10-14 12:55       ` Thomas Petazzoni
2012-10-14 13:57         ` Arnout Vandecappelle
2012-10-16 20:03   ` Arnout Vandecappelle
2012-10-17 17:26     ` Thomas Petazzoni
2012-10-17 18:42       ` Sagaert Johan
2012-10-14 18:56 ` Thomas De Schampheleire

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121013232039.19428.5883.stgit@localhost \
    --to=arnout@mind.be \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.