[madwifi] make madwifi compile with kernel 2.6.29.
[openwrt.git] / include / download.mk
1 #
2 # Copyright (C) 2007 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://%,$(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/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
65 define DownloadMethod/svn
66 $(call wrap_mirror, \
67 echo "Checking out files from the svn repository..."; \
68 mkdir -p $(TMP_DIR)/dl && \
69 cd $(TMP_DIR)/dl && \
70 rm -rf $(SUBDIR) && \
71 [ \! -d $(SUBDIR) ] && \
72 svn co --non-interactive -r$(VERSION) $(URL) $(SUBDIR) && \
73 find $(SUBDIR) -name .svn | xargs rm -rf && \
74 echo "Packing checkout..." && \
75 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
76 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
77 )
78 endef
79
80 define DownloadMethod/git
81 $(call wrap_mirror, \
82 echo "Checking out files from the git repository..."; \
83 mkdir -p $(TMP_DIR)/dl && \
84 cd $(TMP_DIR)/dl && \
85 rm -rf $(SUBDIR) && \
86 [ \! -d $(SUBDIR) ] && \
87 git clone $(URL) $(SUBDIR) && \
88 (cd $(SUBDIR) && git checkout $(VERSION)) && \
89 echo "Packing checkout..." && \
90 rm -rf $(SUBDIR)/.git && \
91 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
92 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
93 )
94 endef
95
96 define DownloadMethod/hg
97 $(call wrap_mirror, \
98 echo "Checking out files from the hg repository..."; \
99 mkdir -p $(TMP_DIR)/dl && \
100 cd $(TMP_DIR)/dl && \
101 rm -rf $(SUBDIR) && \
102 [ \! -d $(SUBDIR) ] && \
103 hg clone -r $(VERSION) $(URL) $(SUBDIR) && \
104 find $(SUBDIR) -name .hg | xargs rm -rf && \
105 echo "Packing checkout..." && \
106 $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
107 mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/; \
108 )
109 endef
110
111 Validate/cvs=VERSION SUBDIR
112 Validate/svn=VERSION SUBDIR
113 Validate/git=VERSION SUBDIR
114 Validate/hg=VERSION SUBDIR
115
116 define Download/Defaults
117 URL:=
118 FILE:=
119 PROTO:=
120 MD5SUM:=
121 SUBDIR:=
122 MIRROR:=1
123 VERSION:=
124 endef
125
126 define Download
127 $(eval $(Download/Defaults))
128 $(eval $(Download/$(1)))
129 $(foreach FIELD,URL FILE $(Validate/$(call dl_method,$(URL),$(PROTO))),
130 ifeq ($($(FIELD)),)
131 $$(error Download/$(1) is missing the $(FIELD) field.)
132 endif
133 )
134
135 $(foreach dep,$(DOWNLOAD_RDEP),
136 $(dep): $(DL_DIR)/$(FILE)
137 )
138 download: $(DL_DIR)/$(FILE)
139
140 $(DL_DIR)/$(FILE):
141 mkdir -p $(DL_DIR)
142 $(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown))
143
144 endef
This page took 0.053736 seconds and 5 git commands to generate.