cns3xxx: fix missing and incomplete cache flushes on DMA cache sync for cpu - fixes...
[openwrt.git] / include / download.mk
1 #
2 # Copyright (C) 2006-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED)
9
10 # Try to guess the download method from the URL
11 define dl_method
12 $(strip \
13 $(if $(2),$(2), \
14 $(if $(filter @GNOME/% @GNU/% @KERNEL/% @SF/% ftp://% http://% https://% file://%,$(1)),default, \
15 $(if $(filter git://%,$(1)),git, \
16 $(if $(filter svn://%,$(1)),svn, \
17 $(if $(filter cvs://%,$(1)),cvs, \
18 $(if $(filter hg://%,$(1)),hg, \
19 $(if $(filter sftp://%,$(1)),bzr, \
20 unknown \
21 ) \
22 ) \
23 ) \
24 ) \
25 ) \
26 ) \
27 ) \
28 )
29 endef
30
31 # code for creating tarballs from cvs/svn/git/bzr/hg/darcs checkouts - useful for mirror support
32 dl_pack/bz2=$(TAR) cfj $(1) $(2)
33 dl_pack/gz=$(TAR) cfz $(1) $(2)
34 dl_pack/unknown=echo "ERROR: Unknown pack format for file $(1)"; false
35 define dl_pack
36 $(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown))
37 endef
38
39 define DownloadMethod/unknown
40 @echo "ERROR: No download method available"; false
41 endef
42
43 define DownloadMethod/default
44 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(foreach url,$(URL),"$(url)")
45 endef
46
47 define wrap_mirror
48 $(if $(MIRROR),@$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" || ( $(1) ),$(1))
49 endef
50
51 define DownloadMethod/cvs
52 $(call wrap_mirror, \
53 echo "Checking out files from the cvs repository..."; \
54 mkdir -p $(TMP_DIR)/dl && \
55 cd $(TMP_DIR)/dl && \
56 rm -rf $(SUBDIR) && \
57 [ \! -d $(SUBDIR) ] && \
58 cvs -d $(URL) export $(VERSION) $(SUBDIR) && \
59 echo "Packing checkout..." && \
60 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
61 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
62 rm -rf $(SUBDIR); \
63 )
64 endef
65
66 define DownloadMethod/svn
67 $(call wrap_mirror, \
68 echo "Checking out files from the svn repository..."; \
69 mkdir -p $(TMP_DIR)/dl && \
70 cd $(TMP_DIR)/dl && \
71 rm -rf $(SUBDIR) && \
72 [ \! -d $(SUBDIR) ] && \
73 ( svn help export | grep -q trust-server-cert && \
74 svn export --non-interactive --trust-server-cert -r$(VERSION) $(URL) $(SUBDIR) || \
75 svn export --non-interactive -r$(VERSION) $(URL) $(SUBDIR) ) && \
76 echo "Packing checkout..." && \
77 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
78 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
79 rm -rf $(SUBDIR); \
80 )
81 endef
82
83 define DownloadMethod/git
84 $(call wrap_mirror, \
85 echo "Checking out files from the git repository..."; \
86 mkdir -p $(TMP_DIR)/dl && \
87 cd $(TMP_DIR)/dl && \
88 rm -rf $(SUBDIR) && \
89 [ \! -d $(SUBDIR) ] && \
90 git clone $(URL) $(SUBDIR) && \
91 (cd $(SUBDIR) && git checkout $(VERSION)) && \
92 echo "Packing checkout..." && \
93 rm -rf $(SUBDIR)/.git && \
94 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
95 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
96 rm -rf $(SUBDIR); \
97 )
98 endef
99
100 define DownloadMethod/bzr
101 $(call wrap_mirror, \
102 echo "Checking out files from the bzr repository..."; \
103 mkdir -p $(TMP_DIR)/dl && \
104 cd $(TMP_DIR)/dl && \
105 rm -rf $(SUBDIR) && \
106 [ \! -d $(SUBDIR) ] && \
107 bzr export -r$(VERSION) $(SUBDIR) $(URL) && \
108 echo "Packing checkout..." && \
109 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
110 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
111 rm -rf $(SUBDIR); \
112 )
113 endef
114
115 define DownloadMethod/hg
116 $(call wrap_mirror, \
117 echo "Checking out files from the hg repository..."; \
118 mkdir -p $(TMP_DIR)/dl && \
119 cd $(TMP_DIR)/dl && \
120 rm -rf $(SUBDIR) && \
121 [ \! -d $(SUBDIR) ] && \
122 hg clone -r $(VERSION) $(URL) $(SUBDIR) && \
123 find $(SUBDIR) -name .hg | xargs rm -rf && \
124 echo "Packing checkout..." && \
125 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
126 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
127 rm -rf $(SUBDIR); \
128 )
129 endef
130
131 define DownloadMethod/darcs
132 $(call wrap_mirror, \
133 echo "Checking out files from the darcs repository..."; \
134 mkdir -p $(TMP_DIR)/dl && \
135 cd $(TMP_DIR)/dl && \
136 rm -rf $(SUBDIR) && \
137 [ \! -d $(SUBDIR) ] && \
138 darcs get -t $(VERSION) $(URL) $(SUBDIR) && \
139 find $(SUBDIR) -name _darcs | xargs rm -rf && \
140 echo "Packing checkout..." && \
141 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
142 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
143 rm -rf $(SUBDIR); \
144 )
145 endef
146
147 Validate/cvs=VERSION SUBDIR
148 Validate/svn=VERSION SUBDIR
149 Validate/git=VERSION SUBDIR
150 Validate/bzr=VERSION SUBDIR
151 Validate/hg=VERSION SUBDIR
152 Validate/darcs=VERSION SUBDIR
153
154 define Download/Defaults
155 URL:=
156 FILE:=
157 PROTO:=
158 MD5SUM:=
159 SUBDIR:=
160 MIRROR:=1
161 MIRROR_MD5SUM:=x
162 VERSION:=
163 endef
164
165 define Download
166 $(eval $(Download/Defaults))
167 $(eval $(Download/$(1)))
168 $(foreach FIELD,URL FILE $(Validate/$(call dl_method,$(URL),$(PROTO))),
169 ifeq ($($(FIELD)),)
170 $$(error Download/$(1) is missing the $(FIELD) field.)
171 endif
172 )
173
174 $(foreach dep,$(DOWNLOAD_RDEP),
175 $(dep): $(DL_DIR)/$(FILE)
176 )
177 download: $(DL_DIR)/$(FILE)
178
179 $(DL_DIR)/$(FILE):
180 mkdir -p $(DL_DIR)
181 $(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown))
182
183 endef
This page took 0.054736 seconds and 5 git commands to generate.