1,6 → 1,6 |
# AVR32 Toolchain Makefile |
# |
# Copyright (C) 2012 by Jasmin Jessich <jasmin.jessich@frequentis.com> |
# Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org> |
# |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
# of this software and associated documentation files (the "Software"), to deal |
19,20 → 19,7 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
# THE SOFTWARE. |
# |
# This Makefile is based on the one from here: |
# https://github.com/jsnyder/avr32-toolchain/blob/master/Makefile |
# Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org> |
|
# |
# This makefile uses macros to generate the different rules for the different |
# tools. This saves a lot of work, when a new tool is added. Moreover, bugfixes |
# have to be done only one place. |
# |
# NOTE: Currently ONLY binutils is finished! |
# |
|
|
#### PRIMARY TOOLCHAIN VERSIONS ##### |
|
GCC_VERSION = 4.4.3 |
50,6 → 37,7 |
|
SHELL = /bin/bash |
TARGET = avr32 |
# maybe better: avr32-unknown-none |
|
TODAY = $(shell date "+%Y%m%d") |
GIT_REV = $(shell git rev-parse --verify HEAD --short 2> /dev/null) |
77,13 → 65,6 |
PROCS ?= 2 |
endif |
|
# enable maintainer-mode with yes |
M_MODE ?= no |
|
# enable binutils autotool file regeneration with yes |
BINUTILS_REGEN ?= no |
|
|
SUPP_PREFIX = $(CURDIR)/supp |
PATH := ${PREFIX}/bin:${SUPP_PREFIX}/bin:${PATH} |
AUTOCONF = $(SUPP_PREFIX)/bin/autoconf |
96,8 → 77,8 |
ifeq ($(strip $(BUG_URL)),) |
BUG_URL = https://github.com/jsnyder/avr32-toolchain |
endif |
#PKG_VERSION ?= "AVR 32 bit GNU Toolchain-$(AVR_PATCH_REV)-$(TOOL_REV)" |
PKG_VERSION ?= "AVR 32 bit GNU Toolchain-$(TOOL_REV)" |
#PKG_VERSION = "AVR 32 bit GNU Toolchain-$(AVR_PATCH_REV)-$(TOOL_REV)" |
PKG_VERSION = "AVR 32 bit GNU Toolchain-$(TOOL_REV)" |
|
|
#### PRIMARY TOOLCHAIN URLS ##### |
126,11 → 107,6 |
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857 |
install_dir_avr32patches := source/avr32 |
|
NEWPATCHESBINUTILS_ARCHIVE = binutils-2.22-avr32-full.patch |
NEWPATCHESBINUTILS_URL=http://avr.anw.at/avr32/patches/binutils/2_22/$(NEWPATCHESBINUTILS_ARCHIVE) |
NEWPATCHESBINUTILS_MD5 = aca9dd1aaeda63fa1a0cc4c68b94fa6f |
install_dir_newpatchesbinutils := source/avr32/binutils |
|
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip |
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE) |
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228 |
145,7 → 121,6 |
#AUTOMAKE_VERSION = 1.11 |
AUTOMAKE_VERSION = 1.11.1 |
LIBTOOL_VERSION = 2.2.6b |
DEJAGNU_VERSION = 1.5 |
MPC_VERSION = 0.8.1 |
|
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2 |
163,15 → 138,9 |
LIBTOOL_URL = http://mirror.anl.gov/pub/gnu/libtool/$(LIBTOOL_ARCHIVE) |
LIBTOOL_MD5 = 07da460450490148c6d2df0f21481a25 |
|
DEJAGNU_ARCHIVE = dejagnu-$(DEJAGNU_VERSION).tar.gz |
DEJAGNU_URL = http://mirror.anl.gov/pub/gnu/dejagnu/$(DEJAGNU_ARCHIVE) |
DEJAGNU_MD5 = 3df1cbca885e751e22d3ebd1ac64dc3c |
|
SUPP_TOOLS := autoconf automake libtool |
SUPP_TOOLS_TEST := dejagnu |
ALL_TOOLS := gcc gdb binutils newlib avr32patches avr32headers dfu \ |
newpatchesbinutils \ |
$(SUPP_TOOLS) $(SUPP_TOOLS_TEST) |
ALL_TOOLS := gcc gdb binutils newlib avr32patches avr32headers dfu $(SUPP_TOOLS) |
|
|
all: install-cross |
265,9 → 234,8 |
|
## create the extract rule and force extract rule |
define EXTRACT_template |
$(1)_extract_cmds ?= $($(2)) $$< $(3) |
|
extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)" |
|
extract-$(1): $(call name_stamp,extract-$(1)) |
extract-$(1)-f $(call name_stamp,extract-$(1)): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE) |
@(rm -rf $(1)-*; \ |
275,7 → 243,7 |
[ "$$$$t1" = "$$($(1)_MD5)" ] || \ |
( echo "Bad Checksum! Please remove the following file and retry: $$<" && false )) |
$(call quiet_text,$$(extract-$(1)_TEXT)) |
$$($(1)_extract_cmds) |
$($(2)) $$< $(3) |
$(call make_stamp,extract-$(1)) |
|
extract-$(1)-remove: |
291,17 → 259,14 |
|
## create the patch rule |
define PATCH_template |
$(1)_patch_level ?= -p0 |
|
patch-$(1)_TEXT := "Patching $$($(1)_ARCHIVE)" |
patch-$(1): $(call name_stamp,patch-$(1)) |
$(call name_stamp,patch-$(1)): $(call name_stamp,extract-$(1)) $(call name_stamp,extract-avr32patches) \ |
$(call name_stamp,extract-newpatchesbinutils) |
$(call name_stamp,patch-$(1)): $(call name_stamp,extract-$(1)) $(call name_stamp,extract-avr32patches) |
$(call quiet_text,$$(patch-$(1)_TEXT)) |
@(pushd $(1)-$$($(1)_VERSION) ; \ |
for f in ../$(install_dir_avr32patches)/$(1)/*.patch; do \ |
echo "Patching using: $$$${f}" ; \ |
patch -N $$($(1)_patch_level) --no-backup-if-mismatch -i $$$${f} ; \ |
patch -N -p0 --no-backup-if-mismatch < $$$${f} ; \ |
if [ $$$$? -ne 0 ] ; then exit -1 ; fi ; \ |
done ; \ |
popd) |
359,12 → 324,6 |
define CONF_template |
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)" |
conf-$(1): $(call name_stamp,conf-$(1)) |
|
# we need configure parameters! |
ifeq ($$(strip $$($(1)_conf_opts)),) |
$$(error "Configure options '$(1)_conf_opts' not defined") |
endif |
|
conf-$(1)-f $(call name_stamp,conf-$(1)): $(call name_stamp,$(2)-$(1)) $$($(1)_conf_deps) |
@(rm -rf $(BUILD_DIR)/$(1) ; mkdir -p $(BUILD_DIR)/$(1)) |
$(call quiet_text,$$(conf-$(1)_TEXT)) |
384,36 → 343,23 |
|
## create the build rule and force build rule |
define BUILD_template |
build-$(1): $(call name_stamp,build-$(1)) |
build-$(1)-f: build-$(1)-clean build-$(1) |
|
# default commands overrideable |
$(1)_build_cmds ?= $(MAKE) -j$(PROCS) |
$(1)_build_clean_cmds ?= $(MAKE) clean |
|
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)" |
$(call name_stamp,build-$(1)): $(call name_stamp,conf-$(1)) |
build-$(1): $(call name_stamp,build-$(1)) |
build-$(1)-f $(call name_stamp,build-$(1)): $(call name_stamp,conf-$(1)) |
$(call quiet_text,$$(build-$(1)_TEXT)) |
cd $(BUILD_DIR)/$(1) && \ |
$$($(1)_build_cmds) |
$(call make_stamp,build-$(1)) |
|
build-$(1)-clean_TEXT := "Cleaning $(1) $$($(1)_VERSION)" |
build-$(1)-clean: |
$(call quiet_text,$$(build-$(1)-clean_TEXT)) |
cd $(BUILD_DIR)/$(1) && \ |
$$($(1)_build_clean_cmds) |
$(call rm_stamp,build-$(1)) |
|
build-$(1)-remove: |
rm -rf $(BUILD_DIR)/$(1) |
$(call rm_stamp,build-$(1)) |
|
clean_build_$(1)_rule := build-$(1)-remove |
|
available_targets += build-$(1) build-$(1)-f build-$(1)-clean build-$(1)-remove |
available_targets += build-$(1) build-$(1)-f build-$(1)-remove |
|
PHONY += build-$(1) build-$(1)-f build-$(1)-clean build-$(1)-remove |
PHONY += build-$(1) build-$(1)-f build-$(1)-remove |
endef |
|
## create the install rule and force install rule |
472,6 → 418,8 |
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2)) |
autoconf_conf_opts := --prefix="$(SUPP_PREFIX)" |
$(eval $(call CONF_template,autoconf,extract)) |
autoconf_build_cmds :=\ |
$(MAKE) clean && $(MAKE) -j$(PROCS) |
$(eval $(call BUILD_template,autoconf)) |
$(eval $(call INSTALL_template,autoconf)) |
$(eval $(call CLEAN_template,autoconf)) |
485,6 → 433,7 |
# automake needs the new autoconf allready installed |
automake_conf_deps := $(call name_stamp,install-autoconf) |
$(eval $(call CONF_template,automake,extract)) |
automake_build_cmds := $(autoconf_build_cmds) |
$(eval $(call BUILD_template,automake)) |
$(eval $(call INSTALL_template,automake)) |
$(eval $(call CLEAN_template,automake)) |
499,25 → 448,12 |
libtool_conf_deps := $(call name_stamp,install-autoconf) \ |
$(call name_stamp,install-automake) |
$(eval $(call CONF_template,libtool,extract)) |
libtool_build_cmds := $(autoconf_build_cmds) |
$(eval $(call BUILD_template,libtool)) |
$(eval $(call INSTALL_template,libtool)) |
$(eval $(call CLEAN_template,libtool)) |
|
|
############ SUPP-TEST: DEJAGNU ############ |
|
$(eval $(call DOWNLOAD_template,dejagnu)) |
$(eval $(call EXTRACT_template,dejagnu,EXT_TGZ)) |
dejagnu_conf_opts := --prefix="$(SUPP_PREFIX)" |
# dejagnu needs the new autoconf/automake allready installed |
dejagnu_conf_deps := $(call name_stamp,install-autoconf) \ |
$(call name_stamp,install-automake) |
$(eval $(call CONF_template,dejagnu,extract)) |
$(eval $(call BUILD_template,dejagnu)) |
$(eval $(call INSTALL_template,dejagnu)) |
$(eval $(call CLEAN_template,dejagnu)) |
|
|
############# AVR32 PATCHES ############ |
|
$(eval $(call DOWNLOAD_template,avr32patches)) |
533,27 → 469,6 |
$(eval $(call CLEAN_template,avr32patches)) |
|
|
############# NEWPATCHESBINUTILS ############ |
|
$(eval $(call DOWNLOAD_template,newpatchesbinutils)) |
newpatchesbinutils_extract_cmds := \ |
@([ -d $(install_dir_newpatchesbinutils) ] && \ |
mv $(install_dir_newpatchesbinutils) $(install_dir_newpatchesbinutils).x ; \ |
mkdir -p $(install_dir_newpatchesbinutils) ; \ |
cp $(DOWNLOAD_DIR)/$(NEWPATCHESBINUTILS_ARCHIVE) $(install_dir_newpatchesbinutils) \ |
) |
$(eval $(call EXTRACT_template,newpatchesbinutils)) |
|
## use the uninstall-XXX rule to remove the patches directory |
PHONY += uninstall-avr32patches |
uninstall-newpatchesbinutils: |
rm -rf $(install_dir_newpatchesbinutils) |
|
clean_uninstall_newpatchesbinutils_rule = uninstall-newpatchesbinutils |
|
$(eval $(call CLEAN_template,newpatchesbinutils)) |
|
|
############# AVR32 HEADERS ############ |
$(eval $(call DOWNLOAD_template,avr32headers)) |
|
577,38 → 492,33 |
|
$(eval $(call DOWNLOAD_template,binutils)) |
$(eval $(call EXTRACT_template,binutils,EXT_BZ2)) |
binutils_patch_level := -p1 |
$(eval $(call PATCH_template,binutils)) |
binutils_regen_dirs := bfd opcodes binutils gas ld |
$(eval $(call REGEN_template,binutils,patch)) |
# --enable-maintainer-mode \ |
|
ifneq ($(M_MODE),no) |
binutils_maintainer_mode := --enable-maintainer-mode |
endif |
|
ifneq ($(BINUTILS_REGEN),no) |
binutils_conf_depend :=regen |
else |
binutils_conf_depend :=patch |
endif |
|
binutils_conf_opts := \ |
$(binutils_maintainer_mode) \ |
--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls \ |
--disable-shared --disable-werror \ |
--enable-ld=yes --enable-gold=no \ |
--with-pkgversion=$(PKG_VERSION) \ |
--with-sysroot="$(PREFIX)/$(TARGET)" |
# --with-bugurl=$(BUG_URL) |
--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) |
$(eval $(call CONF_template,binutils,regen)) |
binutils_build_cmds := \ |
$(MAKE) -j$(PROCS) |
# $(MAKE) clean && $(MAKE) -j$(PROCS) |
|
$(eval $(call CONF_template,binutils,$(binutils_conf_depend))) |
#binutils_build_cmds := ??? |
#binutils_build_clean_cmds := ??? |
# $(MAKE) all-bfd TARGET-bfd=headers; \ |
# rm bfd/Makefile; \ |
# make configure-bfd; \ |
# $(MAKE) |
|
$(eval $(call BUILD_template,binutils)) |
$(eval $(call INSTALL_template,binutils)) |
$(eval $(call CLEAN_template,binutils)) |
|
|
|
.PHONY: $(PHONY) |
|
|
656,15 → 566,6 |
@echo "help : this inforamtion" |
@echo "helpx : this inforamtion + available targets" |
@echo "" |
@echo "The installation prefix can be set by" |
@echo " PREFIX=.... make aaa-XXX" |
@echo "And the package version with" |
@echo " PKG_VERSION=\"AVR 32 bit GNU Toolchain-XXX\"" |
@echo "" |
@echo "Maintainers may use" |
@echo " M_MODE=y or BINUTILS_REGEN=y" |
@echo "Please have a look to the Makefile for details" |
@echo "" |
|
define print_target |
@echo "$(1)" |
700,26 → 601,9 |
clean: $(clean_rules) |
|
realclean: $(realclean_rules) |
# rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp |
|
|
|
################################################################# |
################################################################# |
#### ###### |
#### ###### |
#### ###### |
#### FROM HERE ON OLD CODE OF ORIGINAL MAKEFILE ###### |
#### COMPLETELY UNSUPPORTED AND FOR PATTERN FOR ###### |
#### ADDITIONAL WORK ONLY ###### |
#### ###### |
#### ###### |
#### ###### |
################################################################# |
################################################################# |
|
|
|
|
############ SUPP: AUTOMAKE ############ |
|
##.PHONY: download-automake download-automake-force |