From b26d576fd70a23f515d573e2bd301856f8b73fbc Mon Sep 17 00:00:00 2001
From: nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Fri, 28 Sep 2007 01:23:56 +0000
Subject: [PATCH] some minor fixes, cleanups, package build abstraction

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9051 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 include/package-ipkg.mk |  5 +----
 include/package.mk      | 11 +++++++++--
 include/prereq.mk       |  4 ++++
 include/quilt.mk        |  4 ++++
 include/target.mk       |  8 +++++---
 5 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index f75c0a23f..16378a0f0 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -23,7 +23,7 @@ define BuildIPKGVariable
 endef
 
 ifeq ($(DUMP),)
-  define BuildIPKG
+  define BuildTarget/ipkg
     IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
     IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
     INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
@@ -92,9 +92,6 @@ ifeq ($(DUMP),)
     $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(STAMP_PREPARED)
 	-@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null
 	@touch $$@
-
-    $$(eval $$(call Build/DefaultTargets,$(1)))
-
   endef
 
   $(STAGING_DIR)/etc/ipkg.conf:
diff --git a/include/package.mk b/include/package.mk
index 43d0663f6..909045565 100644
--- a/include/package.mk
+++ b/include/package.mk
@@ -97,8 +97,15 @@ endif
   $(call shexport,Package/$(1)/description)
   $(call shexport,Package/$(1)/config)
 
-  $(Dumpinfo)
-  $(BuildIPKG)
+  $(if $(DUMP), \
+    $(Dumpinfo), \
+    $(foreach target, \
+      $(if $(Package/$(1)/targets),$(Package/$(1)/targets), \
+        $(if $(PKG_TARGETS),$(PKG_TARGETS), ipkg ) \
+      ), $(BuildTarget/$(target)) \
+    ) \
+  )
+  $(if $(DUMP),,$(call Build/DefaultTargets,$(1)))
 endef
 
 # prevent libtool from setting rpath when linking
diff --git a/include/prereq.mk b/include/prereq.mk
index 8e5490ccf..4a55c89ff 100644
--- a/include/prereq.mk
+++ b/include/prereq.mk
@@ -5,6 +5,9 @@
 # See /LICENSE for more information.
 #
 
+ifneq ($(__prereq_inc),1)
+__prereq_inc:=1
+
 prereq:
 	if [ -f $(TMP_DIR)/.prereq-error ]; then \
 		echo; \
@@ -15,6 +18,7 @@ prereq:
 	fi
 
 .SILENT: prereq
+endif
 
 define Require
   export PREREQ_CHECK=1
diff --git a/include/quilt.mk b/include/quilt.mk
index a7aac91c0..4dce2a6d8 100644
--- a/include/quilt.mk
+++ b/include/quilt.mk
@@ -5,6 +5,9 @@
 # See /LICENSE for more information.
 #
 
+ifneq ($(__quilt_inc),1)
+__quilt_inc:=1
+
 ifeq ($(TARGET_BUILD),1)
   PKG_BUILD_DIR:=$(LINUX_DIR)
 endif
@@ -134,3 +137,4 @@ refresh: quilt-check
 update: quilt-check
 	$(if $(KERNEL_BUILD),$(Quilt/Refresh/Kernel),$(Quilt/Refresh/Package))
 
+endif
diff --git a/include/target.mk b/include/target.mk
index c8eb76c25..1590b9109 100644
--- a/include/target.mk
+++ b/include/target.mk
@@ -75,9 +75,11 @@ define Profile
   endif
 endef
 
--include $(PLATFORM_DIR)/profiles/*.mk
-ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
-  -include $(PLATFORM_SUBDIR)/profiles/*.mk
+ifeq ($(DUMP)$(if $(TARGET_BUILD),,1),)
+  -include $(PLATFORM_DIR)/profiles/*.mk
+  ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
+    -include $(PLATFORM_SUBDIR)/profiles/*.mk
+  endif
 endif
 
 $(eval $(call shexport,Target/Description))
-- 
2.20.1