123,7 → 123,10 |
AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f |
|
|
ALL_TOOLS := gcc gdb binutils newlib avr32patches avr32headers dfu autoconf automake |
|
|
|
.PHONY: install-tools |
install-tools: install-binutils install-final-gcc install-newlib install-headers |
|
149,6 → 152,7 |
|
############ MACROS for the lazy people ;-) ############ |
|
## in silent mode (make -s),, print whats ging on |
ifeq ($(strip $(MAKEFLAGS)),s) |
define quiet_text |
@echo "$1" |
158,6 → 162,11 |
endef |
endif |
|
## the stamp name |
define name_stamp |
$(STAMP_DIR)/$(1) |
endef |
|
## remove a stamp |
define rm_stamp |
rm -f $(STAMP_DIR)/$(1) |
174,31 → 183,37 |
date > $(STAMP_DIR)/$(1) |
endef |
|
define GET_MY_VARS |
UP_$(1) = $$(shell echo "$(1)" | tr '[a-z]' '[A-Z]') |
MY_VERSION = $$($$(UP_$(1))_VERSION) |
MY_ARCHIVE = $$($$(UP_$(1))_ARCHIVE) |
MY_URL = $$($$(UP_$(1))_URL) |
MY_MD5 = $$($$(UP_$(1))_MD5) |
## delete the given directory, if it is empty |
define del_all_empty-directories |
@find . -type d -empty | xargs rm -rf |
endef |
|
## to make the following macros more simply, we need the variables |
## with the tool name in lowercase. I could have changed the original |
## definition, but I don't want to break the make convention of upper |
## case definitions for such user defined variables. |
|
define LOWER_TOOL_VARS |
UP_$(1) := $(shell echo "$(1)" | tr '[a-z]' '[A-Z]') |
$(1)_VERSION := $$($$(UP_$(1))_VERSION) |
$(1)_ARCHIVE := $$($$(UP_$(1))_ARCHIVE) |
$(1)_URL := $$($$(UP_$(1))_URL) |
$(1)_MD5 := $$($$(UP_$(1))_MD5) |
endef |
|
$(foreach tool,$(ALL_TOOLS),$(eval $(call LOWER_TOOL_VARS,$(tool)))) |
|
|
## create the download rule and force download rule |
define DOWNLOAD_template |
$(call GET_MY_VARS,$(1)) |
$(warning $(1) -> $(MY_URL)) |
$(warning $(1) -> $(MY_URL)) |
$(warning $(1) -> $(MY_URL)) |
$(warning $(1) -> $(MY_URL)) |
$(warning $(1) -> $(MY_URL)) |
$(warning $(1) -> $(MY_URL)) |
$(warning $(1) -> $(MY_URL)) |
$(warning $(1) -> $(MY_URL)) |
download-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE) |
download-$(1)-f $(DOWNLOAD_DIR)/$$(MY_ARCHIVE): $(DOWNLOAD_DIR) |
cd $(DOWNLOAD_DIR) && curl -LO $$(MY_URL) |
download-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE) |
download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE): $(DOWNLOAD_DIR) |
cd $(DOWNLOAD_DIR) && curl -LO $$($(1)_URL) |
|
download-$(1)_TEXT := "Removing $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)" |
download-$(1)-remove: |
rm -f $(DOWNLOAD_DIR)/$$(MY_ARCHIVE) |
$(call quiet_text,$$(download-$(1)_TEXT)) |
rm -f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE) |
|
PHONY += download-$(1) download-$(1)-f download-$(1)-remove |
endef |
210,14 → 225,15 |
|
## create the extract rule and force extract rule |
define EXTRACT_template |
$(call GET_MY_VARS,$(1)) |
extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)" |
|
extract-$(1): $(STAMP_DIR)/extract-$(1) |
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE) |
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE) |
@(rm -rf $(1)-*; \ |
t1=`openssl md5 $$< | cut -f 2 -d " " -` && \ |
[ "$$$$t1" = "$$(MY_MD5)" ] || \ |
[ "$$$$t1" = "$$($(1)_MD5)" ] || \ |
( echo "Bad Checksum! Please remove the following file and retry: $$<" && false )) |
$(call quiet_text,"Extracting $$(MY_ARCHIVE)") |
$(call quiet_text,$$(extract-$(1)_TEXT)) |
$($(2)) $$< |
$(call make_stamp,extract-$(1)) |
|
230,12 → 246,13 |
|
## create the configure rule and force configure rule |
define CONF_template |
$(call GET_MY_VARS,$(1)) |
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)" |
conf-$(1): $(STAMP_DIR)/conf-$(1) |
conf-$(1)-f $(STAMP_DIR)/conf-$(1): $(STAMP_DIR)/$(2)-$(1) $(BUILD_DIR)/$(1) |
@rm -rf $(BUILD_DIR)/$(1)/* |
$(call quiet_text,$$(conf-$(1)_TEXT)) |
cd $(BUILD_DIR)/$(1) && \ |
../../$(1)-$$(MY_VERSION)/configure $$($(1)_conf_opts) |
../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts) |
$(call make_stamp,conf-$(1)) |
|
conf-$(1)-remove: |
246,9 → 263,10 |
|
## create the build rule and force build rule |
define BUILD_template |
$(call GET_MY_VARS,$(1)) |
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)" |
build-$(1): $(STAMP_DIR)/build-$(1) |
build-$(1)-f $(STAMP_DIR)/build-$(1): $(STAMP_DIR)/conf-$(1) |
$(call quiet_text,$$(build-$(1)_TEXT)) |
cd $(BUILD_DIR)/$(1) && \ |
$(MAKE) clean && $(MAKE) -j$(PROCS) |
$(call make_stamp,build-$(1)) |
262,14 → 280,19 |
|
## create the install rule and force install rule |
define INSTALL_template |
install-$(1)_TEXT := "Installing $(1) $$($(1)_VERSION)" |
install-$(1): $(STAMP_DIR)/install-$(1) |
install-$(1)-f $(STAMP_DIR)/install-$(1): $(STAMP_DIR)/build-$(1) |
$(call quiet_text,$$(install-$(1)_TEXT)) |
cd $(BUILD_DIR)/$(1) && \ |
$(MAKE) install |
$(call make_stamp,install-$(1)) |
|
uninstall-$(1)_TEXT := "Uninstalling $(1) $$($(1)_VERSION)" |
uninstall-$(1): |
$(call quiet_text,$$(uninstall-$(1)_TEXT)) |
[ -f $(BUILD_DIR)/$(1)/Makefile ] && \ |
[ -f $(call name_stamp,install-$(1)) ] && \ |
cd $(BUILD_DIR)/$(1) && \ |
$(MAKE) uninstall || true |
$(call rm_stamp,install-$(1)) |
279,22 → 302,33 |
|
## create the clean rule and realclean rule |
define CLEAN_template |
clean-$(1): uninstall-$(1) extract-$(1)-remove build-$(1)-remove conf-$(1)-remove |
clean-$(1)_TEXT := "Cleaning $(1) $$($(1)_VERSION)" |
clean-$(1)-text: |
$(call quiet_text,$$(clean-$(1)_TEXT)) |
|
clean-$(1): clean-$(1)-text uninstall-$(1) extract-$(1)-remove build-$(1)-remove conf-$(1)-remove |
$(call del_all_empty-directories) |
$(call del_all_empty-directories) |
$(call del_all_empty-directories) |
|
realclean-$(1): clean-$(1) download-$(1)-remove |
$(call del_all_empty-directories) |
$(call del_all_empty-directories) |
$(call del_all_empty-directories) |
|
PHONY += clean-$(1) realclean-$(1) |
PHONY += clean-$(1) realclean-$(1) clean-$(1)-text |
endef |
|
|
|
|
$(DOWNLOAD_DIR): |
mkdir $(DOWNLOAD_DIR) |
mkdir -p $@ |
|
$(BUILD_DIR)/%: |
mkdir -p $@ |
|
|
############# SUPP: AUTOCONF ############ |
|
$(eval $(call DOWNLOAD_template,autoconf)) |