From: Alexandru Ardelean <ardeleanalex@gmail.com>
Date: Wed, 5 Oct 2016 14:28:46 +0000 (+0300)
Subject: build: copy contents of 'src' folder to build dirs (if present)
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=7c8c3226dc8ecd2b77d1d1e8215e0fbb52819cd7;p=openwrt%2Fstaging%2Fblogic.git

build: copy contents of 'src' folder to build dirs (if present)

The normal Prepare step for a build is unpack, apply patches.
But for certain packages, patches contain whole files, which
would be nice to have separately and copied over as a last step
in the Prepare phase.

We need it for some other packages + patches, but I think
the 'hostapd' package can be used as a test for this.

As a quick note:
the reason the condition is being evaluated as
`[ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR)`
and not with
`[ -d ./src/ ] && $(CP) ./src/* $(HOST_BUILD_DIR)`
is that the latter would translate in a build failure if the `src`
folder is not present (the exit code would be 1).
The first one, succeeds for both cases (if `src` present or not).

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
---

diff --git a/include/host-build.mk b/include/host-build.mk
index 72b32597d4d2..56e0e4e4136e 100644
--- a/include/host-build.mk
+++ b/include/host-build.mk
@@ -43,6 +43,7 @@ Host/Patch:=$(Host/Patch/Default)
 ifneq ($(strip $(HOST_UNPACK)),)
   define Host/Prepare/Default
 	$(HOST_UNPACK)
+	[ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR)
 	$(Host/Patch)
   endef
 endif
diff --git a/include/package-defaults.mk b/include/package-defaults.mk
index 4eb54099098d..487811c0e256 100644
--- a/include/package-defaults.mk
+++ b/include/package-defaults.mk
@@ -62,6 +62,7 @@ Build/Patch:=$(Build/Patch/Default)
 ifneq ($(strip $(PKG_UNPACK)),)
   define Build/Prepare/Default
 	$(PKG_UNPACK)
+	[ ! -d ./src/ ] || $(CP) ./src/* $(PKG_BUILD_DIR)
 	$(Build/Patch)
   endef
 endif