35 # COMPONENT_ARCHIVE macro defining a local file name for the archive, and |
35 # COMPONENT_ARCHIVE macro defining a local file name for the archive, and |
36 # optional COMPONENT_ARCHIVE_HASH and COMPONENT_SIG_URL containing a hash of |
36 # optional COMPONENT_ARCHIVE_HASH and COMPONENT_SIG_URL containing a hash of |
37 # the file and signature for verification of its contents. |
37 # the file and signature for verification of its contents. |
38 # |
38 # |
39 |
39 |
40 URL_SUFFIXES = $(subst COMPONENT_ARCHIVE_URL_,, \ |
40 # Filter out any suffixes which correspond to auto-generated github archive |
41 $(filter COMPONENT_ARCHIVE_URL_%, $(.VARIABLES))) |
41 # URLs (see prep-git.mk for the definition of GITHUB_ARCHIVE_SUFFIXES). If |
|
42 # the primary archive shouldn't be processed here, we check for it before |
|
43 # evaling. |
|
44 URL_SUFFIXES = $(filter-out $(GITHUB_ARCHIVE_SUFFIXES), \ |
|
45 $(subst COMPONENT_ARCHIVE_URL_,, \ |
|
46 $(filter COMPONENT_ARCHIVE_URL_%, $(.VARIABLES)))) |
42 |
47 |
43 # Template for download rules. |
48 # Templates for download variables and rules. We separate the variable |
44 define download-rules |
49 # assignments from the rules so that all the variable assignments are given a |
45 ifdef COMPONENT_ARCHIVE_URL$(1) |
50 # chance to complete before those variables are used in targets or |
46 |
51 # prerequisites, where they'll be expanded immediately. Use ifneq/origin |
|
52 # instead of ifdef due to GNU Make bug 49093. |
|
53 define download-variables |
|
54 ifneq "$(origin COMPONENT_ARCHIVE_URL$(1))" "undefined" |
47 ARCHIVES += $$(COMPONENT_ARCHIVE$(1)) |
55 ARCHIVES += $$(COMPONENT_ARCHIVE$(1)) |
48 CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1)) $$(notdir $$(COMPONENT_SIG_URL$(1))) |
56 CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1)) $$(notdir $$(COMPONENT_SIG_URL$(1))) |
|
57 endif |
|
58 endef |
49 |
59 |
|
60 define download-rules |
|
61 ifneq "$(origin COMPONENT_ARCHIVE_URL$(1))" "undefined" |
50 download:: $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)) |
62 download:: $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)) |
51 |
63 |
52 $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ) |
64 $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ) |
53 $$(FETCH) --file $$@ \ |
65 $$(FETCH) --file $$@ \ |
54 $$(COMPONENT_ARCHIVE_URL$(1):%=--url %) \ |
66 $$(COMPONENT_ARCHIVE_URL$(1):%=--url %) \ |
59 REQUIRED_PACKAGES += runtime/python-27 |
71 REQUIRED_PACKAGES += runtime/python-27 |
60 |
72 |
61 endif |
73 endif |
62 endef |
74 endef |
63 |
75 |
64 # |
76 # Evaluate the variable assignments immediately. If we're pulling the main |
65 # Define the rules required to download any source archives and augment any |
77 # (unsuffixed) archive from github, gia prep-git.mk, then skip doing that here. |
66 # cleanup macros. |
78 # Use $(if) instead of ifeq() because the latter is evaluated immediately. |
67 # |
79 $(if $(findstring __BLANK__,$(GITHUB_ARCHIVE_SUFFIXES)),,$(eval $(call download-variables,))) |
68 $(eval $(call download-rules,)) |
80 $(foreach suffix, $(URL_SUFFIXES), $(eval $(call download-variables,_$(suffix)))) |
|
81 |
|
82 # Put the rule evaluations in a variable for deferred evaluation. |
|
83 define eval-download-rules |
|
84 $(if $(findstring __BLANK__,$(GITHUB_ARCHIVE_SUFFIXES)),,$(eval $(call download-rules,))) |
69 $(foreach suffix, $(URL_SUFFIXES), $(eval $(call download-rules,_$(suffix)))) |
85 $(foreach suffix, $(URL_SUFFIXES), $(eval $(call download-rules,_$(suffix)))) |
|
86 endef |
70 |
87 |
71 # Needed for signature validation of downloads |
88 # Needed for signature validation of downloads |
72 REQUIRED_PACKAGES += crypto/gnupg |
89 REQUIRED_PACKAGES += crypto/gnupg |