Subversion Repositories avr32-toolchain

Compare Revisions

Ignore whitespace Rev 13 → Rev 15

/branches/try_gdb/Makefile
99,6 → 99,7
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
AVR32PATCHES_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32PATCHES_ARCHIVE)
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
install_dir_avr32patches := source/avr32
 
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
183,11 → 184,20
date > $(STAMP_DIR)/$(1)
endef
 
## delete the given directory, if it is empty
define del_all_empty-directories
## delete empty directories
define del_empty-directories
@find . -type d -empty | xargs rm -rf
endef
 
## delete all empty directories
## need to do this several times. to remove empty sub directories
define del_all_empty-directories
$(call del_empty-directories)
$(call del_empty-directories)
$(call del_empty-directories)
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
207,7 → 217,8
## create the download rule and force download rule
define DOWNLOAD_template
download-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE): $(DOWNLOAD_DIR)
download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE):
[ -d $(DOWNLOAD_DIR) ] || mkdir -p $(DOWNLOAD_DIR)
cd $(DOWNLOAD_DIR) && curl -LO $$($(1)_URL)
 
download-$(1)_TEXT := "Removing $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)"
234,7 → 245,7
[ "$$$$t1" = "$$($(1)_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
$(call quiet_text,$$(extract-$(1)_TEXT))
$($(2)) $$<
$($(2)) $$< $(3)
$(call make_stamp,extract-$(1))
 
extract-$(1)-remove:
244,6 → 255,46
PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove
endef
 
## create the patch rule
define PATCH_template
patch-$(1)_TEXT := "Patching $$($(1)_ARCHIVE)"
patch-$(1): $(STAMP_DIR)/patch-$(1)
$(STAMP_DIR)/patch-$(1): $(STAMP_DIR)/extract-$(1) $(STAMP_DIR)/extract-avr32patches
$(call quiet_text,$$(patch-$(1)_TEXT))
@(pushd $(1)-$$($(1)_VERSION) ; \
for f in ../$(install_dir_avr32patches)/$(1)/*.patch; do \
patch -N -p0 < $$$${f} ; \
done ; \
popd)
$(call make_stamp,patch-$(1))
 
patch-$(1)-remove: extract-$(1)-remove
$(call rm_stamp,patch-$(1))
 
PHONY += patch-$(1) patch-$(1)-remove
endef
 
 
#.PHONY: regen-binutils regen-binutils-force
#regen-binutils: stamps/regen-binutils
#regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
# pushd binutils-$(BINUTILS_VERSION) ; \
# "$(SUPP_PREFIX)/bin/aclocal" -I config ; \
# "$(SUPP_PREFIX)/bin/autoconf" ; \
# "$(SUPP_PREFIX)/bin/automake" ; \
# "$(SUPP_PREFIX)/bin/autoheader" ; \
# for dir in bfd opcodes binutils gas ld; do \
# pushd $$dir ; \
# "$(SUPP_PREFIX)/bin/autoconf"; \
# "$(SUPP_PREFIX)/bin/automake"; \
# "$(SUPP_PREFIX)/bin/autoheader"; \
# popd ; \
# done; \
# popd; \
# [ -d stamps ] || mkdir stamps ;
# touch stamps/regen-binutils;
 
 
## create the configure rule and force configure rule
define CONF_template
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)"
306,25 → 357,31
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
clean-$(1): clean-$(1)-text uninstall-$(1) extract-$(1)-remove patch-$(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) clean-$(1)-text
endef
 
## create some dummy rules for the clean rule
define DUMMY_patch_remove
patch-$(1)-remove:
PHONY += patch-$(1)-remove
endef
define DUMMY_conf_remove
conf-$(1)-remove:
PHONY += conf-$(1)-remove
endef
define DUMMY_build_remove
build-$(1)-remove:
PHONY += build-$(1)-remove
endef
 
 
 
$(DOWNLOAD_DIR):
mkdir -p $@
 
$(BUILD_DIR)/%:
mkdir -p $@
 
351,6 → 408,62
$(eval $(call CLEAN_template,automake))
 
 
############# AVR32 PATCHES ############
 
$(eval $(call DOWNLOAD_template,avr32patches))
$(eval $(call EXTRACT_template,avr32patches,EXT_ZIP))
 
## use the uninstall-XXX rule to remove the patches directory
PHONY += uninstall-avr32patches
uninstall-avr32patches:
rm -rf $(install_dir_avr32patches)
 
$(eval $(call CLEAN_template,avr32patches))
 
 
############# AVR32 HEADERS ############
$(eval $(call DOWNLOAD_template,avr32headers))
 
###### FIXME: Need to add a dependency to "stamps/install-final-gcc"
install_path_avr32headers := $(PREFIX)/$(TARGET)/include/
avr32headers_unzip_opt := -d "$(install_path_avr32headers)"
$(eval $(call EXTRACT_template,avr32headers,EXT_ZIP,$(avr32headers_unzip_opt)))
 
## use the uninstall-XXX rule to remove the patches directory
install_dir_avr32headers := $(install_path_avr32headers)/avr32
PHONY += uninstall-avr32headers
uninstall-avr32headers:
rm -rf $(install_dir_avr32headers)
 
$(eval $(call CLEAN_template,avr32headers))
 
 
################ BINUTILS ################
 
$(eval $(call DOWNLOAD_template,binutils))
$(eval $(call EXTRACT_template,binutils,EXT_BZ2))
$(eval $(call PATCH_template,binutils))
#$(eval $(call REGEN_template,binutils))
binutils_conf_opts = \
--enable-maintainer-mode \
--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls \
--disable-shared --disable-werror \
--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL)
$(eval $(call CONF_template,binutils,extract))
$(eval $(call BUILD_template,binutils))
$(eval $(call INSTALL_template,binutils))
$(eval $(call CLEAN_template,binutils))
 
 
# we need to satisfy the rules, generated by the CLEAN_template, if they not exist
patch_remove_dummy_tools := autoconf automake avr32patches avr32headers
$(foreach tool,$(patch_remove_dummy_tools),$(eval $(call DUMMY_patch_remove,$(tool))))
conf_remove_dummy_tools := avr32patches avr32headers
$(foreach tool,$(conf_remove_dummy_tools),$(eval $(call DUMMY_conf_remove,$(tool))))
build_remove_dummy_tools := avr32patches avr32headers
$(foreach tool,$(build_remove_dummy_tools),$(eval $(call DUMMY_build_remove,$(tool))))
 
 
.PHONY: $(PHONY)
 
 
361,6 → 474,33
$(call rm_stamp,JES)
 
 
.PHONY: help
help:
@echo ""
@echo "The following targets are available:"
@echo ""
@echo "download-XXX : download the required package"
@echo "extract-XXX : extract the downloaded package"
@echo "conf-XXX : configure the extracted package"
@echo "build-XXX : build the configured package"
@echo "install-XXX : install the build package"
@echo "uninstall-XXX : uninstall the installed package"
@echo "clean-XXX : clean the package source and build tree"
@echo "realclean-XXX : same as clean-XXX, but remove the downloaded"
@echo " package, too"
@echo ""
@echo "XXX can be one of the following: "
@echo "$(ALL_TOOLS)"
@echo ""
@echo "The above targets will be executed in the right order and only if"
@echo "they need to be be really built. If you want to rebuild one of then"
@echo "manualy, you can use the aaaa-XXX-f target (e.g.: build-autoconf-f,"
@echo "download-automake-f). Please note, that not all steps are available for"
@echo "all tools (e.g.: install-avr32patches is not available)."
@echo ""
@echo ""
 
 
.PHONY: install-note
install-note: install-tools
@echo
436,54 → 576,54
 
############# AVR32 PATCHES ############
 
.PHONY: download-avr32patches download-avr32patches-force
download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
cd downloads && curl -LO $(AVR32PATCHES_URL)
##.PHONY: download-avr32patches download-avr32patches-force
##download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
##download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
## cd downloads && curl -LO $(AVR32PATCHES_URL)
 
.PHONY: extract-avr32patches extract-avr32patches-force
extract-avr32patches: stamps/extract-avr32patches
extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
unzip -o $<
[ -d stamps ] || mkdir stamps
touch stamps/extract-avr32patches;
##.PHONY: extract-avr32patches extract-avr32patches-force
##extract-avr32patches: stamps/extract-avr32patches
##extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
## @(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
## [ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
## ( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
## unzip -o $<
## [ -d stamps ] || mkdir stamps
## touch stamps/extract-avr32patches;
 
.PHONY: clean-avr32patches
clean-avr32patches:
rm -rf stamps/*-avr32patches source
##.PHONY: clean-avr32patches
##clean-avr32patches:
## rm -rf stamps/*-avr32patches source
 
.PHONY: realclean-avr32patches
realclean-avr32patches: clean-avr32patches
rm downloads/$(AVR32PATCHES_ARCHIVE)
##.PHONY: realclean-avr32patches
##realclean-avr32patches: clean-avr32patches
## rm downloads/$(AVR32PATCHES_ARCHIVE)
 
 
############# AVR32 HEADERS ############
 
.PHONY: download-avr32headers download-avr32headers-force
download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
cd downloads && curl -LO $(AVR32HEADERS_URL)
##.PHONY: download-avr32headers download-avr32headers-force
##download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
##download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
## cd downloads && curl -LO $(AVR32HEADERS_URL)
 
.PHONY: install-headers install-headers-force
install-headers: stamps/install-headers
install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
[ -d stamps ] || mkdir stamps
touch stamps/install-headers;
##.PHONY: install-headers install-headers-force
##install-headers: stamps/install-headers
##install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
## @(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
## [ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
## ( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
## unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
## [ -d stamps ] || mkdir stamps
## touch stamps/install-headers;
 
.PHONY: clean-headers
clean-headers:
rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
##.PHONY: clean-headers
##clean-headers:
## rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
 
.PHONY: realclean-headers
realclean-headers: clean-headers
rm downloads/$(AVR32HEADERS_ARCHIVE)
##.PHONY: realclean-headers
##realclean-headers: clean-headers
## rm downloads/$(AVR32HEADERS_ARCHIVE)
 
 
################ NEWLIB ################
573,83 → 713,83
 
################ BINUTILS ################
 
.PHONY: download-binutils download-binutils-force
download-binutils: downloads/$(BINUTILS_ARCHIVE)
download-binutils-force downloads/$(BINUTILS_ARCHIVE):
[ -d downloads ] || mkdir downloads ;
cd downloads && curl -LO $(BINUTILS_URL)
##.PHONY: download-binutils download-binutils-force
##download-binutils: downloads/$(BINUTILS_ARCHIVE)
##download-binutils-force downloads/$(BINUTILS_ARCHIVE):
## [ -d downloads ] || mkdir downloads ;
## cd downloads && curl -LO $(BINUTILS_URL)
 
.PHONY: extract-binutils extract-binutils-force
extract-binutils: stamps/extract-binutils
extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
[ "$$t1" = "$(BINUTILS_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
tar -jxf $< ;
[ -d stamps ] || mkdir stamps ;
touch stamps/extract-binutils;
##.PHONY: extract-binutils extract-binutils-force
##extract-binutils: stamps/extract-binutils
##extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
## @(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
## [ "$$t1" = "$(BINUTILS_MD5)" ] || \
## ( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
## tar -jxf $< ;
## [ -d stamps ] || mkdir stamps ;
## touch stamps/extract-binutils;
 
.PHONY: patch-binutils patch-binutils-force
patch-binutils: stamps/patch-binutils
patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
pushd binutils-$(BINUTILS_VERSION) ; \
for f in ../source/avr32/binutils/*.patch; do \
patch -N -p0 <$${f} ; \
done ; \
popd ; \
[ -d stamps ] || mkdir stamps
touch stamps/patch-binutils;
##.PHONY: patch-binutils patch-binutils-force
##patch-binutils: stamps/patch-binutils
##patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
## pushd binutils-$(BINUTILS_VERSION) ; \
## for f in ../source/avr32/binutils/*.patch; do \
## patch -N -p0 <$${f} ; \
## done ; \
## popd ; \
## [ -d stamps ] || mkdir stamps
## touch stamps/patch-binutils;
 
.PHONY: regen-binutils regen-binutils-force
regen-binutils: stamps/regen-binutils
regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
pushd binutils-$(BINUTILS_VERSION) ; \
"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
"$(SUPP_PREFIX)/bin/autoconf" ; \
"$(SUPP_PREFIX)/bin/automake" ; \
"$(SUPP_PREFIX)/bin/autoheader" ; \
for dir in bfd opcodes binutils gas ld; do \
pushd $$dir ; \
"$(SUPP_PREFIX)/bin/autoconf"; \
"$(SUPP_PREFIX)/bin/automake"; \
"$(SUPP_PREFIX)/bin/autoheader"; \
popd ; \
done; \
popd; \
[ -d stamps ] || mkdir stamps ;
touch stamps/regen-binutils;
##.PHONY: regen-binutils regen-binutils-force
##regen-binutils: stamps/regen-binutils
##regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
## pushd binutils-$(BINUTILS_VERSION) ; \
## "$(SUPP_PREFIX)/bin/aclocal" -I config ; \
## "$(SUPP_PREFIX)/bin/autoconf" ; \
## "$(SUPP_PREFIX)/bin/automake" ; \
## "$(SUPP_PREFIX)/bin/autoheader" ; \
## for dir in bfd opcodes binutils gas ld; do \
## pushd $$dir ; \
## "$(SUPP_PREFIX)/bin/autoconf"; \
## "$(SUPP_PREFIX)/bin/automake"; \
## "$(SUPP_PREFIX)/bin/autoheader"; \
## popd ; \
## done; \
## popd; \
## [ -d stamps ] || mkdir stamps ;
## touch stamps/regen-binutils;
 
.PHONY: build-binutils build-binutils-force
build-binutils: stamps/build-binutils
build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
cd binutils-$(BINUTILS_VERSION) ; \
./configure --enable-maintainer-mode \
--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls \
--disable-shared --disable-werror \
--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) && \
$(MAKE) all-bfd TARGET-bfd=headers; \
rm bfd/Makefile; \
make configure-bfd; \
$(MAKE)
[ -d stamps ] || mkdir stamps ;
touch stamps/build-binutils;
##.PHONY: build-binutils build-binutils-force
##build-binutils: stamps/build-binutils
##build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
## cd binutils-$(BINUTILS_VERSION) ; \
## ./configure --enable-maintainer-mode \
## --prefix="$(PREFIX)" --target=$(TARGET) --disable-nls \
## --disable-shared --disable-werror \
## --with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) && \
## $(MAKE) all-bfd TARGET-bfd=headers; \
## rm bfd/Makefile; \
## make configure-bfd; \
## $(MAKE)
## [ -d stamps ] || mkdir stamps ;
## touch stamps/build-binutils;
 
.PHONY: install-binutils install-binutils-force
install-binutils: stamps/install-binutils
install-binutils-force stamps/install-binutils: stamps/build-binutils
cd binutils-$(BINUTILS_VERSION) && \
$(MAKE) installdirs install-host install-target
[ -d stamps ] || mkdir stamps ;
touch stamps/install-binutils;
##.PHONY: install-binutils install-binutils-force
##install-binutils: stamps/install-binutils
##install-binutils-force stamps/install-binutils: stamps/build-binutils
## cd binutils-$(BINUTILS_VERSION) && \
## $(MAKE) installdirs install-host install-target
## [ -d stamps ] || mkdir stamps ;
## touch stamps/install-binutils;
 
 
.PHONY: clean-binutils
clean-binutils:
rm -rf build/binutils stamps/*-binutils binutils-*
##.PHONY: clean-binutils
##clean-binutils:
## rm -rf build/binutils stamps/*-binutils binutils-*
 
.PHONY: realclean-binutils
realclean-binutils: clean-binutils
rm downloads/$(BINUTILS_ARCHIVE)
##.PHONY: realclean-binutils
##realclean-binutils: clean-binutils
## rm downloads/$(BINUTILS_ARCHIVE)
 
 
########## DFU PROGRAMMER ###########