make-rules/prep.mk
changeset 142 6f1cb90a0ef3
parent 115 c360825c3a3f
child 198 172fc01ce997
--- a/make-rules/prep.mk	Fri Mar 18 09:25:30 2011 -0700
+++ b/make-rules/prep.mk	Fri Mar 18 12:47:51 2011 -0700
@@ -26,7 +26,6 @@
 
 ARCHIVES += $(COMPONENT_ARCHIVE)
 CLEAN_PATHS += $(SOURCE_DIR)
-CLOBBER_PATHS += $(COMPONENT_ARCHIVE)
 
 PATCH_DIR =	patches
 PATCH_PATTERN =	*.patch
@@ -38,13 +37,23 @@
 	$(GPATCH) -d $(@D) $(GPATCH_FLAGS) < $<
 	$(TOUCH) [email protected]
 
-$(USERLAND_ARCHIVES)$(COMPONENT_ARCHIVE):	Makefile
-	$(FETCH) --file [email protected] \
-		$(COMPONENT_ARCHIVE_URL:%=--url %) \
-		$(COMPONENT_ARCHIVE_HASH:%=--hash %)
-	$(TOUCH) [email protected]
+# template for download rules. add new rules with $(call download-rule, suffix)
+define download-rule
+ARCHIVES += $$(COMPONENT_ARCHIVE$(1))
+CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1))
+$$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)):	Makefile
+	$$(FETCH) --file [email protected] \
+		$$(COMPONENT_ARCHIVE_URL$(1):%=--url %) \
+		$$(COMPONENT_ARCHIVE_HASH$(1):%=--hash %)
+	$$(TOUCH) [email protected]
+endef
 
-$(SOURCE_DIR)/.unpacked:	$(USERLAND_ARCHIVES)$(COMPONENT_ARCHIVE) Makefile $(PATCHES)
+# Generate the download rules from the above template
+NUM_ARCHIVES =	1 2 3 4 5 6 7
+$(eval $(call download-rule,))
+$(foreach suffix,$(NUM_ARCHIVES),$(eval $(call download-rule,_$(suffix))))
+
+$(SOURCE_DIR)/.unpacked:	download Makefile $(PATCHES)
 	$(RM) -r $(SOURCE_DIR)
 	$(UNPACK) $(UNPACK_ARGS) $(USERLAND_ARCHIVES)$(COMPONENT_ARCHIVE)
 	$(TOUCH) [email protected]
@@ -58,11 +67,10 @@
 
 prep::	$(SOURCE_DIR)/.prep
 
-download::	$(USERLAND_ARCHIVES)$(COMPONENT_ARCHIVE)
+download::	$(ARCHIVES:%=$(USERLAND_ARCHIVES)%)
 
 clean::
 	$(RM) -r $(CLEAN_PATHS)
 
 clobber::	clean
 	$(RM) -r $(CLOBBER_PATHS)
-