Subversion Repositories avr32-toolchain

Compare Revisions

Ignore whitespace Rev 13 → Rev 14

/tags/try_gdb_0_2_0/ReleaseNotes
New file
0,0 → 1,21
try_gdb_0_2_0 (jjessich on Sun Apr 01 02:40:52 CEST 2012):
+ Added tools revision generation out of svn.
+ Internal structure completely changed to make macros, which will expand
the rules.
+ The different targets will now execute only, if the dependend thing
is not allready made.
+ Added new rules to force the execution (xxxx-yyyy-f).
NOTE: Currently only autoconf and automake reworked.
 
try_gdb_0_1_0 (jasmin on Sun Mar 25 20:41:08 CEST 2012):
+ gdb added (not working).
+ When executing make with a target, it is not rebuild any longer, if
nothing has been changed.
+ Added *-force tags to have the old behaviour still available (not
finished).
+ Added clean-* rules for each sub target.
+ Added realclean-* ruels, whch will remove the downloaded file, too.
NOTE: Currently NOT TESTED!!!
 
rel_0_1_0 (jasmin on Sun Mar 25 19:21:33 CEST 2012):
+ Initial release based on vendor version 990c274.
/tags/try_gdb_0_2_0/README.asciidoc
New file
0,0 → 1,126
== AVR32 Toolchain Builder ==
 
This is a early implementation of a Makefile for an AVR32 toolchain
builder for Mac OS X & Linux, and it has not been extensively tested.
That said the patches are taken directly from Atmel, and basic testing
is done with some more complicated builds (i.e.:
link:http://eluaproject.net[eLua] in float and integer mode) to ensure
that that at least these work after toolchain modifications.
 
Note: If you have previously built a toolchain of another version, out
of the same builder directory, make sure to do the following first
before building with newer sources:
 
----
make clean
----
 
=== Requirements (OS X) ===
 
You will need to have GCC, make and binutils on your machine to
compile all of this. You can get all of these on Mac OS X, by just
installing the Apple
link:http://developer.apple.com/technologies/tools/[Developer Tools].
You should be able to download free versions of 3.x from the ADC
website, install from the OS X install disc that came with your
machine, or download XCode 4 from the App Store (now free again for
all registered users).
 
You will also need gmp, mpfr and mpc first. I recommend installing
these from link:https://github.com/mxcl/homebrew[homebrew] for now.
I'll add these to the Makefile once I have a consistent configuration
that can be used for both Linux & OS X.
 
With homebrew you can install those dependencies like this:
----
brew install mpfr gmp libmpc texinfo
----
 
If you would like to build dfu-programmer, also install libusb:
 
----
brew install libusb-compat
----
 
 
=== Requirements (Ubuntu) ===
 
These instructions should now also work on Ubuntu Linux, provided the
following packages have been installed prior to attempting the build:
 
----
sudo apt-get install curl flex bison libgmp3-dev libmpfr-dev autoconf build-essential libncurses5-dev libmpc-dev texinfo
----
 
If you would like to build dfu-programmer, also install libusb:
 
----
sudo apt-get install libusb-dev
----
 
=== Main Build Instructions ===
 
Next build the toolchain:
 
----
make install-cross
----
 
You should be able to also specify a specific install/prefix location
by building using the following type of invokation:
 
----
PREFIX=$HOME/avr32-tools make install-cross
----
 
If you do this, make sure you have permissions to create a directory
at this location and/or to create directories within this location if
the directory already exists.
 
 
*NOTE:* If you're running Mac OS X Lion or XCode 4.1 you may find that
you're unable to bootstrap GCC. To work around this until the issue
is fixed in Apple's distribution of llvm-gcc, use the following
command instead of the above to build.
 
----
CC=gcc-4.2 make install-cross
----
 
 
 
This should build the compiler, newlib, gdb, etc.. and install them all
into a directory called arm-cs-tools in your home directory. If you
want to install to another location, feel free to change the export
lines and to adjust the definitions at the top of the Makefile.
 
Keep in mind that the Makefile does install at the end of each build.
 
Once you’re done, the makefile should notify you of the install
location, which will be based on the git revision if you cloned the
repository or the current date if you grabbed a tarball and/or you
don't have the git binary. The message should look like the following:
 
----
====== INSTALLATION NOTE ======
Your tools have now been installed at the following prefix:
/Users/jsnyder/avr32-tools-bd2485b
 
Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
export PATH=/Users/jsnyder/avr32-tools-bd2485b/bin:$PATH
----
 
If it uses the date instead the the git short revision will bve
replaced with a date number like: 20110726.
 
If you also would like dfu-programmer installed intalled (make sure
you have previously installed libusb as described in requirements):
 
----
make install-dfu
----
 
=== Special Thanks ===
 
Special thanks to Rob Emanuele for the basis of this Makefile:
http://elua-development.2368040.n2.nabble.com/Building-GCC-for-Cortex-td2421927.html
/tags/try_gdb_0_2_0/Makefile
New file
0,0 → 1,955
# AVR32 Toolchain Makefile
#
# 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
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# 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.
 
#### PRIMARY TOOLCHAIN VERSIONS #####
 
GCC_VERSION = 4.4.3
GDB_VERSION_DLOAD = 6.7.1a
GDB_VERSION = 6.7.1
BINUTILS_VERSION = 2.20.1
NEWLIB_VERSION = 1.16.0
DFU_VERSION = 0.5.4
AVR_PATCH_REV = 3.2.3.261
AVR_HEADER_REV = 3.2.3.258
 
 
#### PATHS AND ENVIRONMENT VARIABLES #####
 
SHELL = /bin/bash
TARGET = avr32
 
TODAY = $(shell date "+%Y%m%d")
GIT_REV = $(shell git rev-parse --verify HEAD --short 2> /dev/null)
SVN_REV = $(shell head -1 ReleaseNotes 2> /dev/null | cut -f 1 -d " ")
 
ifeq ($(strip $(GIT_REV)),)
ifeq ($(strip $(SVN_REV)),)
PREFIX ?= $(HOME)/avr32-tools-$(TODAY)
TOOL_REV = $(TODAY)
else
PREFIX ?= $(HOME)/avr32-tools-$(SVN_REV)
TOOL_REV = $(SVN_REV)
BUG_URL = jasmin@anw.at
endif
else
PREFIX ?= $(HOME)/avr32-tools-$(GIT_REV)
TOOL_REV = $(GIT_REV)
endif
 
ifeq ($(UNAME), Linux)
PROCS ?= $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(UNAME), Darwin)
PROCS ?= $(shell sysctl hw.ncpu | awk '{print $$2}')
else
PROCS ?= 2
endif
 
SUPP_PREFIX = $(CURDIR)/supp
PATH := ${PREFIX}/bin:${SUPP_PREFIX}/bin:${PATH}
AUTOCONF = $(SUPP_PREFIX)/bin/autoconf
AUTOMAKE = $(SUPP_PREFIX)/bin/automake
 
STAMP_DIR := $(CURDIR)/stamps
DOWNLOAD_DIR := $(CURDIR)/downloads
BUILD_DIR := $(CURDIR)/build
 
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)"
 
 
#### PRIMARY TOOLCHAIN URLS #####
 
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
GCC_URL = http://mirror.anl.gov/pub/gnu/gcc/gcc-$(GCC_VERSION)/$(GCC_ARCHIVE)
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
 
GDB_ARCHIVE = gdb-$(GDB_VERSION_DLOAD).tar.bz2
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
GDB_MD5 = 3564f308f3e4d4f2750891bc2ce9b214
 
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
 
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
 
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
 
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
 
DFU_ARCHIVE = dfu-programmer-$(DFU_VERSION).tar.gz
DFU_URL = http://surfnet.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/$(DFU_VERSION)/$(DFU_ARCHIVE)
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
 
 
##### SUPPORT TOOLS VERSIONS / URLS ######
AUTOCONF_VERSION = 2.64
AUTOMAKE_VERSION = 1.11
MPC_VERSION = 0.8.1
 
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
 
AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2
AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE)
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
 
.PHONY: install-cross
install-cross: install-tools install-note
 
 
.PHONY: sudomode
sudomode:
ifneq ($(USER),root)
@echo Please run this target with sudo!
@echo e.g.: sudo make targetname
@exit 1
endif
 
 
.PHONY: tst
tst:
@echo "PREFIX=$(PREFIX)"
@echo "PKG_VERSION=$(PKG_VERSION)"
@echo "BUG_URL=$(BUG_URL)"
 
 
############ MACROS for the lazy people ;-) ############
 
## in silent mode (make -s),, print whats ging on
ifeq ($(strip $(MAKEFLAGS)),s)
define quiet_text
@echo "$1"
endef
else
define quiet_text
endef
endif
 
## the stamp name
define name_stamp
$(STAMP_DIR)/$(1)
endef
 
## remove a stamp
define rm_stamp
rm -f $(STAMP_DIR)/$(1)
endef
 
## remove all stamps
define rm_stamps
rm -f $(STAMP_DIR)/*-$(1)
endef
 
## create the stamp directory if not existing and the stamp
define make_stamp
@[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR)
date > $(STAMP_DIR)/$(1)
endef
 
## 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
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:
$(call quiet_text,$$(download-$(1)_TEXT))
rm -f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
 
PHONY += download-$(1) download-$(1)-f download-$(1)-remove
endef
 
## extract commands
EXT_BZ2 := tar -jxf
EXT_TGZ := tar -xf
EXT_ZIP := unzip -o
 
## create the extract rule and force extract rule
define EXTRACT_template
extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)"
 
extract-$(1): $(STAMP_DIR)/extract-$(1)
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
@(rm -rf $(1)-*; \
t1=`openssl md5 $$< | cut -f 2 -d " " -` && \
[ "$$$$t1" = "$$($(1)_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
$(call quiet_text,$$(extract-$(1)_TEXT))
$($(2)) $$<
$(call make_stamp,extract-$(1))
 
extract-$(1)-remove:
rm -rf $(1)-*
$(call rm_stamp,extract-$(1))
 
PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove
endef
 
## create the configure rule and force configure rule
define CONF_template
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)-$$($(1)_VERSION)/configure $$($(1)_conf_opts)
$(call make_stamp,conf-$(1))
 
conf-$(1)-remove:
$(call rm_stamp,conf-$(1))
 
PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove
endef
 
## create the build rule and force build rule
define BUILD_template
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))
 
build-$(1)-remove:
rm -rf $(BUILD_DIR)/$(1)
$(call rm_stamp,build-$(1))
 
PHONY += build-$(1) build-$(1)-f build-$(1)-remove
endef
 
## 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))
 
PHONY += install-$(1) install-$(1)-f uninstall-$(1)
endef
 
## create the clean rule and realclean rule
define CLEAN_template
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) clean-$(1)-text
endef
 
 
 
 
$(DOWNLOAD_DIR):
mkdir -p $@
 
$(BUILD_DIR)/%:
mkdir -p $@
 
 
############# SUPP: AUTOCONF ############
 
$(eval $(call DOWNLOAD_template,autoconf))
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2))
autoconf_conf_opts = --prefix="$(SUPP_PREFIX)"
$(eval $(call CONF_template,autoconf,extract))
$(eval $(call BUILD_template,autoconf))
$(eval $(call INSTALL_template,autoconf))
$(eval $(call CLEAN_template,autoconf))
 
 
############ SUPP: AUTOMAKE ############
 
$(eval $(call DOWNLOAD_template,automake))
$(eval $(call EXTRACT_template,automake,EXT_BZ2))
automake_conf_opts = --prefix="$(SUPP_PREFIX)"
$(eval $(call CONF_template,automake,extract))
$(eval $(call BUILD_template,automake))
$(eval $(call INSTALL_template,automake))
$(eval $(call CLEAN_template,automake))
 
 
.PHONY: $(PHONY)
 
 
.PHONY: tst2 tst3
tst2:
$(call make_stamp,JES)
tst3:
$(call rm_stamp,JES)
 
 
.PHONY: install-note
install-note: install-tools
@echo
@echo ====== INSTALLATION NOTE ======
@echo Your tools have now been installed at the following prefix:
@echo $(PREFIX)
@echo
@echo Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
@echo export PATH=$(PREFIX)/bin:'$$PATH'
 
 
.PHONY: install-supp-tools install-supp-tools-force
install-supp-tools: stamps/install-supp-tools
install-supp-tools-force stamps/install-supp-tools: stamps/install-autoconf stamps/install-automake
[ -d stamps ] || mkdir stamps ;
touch stamps/install-supp-tools;
 
.PHONY: clean-supp-tools
clean-supp-tools: clean-autoconf clean-automake
rm stamps/install-supp-tools;
 
.PHONY: realclean-supp-tools
realclean-supp-tools: realclean-autoconf realclean-automake
rm stamps/install-supp-tools;
 
 
 
 
 
############ SUPP: AUTOMAKE ############
 
##.PHONY: download-automake download-automake-force
##download-automake: downloads/$(AUTOMAKE_ARCHIVE)
##download-automake-force downloads/$(AUTOMAKE_ARCHIVE):
## [ -d downloads ] || mkdir downloads ;
## cd downloads && curl -LO $(AUTOMAKE_URL)
 
##.PHONY: extract-automake extract-automake-force
##extract-automake: stamps/extract-automake
##extract-automake-force stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
## @(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
## [ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
## ( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
## tar -jxf $< ;
## [ -d stamps ] || mkdir stamps ;
## touch stamps/extract-automake;
 
##.PHONY: build-automake build-automake-force
##build-automake: stamps/build-automake
##build-automake-force stamps/build-automake: stamps/extract-automake stamps/install-autoconf
## mkdir -p build/automake && cd build/automake && \
## ../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
## $(MAKE) -j$(PROCS)
## [ -d stamps ] || mkdir stamps
## touch stamps/build-automake;
 
##.PHONY: install-automake install-automake-force
##install-automake: stamps/install-automake
##install-automake-force stamps/install-automake: stamps/build-automake
## cd build/automake && \
## $(MAKE) install
## [ -d stamps ] || mkdir stamps
## touch stamps/install-automake;
 
##.PHONY: clean-automake
##clean-automake:
## rm -rf build/automake stamps/*-automake automake-*
 
##.PHONY: realclean-automake
##realclean-automake: clean-automake
## rm downloads/$(AUTOMAKE_ARCHIVE)
 
 
############# 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: 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: 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: 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: realclean-headers
realclean-headers: clean-headers
rm downloads/$(AVR32HEADERS_ARCHIVE)
 
 
################ NEWLIB ################
 
.PHONY: download-newlib download-newlib-force
download-newlib: downloads/$(NEWLIB_ARCHIVE)
download-newlib-force downloads/$(NEWLIB_ARCHIVE):
[ -d downloads ] || mkdir downloads ;
cd downloads && curl -LO $(NEWLIB_URL)
 
.PHONY: extract-newlib extract-newlib-force
extract-newlib: stamps/extract-newlib
extract-newlib-force stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
[ "$$t1" = "$(NEWLIB_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
tar -xf $<
[ -d stamps ] || mkdir stamps
touch stamps/extract-newlib;
 
 
.PHONY: patch-newlib patch-newlib-force
patch-newlib: stamps/patch-newlib
patch-newlib-force stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
pushd newlib-$(NEWLIB_VERSION) ; \
for f in ../source/avr32/newlib/*.patch; do \
patch -N -p0 <$${f} ; \
done ; \
popd ;
[ -d stamps ] || mkdir stamps
touch stamps/patch-newlib;
 
.PHONY: regen-newlib regen-newlib-force
regen-newlib: stamps/regen-newlib
regen-newlib-force stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
pushd newlib-$(NEWLIB_VERSION) ; \
"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
pushd $$dir ; \
"$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake"; \
popd ; \
done; \
popd;
[ -d stamps ] || mkdir stamps
touch stamps/regen-newlib;
 
NEWLIB_FLAGS="-ffunction-sections -fdata-sections \
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os \
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128 \
-DSMALL_MEMORY"
 
.PHONY: build-newlib build-newlib-force
build-newlib: stamps/build-newlib
build-newlib-force stamps/build-newlib: stamps/regen-newlib stamps/install-binutils stamps/install-gcc
mkdir -p build/newlib && cd build/newlib && \
pushd ../../newlib-$(NEWLIB_VERSION) ; \
make clean ; \
popd ; \
../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX) \
--with-build-time-tools=$(PREFIX) \
--target=$(TARGET) --disable-newlib-supplied-syscalls \
--disable-libgloss --disable-nls --disable-shared \
--enable-newlib-io-long-long --enable-newlib-io-long-double \
--enable-target-optspace --enable-newlib-io-pos-args \
--enable-newlib-reent-small && \
$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
[ -d stamps ] || mkdir stamps
touch stamps/build-newlib;
 
.PHONY: install-newlib install-newlib-force
install-newlib: stamps/install-newlib
install-newlib-force stamps/install-newlib: stamps/build-newlib
cd build/newlib && \
$(MAKE) install
[ -d stamps ] || mkdir stamps
touch stamps/install-newlib;
 
.PHONY: clean-newlib
clean-newlib:
rm -rf build/newlib stamps/*-newlib newlib-*
 
.PHONY: realclean-newlib
realclean-newlib: clean-newlib
rm downloads/$(NEWLIB_ARCHIVE)
 
 
################ 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: 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: 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: 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: realclean-binutils
realclean-binutils: clean-binutils
rm downloads/$(BINUTILS_ARCHIVE)
 
 
########## DFU PROGRAMMER ###########
 
.PHONY: download-dfu download-dfu-force
download-dfu: downloads/$(DFU_ARCHIVE)
download-dfu-force downloads/$(DFU_ARCHIVE):
[ -d downloads ] || mkdir downloads ;
cd downloads && curl -LO $(DFU_URL)
 
.PHONY: extract-dfu extract-dfu-force
extract-dfu: stamps/extract-dfu
extract-dfu-force stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
[ "$$t1" = "$(DFU_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
tar -zxf $< ;
[ -d stamps ] || mkdir stamps ;
touch stamps/extract-dfu;
 
.PHONY: build-dfu build-dfu-force
build-dfu: stamps/build-dfu
build-dfu-force stamps/build-dfu: stamps/extract-dfu
mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
$(MAKE) -j$(PROCS)
[ -d stamps ] || mkdir stamps
touch stamps/build-dfu;
 
.PHONY: install-dfu install-dfu-force
install-dfu: stamps/install-dfu
install-dfu-force stamps/install-dfu: stamps/build-dfu
cd build/dfu-programmer && \
$(MAKE) install
[ -d stamps ] || mkdir stamps
touch stamps/install-dfu;
 
.PHONY: clean-dfu
clean-dfu:
rm -rf build/dfu stamps/*-dfu dfu-*
 
.PHONY: realclean-dfu
realclean-dfu: clean-dfu
rm downloads/$(DFU_ARCHIVE)
 
 
################ Bootstrap GCC ################
 
.PHONY: download-gcc download-gcc-force
download-gcc: downloads/$(GCC_ARCHIVE)
download-gcc-force downloads/$(GCC_ARCHIVE):
[ -d downloads ] || mkdir downloads ;
cd downloads && curl -LO $(GCC_URL)
 
.PHONY: extract-gcc extract-gcc-force
extract-gcc: stamps/extract-gcc
extract-gcc-force stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
[ "$$t1" = "$(GCC_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
tar -jxf $< ;
[ -d stamps ] || mkdir stamps ;
touch stamps/extract-gcc;
 
.PHONY: patch-gcc patch-gcc-force
patch-gcc: stamps/patch-gcc
patch-gcc-force stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
pushd gcc-$(GCC_VERSION) ; \
for f in ../source/avr32/gcc/*.patch; do \
patch -N -p0 <$${f} ; \
done ; \
popd ;
[ -d stamps ] || mkdir stamps
touch stamps/patch-gcc;
 
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections \
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g \
-Os -fno-unroll-loops"
 
.PHONY: build-gcc build-gcc-force
build-gcc: stamps/build-gcc
build-gcc-force stamps/build-gcc: stamps/install-binutils stamps/patch-gcc
mkdir -p build/gcc && cd build/gcc && \
pushd ../../gcc-$(GCC_VERSION) ; \
make clean ; \
popd ; \
../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)" \
--target=$(TARGET) --enable-languages="c" --with-gnu-ld \
--with-gnu-as --with-newlib --disable-nls --disable-libssp \
--with-dwarf2 --enable-sjlj-exceptions \
--enable-version-specific-runtime-libs --disable-libstdcxx-pch \
--disable-shared \
--with-build-time-tools="$(PREFIX)/$(TARGET)/bin" \
--enable-cxx-flags=$(CFLAGS_FOR_TARGET) \
--with-sysroot="$(PREFIX)/$(TARGET)" \
--with-build-sysroot="$(PREFIX)/$(TARGET)" \
--with-build-time-tools="$(PREFIX)/$(TARGET)/bin" \
CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) \
LDFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\"" \
CPPFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\"" \
--with-bugurl=$(BUG_URL) \
--with-pkgversion=$(PKG_VERSION) && \
$(MAKE) -j$(PROCS)
[ -d stamps ] || mkdir stamps
touch stamps/build-gcc;
 
.PHONY: install-gcc install-gcc-force
install-gcc: stamps/install-gcc
install-gcc-force stamps/install-gcc: stamps/build-gcc
cd build/gcc && \
$(MAKE) installdirs install-target && \
$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
[ -d stamps ] || mkdir stamps
touch stamps/install-gcc;
 
.PHONY: clean-gcc
clean-gcc:
rm -rf build/gcc stamps/*-gcc gcc-*
 
.PHONY: realclean-gcc
realclean-gcc: clean-gcc
rm downloads/$(GCC_ARCHIVE)
 
 
################ Final GCC ################
 
.PHONY: build-final-gcc build-final-gcc-force
build-final-gcc: stamps/build-final-gcc
build-final-gcc-force stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/patch-gcc
mkdir -p build/final-gcc && cd build/final-gcc && \
pushd ../../gcc-$(GCC_VERSION) ; \
make clean ; \
popd ; \
../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
--target=$(TARGET) $(DEPENDENCIES) --enable-languages="c,c++" --with-gnu-ld \
--with-gnu-as --with-newlib --disable-nls --disable-libssp \
--with-dwarf2 --enable-sjlj-exceptions \
--enable-version-specific-runtime-libs --disable-libstdcxx-pch \
--disable-shared --enable-__cxa_atexit \
--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
--enable-cxx-flags=$(CFLAGS_FOR_TARGET) \
--with-sysroot=$(PREFIX)/$(TARGET) \
--with-build-sysroot=$(PREFIX)/$(TARGET) \
--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) \
LDFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
CPPFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
--with-bugurl=$(BUG_URL) \
--with-pkgversion=$(PKG_VERSION) && \
$(MAKE) -j$(PROCS)
[ -d stamps ] || mkdir stamps
touch stamps/build-final-gcc;
 
.PHONY: install-final-gcc install-final-gcc-force
install-final-gcc: stamps/install-final-gcc
install-final-gcc-force stamps/install-final-gcc: stamps/build-final-gcc
cd build/final-gcc && \
$(MAKE) installdirs install-target && \
$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
[ -d stamps ] || mkdir stamps
touch stamps/install-final-gcc;
 
.PHONY: clean-final-gcc
clean-final-gcc: clean-gcc
rm -rf build/final-gcc stamps/*-final-gcc
 
.PHONY: realclean-final-gcc
realclean-final-gcc: realclean-gcc
 
 
########## GDB ###########
 
.PHONY: download-gdb download-gdb-force
download-gdb: downloads/$(GDB_ARCHIVE)
download-gdb-force downloads/$(GDB_ARCHIVE):
[ -d downloads ] || mkdir downloads ;
cd downloads && curl -LO $(GDB_URL)
 
.PHONY: extract-gdb extract-gdb-force
extract-gdb: stamps/extract-gdb
extract-gdb-force stamps/extract-gdb: downloads/$(GDB_ARCHIVE)
@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
[ "$$t1" = "$(GDB_MD5)" ] || \
( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
tar -jxf $< ;
[ -d stamps ] || mkdir stamps ;
touch stamps/extract-gdb;
 
.PHONY: patch-gdb patch-gdb-force
patch-gdb: stamps/patch-gdb
patch-gdb-force stamps/patch-gdb: stamps/extract-gdb stamps/extract-avr32patches
pushd gdb-$(GDB_VERSION) ; \
for f in ../source/avr32/gdb/*.patch; do \
patch -N -p0 <$${f} ; \
done ; \
popd ; \
[ -d stamps ] || mkdir stamps
touch stamps/patch-gdb;
 
.PHONY: regen-gdb regen-gdb-force
regen-gdb: stamps/regen-gdb
regen-gdb-force stamps/regen-gdb: stamps/patch-gdb stamps/install-supp-tools
pushd gdb-$(GDB_VERSION) ; \
"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
"$(SUPP_PREFIX)/bin/autoconf" ; \
"$(SUPP_PREFIX)/bin/automake" ; \
"$(SUPP_PREFIX)/bin/autoheader" ; \
for dir in bfd opcodes gdb; do \
pushd $$dir ; \
echo "JESS 1: $$dir" >&2 ; \
"$(SUPP_PREFIX)/bin/autoconf"; \
"$(SUPP_PREFIX)/bin/automake"; \
"$(SUPP_PREFIX)/bin/autoheader"; \
echo "JESS 2: $$dir" >&2 ; \
popd ; \
done; \
popd; \
[ -d stamps ] || mkdir stamps ;
touch stamps/regen-gdb;
 
.PHONY: build-gdb build-gdb-force
build-gdb: stamps/build-gdb
build-gdb-force stamps/build-gdb: stamps/regen-gdb stamps/install-supp-tools
echo "JESS 3" >&2 ; \
mkdir -p build/gdb && cd build/gdb && \
../../gdb-$(GDB_VERSION)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
$(MAKE) -j$(PROCS)
$(MAKE) installdirs install-host install-target
[ -d stamps ] || mkdir stamps
touch stamps/build-gdb;
 
.PHONY: install-gdb install-gdb-force
install-gdb: stamps/install-gdb
install-gdb-force stamps/install-gdb: stamps/build-gdb
cd build/gdb && \
$(MAKE) install
[ -d stamps ] || mkdir stamps
touch stamps/install-gdb;
 
.PHONY: clean-gdb
clean-gdb:
rm -rf build/gdb stamps/*-gdb gdb-*
 
.PHONY: realclean-gdb
realclean-gdb: clean-gdb
rm downloads/$(GDB_ARCHIVE)
 
################ NON-WORKING/NON-ADJUSTED TARGETS ################
 
 
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
pushd gcc-$(GCC_VERSION)-$(CS_BASE) ; \
patch -N -p1 < ../patches/gcc-optsize.patch ; \
popd ;
 
gmp: gmp-$(CS_BASE)/ sudomode
sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
pushd ../../gmp-$(CS_BASE) ; \
make clean ; \
popd ; \
sudo -u $(SUDO_USER) ../../gmp-$(CS_BASE)/configure --disable-shared && \
sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
$(MAKE) install
 
mpc: mpc-$(MPC_VERSION)/ sudomode
sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
pushd ../../mpc-$(MPC_VERSION) ; \
make clean ; \
popd ; \
sudo -u $(SUDO_USER) ../../mpc-$(MPC_VERSION)/configure --disable-shared && \
sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
$(MAKE) install
 
mpc-$(MPC_VERSION) : $(LOCAL_BASE)/mpc-$(CS_VERSION).tar.bz2
ifeq ($(USER),root)
sudo -u $(SUDO_USER) tar -jxf $<
else
tar -jxf $<
endif
 
mpfr: gmp mpfr-$(CS_BASE)/ sudomode
sudo -u $(SUDO_USER) mkdir -p build/mpfr && cd build/mpfr && \
pushd ../../mpfr-$(CS_BASE) ; \
make clean ; \
popd ; \
sudo -u $(SUDO_USER) ../../mpfr-$(CS_BASE)/configure LDFLAGS="-Wl,-search_paths_first" --disable-shared && \
sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
$(MAKE) install
 
cross-gdb: gdb-$(CS_BASE)/
mkdir -p build/gdb && cd build/gdb && \
pushd ../../gdb-$(CS_BASE) ; \
make clean ; \
popd ; \
../../gdb-$(CS_BASE)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
$(MAKE) -j$(PROCS) && \
$(MAKE) installdirs install-host install-target && \
mkdir -p "$(PREFIX)/man/man1" && \
cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
 
.PHONY : clean
clean:
rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp