Subversion Repositories avr32-toolchain

Rev

Rev 13 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13 Rev 14
1
# AVR32 Toolchain Makefile
1
# AVR32 Toolchain Makefile
2
#
2
#
3
# Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org>
3
# Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org>
4
#
4
#
5
# Permission is hereby granted, free of charge, to any person obtaining a copy
5
# Permission is hereby granted, free of charge, to any person obtaining a copy
6
# of this software and associated documentation files (the "Software"), to deal
6
# of this software and associated documentation files (the "Software"), to deal
7
# in the Software without restriction, including without limitation the rights
7
# in the Software without restriction, including without limitation the rights
8
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
# copies of the Software, and to permit persons to whom the Software is
9
# copies of the Software, and to permit persons to whom the Software is
10
# furnished to do so, subject to the following conditions:
10
# furnished to do so, subject to the following conditions:
11
#
11
#
12
# The above copyright notice and this permission notice shall be included in
12
# The above copyright notice and this permission notice shall be included in
13
# all copies or substantial portions of the Software.
13
# all copies or substantial portions of the Software.
14
#
14
#
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
# THE SOFTWARE.
21
# THE SOFTWARE.
22
22
23
#### PRIMARY TOOLCHAIN VERSIONS #####
23
#### PRIMARY TOOLCHAIN VERSIONS #####
24
24
25
GCC_VERSION       = 4.4.3
25
GCC_VERSION       = 4.4.3
26
GDB_VERSION_DLOAD = 6.7.1a
26
GDB_VERSION_DLOAD = 6.7.1a
27
GDB_VERSION       = 6.7.1
27
GDB_VERSION       = 6.7.1
28
BINUTILS_VERSION  = 2.20.1
28
BINUTILS_VERSION  = 2.20.1
29
NEWLIB_VERSION    = 1.16.0
29
NEWLIB_VERSION    = 1.16.0
30
DFU_VERSION       = 0.5.4
30
DFU_VERSION       = 0.5.4
31
AVR_PATCH_REV	  = 3.2.3.261
31
AVR_PATCH_REV	  = 3.2.3.261
32
AVR_HEADER_REV    = 3.2.3.258
32
AVR_HEADER_REV    = 3.2.3.258
33
33
34
34
35
#### PATHS AND ENVIRONMENT VARIABLES #####
35
#### PATHS AND ENVIRONMENT VARIABLES #####
36
36
37
SHELL       = /bin/bash
37
SHELL       = /bin/bash
38
TARGET      = avr32
38
TARGET      = avr32
39
39
40
TODAY = $(shell date "+%Y%m%d")
40
TODAY = $(shell date "+%Y%m%d")
41
GIT_REV	    = $(shell git rev-parse --verify HEAD --short 2> /dev/null)
41
GIT_REV	    = $(shell git rev-parse --verify HEAD --short 2> /dev/null)
42
SVN_REV	    = $(shell head -1 ReleaseNotes 2> /dev/null | cut -f 1 -d " ")
42
SVN_REV	    = $(shell head -1 ReleaseNotes 2> /dev/null | cut -f 1 -d " ")
43
43
44
ifeq ($(strip $(GIT_REV)),)
44
ifeq ($(strip $(GIT_REV)),)
45
ifeq ($(strip $(SVN_REV)),)
45
ifeq ($(strip $(SVN_REV)),)
46
PREFIX     ?= $(HOME)/avr32-tools-$(TODAY)
46
PREFIX     ?= $(HOME)/avr32-tools-$(TODAY)
47
TOOL_REV   = $(TODAY)
47
TOOL_REV   = $(TODAY)
48
else
48
else
49
PREFIX     ?= $(HOME)/avr32-tools-$(SVN_REV)
49
PREFIX     ?= $(HOME)/avr32-tools-$(SVN_REV)
50
TOOL_REV   = $(SVN_REV)
50
TOOL_REV   = $(SVN_REV)
51
BUG_URL = jasmin@anw.at
51
BUG_URL = jasmin@anw.at
52
endif
52
endif
53
else
53
else
54
PREFIX     ?= $(HOME)/avr32-tools-$(GIT_REV)
54
PREFIX     ?= $(HOME)/avr32-tools-$(GIT_REV)
55
TOOL_REV   = $(GIT_REV)
55
TOOL_REV   = $(GIT_REV)
56
endif
56
endif
57
57
58
ifeq ($(UNAME), Linux)
58
ifeq ($(UNAME), Linux)
59
PROCS  ?= $(shell grep -c ^processor /proc/cpuinfo)
59
PROCS  ?= $(shell grep -c ^processor /proc/cpuinfo)
60
else ifeq ($(UNAME), Darwin)
60
else ifeq ($(UNAME), Darwin)
61
PROCS  ?= $(shell sysctl hw.ncpu | awk '{print $$2}')
61
PROCS  ?= $(shell sysctl hw.ncpu | awk '{print $$2}')
62
else
62
else
63
PROCS  ?= 2
63
PROCS  ?= 2
64
endif
64
endif
65
65
66
SUPP_PREFIX = $(CURDIR)/supp
66
SUPP_PREFIX = $(CURDIR)/supp
67
PATH       := ${PREFIX}/bin:${SUPP_PREFIX}/bin:${PATH}
67
PATH       := ${PREFIX}/bin:${SUPP_PREFIX}/bin:${PATH}
68
AUTOCONF    = $(SUPP_PREFIX)/bin/autoconf
68
AUTOCONF    = $(SUPP_PREFIX)/bin/autoconf
69
AUTOMAKE    = $(SUPP_PREFIX)/bin/automake
69
AUTOMAKE    = $(SUPP_PREFIX)/bin/automake
70
70
71
STAMP_DIR  := $(CURDIR)/stamps
71
STAMP_DIR  := $(CURDIR)/stamps
72
DOWNLOAD_DIR := $(CURDIR)/downloads
72
DOWNLOAD_DIR := $(CURDIR)/downloads
73
BUILD_DIR := $(CURDIR)/build
73
BUILD_DIR := $(CURDIR)/build
74
74
75
ifeq ($(strip $(BUG_URL)),)
75
ifeq ($(strip $(BUG_URL)),)
76
BUG_URL = https://github.com/jsnyder/avr32-toolchain
76
BUG_URL = https://github.com/jsnyder/avr32-toolchain
77
endif
77
endif
78
PKG_VERSION = "AVR 32 bit GNU Toolchain-$(AVR_PATCH_REV)-$(TOOL_REV)"
78
PKG_VERSION = "AVR 32 bit GNU Toolchain-$(AVR_PATCH_REV)-$(TOOL_REV)"
79
79
80
80
81
#### PRIMARY TOOLCHAIN URLS #####
81
#### PRIMARY TOOLCHAIN URLS #####
82
82
83
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
83
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
84
GCC_URL = http://mirror.anl.gov/pub/gnu/gcc/gcc-$(GCC_VERSION)/$(GCC_ARCHIVE)
84
GCC_URL = http://mirror.anl.gov/pub/gnu/gcc/gcc-$(GCC_VERSION)/$(GCC_ARCHIVE)
85
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
85
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
86
86
87
GDB_ARCHIVE = gdb-$(GDB_VERSION_DLOAD).tar.bz2
87
GDB_ARCHIVE = gdb-$(GDB_VERSION_DLOAD).tar.bz2
88
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
88
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
89
GDB_MD5 = 3564f308f3e4d4f2750891bc2ce9b214
89
GDB_MD5 = 3564f308f3e4d4f2750891bc2ce9b214
90
90
91
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
91
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
92
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
92
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
93
BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
93
BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
94
94
95
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
95
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
96
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
96
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
97
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
97
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
98
98
99
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
99
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
100
AVR32PATCHES_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32PATCHES_ARCHIVE)
100
AVR32PATCHES_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32PATCHES_ARCHIVE)
101
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
101
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
102
102
103
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
103
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
104
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
104
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
105
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
105
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
106
106
107
DFU_ARCHIVE = dfu-programmer-$(DFU_VERSION).tar.gz
107
DFU_ARCHIVE = dfu-programmer-$(DFU_VERSION).tar.gz
108
DFU_URL = http://surfnet.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/$(DFU_VERSION)/$(DFU_ARCHIVE)
108
DFU_URL = http://surfnet.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/$(DFU_VERSION)/$(DFU_ARCHIVE)
109
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
109
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
110
110
111
111
112
##### SUPPORT TOOLS VERSIONS / URLS ######
112
##### SUPPORT TOOLS VERSIONS / URLS ######
113
AUTOCONF_VERSION = 2.64
113
AUTOCONF_VERSION = 2.64
114
AUTOMAKE_VERSION = 1.11
114
AUTOMAKE_VERSION = 1.11
115
MPC_VERSION = 0.8.1
115
MPC_VERSION = 0.8.1
116
116
117
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
117
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
118
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
118
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
119
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
119
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
120
120
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
126
ALL_TOOLS := gcc gdb binutils newlib avr32patches avr32headers dfu autoconf automake
127
127
128
128
129
129
130
.PHONY: install-tools
130
.PHONY: install-tools
131
install-tools: install-binutils install-final-gcc install-newlib install-headers
131
install-tools: install-binutils install-final-gcc install-newlib install-headers
132
132
133
.PHONY: install-cross
133
.PHONY: install-cross
134
install-cross: install-tools install-note
134
install-cross: install-tools install-note
135
135
136
136
137
.PHONY: sudomode
137
.PHONY: sudomode
138
sudomode:
138
sudomode:
139
ifneq ($(USER),root)
139
ifneq ($(USER),root)
140
	@echo Please run this target with sudo!
140
	@echo Please run this target with sudo!
141
	@echo e.g.: sudo make targetname
141
	@echo e.g.: sudo make targetname
142
	@exit 1
142
	@exit 1
143
endif
143
endif
144
144
145
145
146
.PHONY: tst
146
.PHONY: tst
147
tst:
147
tst:
148
	@echo "PREFIX=$(PREFIX)"
148
	@echo "PREFIX=$(PREFIX)"
149
	@echo "PKG_VERSION=$(PKG_VERSION)"
149
	@echo "PKG_VERSION=$(PKG_VERSION)"
150
	@echo "BUG_URL=$(BUG_URL)"
150
	@echo "BUG_URL=$(BUG_URL)"
151
151
152
152
153
############ MACROS for the lazy people ;-) ############
153
############ MACROS for the lazy people ;-) ############
154
154
155
## in silent mode (make -s),, print whats ging on
155
## in silent mode (make -s),, print whats ging on
156
ifeq ($(strip $(MAKEFLAGS)),s)
156
ifeq ($(strip $(MAKEFLAGS)),s)
157
define quiet_text
157
define quiet_text
158
	@echo "$1"
158
	@echo "$1"
159
endef
159
endef
160
else
160
else
161
define quiet_text
161
define quiet_text
162
endef
162
endef
163
endif
163
endif
164
164
165
## the stamp name
165
## the stamp name
166
define name_stamp
166
define name_stamp
167
$(STAMP_DIR)/$(1)
167
$(STAMP_DIR)/$(1)
168
endef
168
endef
169
169
170
## remove a stamp
170
## remove a stamp
171
define rm_stamp
171
define rm_stamp
172
	rm -f $(STAMP_DIR)/$(1)
172
	rm -f $(STAMP_DIR)/$(1)
173
endef
173
endef
174
174
175
## remove all stamps
175
## remove all stamps
176
define rm_stamps
176
define rm_stamps
177
	rm -f $(STAMP_DIR)/*-$(1)
177
	rm -f $(STAMP_DIR)/*-$(1)
178
endef
178
endef
179
179
180
## create the stamp directory if not existing and the stamp
180
## create the stamp directory if not existing and the stamp
181
define make_stamp
181
define make_stamp
182
	@[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR)
182
	@[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR)
183
	date > $(STAMP_DIR)/$(1)
183
	date > $(STAMP_DIR)/$(1)
184
endef
184
endef
185
185
186
## delete the given directory, if it is empty
186
## delete the given directory, if it is empty
187
define del_all_empty-directories
187
define del_all_empty-directories
188
	@find . -type d -empty | xargs rm -rf
188
	@find . -type d -empty | xargs rm -rf
189
endef
189
endef
190
190
191
## to make the following macros more simply, we need the variables
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
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
193
## definition, but I don't want to break the make convention of upper
194
## case definitions for such user defined variables.
194
## case definitions for such user defined variables.
195
195
196
define LOWER_TOOL_VARS
196
define LOWER_TOOL_VARS
197
UP_$(1) := $(shell echo "$(1)" | tr '[a-z]' '[A-Z]')
197
UP_$(1) := $(shell echo "$(1)" | tr '[a-z]' '[A-Z]')
198
$(1)_VERSION := $$($$(UP_$(1))_VERSION)
198
$(1)_VERSION := $$($$(UP_$(1))_VERSION)
199
$(1)_ARCHIVE := $$($$(UP_$(1))_ARCHIVE)
199
$(1)_ARCHIVE := $$($$(UP_$(1))_ARCHIVE)
200
$(1)_URL := $$($$(UP_$(1))_URL)
200
$(1)_URL := $$($$(UP_$(1))_URL)
201
$(1)_MD5 := $$($$(UP_$(1))_MD5)
201
$(1)_MD5 := $$($$(UP_$(1))_MD5)
202
endef
202
endef
203
203
204
$(foreach tool,$(ALL_TOOLS),$(eval $(call LOWER_TOOL_VARS,$(tool))))
204
$(foreach tool,$(ALL_TOOLS),$(eval $(call LOWER_TOOL_VARS,$(tool))))
205
205
206
206
207
## create the download rule and force download rule
207
## create the download rule and force download rule
208
define DOWNLOAD_template
208
define DOWNLOAD_template
209
download-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
209
download-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
210
download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE): $(DOWNLOAD_DIR)
210
download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE): $(DOWNLOAD_DIR)
211
	cd $(DOWNLOAD_DIR) && curl -LO $$($(1)_URL)
211
	cd $(DOWNLOAD_DIR) && curl -LO $$($(1)_URL)
212
212
213
download-$(1)_TEXT := "Removing $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)"
213
download-$(1)_TEXT := "Removing $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)"
214
download-$(1)-remove:
214
download-$(1)-remove:
215
	$(call quiet_text,$$(download-$(1)_TEXT))
215
	$(call quiet_text,$$(download-$(1)_TEXT))
216
	rm -f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
216
	rm -f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
217
217
218
PHONY += download-$(1) download-$(1)-f download-$(1)-remove
218
PHONY += download-$(1) download-$(1)-f download-$(1)-remove
219
endef
219
endef
220
220
221
## extract commands
221
## extract commands
222
EXT_BZ2 := tar -jxf
222
EXT_BZ2 := tar -jxf
223
EXT_TGZ := tar -xf
223
EXT_TGZ := tar -xf
224
EXT_ZIP := unzip -o
224
EXT_ZIP := unzip -o
225
225
226
## create the extract rule and force extract rule
226
## create the extract rule and force extract rule
227
define EXTRACT_template
227
define EXTRACT_template
228
extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)"
228
extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)"
229
229
230
extract-$(1): $(STAMP_DIR)/extract-$(1)
230
extract-$(1): $(STAMP_DIR)/extract-$(1)
231
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
231
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
232
	@(rm -rf $(1)-*; \
232
	@(rm -rf $(1)-*; \
233
	t1=`openssl md5 $$< | cut -f 2 -d " " -` && \
233
	t1=`openssl md5 $$< | cut -f 2 -d " " -` && \
234
	[ "$$$$t1" = "$$($(1)_MD5)" ] || \
234
	[ "$$$$t1" = "$$($(1)_MD5)" ] || \
235
	( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
235
	( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
236
	$(call quiet_text,$$(extract-$(1)_TEXT))
236
	$(call quiet_text,$$(extract-$(1)_TEXT))
237
	$($(2)) $$<
237
	$($(2)) $$<
238
	$(call make_stamp,extract-$(1))
238
	$(call make_stamp,extract-$(1))
239
239
240
extract-$(1)-remove:
240
extract-$(1)-remove:
241
	rm -rf $(1)-*
241
	rm -rf $(1)-*
242
	$(call rm_stamp,extract-$(1))
242
	$(call rm_stamp,extract-$(1))
243
243
244
PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove
244
PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove
245
endef
245
endef
246
246
247
## create the configure rule and force configure rule
247
## create the configure rule and force configure rule
248
define CONF_template
248
define CONF_template
249
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)"
249
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)"
250
conf-$(1): $(STAMP_DIR)/conf-$(1)
250
conf-$(1): $(STAMP_DIR)/conf-$(1)
251
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)
252
	@rm -rf $(BUILD_DIR)/$(1)/*
252
	@rm -rf $(BUILD_DIR)/$(1)/*
253
	$(call quiet_text,$$(conf-$(1)_TEXT))
253
	$(call quiet_text,$$(conf-$(1)_TEXT))
254
	cd $(BUILD_DIR)/$(1) && \
254
	cd $(BUILD_DIR)/$(1) && \
255
	../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts)
255
	../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts)
256
	$(call make_stamp,conf-$(1))
256
	$(call make_stamp,conf-$(1))
257
257
258
conf-$(1)-remove:
258
conf-$(1)-remove:
259
	$(call rm_stamp,conf-$(1))
259
	$(call rm_stamp,conf-$(1))
260
260
261
PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove
261
PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove
262
endef
262
endef
263
263
264
## create the build rule and force build rule
264
## create the build rule and force build rule
265
define BUILD_template
265
define BUILD_template
266
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)"
266
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)"
267
build-$(1): $(STAMP_DIR)/build-$(1)
267
build-$(1): $(STAMP_DIR)/build-$(1)
268
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))
269
	$(call quiet_text,$$(build-$(1)_TEXT))
270
	cd $(BUILD_DIR)/$(1) && \
270
	cd $(BUILD_DIR)/$(1) && \
271
	$(MAKE) clean && $(MAKE) -j$(PROCS)
271
	$(MAKE) clean && $(MAKE) -j$(PROCS)
272
	$(call make_stamp,build-$(1))
272
	$(call make_stamp,build-$(1))
273
273
274
build-$(1)-remove:
274
build-$(1)-remove:
275
	rm -rf $(BUILD_DIR)/$(1)
275
	rm -rf $(BUILD_DIR)/$(1)
276
	$(call rm_stamp,build-$(1))
276
	$(call rm_stamp,build-$(1))
277
277
278
PHONY += build-$(1) build-$(1)-f build-$(1)-remove
278
PHONY += build-$(1) build-$(1)-f build-$(1)-remove
279
endef
279
endef
280
280
281
## create the install rule and force install rule
281
## create the install rule and force install rule
282
define INSTALL_template
282
define INSTALL_template
283
install-$(1)_TEXT := "Installing $(1) $$($(1)_VERSION)"
283
install-$(1)_TEXT := "Installing $(1) $$($(1)_VERSION)"
284
install-$(1): $(STAMP_DIR)/install-$(1)
284
install-$(1): $(STAMP_DIR)/install-$(1)
285
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))
286
	$(call quiet_text,$$(install-$(1)_TEXT))
287
	cd $(BUILD_DIR)/$(1) && \
287
	cd $(BUILD_DIR)/$(1) && \
288
	$(MAKE) install
288
	$(MAKE) install
289
	$(call make_stamp,install-$(1))
289
	$(call make_stamp,install-$(1))
290
290
291
uninstall-$(1)_TEXT := "Uninstalling $(1) $$($(1)_VERSION)"
291
uninstall-$(1)_TEXT := "Uninstalling $(1) $$($(1)_VERSION)"
292
uninstall-$(1):
292
uninstall-$(1):
293
	$(call quiet_text,$$(uninstall-$(1)_TEXT))
293
	$(call quiet_text,$$(uninstall-$(1)_TEXT))
294
	[ -f $(BUILD_DIR)/$(1)/Makefile ] && \
294
	[ -f $(BUILD_DIR)/$(1)/Makefile ] && \
295
	[ -f $(call name_stamp,install-$(1)) ] && \
295
	[ -f $(call name_stamp,install-$(1)) ] && \
296
	cd $(BUILD_DIR)/$(1) && \
296
	cd $(BUILD_DIR)/$(1) && \
297
	$(MAKE) uninstall || true
297
	$(MAKE) uninstall || true
298
	$(call rm_stamp,install-$(1))
298
	$(call rm_stamp,install-$(1))
299
299
300
PHONY += install-$(1) install-$(1)-f uninstall-$(1)
300
PHONY += install-$(1) install-$(1)-f uninstall-$(1)
301
endef
301
endef
302
302
303
## create the clean rule and realclean rule
303
## create the clean rule and realclean rule
304
define CLEAN_template
304
define CLEAN_template
305
clean-$(1)_TEXT := "Cleaning $(1) $$($(1)_VERSION)"
305
clean-$(1)_TEXT := "Cleaning $(1) $$($(1)_VERSION)"
306
clean-$(1)-text:
306
clean-$(1)-text:
307
	$(call quiet_text,$$(clean-$(1)_TEXT))
307
	$(call quiet_text,$$(clean-$(1)_TEXT))
308
308
309
clean-$(1): clean-$(1)-text 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)
310
	$(call del_all_empty-directories)
311
	$(call del_all_empty-directories)
311
	$(call del_all_empty-directories)
312
	$(call del_all_empty-directories)
312
	$(call del_all_empty-directories)
313
313
314
realclean-$(1): clean-$(1) download-$(1)-remove
314
realclean-$(1): clean-$(1) download-$(1)-remove
315
	$(call del_all_empty-directories)
315
	$(call del_all_empty-directories)
316
	$(call del_all_empty-directories)
316
	$(call del_all_empty-directories)
317
	$(call del_all_empty-directories)
317
	$(call del_all_empty-directories)
318
318
319
PHONY += clean-$(1) realclean-$(1) clean-$(1)-text
319
PHONY += clean-$(1) realclean-$(1) clean-$(1)-text
320
endef
320
endef
321
321
322
322
323
323
324
324
325
$(DOWNLOAD_DIR):
325
$(DOWNLOAD_DIR):
326
	mkdir -p $@
326
	mkdir -p $@
327
327
328
$(BUILD_DIR)/%:
328
$(BUILD_DIR)/%:
329
	mkdir -p $@
329
	mkdir -p $@
330
330
331
331
332
############# SUPP: AUTOCONF ############
332
############# SUPP: AUTOCONF ############
333
333
334
$(eval $(call DOWNLOAD_template,autoconf))
334
$(eval $(call DOWNLOAD_template,autoconf))
335
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2))
335
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2))
336
autoconf_conf_opts = --prefix="$(SUPP_PREFIX)"
336
autoconf_conf_opts = --prefix="$(SUPP_PREFIX)"
337
$(eval $(call CONF_template,autoconf,extract))
337
$(eval $(call CONF_template,autoconf,extract))
338
$(eval $(call BUILD_template,autoconf))
338
$(eval $(call BUILD_template,autoconf))
339
$(eval $(call INSTALL_template,autoconf))
339
$(eval $(call INSTALL_template,autoconf))
340
$(eval $(call CLEAN_template,autoconf))
340
$(eval $(call CLEAN_template,autoconf))
341
341
342
342
343
############ SUPP: AUTOMAKE ############
343
############ SUPP: AUTOMAKE ############
344
344
345
$(eval $(call DOWNLOAD_template,automake))
345
$(eval $(call DOWNLOAD_template,automake))
346
$(eval $(call EXTRACT_template,automake,EXT_BZ2))
346
$(eval $(call EXTRACT_template,automake,EXT_BZ2))
347
automake_conf_opts = --prefix="$(SUPP_PREFIX)"
347
automake_conf_opts = --prefix="$(SUPP_PREFIX)"
348
$(eval $(call CONF_template,automake,extract))
348
$(eval $(call CONF_template,automake,extract))
349
$(eval $(call BUILD_template,automake))
349
$(eval $(call BUILD_template,automake))
350
$(eval $(call INSTALL_template,automake))
350
$(eval $(call INSTALL_template,automake))
351
$(eval $(call CLEAN_template,automake))
351
$(eval $(call CLEAN_template,automake))
352
352
353
353
354
.PHONY: $(PHONY)
354
.PHONY: $(PHONY)
355
355
356
356
357
.PHONY: tst2 tst3
357
.PHONY: tst2 tst3
358
tst2:
358
tst2:
359
	$(call make_stamp,JES)
359
	$(call make_stamp,JES)
360
tst3:
360
tst3:
361
	$(call rm_stamp,JES)
361
	$(call rm_stamp,JES)
362
362
363
363
364
.PHONY: install-note
364
.PHONY: install-note
365
install-note: install-tools
365
install-note: install-tools
366
	@echo
366
	@echo
367
	@echo ====== INSTALLATION NOTE ======
367
	@echo ====== INSTALLATION NOTE ======
368
	@echo Your tools have now been installed at the following prefix:
368
	@echo Your tools have now been installed at the following prefix:
369
	@echo $(PREFIX)
369
	@echo $(PREFIX)
370
	@echo
370
	@echo
371
	@echo Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
371
	@echo Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
372
	@echo export PATH=$(PREFIX)/bin:'$$PATH'
372
	@echo export PATH=$(PREFIX)/bin:'$$PATH'
373
373
374
374
375
.PHONY: install-supp-tools install-supp-tools-force
375
.PHONY: install-supp-tools install-supp-tools-force
376
install-supp-tools: stamps/install-supp-tools
376
install-supp-tools: stamps/install-supp-tools
377
install-supp-tools-force stamps/install-supp-tools: stamps/install-autoconf stamps/install-automake
377
install-supp-tools-force stamps/install-supp-tools: stamps/install-autoconf stamps/install-automake
378
	[ -d stamps ] || mkdir stamps ;
378
	[ -d stamps ] || mkdir stamps ;
379
	touch stamps/install-supp-tools;
379
	touch stamps/install-supp-tools;
380
380
381
.PHONY: clean-supp-tools
381
.PHONY: clean-supp-tools
382
clean-supp-tools: clean-autoconf clean-automake
382
clean-supp-tools: clean-autoconf clean-automake
383
	rm stamps/install-supp-tools;
383
	rm stamps/install-supp-tools;
384
384
385
.PHONY: realclean-supp-tools
385
.PHONY: realclean-supp-tools
386
realclean-supp-tools: realclean-autoconf realclean-automake
386
realclean-supp-tools: realclean-autoconf realclean-automake
387
	rm stamps/install-supp-tools;
387
	rm stamps/install-supp-tools;
388
388
389
389
390
390
391
391
392
392
393
############ SUPP: AUTOMAKE ############
393
############ SUPP: AUTOMAKE ############
394
394
395
##.PHONY: download-automake download-automake-force
395
##.PHONY: download-automake download-automake-force
396
##download-automake: downloads/$(AUTOMAKE_ARCHIVE)
396
##download-automake: downloads/$(AUTOMAKE_ARCHIVE)
397
##download-automake-force downloads/$(AUTOMAKE_ARCHIVE):
397
##download-automake-force downloads/$(AUTOMAKE_ARCHIVE):
398
##	[ -d downloads ] || mkdir downloads ;
398
##	[ -d downloads ] || mkdir downloads ;
399
##	cd downloads && curl -LO $(AUTOMAKE_URL)
399
##	cd downloads && curl -LO $(AUTOMAKE_URL)
400
400
401
##.PHONY: extract-automake extract-automake-force
401
##.PHONY: extract-automake extract-automake-force
402
##extract-automake: stamps/extract-automake
402
##extract-automake: stamps/extract-automake
403
##extract-automake-force stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
403
##extract-automake-force stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
404
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
404
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
405
##	[ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
405
##	[ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
406
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
406
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
407
##	tar -jxf $< ;
407
##	tar -jxf $< ;
408
##	[ -d stamps ] || mkdir stamps ;
408
##	[ -d stamps ] || mkdir stamps ;
409
##	touch stamps/extract-automake;
409
##	touch stamps/extract-automake;
410
410
411
##.PHONY: build-automake build-automake-force
411
##.PHONY: build-automake build-automake-force
412
##build-automake: stamps/build-automake
412
##build-automake: stamps/build-automake
413
##build-automake-force stamps/build-automake: stamps/extract-automake stamps/install-autoconf
413
##build-automake-force stamps/build-automake: stamps/extract-automake stamps/install-autoconf
414
##	mkdir -p build/automake && cd build/automake && \
414
##	mkdir -p build/automake && cd build/automake && \
415
##	../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
415
##	../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
416
##	$(MAKE) -j$(PROCS)
416
##	$(MAKE) -j$(PROCS)
417
##	[ -d stamps ] || mkdir stamps
417
##	[ -d stamps ] || mkdir stamps
418
##	touch stamps/build-automake;
418
##	touch stamps/build-automake;
419
419
420
##.PHONY: install-automake install-automake-force
420
##.PHONY: install-automake install-automake-force
421
##install-automake: stamps/install-automake
421
##install-automake: stamps/install-automake
422
##install-automake-force stamps/install-automake: stamps/build-automake
422
##install-automake-force stamps/install-automake: stamps/build-automake
423
##	cd build/automake && \
423
##	cd build/automake && \
424
##	$(MAKE) install
424
##	$(MAKE) install
425
##	[ -d stamps ] || mkdir stamps
425
##	[ -d stamps ] || mkdir stamps
426
##	touch stamps/install-automake;
426
##	touch stamps/install-automake;
427
427
428
##.PHONY: clean-automake
428
##.PHONY: clean-automake
429
##clean-automake:
429
##clean-automake:
430
##	rm -rf build/automake stamps/*-automake automake-*
430
##	rm -rf build/automake stamps/*-automake automake-*
431
431
432
##.PHONY: realclean-automake
432
##.PHONY: realclean-automake
433
##realclean-automake: clean-automake
433
##realclean-automake: clean-automake
434
##	rm downloads/$(AUTOMAKE_ARCHIVE)
434
##	rm downloads/$(AUTOMAKE_ARCHIVE)
435
435
436
436
437
############# AVR32 PATCHES ############
437
############# AVR32 PATCHES ############
438
438
439
.PHONY: download-avr32patches download-avr32patches-force
439
.PHONY: download-avr32patches download-avr32patches-force
440
download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
440
download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
441
download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
441
download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
442
	cd downloads && curl -LO $(AVR32PATCHES_URL)
442
	cd downloads && curl -LO $(AVR32PATCHES_URL)
443
443
444
.PHONY: extract-avr32patches extract-avr32patches-force
444
.PHONY: extract-avr32patches extract-avr32patches-force
445
extract-avr32patches: stamps/extract-avr32patches
445
extract-avr32patches: stamps/extract-avr32patches
446
extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
446
extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
447
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
447
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
448
	[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
448
	[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
449
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
449
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
450
	unzip -o $<
450
	unzip -o $<
451
	[ -d stamps ] || mkdir stamps
451
	[ -d stamps ] || mkdir stamps
452
	touch stamps/extract-avr32patches;
452
	touch stamps/extract-avr32patches;
453
453
454
.PHONY: clean-avr32patches
454
.PHONY: clean-avr32patches
455
clean-avr32patches:
455
clean-avr32patches:
456
	rm -rf stamps/*-avr32patches source
456
	rm -rf stamps/*-avr32patches source
457
457
458
.PHONY: realclean-avr32patches
458
.PHONY: realclean-avr32patches
459
realclean-avr32patches: clean-avr32patches
459
realclean-avr32patches: clean-avr32patches
460
	rm downloads/$(AVR32PATCHES_ARCHIVE)
460
	rm downloads/$(AVR32PATCHES_ARCHIVE)
461
461
462
462
463
############# AVR32 HEADERS ############
463
############# AVR32 HEADERS ############
464
464
465
.PHONY: download-avr32headers download-avr32headers-force
465
.PHONY: download-avr32headers download-avr32headers-force
466
download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
466
download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
467
download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
467
download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
468
	cd downloads && curl -LO $(AVR32HEADERS_URL)
468
	cd downloads && curl -LO $(AVR32HEADERS_URL)
469
469
470
.PHONY: install-headers install-headers-force
470
.PHONY: install-headers install-headers-force
471
install-headers: stamps/install-headers
471
install-headers: stamps/install-headers
472
install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
472
install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
473
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
473
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
474
	[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
474
	[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
475
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
475
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
476
	unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
476
	unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
477
	[ -d stamps ] || mkdir stamps
477
	[ -d stamps ] || mkdir stamps
478
	touch stamps/install-headers;
478
	touch stamps/install-headers;
479
479
480
.PHONY: clean-headers
480
.PHONY: clean-headers
481
clean-headers:
481
clean-headers:
482
	rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
482
	rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
483
483
484
.PHONY: realclean-headers
484
.PHONY: realclean-headers
485
realclean-headers: clean-headers
485
realclean-headers: clean-headers
486
	rm downloads/$(AVR32HEADERS_ARCHIVE)
486
	rm downloads/$(AVR32HEADERS_ARCHIVE)
487
487
488
488
489
################ NEWLIB ################
489
################ NEWLIB ################
490
490
491
.PHONY: download-newlib download-newlib-force
491
.PHONY: download-newlib download-newlib-force
492
download-newlib: downloads/$(NEWLIB_ARCHIVE)
492
download-newlib: downloads/$(NEWLIB_ARCHIVE)
493
download-newlib-force downloads/$(NEWLIB_ARCHIVE):
493
download-newlib-force downloads/$(NEWLIB_ARCHIVE):
494
	[ -d downloads ] || mkdir downloads ;
494
	[ -d downloads ] || mkdir downloads ;
495
	cd downloads && curl -LO $(NEWLIB_URL)
495
	cd downloads && curl -LO $(NEWLIB_URL)
496
496
497
.PHONY: extract-newlib extract-newlib-force
497
.PHONY: extract-newlib extract-newlib-force
498
extract-newlib: stamps/extract-newlib
498
extract-newlib: stamps/extract-newlib
499
extract-newlib-force stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
499
extract-newlib-force stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
500
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
500
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
501
	[ "$$t1" = "$(NEWLIB_MD5)" ] || \
501
	[ "$$t1" = "$(NEWLIB_MD5)" ] || \
502
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
502
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
503
	tar -xf $<
503
	tar -xf $<
504
	[ -d stamps ] || mkdir stamps
504
	[ -d stamps ] || mkdir stamps
505
	touch stamps/extract-newlib;
505
	touch stamps/extract-newlib;
506
506
507
507
508
.PHONY: patch-newlib patch-newlib-force
508
.PHONY: patch-newlib patch-newlib-force
509
patch-newlib: stamps/patch-newlib
509
patch-newlib: stamps/patch-newlib
510
patch-newlib-force stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
510
patch-newlib-force stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
511
	pushd newlib-$(NEWLIB_VERSION) ; \
511
	pushd newlib-$(NEWLIB_VERSION) ; \
512
	for f in ../source/avr32/newlib/*.patch; do \
512
	for f in ../source/avr32/newlib/*.patch; do \
513
	patch -N -p0 <$${f} ; \
513
	patch -N -p0 <$${f} ; \
514
	done ; \
514
	done ; \
515
	popd ;
515
	popd ;
516
	[ -d stamps ] || mkdir stamps
516
	[ -d stamps ] || mkdir stamps
517
	touch stamps/patch-newlib;
517
	touch stamps/patch-newlib;
518
518
519
.PHONY: regen-newlib regen-newlib-force
519
.PHONY: regen-newlib regen-newlib-force
520
regen-newlib: stamps/regen-newlib
520
regen-newlib: stamps/regen-newlib
521
regen-newlib-force stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
521
regen-newlib-force stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
522
	pushd newlib-$(NEWLIB_VERSION) ; \
522
	pushd newlib-$(NEWLIB_VERSION) ; \
523
	"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
523
	"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
524
	for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
524
	for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
525
	  pushd $$dir ; \
525
	  pushd $$dir ; \
526
	  "$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
526
	  "$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
527
	  "$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake"; \
527
	  "$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake"; \
528
	  popd ; \
528
	  popd ; \
529
	done; \
529
	done; \
530
	popd;
530
	popd;
531
	[ -d stamps ] || mkdir stamps
531
	[ -d stamps ] || mkdir stamps
532
	touch stamps/regen-newlib;
532
	touch stamps/regen-newlib;
533
533
534
NEWLIB_FLAGS="-ffunction-sections -fdata-sections	\
534
NEWLIB_FLAGS="-ffunction-sections -fdata-sections	\
535
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os	\
535
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os	\
536
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128	\
536
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128	\
537
-DSMALL_MEMORY"
537
-DSMALL_MEMORY"
538
538
539
.PHONY: build-newlib build-newlib-force
539
.PHONY: build-newlib build-newlib-force
540
build-newlib: stamps/build-newlib
540
build-newlib: stamps/build-newlib
541
build-newlib-force stamps/build-newlib: stamps/regen-newlib stamps/install-binutils stamps/install-gcc
541
build-newlib-force stamps/build-newlib: stamps/regen-newlib stamps/install-binutils stamps/install-gcc
542
	mkdir -p build/newlib && cd build/newlib && \
542
	mkdir -p build/newlib && cd build/newlib && \
543
	pushd ../../newlib-$(NEWLIB_VERSION) ; \
543
	pushd ../../newlib-$(NEWLIB_VERSION) ; \
544
	make clean ; \
544
	make clean ; \
545
	popd ; \
545
	popd ; \
546
	../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX)	\
546
	../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX)	\
547
	--with-build-time-tools=$(PREFIX)				\
547
	--with-build-time-tools=$(PREFIX)				\
548
	--target=$(TARGET) --disable-newlib-supplied-syscalls		\
548
	--target=$(TARGET) --disable-newlib-supplied-syscalls		\
549
	--disable-libgloss --disable-nls --disable-shared		\
549
	--disable-libgloss --disable-nls --disable-shared		\
550
	--enable-newlib-io-long-long --enable-newlib-io-long-double	\
550
	--enable-newlib-io-long-long --enable-newlib-io-long-double	\
551
	--enable-target-optspace --enable-newlib-io-pos-args		\
551
	--enable-target-optspace --enable-newlib-io-pos-args		\
552
	--enable-newlib-reent-small  && \
552
	--enable-newlib-reent-small  && \
553
	$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
553
	$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
554
	[ -d stamps ] || mkdir stamps
554
	[ -d stamps ] || mkdir stamps
555
	touch stamps/build-newlib;
555
	touch stamps/build-newlib;
556
556
557
.PHONY: install-newlib install-newlib-force
557
.PHONY: install-newlib install-newlib-force
558
install-newlib: stamps/install-newlib
558
install-newlib: stamps/install-newlib
559
install-newlib-force stamps/install-newlib: stamps/build-newlib
559
install-newlib-force stamps/install-newlib: stamps/build-newlib
560
	cd build/newlib && \
560
	cd build/newlib && \
561
	$(MAKE) install
561
	$(MAKE) install
562
	[ -d stamps ] || mkdir stamps
562
	[ -d stamps ] || mkdir stamps
563
	touch stamps/install-newlib;
563
	touch stamps/install-newlib;
564
564
565
.PHONY: clean-newlib
565
.PHONY: clean-newlib
566
clean-newlib:
566
clean-newlib:
567
	rm -rf build/newlib stamps/*-newlib newlib-*
567
	rm -rf build/newlib stamps/*-newlib newlib-*
568
568
569
.PHONY: realclean-newlib
569
.PHONY: realclean-newlib
570
realclean-newlib: clean-newlib
570
realclean-newlib: clean-newlib
571
	rm downloads/$(NEWLIB_ARCHIVE)
571
	rm downloads/$(NEWLIB_ARCHIVE)
572
572
573
573
574
################ BINUTILS ################
574
################ BINUTILS ################
575
575
576
.PHONY: download-binutils download-binutils-force
576
.PHONY: download-binutils download-binutils-force
577
download-binutils: downloads/$(BINUTILS_ARCHIVE)
577
download-binutils: downloads/$(BINUTILS_ARCHIVE)
578
download-binutils-force downloads/$(BINUTILS_ARCHIVE):
578
download-binutils-force downloads/$(BINUTILS_ARCHIVE):
579
	[ -d downloads ] || mkdir downloads ;
579
	[ -d downloads ] || mkdir downloads ;
580
	cd downloads && curl -LO $(BINUTILS_URL)
580
	cd downloads && curl -LO $(BINUTILS_URL)
581
581
582
.PHONY: extract-binutils extract-binutils-force
582
.PHONY: extract-binutils extract-binutils-force
583
extract-binutils: stamps/extract-binutils
583
extract-binutils: stamps/extract-binutils
584
extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
584
extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
585
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
585
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
586
	[ "$$t1" = "$(BINUTILS_MD5)" ] || \
586
	[ "$$t1" = "$(BINUTILS_MD5)" ] || \
587
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
587
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
588
	tar -jxf $< ;
588
	tar -jxf $< ;
589
	[ -d stamps ] || mkdir stamps ;
589
	[ -d stamps ] || mkdir stamps ;
590
	touch stamps/extract-binutils;
590
	touch stamps/extract-binutils;
591
591
592
.PHONY: patch-binutils patch-binutils-force
592
.PHONY: patch-binutils patch-binutils-force
593
patch-binutils: stamps/patch-binutils
593
patch-binutils: stamps/patch-binutils
594
patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
594
patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
595
	pushd binutils-$(BINUTILS_VERSION) ; \
595
	pushd binutils-$(BINUTILS_VERSION) ; \
596
	for f in ../source/avr32/binutils/*.patch; do \
596
	for f in ../source/avr32/binutils/*.patch; do \
597
	patch -N -p0 <$${f} ; \
597
	patch -N -p0 <$${f} ; \
598
	done ; \
598
	done ; \
599
	popd ; \
599
	popd ; \
600
	[ -d stamps ] || mkdir stamps
600
	[ -d stamps ] || mkdir stamps
601
	touch stamps/patch-binutils;
601
	touch stamps/patch-binutils;
602
602
603
.PHONY: regen-binutils regen-binutils-force
603
.PHONY: regen-binutils regen-binutils-force
604
regen-binutils: stamps/regen-binutils
604
regen-binutils: stamps/regen-binutils
605
regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
605
regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
606
	pushd binutils-$(BINUTILS_VERSION) ; \
606
	pushd binutils-$(BINUTILS_VERSION) ; \
607
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
607
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
608
	"$(SUPP_PREFIX)/bin/autoconf" ; \
608
	"$(SUPP_PREFIX)/bin/autoconf" ; \
609
	"$(SUPP_PREFIX)/bin/automake" ; \
609
	"$(SUPP_PREFIX)/bin/automake" ; \
610
	"$(SUPP_PREFIX)/bin/autoheader" ; \
610
	"$(SUPP_PREFIX)/bin/autoheader" ; \
611
	for dir in bfd opcodes binutils gas ld; do \
611
	for dir in bfd opcodes binutils gas ld; do \
612
	  pushd $$dir ; \
612
	  pushd $$dir ; \
613
	  "$(SUPP_PREFIX)/bin/autoconf"; \
613
	  "$(SUPP_PREFIX)/bin/autoconf"; \
614
	  "$(SUPP_PREFIX)/bin/automake"; \
614
	  "$(SUPP_PREFIX)/bin/automake"; \
615
	  "$(SUPP_PREFIX)/bin/autoheader"; \
615
	  "$(SUPP_PREFIX)/bin/autoheader"; \
616
	  popd ; \
616
	  popd ; \
617
	done; \
617
	done; \
618
	popd; \
618
	popd; \
619
	[ -d stamps ] || mkdir stamps ;
619
	[ -d stamps ] || mkdir stamps ;
620
	touch stamps/regen-binutils;
620
	touch stamps/regen-binutils;
621
621
622
.PHONY: build-binutils build-binutils-force
622
.PHONY: build-binutils build-binutils-force
623
build-binutils: stamps/build-binutils
623
build-binutils: stamps/build-binutils
624
build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
624
build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
625
	cd binutils-$(BINUTILS_VERSION) ; \
625
	cd binutils-$(BINUTILS_VERSION) ; \
626
	./configure   --enable-maintainer-mode		\
626
	./configure   --enable-maintainer-mode		\
627
	--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls		\
627
	--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls		\
628
	--disable-shared --disable-werror				\
628
	--disable-shared --disable-werror				\
629
	--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) &&	\
629
	--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) &&	\
630
	$(MAKE) all-bfd TARGET-bfd=headers; \
630
	$(MAKE) all-bfd TARGET-bfd=headers; \
631
	rm bfd/Makefile; \
631
	rm bfd/Makefile; \
632
	make configure-bfd; \
632
	make configure-bfd; \
633
	$(MAKE)
633
	$(MAKE)
634
	[ -d stamps ] || mkdir stamps ;
634
	[ -d stamps ] || mkdir stamps ;
635
	touch stamps/build-binutils;
635
	touch stamps/build-binutils;
636
636
637
.PHONY: install-binutils install-binutils-force
637
.PHONY: install-binutils install-binutils-force
638
install-binutils: stamps/install-binutils
638
install-binutils: stamps/install-binutils
639
install-binutils-force stamps/install-binutils: stamps/build-binutils
639
install-binutils-force stamps/install-binutils: stamps/build-binutils
640
	cd binutils-$(BINUTILS_VERSION) && \
640
	cd binutils-$(BINUTILS_VERSION) && \
641
	$(MAKE) installdirs install-host install-target
641
	$(MAKE) installdirs install-host install-target
642
	[ -d stamps ] || mkdir stamps ;
642
	[ -d stamps ] || mkdir stamps ;
643
	touch stamps/install-binutils;
643
	touch stamps/install-binutils;
644
644
645
645
646
.PHONY: clean-binutils
646
.PHONY: clean-binutils
647
clean-binutils:
647
clean-binutils:
648
	rm -rf build/binutils stamps/*-binutils binutils-*
648
	rm -rf build/binutils stamps/*-binutils binutils-*
649
649
650
.PHONY: realclean-binutils
650
.PHONY: realclean-binutils
651
realclean-binutils: clean-binutils
651
realclean-binutils: clean-binutils
652
	rm downloads/$(BINUTILS_ARCHIVE)
652
	rm downloads/$(BINUTILS_ARCHIVE)
653
653
654
654
655
########## DFU PROGRAMMER ###########
655
########## DFU PROGRAMMER ###########
656
656
657
.PHONY: download-dfu download-dfu-force
657
.PHONY: download-dfu download-dfu-force
658
download-dfu: downloads/$(DFU_ARCHIVE)
658
download-dfu: downloads/$(DFU_ARCHIVE)
659
download-dfu-force downloads/$(DFU_ARCHIVE):
659
download-dfu-force downloads/$(DFU_ARCHIVE):
660
	[ -d downloads ] || mkdir downloads ;
660
	[ -d downloads ] || mkdir downloads ;
661
	cd downloads && curl -LO $(DFU_URL)
661
	cd downloads && curl -LO $(DFU_URL)
662
662
663
.PHONY: extract-dfu extract-dfu-force
663
.PHONY: extract-dfu extract-dfu-force
664
extract-dfu: stamps/extract-dfu
664
extract-dfu: stamps/extract-dfu
665
extract-dfu-force stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
665
extract-dfu-force stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
666
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
666
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
667
	[ "$$t1" = "$(DFU_MD5)" ] || \
667
	[ "$$t1" = "$(DFU_MD5)" ] || \
668
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
668
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
669
	tar -zxf $< ;
669
	tar -zxf $< ;
670
	[ -d stamps ] || mkdir stamps ;
670
	[ -d stamps ] || mkdir stamps ;
671
	touch stamps/extract-dfu;
671
	touch stamps/extract-dfu;
672
672
673
.PHONY: build-dfu build-dfu-force
673
.PHONY: build-dfu build-dfu-force
674
build-dfu: stamps/build-dfu
674
build-dfu: stamps/build-dfu
675
build-dfu-force stamps/build-dfu: stamps/extract-dfu
675
build-dfu-force stamps/build-dfu: stamps/extract-dfu
676
	mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
676
	mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
677
	../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
677
	../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
678
	$(MAKE) -j$(PROCS)
678
	$(MAKE) -j$(PROCS)
679
	[ -d stamps ] || mkdir stamps
679
	[ -d stamps ] || mkdir stamps
680
	touch stamps/build-dfu;
680
	touch stamps/build-dfu;
681
681
682
.PHONY: install-dfu install-dfu-force
682
.PHONY: install-dfu install-dfu-force
683
install-dfu: stamps/install-dfu
683
install-dfu: stamps/install-dfu
684
install-dfu-force stamps/install-dfu: stamps/build-dfu
684
install-dfu-force stamps/install-dfu: stamps/build-dfu
685
	cd build/dfu-programmer && \
685
	cd build/dfu-programmer && \
686
	$(MAKE) install
686
	$(MAKE) install
687
	[ -d stamps ] || mkdir stamps
687
	[ -d stamps ] || mkdir stamps
688
	touch stamps/install-dfu;
688
	touch stamps/install-dfu;
689
689
690
.PHONY: clean-dfu
690
.PHONY: clean-dfu
691
clean-dfu:
691
clean-dfu:
692
	rm -rf build/dfu stamps/*-dfu dfu-*
692
	rm -rf build/dfu stamps/*-dfu dfu-*
693
693
694
.PHONY: realclean-dfu
694
.PHONY: realclean-dfu
695
realclean-dfu: clean-dfu
695
realclean-dfu: clean-dfu
696
	rm downloads/$(DFU_ARCHIVE)
696
	rm downloads/$(DFU_ARCHIVE)
697
697
698
698
699
################ Bootstrap GCC ################
699
################ Bootstrap GCC ################
700
700
701
.PHONY: download-gcc download-gcc-force
701
.PHONY: download-gcc download-gcc-force
702
download-gcc: downloads/$(GCC_ARCHIVE)
702
download-gcc: downloads/$(GCC_ARCHIVE)
703
download-gcc-force downloads/$(GCC_ARCHIVE):
703
download-gcc-force downloads/$(GCC_ARCHIVE):
704
	[ -d downloads ] || mkdir downloads ;
704
	[ -d downloads ] || mkdir downloads ;
705
	cd downloads && curl -LO $(GCC_URL)
705
	cd downloads && curl -LO $(GCC_URL)
706
706
707
.PHONY: extract-gcc extract-gcc-force
707
.PHONY: extract-gcc extract-gcc-force
708
extract-gcc: stamps/extract-gcc
708
extract-gcc: stamps/extract-gcc
709
extract-gcc-force stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
709
extract-gcc-force stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
710
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
710
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
711
	[ "$$t1" = "$(GCC_MD5)" ] || \
711
	[ "$$t1" = "$(GCC_MD5)" ] || \
712
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
712
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
713
	tar -jxf $< ;
713
	tar -jxf $< ;
714
	[ -d stamps ] || mkdir stamps ;
714
	[ -d stamps ] || mkdir stamps ;
715
	touch stamps/extract-gcc;
715
	touch stamps/extract-gcc;
716
716
717
.PHONY: patch-gcc patch-gcc-force
717
.PHONY: patch-gcc patch-gcc-force
718
patch-gcc: stamps/patch-gcc
718
patch-gcc: stamps/patch-gcc
719
patch-gcc-force stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
719
patch-gcc-force stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
720
	pushd gcc-$(GCC_VERSION) ; \
720
	pushd gcc-$(GCC_VERSION) ; \
721
	for f in ../source/avr32/gcc/*.patch; do \
721
	for f in ../source/avr32/gcc/*.patch; do \
722
	patch -N -p0 <$${f} ; \
722
	patch -N -p0 <$${f} ; \
723
	done ; \
723
	done ; \
724
	popd ;
724
	popd ;
725
	[ -d stamps ] || mkdir stamps
725
	[ -d stamps ] || mkdir stamps
726
	touch stamps/patch-gcc;
726
	touch stamps/patch-gcc;
727
727
728
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections			\
728
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections			\
729
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g	\
729
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g	\
730
-Os -fno-unroll-loops"
730
-Os -fno-unroll-loops"
731
731
732
.PHONY: build-gcc build-gcc-force
732
.PHONY: build-gcc build-gcc-force
733
build-gcc: stamps/build-gcc
733
build-gcc: stamps/build-gcc
734
build-gcc-force stamps/build-gcc: stamps/install-binutils stamps/patch-gcc
734
build-gcc-force stamps/build-gcc: stamps/install-binutils stamps/patch-gcc
735
	mkdir -p build/gcc && cd build/gcc && \
735
	mkdir -p build/gcc && cd build/gcc && \
736
	pushd ../../gcc-$(GCC_VERSION) ; \
736
	pushd ../../gcc-$(GCC_VERSION) ; \
737
	make clean ; \
737
	make clean ; \
738
	popd ; \
738
	popd ; \
739
	../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)"		\
739
	../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)"		\
740
	--target=$(TARGET) --enable-languages="c" --with-gnu-ld		\
740
	--target=$(TARGET) --enable-languages="c" --with-gnu-ld		\
741
	--with-gnu-as --with-newlib --disable-nls --disable-libssp	\
741
	--with-gnu-as --with-newlib --disable-nls --disable-libssp	\
742
	--with-dwarf2 --enable-sjlj-exceptions				\
742
	--with-dwarf2 --enable-sjlj-exceptions				\
743
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch	\
743
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch	\
744
	--disable-shared						\
744
	--disable-shared						\
745
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
745
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
746
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET)				\
746
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET)				\
747
	--with-sysroot="$(PREFIX)/$(TARGET)"				\
747
	--with-sysroot="$(PREFIX)/$(TARGET)"				\
748
	--with-build-sysroot="$(PREFIX)/$(TARGET)"			\
748
	--with-build-sysroot="$(PREFIX)/$(TARGET)"			\
749
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
749
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
750
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)				\
750
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)				\
751
	LDFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
751
	LDFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
752
	CPPFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
752
	CPPFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
753
	--with-bugurl=$(BUG_URL) \
753
	--with-bugurl=$(BUG_URL) \
754
	--with-pkgversion=$(PKG_VERSION) && \
754
	--with-pkgversion=$(PKG_VERSION) && \
755
	$(MAKE) -j$(PROCS)
755
	$(MAKE) -j$(PROCS)
756
	[ -d stamps ] || mkdir stamps
756
	[ -d stamps ] || mkdir stamps
757
	touch stamps/build-gcc;
757
	touch stamps/build-gcc;
758
758
759
.PHONY: install-gcc install-gcc-force
759
.PHONY: install-gcc install-gcc-force
760
install-gcc: stamps/install-gcc
760
install-gcc: stamps/install-gcc
761
install-gcc-force stamps/install-gcc: stamps/build-gcc
761
install-gcc-force stamps/install-gcc: stamps/build-gcc
762
	cd build/gcc && \
762
	cd build/gcc && \
763
	$(MAKE) installdirs install-target && \
763
	$(MAKE) installdirs install-target && \
764
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
764
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
765
	[ -d stamps ] || mkdir stamps
765
	[ -d stamps ] || mkdir stamps
766
	touch stamps/install-gcc;
766
	touch stamps/install-gcc;
767
767
768
.PHONY: clean-gcc
768
.PHONY: clean-gcc
769
clean-gcc:
769
clean-gcc:
770
	rm -rf build/gcc stamps/*-gcc gcc-*
770
	rm -rf build/gcc stamps/*-gcc gcc-*
771
771
772
.PHONY: realclean-gcc
772
.PHONY: realclean-gcc
773
realclean-gcc: clean-gcc
773
realclean-gcc: clean-gcc
774
	rm downloads/$(GCC_ARCHIVE)
774
	rm downloads/$(GCC_ARCHIVE)
775
775
776
776
777
################ Final GCC ################
777
################ Final GCC ################
778
778
779
.PHONY: build-final-gcc build-final-gcc-force
779
.PHONY: build-final-gcc build-final-gcc-force
780
build-final-gcc: stamps/build-final-gcc
780
build-final-gcc: stamps/build-final-gcc
781
build-final-gcc-force stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/patch-gcc
781
build-final-gcc-force stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/patch-gcc
782
	mkdir -p build/final-gcc && cd build/final-gcc && \
782
	mkdir -p build/final-gcc && cd build/final-gcc && \
783
	pushd ../../gcc-$(GCC_VERSION) ; \
783
	pushd ../../gcc-$(GCC_VERSION) ; \
784
	make clean ; \
784
	make clean ; \
785
	popd ; \
785
	popd ; \
786
	../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
786
	../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
787
	--target=$(TARGET) $(DEPENDENCIES) --enable-languages="c,c++" --with-gnu-ld \
787
	--target=$(TARGET) $(DEPENDENCIES) --enable-languages="c,c++" --with-gnu-ld \
788
	--with-gnu-as --with-newlib --disable-nls --disable-libssp \
788
	--with-gnu-as --with-newlib --disable-nls --disable-libssp \
789
	--with-dwarf2 --enable-sjlj-exceptions \
789
	--with-dwarf2 --enable-sjlj-exceptions \
790
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch \
790
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch \
791
	--disable-shared --enable-__cxa_atexit \
791
	--disable-shared --enable-__cxa_atexit \
792
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
792
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
793
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET) \
793
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET) \
794
	--with-sysroot=$(PREFIX)/$(TARGET) \
794
	--with-sysroot=$(PREFIX)/$(TARGET) \
795
	--with-build-sysroot=$(PREFIX)/$(TARGET) \
795
	--with-build-sysroot=$(PREFIX)/$(TARGET) \
796
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
796
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
797
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) \
797
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) \
798
	LDFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
798
	LDFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
799
	CPPFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
799
	CPPFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
800
	--with-bugurl=$(BUG_URL) \
800
	--with-bugurl=$(BUG_URL) \
801
	--with-pkgversion=$(PKG_VERSION) && \
801
	--with-pkgversion=$(PKG_VERSION) && \
802
	$(MAKE) -j$(PROCS)
802
	$(MAKE) -j$(PROCS)
803
	[ -d stamps ] || mkdir stamps
803
	[ -d stamps ] || mkdir stamps
804
	touch stamps/build-final-gcc;
804
	touch stamps/build-final-gcc;
805
805
806
.PHONY: install-final-gcc install-final-gcc-force
806
.PHONY: install-final-gcc install-final-gcc-force
807
install-final-gcc: stamps/install-final-gcc
807
install-final-gcc: stamps/install-final-gcc
808
install-final-gcc-force stamps/install-final-gcc: stamps/build-final-gcc
808
install-final-gcc-force stamps/install-final-gcc: stamps/build-final-gcc
809
	cd build/final-gcc && \
809
	cd build/final-gcc && \
810
	$(MAKE) installdirs install-target && \
810
	$(MAKE) installdirs install-target && \
811
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
811
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
812
	[ -d stamps ] || mkdir stamps
812
	[ -d stamps ] || mkdir stamps
813
	touch stamps/install-final-gcc;
813
	touch stamps/install-final-gcc;
814
814
815
.PHONY: clean-final-gcc
815
.PHONY: clean-final-gcc
816
clean-final-gcc: clean-gcc
816
clean-final-gcc: clean-gcc
817
	rm -rf build/final-gcc stamps/*-final-gcc
817
	rm -rf build/final-gcc stamps/*-final-gcc
818
818
819
.PHONY: realclean-final-gcc
819
.PHONY: realclean-final-gcc
820
realclean-final-gcc: realclean-gcc
820
realclean-final-gcc: realclean-gcc
821
821
822
822
823
########## GDB ###########
823
########## GDB ###########
824
824
825
.PHONY: download-gdb download-gdb-force
825
.PHONY: download-gdb download-gdb-force
826
download-gdb: downloads/$(GDB_ARCHIVE)
826
download-gdb: downloads/$(GDB_ARCHIVE)
827
download-gdb-force downloads/$(GDB_ARCHIVE):
827
download-gdb-force downloads/$(GDB_ARCHIVE):
828
	[ -d downloads ] || mkdir downloads ;
828
	[ -d downloads ] || mkdir downloads ;
829
	cd downloads && curl -LO $(GDB_URL)
829
	cd downloads && curl -LO $(GDB_URL)
830
830
831
.PHONY: extract-gdb extract-gdb-force
831
.PHONY: extract-gdb extract-gdb-force
832
extract-gdb: stamps/extract-gdb
832
extract-gdb: stamps/extract-gdb
833
extract-gdb-force stamps/extract-gdb: downloads/$(GDB_ARCHIVE)
833
extract-gdb-force stamps/extract-gdb: downloads/$(GDB_ARCHIVE)
834
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
834
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
835
	[ "$$t1" = "$(GDB_MD5)" ] || \
835
	[ "$$t1" = "$(GDB_MD5)" ] || \
836
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
836
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
837
	tar -jxf $< ;
837
	tar -jxf $< ;
838
	[ -d stamps ] || mkdir stamps ;
838
	[ -d stamps ] || mkdir stamps ;
839
	touch stamps/extract-gdb;
839
	touch stamps/extract-gdb;
840
840
841
.PHONY: patch-gdb patch-gdb-force
841
.PHONY: patch-gdb patch-gdb-force
842
patch-gdb: stamps/patch-gdb
842
patch-gdb: stamps/patch-gdb
843
patch-gdb-force stamps/patch-gdb: stamps/extract-gdb stamps/extract-avr32patches
843
patch-gdb-force stamps/patch-gdb: stamps/extract-gdb stamps/extract-avr32patches
844
	pushd gdb-$(GDB_VERSION) ; \
844
	pushd gdb-$(GDB_VERSION) ; \
845
	for f in ../source/avr32/gdb/*.patch; do \
845
	for f in ../source/avr32/gdb/*.patch; do \
846
	patch -N -p0 <$${f} ; \
846
	patch -N -p0 <$${f} ; \
847
	done ; \
847
	done ; \
848
	popd ; \
848
	popd ; \
849
	[ -d stamps ] || mkdir stamps
849
	[ -d stamps ] || mkdir stamps
850
	touch stamps/patch-gdb;
850
	touch stamps/patch-gdb;
851
851
852
.PHONY: regen-gdb regen-gdb-force
852
.PHONY: regen-gdb regen-gdb-force
853
regen-gdb: stamps/regen-gdb
853
regen-gdb: stamps/regen-gdb
854
regen-gdb-force stamps/regen-gdb: stamps/patch-gdb stamps/install-supp-tools
854
regen-gdb-force stamps/regen-gdb: stamps/patch-gdb stamps/install-supp-tools
855
	pushd gdb-$(GDB_VERSION) ; \
855
	pushd gdb-$(GDB_VERSION) ; \
856
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
856
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
857
	"$(SUPP_PREFIX)/bin/autoconf" ; \
857
	"$(SUPP_PREFIX)/bin/autoconf" ; \
858
	"$(SUPP_PREFIX)/bin/automake" ; \
858
	"$(SUPP_PREFIX)/bin/automake" ; \
859
	"$(SUPP_PREFIX)/bin/autoheader" ; \
859
	"$(SUPP_PREFIX)/bin/autoheader" ; \
860
	for dir in bfd opcodes gdb; do \
860
	for dir in bfd opcodes gdb; do \
861
	  pushd $$dir ; \
861
	  pushd $$dir ; \
862
	  echo "JESS 1: $$dir" >&2 ; \
862
	  echo "JESS 1: $$dir" >&2 ; \
863
	  "$(SUPP_PREFIX)/bin/autoconf"; \
863
	  "$(SUPP_PREFIX)/bin/autoconf"; \
864
	  "$(SUPP_PREFIX)/bin/automake"; \
864
	  "$(SUPP_PREFIX)/bin/automake"; \
865
	  "$(SUPP_PREFIX)/bin/autoheader"; \
865
	  "$(SUPP_PREFIX)/bin/autoheader"; \
866
	  echo "JESS 2: $$dir" >&2 ; \
866
	  echo "JESS 2: $$dir" >&2 ; \
867
	  popd ; \
867
	  popd ; \
868
	done; \
868
	done; \
869
	popd; \
869
	popd; \
870
	[ -d stamps ] || mkdir stamps ;
870
	[ -d stamps ] || mkdir stamps ;
871
	touch stamps/regen-gdb;
871
	touch stamps/regen-gdb;
872
872
873
.PHONY: build-gdb build-gdb-force
873
.PHONY: build-gdb build-gdb-force
874
build-gdb: stamps/build-gdb
874
build-gdb: stamps/build-gdb
875
build-gdb-force stamps/build-gdb: stamps/regen-gdb stamps/install-supp-tools
875
build-gdb-force stamps/build-gdb: stamps/regen-gdb stamps/install-supp-tools
876
	echo "JESS 3" >&2 ; \
876
	echo "JESS 3" >&2 ; \
877
	mkdir -p build/gdb && cd build/gdb && \
877
	mkdir -p build/gdb && cd build/gdb && \
878
	../../gdb-$(GDB_VERSION)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
878
	../../gdb-$(GDB_VERSION)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
879
	$(MAKE) -j$(PROCS)
879
	$(MAKE) -j$(PROCS)
880
	$(MAKE) installdirs install-host install-target
880
	$(MAKE) installdirs install-host install-target
881
	[ -d stamps ] || mkdir stamps
881
	[ -d stamps ] || mkdir stamps
882
	touch stamps/build-gdb;
882
	touch stamps/build-gdb;
883
883
884
.PHONY: install-gdb install-gdb-force
884
.PHONY: install-gdb install-gdb-force
885
install-gdb: stamps/install-gdb
885
install-gdb: stamps/install-gdb
886
install-gdb-force stamps/install-gdb: stamps/build-gdb
886
install-gdb-force stamps/install-gdb: stamps/build-gdb
887
	cd build/gdb && \
887
	cd build/gdb && \
888
	$(MAKE) install
888
	$(MAKE) install
889
	[ -d stamps ] || mkdir stamps
889
	[ -d stamps ] || mkdir stamps
890
	touch stamps/install-gdb;
890
	touch stamps/install-gdb;
891
891
892
.PHONY: clean-gdb
892
.PHONY: clean-gdb
893
clean-gdb:
893
clean-gdb:
894
	rm -rf build/gdb stamps/*-gdb gdb-*
894
	rm -rf build/gdb stamps/*-gdb gdb-*
895
895
896
.PHONY: realclean-gdb
896
.PHONY: realclean-gdb
897
realclean-gdb: clean-gdb
897
realclean-gdb: clean-gdb
898
	rm downloads/$(GDB_ARCHIVE)
898
	rm downloads/$(GDB_ARCHIVE)
899
899
900
################ NON-WORKING/NON-ADJUSTED TARGETS ################
900
################ NON-WORKING/NON-ADJUSTED TARGETS ################
901
901
902
902
903
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
903
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
904
	pushd gcc-$(GCC_VERSION)-$(CS_BASE) ; \
904
	pushd gcc-$(GCC_VERSION)-$(CS_BASE) ; \
905
	patch -N -p1 < ../patches/gcc-optsize.patch ; \
905
	patch -N -p1 < ../patches/gcc-optsize.patch ; \
906
	popd ;
906
	popd ;
907
907
908
gmp: gmp-$(CS_BASE)/ sudomode
908
gmp: gmp-$(CS_BASE)/ sudomode
909
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
909
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
910
	pushd ../../gmp-$(CS_BASE) ; \
910
	pushd ../../gmp-$(CS_BASE) ; \
911
	make clean ; \
911
	make clean ; \
912
	popd ; \
912
	popd ; \
913
	sudo -u $(SUDO_USER) ../../gmp-$(CS_BASE)/configure --disable-shared && \
913
	sudo -u $(SUDO_USER) ../../gmp-$(CS_BASE)/configure --disable-shared && \
914
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
914
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
915
	$(MAKE) install
915
	$(MAKE) install
916
916
917
mpc: mpc-$(MPC_VERSION)/ sudomode
917
mpc: mpc-$(MPC_VERSION)/ sudomode
918
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
918
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
919
	pushd ../../mpc-$(MPC_VERSION) ; \
919
	pushd ../../mpc-$(MPC_VERSION) ; \
920
	make clean ; \
920
	make clean ; \
921
	popd ; \
921
	popd ; \
922
	sudo -u $(SUDO_USER) ../../mpc-$(MPC_VERSION)/configure --disable-shared && \
922
	sudo -u $(SUDO_USER) ../../mpc-$(MPC_VERSION)/configure --disable-shared && \
923
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
923
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
924
	$(MAKE) install
924
	$(MAKE) install
925
925
926
mpc-$(MPC_VERSION) : $(LOCAL_BASE)/mpc-$(CS_VERSION).tar.bz2
926
mpc-$(MPC_VERSION) : $(LOCAL_BASE)/mpc-$(CS_VERSION).tar.bz2
927
ifeq ($(USER),root)
927
ifeq ($(USER),root)
928
	sudo -u $(SUDO_USER) tar -jxf $<
928
	sudo -u $(SUDO_USER) tar -jxf $<
929
else
929
else
930
	tar -jxf $<
930
	tar -jxf $<
931
endif
931
endif
932
932
933
mpfr: gmp mpfr-$(CS_BASE)/ sudomode
933
mpfr: gmp mpfr-$(CS_BASE)/ sudomode
934
	sudo -u $(SUDO_USER) mkdir -p build/mpfr && cd build/mpfr && \
934
	sudo -u $(SUDO_USER) mkdir -p build/mpfr && cd build/mpfr && \
935
	pushd ../../mpfr-$(CS_BASE) ; \
935
	pushd ../../mpfr-$(CS_BASE) ; \
936
	make clean ; \
936
	make clean ; \
937
	popd ; \
937
	popd ; \
938
	sudo -u $(SUDO_USER) ../../mpfr-$(CS_BASE)/configure LDFLAGS="-Wl,-search_paths_first" --disable-shared && \
938
	sudo -u $(SUDO_USER) ../../mpfr-$(CS_BASE)/configure LDFLAGS="-Wl,-search_paths_first" --disable-shared && \
939
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
939
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
940
	$(MAKE) install
940
	$(MAKE) install
941
941
942
cross-gdb: gdb-$(CS_BASE)/
942
cross-gdb: gdb-$(CS_BASE)/
943
	mkdir -p build/gdb && cd build/gdb && \
943
	mkdir -p build/gdb && cd build/gdb && \
944
	pushd ../../gdb-$(CS_BASE) ; \
944
	pushd ../../gdb-$(CS_BASE) ; \
945
	make clean ; \
945
	make clean ; \
946
	popd ; \
946
	popd ; \
947
	../../gdb-$(CS_BASE)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
947
	../../gdb-$(CS_BASE)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
948
	$(MAKE) -j$(PROCS) && \
948
	$(MAKE) -j$(PROCS) && \
949
	$(MAKE) installdirs install-host install-target && \
949
	$(MAKE) installdirs install-host install-target && \
950
	mkdir -p "$(PREFIX)/man/man1" && \
950
	mkdir -p "$(PREFIX)/man/man1" && \
951
	cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
951
	cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
952
952
953
.PHONY : clean
953
.PHONY : clean
954
clean:
954
clean:
955
	rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp
955
	rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp