fix missing symbol
[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://% 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 unknown \
20 ) \
21 ) \
22 ) \
23 ) \
24 ) \
25 ) \
26 )
27 endef
28
29 # code for creating tarballs from cvs/svn/git/bzr/hg checkouts - useful for mirror support
30 dl_pack/bz2=$(TAR) cfj $(1) $(2)
31 dl_pack/gz=$(TAR) cfz $(1) $(2)
32 dl_pack/unknown=echo "ERROR: Unknown pack format for file $(1)"; false
33 define dl_pack
34 $(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown))
35 endef
36
37 define DownloadMethod/unknown
38 @echo "ERROR: No download method available"; false
39 endef
40
41 define DownloadMethod/default
42 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(URL)
43 endef
44
45 define wrap_mirror
46 $(if $(MIRROR),@$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "x" || ( $(1) ),$(1))
47 endef
48
49 define DownloadMethod/cvs
50 $(call wrap_mirror, \
51 echo "Checking out files from the cvs repository..."; \
52 mkdir -p $(TMP_DIR)/dl && \
53 cd $(TMP_DIR)/dl && \
54 rm -rf $(SUBDIR) && \
55 [ \! -d $(SUBDIR) ] && \
56 cvs -d $(URL) co $(VERSION) $(SUBDIR) && \
57 find $(SUBDIR) -name CVS | xargs rm -rf && \
58 echo "Packing checkout..." && \
59 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
60 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
61 )
62 endef
63
64 define DownloadMethod/svn
65 $(call wrap_mirror, \
66 echo "Checking out files from the svn repository..."; \
67 mkdir -p $(TMP_DIR)/dl && \
68 cd $(TMP_DIR)/dl && \
69 rm -rf $(SUBDIR) && \
70 [ \! -d $(SUBDIR) ] && \
71 svn co --non-interactive -r$(VERSION) $(URL) $(SUBDIR) && \
72 find $(SUBDIR) -name .svn | xargs rm -rf && \
73 echo "Packing checkout..." && \
74 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
75 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
76 )
77 endef
78
79 define DownloadMethod/git
80 $(call wrap_mirror, \
81 echo "Checking out files from the git repository..."; \
82 mkdir -p $(TMP_DIR)/dl && \
83 cd $(TMP_DIR)/dl && \
84 rm -rf $(SUBDIR) && \
85 [ \! -d $(SUBDIR) ] && \
86 git clone $(URL) $(SUBDIR) && \
87 (cd $(SUBDIR) && git checkout $(VERSION)) && \
88 echo "Packing checkout..." && \
89 rm -rf $(SUBDIR)/.git && \
90 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
91 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
92 )
93 endef
94
95 define DownloadMethod/bzr
96 $(call wrap_mirror, \
97 echo "Checking out files from the bzr repository..."; \
98 mkdir -p $(TMP_DIR)/dl && \
99 cd $(TMP_DIR)/dl && \
100 rm -rf $(SUBDIR) && \
101 [ \! -d $(SUBDIR) ] && \
102 bzr co --lightweight -r$(VERSION) $(URL) $(SUBDIR) && \
103 find $(SUBDIR) -name .bzr | xargs rm -rf && \
104 echo "Packing checkout..." && \
105 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
106 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
107 )
108 endef
109
110 define DownloadMethod/hg
111 $(call wrap_mirror, \
112 echo "Checking out files from the hg repository..."; \
113 mkdir -p $(TMP_DIR)/dl && \
114 cd $(TMP_DIR)/dl && \
115 rm -rf $(SUBDIR) && \
116 [ \! -d $(SUBDIR) ] && \
117 hg clone -r $(VERSION) $(URL) $(SUBDIR) && \
118 find $(SUBDIR) -name .hg | xargs rm -rf && \
119 echo "Packing checkout..." && \
120 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
121 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
122 )
123 endef
124
125 Validate/cvs=VERSION SUBDIR
126 Validate/svn=VERSION SUBDIR
127 Validate/git=VERSION SUBDIR
128 Validate/bzr=VERSION SUBDIR
129 Validate/hg=VERSION SUBDIR
130
131 define Download/Defaults
132 URL:=
133 FILE:=
134 PROTO:=
135 MD5SUM:=
136 SUBDIR:=
137 MIRROR:=1
138 VERSION:=
139 endef
140
141 define Download
142 $(eval $(Download/Defaults))
143 $(eval $(Download/$(1)))
144 $(foreach FIELD,URL FILE $(Validate/$(call dl_method,$(URL),$(PROTO))),
145 ifeq ($($(FIELD)),)
146 $$(error Download/$(1) is missing the $(FIELD) field.)
147 endif
148 )
149
150 $(foreach dep,$(DOWNLOAD_RDEP),
151 $(dep): $(DL_DIR)/$(FILE)
152 )
153 download: $(DL_DIR)/$(FILE)
154
155 $(DL_DIR)/$(FILE):
156 mkdir -p $(DL_DIR)
157 $(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown))
158
159 endef
This page took 0.047463 seconds and 5 git commands to generate.