Rev 12 | Rev 15 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 12 | Rev 13 | ||
|---|---|---|---|
| Line 121... | Line 121... | ||
| 121 | AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2 |
121 | AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2 |
| 122 | AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE) |
122 | AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE) |
| 123 | AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f |
123 | AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f |
| 124 | 124 | ||
| 125 | 125 | ||
| - | 126 | ALL_TOOLS := gcc gdb binutils newlib avr32patches avr32headers dfu autoconf automake |
|
| - | 127 | ||
| - | 128 | ||
| 126 | 129 | ||
| 127 | .PHONY: install-tools |
130 | .PHONY: install-tools |
| 128 | install-tools: install-binutils install-final-gcc install-newlib install-headers |
131 | install-tools: install-binutils install-final-gcc install-newlib install-headers |
| 129 | 132 | ||
| 130 | .PHONY: install-cross |
133 | .PHONY: install-cross |
| Line 147... | Line 150... | ||
| 147 | @echo "BUG_URL=$(BUG_URL)" |
150 | @echo "BUG_URL=$(BUG_URL)" |
| 148 | 151 | ||
| 149 | 152 | ||
| 150 | ############ MACROS for the lazy people ;-) ############ |
153 | ############ MACROS for the lazy people ;-) ############ |
| 151 | 154 | ||
| - | 155 | ## in silent mode (make -s),, print whats ging on |
|
| 152 | ifeq ($(strip $(MAKEFLAGS)),s) |
156 | ifeq ($(strip $(MAKEFLAGS)),s) |
| 153 | define quiet_text |
157 | define quiet_text |
| 154 | @echo "$1" |
158 | @echo "$1" |
| 155 | endef |
159 | endef |
| 156 | else |
160 | else |
| 157 | define quiet_text |
161 | define quiet_text |
| 158 | endef |
162 | endef |
| 159 | endif |
163 | endif |
| 160 | 164 | ||
| - | 165 | ## the stamp name |
|
| - | 166 | define name_stamp |
|
| - | 167 | $(STAMP_DIR)/$(1) |
|
| - | 168 | endef |
|
| - | 169 | ||
| 161 | ## remove a stamp |
170 | ## remove a stamp |
| 162 | define rm_stamp |
171 | define rm_stamp |
| 163 | rm -f $(STAMP_DIR)/$(1) |
172 | rm -f $(STAMP_DIR)/$(1) |
| 164 | endef |
173 | endef |
| 165 | 174 | ||
| Line 172... | Line 181... | ||
| 172 | define make_stamp |
181 | define make_stamp |
| 173 | @[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR) |
182 | @[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR) |
| 174 | date > $(STAMP_DIR)/$(1) |
183 | date > $(STAMP_DIR)/$(1) |
| 175 | endef |
184 | endef |
| 176 | 185 | ||
| - | 186 | ## delete the given directory, if it is empty |
|
| - | 187 | define del_all_empty-directories |
|
| - | 188 | @find . -type d -empty | xargs rm -rf |
|
| - | 189 | endef |
|
| - | 190 | ||
| - | 191 | ## to make the following macros more simply, we need the variables |
|
| - | 192 | ## with the tool name in lowercase. I could have changed the original |
|
| - | 193 | ## definition, but I don't want to break the make convention of upper |
|
| - | 194 | ## case definitions for such user defined variables. |
|
| - | 195 | ||
| 177 | define GET_MY_VARS |
196 | define LOWER_TOOL_VARS |
| 178 | UP_$(1) = $$(shell echo "$(1)" | tr '[a-z]' '[A-Z]') |
197 | UP_$(1) := $(shell echo "$(1)" | tr '[a-z]' '[A-Z]') |
| 179 | MY_VERSION = $$($$(UP_$(1))_VERSION) |
198 | $(1)_VERSION := $$($$(UP_$(1))_VERSION) |
| 180 | MY_ARCHIVE = $$($$(UP_$(1))_ARCHIVE) |
199 | $(1)_ARCHIVE := $$($$(UP_$(1))_ARCHIVE) |
| 181 | MY_URL = $$($$(UP_$(1))_URL) |
200 | $(1)_URL := $$($$(UP_$(1))_URL) |
| 182 | MY_MD5 = $$($$(UP_$(1))_MD5) |
201 | $(1)_MD5 := $$($$(UP_$(1))_MD5) |
| 183 | endef |
202 | endef |
| - | 203 | ||
| - | 204 | $(foreach tool,$(ALL_TOOLS),$(eval $(call LOWER_TOOL_VARS,$(tool)))) |
|
| - | 205 | ||
| 184 | 206 | ||
| 185 | ## create the download rule and force download rule |
207 | ## create the download rule and force download rule |
| 186 | define DOWNLOAD_template |
208 | define DOWNLOAD_template |
| 187 | $(call GET_MY_VARS,$(1)) |
- | |
| 188 | $(warning $(1) -> $(MY_URL)) |
- | |
| 189 | $(warning $(1) -> $(MY_URL)) |
- | |
| 190 | $(warning $(1) -> $(MY_URL)) |
- | |
| 191 | $(warning $(1) -> $(MY_URL)) |
- | |
| 192 | $(warning $(1) -> $(MY_URL)) |
- | |
| 193 | $(warning $(1) -> $(MY_URL)) |
- | |
| 194 | $(warning $(1) -> $(MY_URL)) |
- | |
| 195 | $(warning $(1) -> $(MY_URL)) |
- | |
| 196 | download-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE) |
209 | download-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE) |
| 197 | download-$(1)-f $(DOWNLOAD_DIR)/$$(MY_ARCHIVE): $(DOWNLOAD_DIR) |
210 | download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE): $(DOWNLOAD_DIR) |
| 198 | cd $(DOWNLOAD_DIR) && curl -LO $$(MY_URL) |
211 | cd $(DOWNLOAD_DIR) && curl -LO $$($(1)_URL) |
| 199 | 212 | ||
| - | 213 | download-$(1)_TEXT := "Removing $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)" |
|
| 200 | download-$(1)-remove: |
214 | download-$(1)-remove: |
| - | 215 | $(call quiet_text,$$(download-$(1)_TEXT)) |
|
| 201 | rm -f $(DOWNLOAD_DIR)/$$(MY_ARCHIVE) |
216 | rm -f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE) |
| 202 | 217 | ||
| 203 | PHONY += download-$(1) download-$(1)-f download-$(1)-remove |
218 | PHONY += download-$(1) download-$(1)-f download-$(1)-remove |
| 204 | endef |
219 | endef |
| 205 | 220 | ||
| 206 | ## extract commands |
221 | ## extract commands |
| Line 208... | Line 223... | ||
| 208 | EXT_TGZ := tar -xf |
223 | EXT_TGZ := tar -xf |
| 209 | EXT_ZIP := unzip -o |
224 | EXT_ZIP := unzip -o |
| 210 | 225 | ||
| 211 | ## create the extract rule and force extract rule |
226 | ## create the extract rule and force extract rule |
| 212 | define EXTRACT_template |
227 | define EXTRACT_template |
| 213 | $(call GET_MY_VARS,$(1)) |
228 | extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)" |
| - | 229 | ||
| 214 | extract-$(1): $(STAMP_DIR)/extract-$(1) |
230 | extract-$(1): $(STAMP_DIR)/extract-$(1) |
| 215 | extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE) |
231 | extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE) |
| 216 | @(rm -rf $(1)-*; \ |
232 | @(rm -rf $(1)-*; \ |
| 217 | t1=`openssl md5 $$< | cut -f 2 -d " " -` && \ |
233 | t1=`openssl md5 $$< | cut -f 2 -d " " -` && \ |
| 218 | [ "$$$$t1" = "$$(MY_MD5)" ] || \ |
234 | [ "$$$$t1" = "$$($(1)_MD5)" ] || \ |
| 219 | ( echo "Bad Checksum! Please remove the following file and retry: $$<" && false )) |
235 | ( echo "Bad Checksum! Please remove the following file and retry: $$<" && false )) |
| 220 | $(call quiet_text,"Extracting $$(MY_ARCHIVE)") |
236 | $(call quiet_text,$$(extract-$(1)_TEXT)) |
| 221 | $($(2)) $$< |
237 | $($(2)) $$< |
| 222 | $(call make_stamp,extract-$(1)) |
238 | $(call make_stamp,extract-$(1)) |
| 223 | 239 | ||
| 224 | extract-$(1)-remove: |
240 | extract-$(1)-remove: |
| 225 | rm -rf $(1)-* |
241 | rm -rf $(1)-* |
| Line 228... | Line 244... | ||
| 228 | PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove |
244 | PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove |
| 229 | endef |
245 | endef |
| 230 | 246 | ||
| 231 | ## create the configure rule and force configure rule |
247 | ## create the configure rule and force configure rule |
| 232 | define CONF_template |
248 | define CONF_template |
| 233 | $(call GET_MY_VARS,$(1)) |
249 | conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)" |
| 234 | conf-$(1): $(STAMP_DIR)/conf-$(1) |
250 | conf-$(1): $(STAMP_DIR)/conf-$(1) |
| 235 | conf-$(1)-f $(STAMP_DIR)/conf-$(1): $(STAMP_DIR)/$(2)-$(1) $(BUILD_DIR)/$(1) |
251 | conf-$(1)-f $(STAMP_DIR)/conf-$(1): $(STAMP_DIR)/$(2)-$(1) $(BUILD_DIR)/$(1) |
| 236 | @rm -rf $(BUILD_DIR)/$(1)/* |
252 | @rm -rf $(BUILD_DIR)/$(1)/* |
| - | 253 | $(call quiet_text,$$(conf-$(1)_TEXT)) |
|
| 237 | cd $(BUILD_DIR)/$(1) && \ |
254 | cd $(BUILD_DIR)/$(1) && \ |
| 238 | ../../$(1)-$$(MY_VERSION)/configure $$($(1)_conf_opts) |
255 | ../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts) |
| 239 | $(call make_stamp,conf-$(1)) |
256 | $(call make_stamp,conf-$(1)) |
| 240 | 257 | ||
| 241 | conf-$(1)-remove: |
258 | conf-$(1)-remove: |
| 242 | $(call rm_stamp,conf-$(1)) |
259 | $(call rm_stamp,conf-$(1)) |
| 243 | 260 | ||
| 244 | PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove |
261 | PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove |
| 245 | endef |
262 | endef |
| 246 | 263 | ||
| 247 | ## create the build rule and force build rule |
264 | ## create the build rule and force build rule |
| 248 | define BUILD_template |
265 | define BUILD_template |
| 249 | $(call GET_MY_VARS,$(1)) |
266 | build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)" |
| 250 | build-$(1): $(STAMP_DIR)/build-$(1) |
267 | build-$(1): $(STAMP_DIR)/build-$(1) |
| 251 | build-$(1)-f $(STAMP_DIR)/build-$(1): $(STAMP_DIR)/conf-$(1) |
268 | build-$(1)-f $(STAMP_DIR)/build-$(1): $(STAMP_DIR)/conf-$(1) |
| - | 269 | $(call quiet_text,$$(build-$(1)_TEXT)) |
|
| 252 | cd $(BUILD_DIR)/$(1) && \ |
270 | cd $(BUILD_DIR)/$(1) && \ |
| 253 | $(MAKE) clean && $(MAKE) -j$(PROCS) |
271 | $(MAKE) clean && $(MAKE) -j$(PROCS) |
| 254 | $(call make_stamp,build-$(1)) |
272 | $(call make_stamp,build-$(1)) |
| 255 | 273 | ||
| 256 | build-$(1)-remove: |
274 | build-$(1)-remove: |
| Line 260... | Line 278... | ||
| 260 | PHONY += build-$(1) build-$(1)-f build-$(1)-remove |
278 | PHONY += build-$(1) build-$(1)-f build-$(1)-remove |
| 261 | endef |
279 | endef |
| 262 | 280 | ||
| 263 | ## create the install rule and force install rule |
281 | ## create the install rule and force install rule |
| 264 | define INSTALL_template |
282 | define INSTALL_template |
| - | 283 | install-$(1)_TEXT := "Installing $(1) $$($(1)_VERSION)" |
|
| 265 | install-$(1): $(STAMP_DIR)/install-$(1) |
284 | install-$(1): $(STAMP_DIR)/install-$(1) |
| 266 | install-$(1)-f $(STAMP_DIR)/install-$(1): $(STAMP_DIR)/build-$(1) |
285 | install-$(1)-f $(STAMP_DIR)/install-$(1): $(STAMP_DIR)/build-$(1) |
| - | 286 | $(call quiet_text,$$(install-$(1)_TEXT)) |
|
| 267 | cd $(BUILD_DIR)/$(1) && \ |
287 | cd $(BUILD_DIR)/$(1) && \ |
| 268 | $(MAKE) install |
288 | $(MAKE) install |
| 269 | $(call make_stamp,install-$(1)) |
289 | $(call make_stamp,install-$(1)) |
| 270 | 290 | ||
| - | 291 | uninstall-$(1)_TEXT := "Uninstalling $(1) $$($(1)_VERSION)" |
|
| 271 | uninstall-$(1): |
292 | uninstall-$(1): |
| - | 293 | $(call quiet_text,$$(uninstall-$(1)_TEXT)) |
|
| 272 | [ -f $(BUILD_DIR)/$(1)/Makefile ] && \ |
294 | [ -f $(BUILD_DIR)/$(1)/Makefile ] && \ |
| - | 295 | [ -f $(call name_stamp,install-$(1)) ] && \ |
|
| 273 | cd $(BUILD_DIR)/$(1) && \ |
296 | cd $(BUILD_DIR)/$(1) && \ |
| 274 | $(MAKE) uninstall || true |
297 | $(MAKE) uninstall || true |
| 275 | $(call rm_stamp,install-$(1)) |
298 | $(call rm_stamp,install-$(1)) |
| 276 | 299 | ||
| 277 | PHONY += install-$(1) install-$(1)-f uninstall-$(1) |
300 | PHONY += install-$(1) install-$(1)-f uninstall-$(1) |
| 278 | endef |
301 | endef |
| 279 | 302 | ||
| 280 | ## create the clean rule and realclean rule |
303 | ## create the clean rule and realclean rule |
| 281 | define CLEAN_template |
304 | define CLEAN_template |
| - | 305 | clean-$(1)_TEXT := "Cleaning $(1) $$($(1)_VERSION)" |
|
| - | 306 | clean-$(1)-text: |
|
| - | 307 | $(call quiet_text,$$(clean-$(1)_TEXT)) |
|
| - | 308 | ||
| 282 | clean-$(1): uninstall-$(1) extract-$(1)-remove build-$(1)-remove conf-$(1)-remove |
309 | clean-$(1): clean-$(1)-text uninstall-$(1) extract-$(1)-remove build-$(1)-remove conf-$(1)-remove |
| - | 310 | $(call del_all_empty-directories) |
|
| - | 311 | $(call del_all_empty-directories) |
|
| - | 312 | $(call del_all_empty-directories) |
|
| 283 | 313 | ||
| 284 | realclean-$(1): clean-$(1) download-$(1)-remove |
314 | realclean-$(1): clean-$(1) download-$(1)-remove |
| - | 315 | $(call del_all_empty-directories) |
|
| - | 316 | $(call del_all_empty-directories) |
|
| - | 317 | $(call del_all_empty-directories) |
|
| 285 | 318 | ||
| 286 | PHONY += clean-$(1) realclean-$(1) |
319 | PHONY += clean-$(1) realclean-$(1) clean-$(1)-text |
| 287 | endef |
320 | endef |
| 288 | 321 | ||
| 289 | 322 | ||
| 290 | 323 | ||
| 291 | 324 | ||
| 292 | $(DOWNLOAD_DIR): |
325 | $(DOWNLOAD_DIR): |
| 293 | mkdir $(DOWNLOAD_DIR) |
326 | mkdir -p $@ |
| 294 | 327 | ||
| 295 | $(BUILD_DIR)/%: |
328 | $(BUILD_DIR)/%: |
| 296 | mkdir -p $@ |
329 | mkdir -p $@ |
| 297 | 330 | ||
| - | 331 | ||
| 298 | ############# SUPP: AUTOCONF ############ |
332 | ############# SUPP: AUTOCONF ############ |
| 299 | 333 | ||
| 300 | $(eval $(call DOWNLOAD_template,autoconf)) |
334 | $(eval $(call DOWNLOAD_template,autoconf)) |
| 301 | $(eval $(call EXTRACT_template,autoconf,EXT_BZ2)) |
335 | $(eval $(call EXTRACT_template,autoconf,EXT_BZ2)) |
| 302 | autoconf_conf_opts = --prefix="$(SUPP_PREFIX)" |
336 | autoconf_conf_opts = --prefix="$(SUPP_PREFIX)" |