Subversion Repositories avr32-toolchain

Rev

Rev 11 | Rev 13 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11 Rev 12
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
74
74
ifeq ($(strip $(BUG_URL)),)
75
ifeq ($(strip $(BUG_URL)),)
75
BUG_URL = https://github.com/jsnyder/avr32-toolchain
76
BUG_URL = https://github.com/jsnyder/avr32-toolchain
76
endif
77
endif
77
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)"
78
79
79
80
80
#### PRIMARY TOOLCHAIN URLS #####
81
#### PRIMARY TOOLCHAIN URLS #####
81
82
82
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
83
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
83
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)
84
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
85
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
85
86
86
GDB_ARCHIVE = gdb-$(GDB_VERSION_DLOAD).tar.bz2
87
GDB_ARCHIVE = gdb-$(GDB_VERSION_DLOAD).tar.bz2
87
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
88
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
88
GDB_MD5 = 3564f308f3e4d4f2750891bc2ce9b214
89
GDB_MD5 = 3564f308f3e4d4f2750891bc2ce9b214
89
90
90
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
91
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
91
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
92
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
92
BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
93
BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
93
94
94
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
95
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
95
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
96
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
96
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
97
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
97
98
98
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
99
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
99
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)
100
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
101
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
101
102
102
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
103
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
103
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)
104
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
105
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
105
106
106
DFU_ARCHIVE = dfu-programmer-$(DFU_VERSION).tar.gz
107
DFU_ARCHIVE = dfu-programmer-$(DFU_VERSION).tar.gz
107
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)
108
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
109
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
109
110
110
111
111
##### SUPPORT TOOLS VERSIONS / URLS ######
112
##### SUPPORT TOOLS VERSIONS / URLS ######
112
AUTOCONF_VERSION = 2.64
113
AUTOCONF_VERSION = 2.64
113
AUTOMAKE_VERSION = 1.11
114
AUTOMAKE_VERSION = 1.11
114
MPC_VERSION = 0.8.1
115
MPC_VERSION = 0.8.1
115
116
116
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
117
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
117
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
118
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
118
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
119
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
119
120
120
AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2
121
AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2
121
AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE)
122
AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE)
122
AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f
123
AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f
123
124
124
125
125
126
126
.PHONY: install-tools
127
.PHONY: install-tools
127
install-tools: install-binutils install-final-gcc install-newlib install-headers
128
install-tools: install-binutils install-final-gcc install-newlib install-headers
128
129
129
.PHONY: install-cross
130
.PHONY: install-cross
130
install-cross: install-tools install-note
131
install-cross: install-tools install-note
131
132
132
133
133
.PHONY: sudomode
134
.PHONY: sudomode
134
sudomode:
135
sudomode:
135
ifneq ($(USER),root)
136
ifneq ($(USER),root)
136
	@echo Please run this target with sudo!
137
	@echo Please run this target with sudo!
137
	@echo e.g.: sudo make targetname
138
	@echo e.g.: sudo make targetname
138
	@exit 1
139
	@exit 1
139
endif
140
endif
140
141
141
142
142
.PHONY: tst
143
.PHONY: tst
143
tst:
144
tst:
144
	@echo "PREFIX=$(PREFIX)"
145
	@echo "PREFIX=$(PREFIX)"
145
	@echo "PKG_VERSION=$(PKG_VERSION)"
146
	@echo "PKG_VERSION=$(PKG_VERSION)"
146
	@echo "BUG_URL=$(BUG_URL)"
147
	@echo "BUG_URL=$(BUG_URL)"
147
148
148
149
149
############ MACROS for the lazy people ;-) ############
150
############ MACROS for the lazy people ;-) ############
150
151
151
ifeq ($(strip $(MAKEFLAGS)),s)
152
ifeq ($(strip $(MAKEFLAGS)),s)
152
define quiet_text
153
define quiet_text
153
	@echo "$1"
154
	@echo "$1"
154
endef
155
endef
155
else
156
else
156
define quiet_text
157
define quiet_text
157
endef
158
endef
158
endif
159
endif
159
160
160
## remove a stamp
161
## remove a stamp
161
define rm_stamp
162
define rm_stamp
162
	rm -f $(STAMP_DIR)/$(1)
163
	rm -f $(STAMP_DIR)/$(1)
163
endef
164
endef
164
165
-
 
166
## remove all stamps
-
 
167
define rm_stamps
-
 
168
	rm -f $(STAMP_DIR)/*-$(1)
-
 
169
endef
-
 
170
165
## create the stamp directory if not existing and the stamp
171
## create the stamp directory if not existing and the stamp
166
define make_stamp
172
define make_stamp
167
	@[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR)
173
	@[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR)
168
	date > $(STAMP_DIR)/$(1)
174
	date > $(STAMP_DIR)/$(1)
169
endef
175
endef
170
176
171
define GET_MY_VARS
177
define GET_MY_VARS
172
UP_$(1):=$$(shell echo "$(1)" | tr '[a-z]' '[A-Z]')
178
UP_$(1) = $$(shell echo "$(1)" | tr '[a-z]' '[A-Z]')
-
 
179
MY_VERSION = $$($$(UP_$(1))_VERSION)
173
MY_ARCHIVE:=$$($$(UP_$(1))_ARCHIVE)
180
MY_ARCHIVE = $$($$(UP_$(1))_ARCHIVE)
174
MY_URL:=$$($$(UP_$(1))_URL)
181
MY_URL = $$($$(UP_$(1))_URL)
175
MY_MD5:=$$($$(UP_$(1))_MD5)
182
MY_MD5 = $$($$(UP_$(1))_MD5)
176
endef	                         
183
endef	                         
177
184
178
## create the download rule and force download rule
185
## create the download rule and force download rule
179
define DOWNLOAD_template
186
define DOWNLOAD_template
180
$(call GET_MY_VARS,$(1))
187
$(call GET_MY_VARS,$(1))
-
 
188
$(warning $(1) -> $(MY_URL))
-
 
189
$(warning $(1) -> $(MY_URL))
-
 
190
$(warning $(1) -> $(MY_URL))
-
 
191
$(warning $(1) -> $(MY_URL))
-
 
192
$(warning $(1) -> $(MY_URL))
-
 
193
$(warning $(1) -> $(MY_URL))
-
 
194
$(warning $(1) -> $(MY_URL))
-
 
195
$(warning $(1) -> $(MY_URL))
181
download-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE)
196
download-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE)
182
download-$(1)-f $(DOWNLOAD_DIR)/$$(MY_ARCHIVE): $(DOWNLOAD_DIR)
197
download-$(1)-f $(DOWNLOAD_DIR)/$$(MY_ARCHIVE): $(DOWNLOAD_DIR)
183
	cd $(DOWNLOAD_DIR) && curl -LO $$(MY_URL)
198
	cd $(DOWNLOAD_DIR) && curl -LO $$(MY_URL)
-
 
199
-
 
200
download-$(1)-remove:
-
 
201
	rm -f $(DOWNLOAD_DIR)/$$(MY_ARCHIVE)
-
 
202
184
PHONY += download-$(1) download-$(1)-f
203
PHONY += download-$(1) download-$(1)-f download-$(1)-remove
185
endef
204
endef
186
205
187
## extract commands
206
## extract commands
188
EXT_BZ2 := tar -jxf
207
EXT_BZ2 := tar -jxf
189
EXT_TGZ := tar -xf
208
EXT_TGZ := tar -xf
190
EXT_ZIP := unzip -o
209
EXT_ZIP := unzip -o
191
210
192
## create the extract rule and force extract rule
211
## create the extract rule and force extract rule
193
define EXTRACT_template
212
define EXTRACT_template
194
$(call GET_MY_VARS,$(1))
213
$(call GET_MY_VARS,$(1))
195
extract-$(1): $(STAMP_DIR)/extract-$(1)
214
extract-$(1): $(STAMP_DIR)/extract-$(1)
196
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE)
215
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$(MY_ARCHIVE)
197
	@(rm -rf autoconf-*; \
216
	@(rm -rf $(1)-*; \
198
	t1=`openssl md5 $$< | cut -f 2 -d " " -` && \
217
	t1=`openssl md5 $$< | cut -f 2 -d " " -` && \
199
	[ "$$$$t1" = "$$(MY_MD5)" ] || \
218
	[ "$$$$t1" = "$$(MY_MD5)" ] || \
200
	( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
219
	( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
201
	$(call quiet_text,"Extracting $$(MY_ARCHIVE)")
220
	$(call quiet_text,"Extracting $$(MY_ARCHIVE)")
202
	$($(2)) $$<
221
	$($(2)) $$<
203
	$(call make_stamp,extract-$(1))
222
	$(call make_stamp,extract-$(1))
-
 
223
-
 
224
extract-$(1)-remove:
-
 
225
	rm -rf $(1)-*
-
 
226
	$(call rm_stamp,extract-$(1))
-
 
227
204
PHONY += extract-$(1) extract-$(1)-f
228
PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove
205
endef
229
endef
206
230
-
 
231
## create the configure rule and force configure rule
-
 
232
define CONF_template
-
 
233
$(call GET_MY_VARS,$(1))
-
 
234
conf-$(1): $(STAMP_DIR)/conf-$(1)
-
 
235
conf-$(1)-f $(STAMP_DIR)/conf-$(1): $(STAMP_DIR)/$(2)-$(1) $(BUILD_DIR)/$(1)
-
 
236
	@rm -rf $(BUILD_DIR)/$(1)/*
-
 
237
	cd $(BUILD_DIR)/$(1) && \
-
 
238
	../../$(1)-$$(MY_VERSION)/configure $$($(1)_conf_opts)
-
 
239
	$(call make_stamp,conf-$(1))
-
 
240
-
 
241
conf-$(1)-remove:
-
 
242
	$(call rm_stamp,conf-$(1))
-
 
243
-
 
244
PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove
-
 
245
endef
-
 
246
-
 
247
## create the build rule and force build rule
-
 
248
define BUILD_template
-
 
249
$(call GET_MY_VARS,$(1))
-
 
250
build-$(1): $(STAMP_DIR)/build-$(1)
-
 
251
build-$(1)-f $(STAMP_DIR)/build-$(1): $(STAMP_DIR)/conf-$(1)
-
 
252
	cd $(BUILD_DIR)/$(1) && \
-
 
253
	$(MAKE) clean && $(MAKE) -j$(PROCS)
-
 
254
	$(call make_stamp,build-$(1))
-
 
255
-
 
256
build-$(1)-remove:
-
 
257
	rm -rf $(BUILD_DIR)/$(1)
-
 
258
	$(call rm_stamp,build-$(1))
-
 
259
-
 
260
PHONY += build-$(1) build-$(1)-f build-$(1)-remove
-
 
261
endef
-
 
262
-
 
263
## create the install rule and force install rule
-
 
264
define INSTALL_template
-
 
265
install-$(1): $(STAMP_DIR)/install-$(1)
-
 
266
install-$(1)-f $(STAMP_DIR)/install-$(1): $(STAMP_DIR)/build-$(1)
-
 
267
	cd $(BUILD_DIR)/$(1) && \
-
 
268
	$(MAKE) install
-
 
269
	$(call make_stamp,install-$(1))
-
 
270
-
 
271
uninstall-$(1):
-
 
272
	[ -f $(BUILD_DIR)/$(1)/Makefile ] && \
-
 
273
	cd $(BUILD_DIR)/$(1) && \
-
 
274
	$(MAKE) uninstall || true
-
 
275
	$(call rm_stamp,install-$(1))
-
 
276
-
 
277
PHONY += install-$(1) install-$(1)-f uninstall-$(1)
-
 
278
endef
-
 
279
-
 
280
## create the clean rule and realclean rule
-
 
281
define CLEAN_template
-
 
282
clean-$(1): uninstall-$(1) extract-$(1)-remove build-$(1)-remove conf-$(1)-remove
-
 
283
-
 
284
realclean-$(1): clean-$(1) download-$(1)-remove
-
 
285
-
 
286
PHONY += clean-$(1) realclean-$(1)
-
 
287
endef
-
 
288
-
 
289
-
 
290
-
 
291
207
$(DOWNLOAD_DIR):
292
$(DOWNLOAD_DIR):
208
	mkdir $(DOWNLOAD_DIR)
293
	mkdir $(DOWNLOAD_DIR)
209
294
-
 
295
$(BUILD_DIR)/%:
-
 
296
	mkdir -p $@
-
 
297
-
 
298
############# SUPP: AUTOCONF ############
-
 
299
210
$(eval $(call DOWNLOAD_template,autoconf))
300
$(eval $(call DOWNLOAD_template,autoconf))
211
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2))
301
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2))
-
 
302
autoconf_conf_opts = --prefix="$(SUPP_PREFIX)"
-
 
303
$(eval $(call CONF_template,autoconf,extract))
-
 
304
$(eval $(call BUILD_template,autoconf))
-
 
305
$(eval $(call INSTALL_template,autoconf))
-
 
306
$(eval $(call CLEAN_template,autoconf))
-
 
307
-
 
308
-
 
309
############ SUPP: AUTOMAKE ############
-
 
310
-
 
311
$(eval $(call DOWNLOAD_template,automake))
-
 
312
$(eval $(call EXTRACT_template,automake,EXT_BZ2))
-
 
313
automake_conf_opts = --prefix="$(SUPP_PREFIX)"
-
 
314
$(eval $(call CONF_template,automake,extract))
-
 
315
$(eval $(call BUILD_template,automake))
-
 
316
$(eval $(call INSTALL_template,automake))
-
 
317
$(eval $(call CLEAN_template,automake))
-
 
318
212
319
213
.PHONY: $(PHONY)
320
.PHONY: $(PHONY)
214
321
215
322
216
.PHONY: tst2 tst3
323
.PHONY: tst2 tst3
217
tst2:
324
tst2:
218
	$(call make_stamp,JES)
325
	$(call make_stamp,JES)
219
tst3:
326
tst3:
220
	$(call rm_stamp,JES)
327
	$(call rm_stamp,JES)
221
328
222
329
223
.PHONY: install-note
330
.PHONY: install-note
224
install-note: install-tools
331
install-note: install-tools
225
	@echo
332
	@echo
226
	@echo ====== INSTALLATION NOTE ======
333
	@echo ====== INSTALLATION NOTE ======
227
	@echo Your tools have now been installed at the following prefix:
334
	@echo Your tools have now been installed at the following prefix:
228
	@echo $(PREFIX)
335
	@echo $(PREFIX)
229
	@echo
336
	@echo
230
	@echo Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
337
	@echo Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
231
	@echo export PATH=$(PREFIX)/bin:'$$PATH'
338
	@echo export PATH=$(PREFIX)/bin:'$$PATH'
232
339
233
340
234
.PHONY: install-supp-tools install-supp-tools-force
341
.PHONY: install-supp-tools install-supp-tools-force
235
install-supp-tools: stamps/install-supp-tools
342
install-supp-tools: stamps/install-supp-tools
236
install-supp-tools-force stamps/install-supp-tools: stamps/install-autoconf stamps/install-automake
343
install-supp-tools-force stamps/install-supp-tools: stamps/install-autoconf stamps/install-automake
237
	[ -d stamps ] || mkdir stamps ;
344
	[ -d stamps ] || mkdir stamps ;
238
	touch stamps/install-supp-tools;
345
	touch stamps/install-supp-tools;
239
346
240
.PHONY: clean-supp-tools
347
.PHONY: clean-supp-tools
241
clean-supp-tools: clean-autoconf clean-automake
348
clean-supp-tools: clean-autoconf clean-automake
242
	rm stamps/install-supp-tools;
349
	rm stamps/install-supp-tools;
243
350
244
.PHONY: realclean-supp-tools
351
.PHONY: realclean-supp-tools
245
realclean-supp-tools: realclean-autoconf realclean-automake
352
realclean-supp-tools: realclean-autoconf realclean-automake
246
	rm stamps/install-supp-tools;
353
	rm stamps/install-supp-tools;
247
354
248
355
249
############# SUPP: AUTOCONF ############
-
 
250
356
-
 
357
-
 
358
-
 
359
############ SUPP: AUTOMAKE ############
-
 
360
251
##.PHONY: download-autoconf download-autoconf-force
361
##.PHONY: download-automake download-automake-force
252
##download-autoconf: downloads/$(AUTOCONF_ARCHIVE)
362
##download-automake: downloads/$(AUTOMAKE_ARCHIVE)
253
##download-autoconf-force downloads/$(AUTOCONF_ARCHIVE):
363
##download-automake-force downloads/$(AUTOMAKE_ARCHIVE):
254
##	[ -d downloads ] || mkdir downloads ;
364
##	[ -d downloads ] || mkdir downloads ;
255
##	cd downloads && curl -LO $(AUTOCONF_URL)
365
##	cd downloads && curl -LO $(AUTOMAKE_URL)
256
366
257
##.PHONY: extract-autoconf extract-autoconf-force
367
##.PHONY: extract-automake extract-automake-force
258
##extract-autoconf: stamps/extract-autoconf
368
##extract-automake: stamps/extract-automake
259
##extract-autoconf-force stamps/extract-autoconf: downloads/$(AUTOCONF_ARCHIVE)
369
##extract-automake-force stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
260
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
370
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
261
##	[ "$$t1" = "$(AUTOCONF_MD5)" ] || \
371
##	[ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
262
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
372
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
263
##	tar -jxf $< ;
373
##	tar -jxf $< ;
264
##	[ -d stamps ] || mkdir stamps ;
374
##	[ -d stamps ] || mkdir stamps ;
265
##	touch stamps/extract-autoconf;
-
 
266
-
 
267
.PHONY: build-autoconf build-autoconf-force
-
 
268
build-autoconf: stamps/build-autoconf
-
 
269
build-autoconf-force stamps/build-autoconf: stamps/extract-autoconf
-
 
270
	mkdir -p build/autoconf && cd build/autoconf && \
-
 
271
	../../autoconf-$(AUTOCONF_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
-
 
272
	$(MAKE) -j$(PROCS)
-
 
273
	[ -d stamps ] || mkdir stamps
-
 
274
	touch stamps/build-autoconf;
-
 
275
-
 
276
.PHONY: install-autoconf install-autoconf-force
-
 
277
install-autoconf: stamps/install-autoconf
-
 
278
install-autoconf-force stamps/install-autoconf:  stamps/build-autoconf
-
 
279
	cd build/autoconf && \
-
 
280
	$(MAKE) install
-
 
281
	[ -d stamps ] || mkdir stamps
-
 
282
	touch stamps/install-autoconf;
-
 
283
-
 
284
.PHONY: clean-autoconf
-
 
285
clean-autoconf:
-
 
286
	rm -rf build/autoconf stamps/*-autoconf autoconf-*
-
 
287
-
 
288
.PHONY: realclean-autoconf
-
 
289
realclean-autoconf: clean-autoconf
-
 
290
	rm downloads/$(AUTOCONF_ARCHIVE)
-
 
291
-
 
292
-
 
293
############ SUPP: AUTOMAKE ############
-
 
294
-
 
295
.PHONY: download-automake download-automake-force
-
 
296
download-automake: downloads/$(AUTOMAKE_ARCHIVE)
-
 
297
download-automake-force downloads/$(AUTOMAKE_ARCHIVE):
-
 
298
	[ -d downloads ] || mkdir downloads ;
-
 
299
	cd downloads && curl -LO $(AUTOMAKE_URL)
-
 
300
-
 
301
.PHONY: extract-automake extract-automake-force
-
 
302
extract-automake: stamps/extract-automake
-
 
303
extract-automake-force stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
-
 
304
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
-
 
305
	[ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
-
 
306
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
307
	tar -jxf $< ;
-
 
308
	[ -d stamps ] || mkdir stamps ;
-
 
309
	touch stamps/extract-automake;
375
##	touch stamps/extract-automake;
310
-
 
311
.PHONY: build-automake build-automake-force
-
 
312
build-automake: stamps/build-automake
-
 
313
build-automake-force stamps/build-automake: stamps/extract-automake stamps/install-autoconf
-
 
314
	mkdir -p build/automake && cd build/automake && \
-
 
315
	../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
-
 
316
	$(MAKE) -j$(PROCS)
-
 
317
	[ -d stamps ] || mkdir stamps
-
 
318
	touch stamps/build-automake;
-
 
319
-
 
320
.PHONY: install-automake install-automake-force
-
 
321
install-automake: stamps/install-automake
-
 
322
install-automake-force stamps/install-automake: stamps/build-automake
-
 
323
	cd build/automake && \
-
 
324
	$(MAKE) install
-
 
325
	[ -d stamps ] || mkdir stamps
-
 
326
	touch stamps/install-automake;
-
 
327
376
-
 
377
##.PHONY: build-automake build-automake-force
-
 
378
##build-automake: stamps/build-automake
-
 
379
##build-automake-force stamps/build-automake: stamps/extract-automake stamps/install-autoconf
-
 
380
##	mkdir -p build/automake && cd build/automake && \
-
 
381
##	../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
-
 
382
##	$(MAKE) -j$(PROCS)
-
 
383
##	[ -d stamps ] || mkdir stamps
-
 
384
##	touch stamps/build-automake;
-
 
385
-
 
386
##.PHONY: install-automake install-automake-force
-
 
387
##install-automake: stamps/install-automake
-
 
388
##install-automake-force stamps/install-automake: stamps/build-automake
-
 
389
##	cd build/automake && \
-
 
390
##	$(MAKE) install
-
 
391
##	[ -d stamps ] || mkdir stamps
-
 
392
##	touch stamps/install-automake;
-
 
393
328
.PHONY: clean-automake
394
##.PHONY: clean-automake
329
clean-automake:
395
##clean-automake:
330
	rm -rf build/automake stamps/*-automake automake-*
396
##	rm -rf build/automake stamps/*-automake automake-*
331
397
332
.PHONY: realclean-automake
398
##.PHONY: realclean-automake
333
realclean-automake: clean-automake
399
##realclean-automake: clean-automake
334
	rm downloads/$(AUTOMAKE_ARCHIVE)
400
##	rm downloads/$(AUTOMAKE_ARCHIVE)
335
401
336
402
337
############# AVR32 PATCHES ############
403
############# AVR32 PATCHES ############
338
404
339
.PHONY: download-avr32patches download-avr32patches-force
405
.PHONY: download-avr32patches download-avr32patches-force
340
download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
406
download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
341
download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
407
download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
342
	cd downloads && curl -LO $(AVR32PATCHES_URL)
408
	cd downloads && curl -LO $(AVR32PATCHES_URL)
343
409
344
.PHONY: extract-avr32patches extract-avr32patches-force
410
.PHONY: extract-avr32patches extract-avr32patches-force
345
extract-avr32patches: stamps/extract-avr32patches
411
extract-avr32patches: stamps/extract-avr32patches
346
extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
412
extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
347
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
413
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
348
	[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
414
	[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
349
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
415
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
350
	unzip -o $<
416
	unzip -o $<
351
	[ -d stamps ] || mkdir stamps
417
	[ -d stamps ] || mkdir stamps
352
	touch stamps/extract-avr32patches;
418
	touch stamps/extract-avr32patches;
353
419
354
.PHONY: clean-avr32patches
420
.PHONY: clean-avr32patches
355
clean-avr32patches:
421
clean-avr32patches:
356
	rm -rf stamps/*-avr32patches source
422
	rm -rf stamps/*-avr32patches source
357
423
358
.PHONY: realclean-avr32patches
424
.PHONY: realclean-avr32patches
359
realclean-avr32patches: clean-avr32patches
425
realclean-avr32patches: clean-avr32patches
360
	rm downloads/$(AVR32PATCHES_ARCHIVE)
426
	rm downloads/$(AVR32PATCHES_ARCHIVE)
361
427
362
428
363
############# AVR32 HEADERS ############
429
############# AVR32 HEADERS ############
364
430
365
.PHONY: download-avr32headers download-avr32headers-force
431
.PHONY: download-avr32headers download-avr32headers-force
366
download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
432
download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
367
download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
433
download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
368
	cd downloads && curl -LO $(AVR32HEADERS_URL)
434
	cd downloads && curl -LO $(AVR32HEADERS_URL)
369
435
370
.PHONY: install-headers install-headers-force
436
.PHONY: install-headers install-headers-force
371
install-headers: stamps/install-headers
437
install-headers: stamps/install-headers
372
install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
438
install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
373
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
439
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
374
	[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
440
	[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
375
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
441
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
376
	unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
442
	unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
377
	[ -d stamps ] || mkdir stamps
443
	[ -d stamps ] || mkdir stamps
378
	touch stamps/install-headers;
444
	touch stamps/install-headers;
379
445
380
.PHONY: clean-headers
446
.PHONY: clean-headers
381
clean-headers:
447
clean-headers:
382
	rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
448
	rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
383
449
384
.PHONY: realclean-headers
450
.PHONY: realclean-headers
385
realclean-headers: clean-headers
451
realclean-headers: clean-headers
386
	rm downloads/$(AVR32HEADERS_ARCHIVE)
452
	rm downloads/$(AVR32HEADERS_ARCHIVE)
387
453
388
454
389
################ NEWLIB ################
455
################ NEWLIB ################
390
456
391
.PHONY: download-newlib download-newlib-force
457
.PHONY: download-newlib download-newlib-force
392
download-newlib: downloads/$(NEWLIB_ARCHIVE)
458
download-newlib: downloads/$(NEWLIB_ARCHIVE)
393
download-newlib-force downloads/$(NEWLIB_ARCHIVE):
459
download-newlib-force downloads/$(NEWLIB_ARCHIVE):
394
	[ -d downloads ] || mkdir downloads ;
460
	[ -d downloads ] || mkdir downloads ;
395
	cd downloads && curl -LO $(NEWLIB_URL)
461
	cd downloads && curl -LO $(NEWLIB_URL)
396
462
397
.PHONY: extract-newlib extract-newlib-force
463
.PHONY: extract-newlib extract-newlib-force
398
extract-newlib: stamps/extract-newlib
464
extract-newlib: stamps/extract-newlib
399
extract-newlib-force stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
465
extract-newlib-force stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
400
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
466
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
401
	[ "$$t1" = "$(NEWLIB_MD5)" ] || \
467
	[ "$$t1" = "$(NEWLIB_MD5)" ] || \
402
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
468
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
403
	tar -xf $<
469
	tar -xf $<
404
	[ -d stamps ] || mkdir stamps
470
	[ -d stamps ] || mkdir stamps
405
	touch stamps/extract-newlib;
471
	touch stamps/extract-newlib;
406
472
407
473
408
.PHONY: patch-newlib patch-newlib-force
474
.PHONY: patch-newlib patch-newlib-force
409
patch-newlib: stamps/patch-newlib
475
patch-newlib: stamps/patch-newlib
410
patch-newlib-force stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
476
patch-newlib-force stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
411
	pushd newlib-$(NEWLIB_VERSION) ; \
477
	pushd newlib-$(NEWLIB_VERSION) ; \
412
	for f in ../source/avr32/newlib/*.patch; do \
478
	for f in ../source/avr32/newlib/*.patch; do \
413
	patch -N -p0 <$${f} ; \
479
	patch -N -p0 <$${f} ; \
414
	done ; \
480
	done ; \
415
	popd ;
481
	popd ;
416
	[ -d stamps ] || mkdir stamps
482
	[ -d stamps ] || mkdir stamps
417
	touch stamps/patch-newlib;
483
	touch stamps/patch-newlib;
418
484
419
.PHONY: regen-newlib regen-newlib-force
485
.PHONY: regen-newlib regen-newlib-force
420
regen-newlib: stamps/regen-newlib
486
regen-newlib: stamps/regen-newlib
421
regen-newlib-force stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
487
regen-newlib-force stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
422
	pushd newlib-$(NEWLIB_VERSION) ; \
488
	pushd newlib-$(NEWLIB_VERSION) ; \
423
	"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
489
	"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
424
	for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
490
	for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
425
	  pushd $$dir ; \
491
	  pushd $$dir ; \
426
	  "$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
492
	  "$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
427
	  "$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake"; \
493
	  "$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake"; \
428
	  popd ; \
494
	  popd ; \
429
	done; \
495
	done; \
430
	popd;
496
	popd;
431
	[ -d stamps ] || mkdir stamps
497
	[ -d stamps ] || mkdir stamps
432
	touch stamps/regen-newlib;
498
	touch stamps/regen-newlib;
433
499
434
NEWLIB_FLAGS="-ffunction-sections -fdata-sections	\
500
NEWLIB_FLAGS="-ffunction-sections -fdata-sections	\
435
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os	\
501
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os	\
436
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128	\
502
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128	\
437
-DSMALL_MEMORY"
503
-DSMALL_MEMORY"
438
504
439
.PHONY: build-newlib build-newlib-force
505
.PHONY: build-newlib build-newlib-force
440
build-newlib: stamps/build-newlib
506
build-newlib: stamps/build-newlib
441
build-newlib-force stamps/build-newlib: stamps/regen-newlib stamps/install-binutils stamps/install-gcc
507
build-newlib-force stamps/build-newlib: stamps/regen-newlib stamps/install-binutils stamps/install-gcc
442
	mkdir -p build/newlib && cd build/newlib && \
508
	mkdir -p build/newlib && cd build/newlib && \
443
	pushd ../../newlib-$(NEWLIB_VERSION) ; \
509
	pushd ../../newlib-$(NEWLIB_VERSION) ; \
444
	make clean ; \
510
	make clean ; \
445
	popd ; \
511
	popd ; \
446
	../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX)	\
512
	../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX)	\
447
	--with-build-time-tools=$(PREFIX)				\
513
	--with-build-time-tools=$(PREFIX)				\
448
	--target=$(TARGET) --disable-newlib-supplied-syscalls		\
514
	--target=$(TARGET) --disable-newlib-supplied-syscalls		\
449
	--disable-libgloss --disable-nls --disable-shared		\
515
	--disable-libgloss --disable-nls --disable-shared		\
450
	--enable-newlib-io-long-long --enable-newlib-io-long-double	\
516
	--enable-newlib-io-long-long --enable-newlib-io-long-double	\
451
	--enable-target-optspace --enable-newlib-io-pos-args		\
517
	--enable-target-optspace --enable-newlib-io-pos-args		\
452
	--enable-newlib-reent-small  && \
518
	--enable-newlib-reent-small  && \
453
	$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
519
	$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
454
	[ -d stamps ] || mkdir stamps
520
	[ -d stamps ] || mkdir stamps
455
	touch stamps/build-newlib;
521
	touch stamps/build-newlib;
456
522
457
.PHONY: install-newlib install-newlib-force
523
.PHONY: install-newlib install-newlib-force
458
install-newlib: stamps/install-newlib
524
install-newlib: stamps/install-newlib
459
install-newlib-force stamps/install-newlib: stamps/build-newlib
525
install-newlib-force stamps/install-newlib: stamps/build-newlib
460
	cd build/newlib && \
526
	cd build/newlib && \
461
	$(MAKE) install
527
	$(MAKE) install
462
	[ -d stamps ] || mkdir stamps
528
	[ -d stamps ] || mkdir stamps
463
	touch stamps/install-newlib;
529
	touch stamps/install-newlib;
464
530
465
.PHONY: clean-newlib
531
.PHONY: clean-newlib
466
clean-newlib:
532
clean-newlib:
467
	rm -rf build/newlib stamps/*-newlib newlib-*
533
	rm -rf build/newlib stamps/*-newlib newlib-*
468
534
469
.PHONY: realclean-newlib
535
.PHONY: realclean-newlib
470
realclean-newlib: clean-newlib
536
realclean-newlib: clean-newlib
471
	rm downloads/$(NEWLIB_ARCHIVE)
537
	rm downloads/$(NEWLIB_ARCHIVE)
472
538
473
539
474
################ BINUTILS ################
540
################ BINUTILS ################
475
541
476
.PHONY: download-binutils download-binutils-force
542
.PHONY: download-binutils download-binutils-force
477
download-binutils: downloads/$(BINUTILS_ARCHIVE)
543
download-binutils: downloads/$(BINUTILS_ARCHIVE)
478
download-binutils-force downloads/$(BINUTILS_ARCHIVE):
544
download-binutils-force downloads/$(BINUTILS_ARCHIVE):
479
	[ -d downloads ] || mkdir downloads ;
545
	[ -d downloads ] || mkdir downloads ;
480
	cd downloads && curl -LO $(BINUTILS_URL)
546
	cd downloads && curl -LO $(BINUTILS_URL)
481
547
482
.PHONY: extract-binutils extract-binutils-force
548
.PHONY: extract-binutils extract-binutils-force
483
extract-binutils: stamps/extract-binutils
549
extract-binutils: stamps/extract-binutils
484
extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
550
extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
485
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
551
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
486
	[ "$$t1" = "$(BINUTILS_MD5)" ] || \
552
	[ "$$t1" = "$(BINUTILS_MD5)" ] || \
487
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
553
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
488
	tar -jxf $< ;
554
	tar -jxf $< ;
489
	[ -d stamps ] || mkdir stamps ;
555
	[ -d stamps ] || mkdir stamps ;
490
	touch stamps/extract-binutils;
556
	touch stamps/extract-binutils;
491
557
492
.PHONY: patch-binutils patch-binutils-force
558
.PHONY: patch-binutils patch-binutils-force
493
patch-binutils: stamps/patch-binutils
559
patch-binutils: stamps/patch-binutils
494
patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
560
patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
495
	pushd binutils-$(BINUTILS_VERSION) ; \
561
	pushd binutils-$(BINUTILS_VERSION) ; \
496
	for f in ../source/avr32/binutils/*.patch; do \
562
	for f in ../source/avr32/binutils/*.patch; do \
497
	patch -N -p0 <$${f} ; \
563
	patch -N -p0 <$${f} ; \
498
	done ; \
564
	done ; \
499
	popd ; \
565
	popd ; \
500
	[ -d stamps ] || mkdir stamps
566
	[ -d stamps ] || mkdir stamps
501
	touch stamps/patch-binutils;
567
	touch stamps/patch-binutils;
502
568
503
.PHONY: regen-binutils regen-binutils-force
569
.PHONY: regen-binutils regen-binutils-force
504
regen-binutils: stamps/regen-binutils
570
regen-binutils: stamps/regen-binutils
505
regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
571
regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
506
	pushd binutils-$(BINUTILS_VERSION) ; \
572
	pushd binutils-$(BINUTILS_VERSION) ; \
507
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
573
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
508
	"$(SUPP_PREFIX)/bin/autoconf" ; \
574
	"$(SUPP_PREFIX)/bin/autoconf" ; \
509
	"$(SUPP_PREFIX)/bin/automake" ; \
575
	"$(SUPP_PREFIX)/bin/automake" ; \
510
	"$(SUPP_PREFIX)/bin/autoheader" ; \
576
	"$(SUPP_PREFIX)/bin/autoheader" ; \
511
	for dir in bfd opcodes binutils gas ld; do \
577
	for dir in bfd opcodes binutils gas ld; do \
512
	  pushd $$dir ; \
578
	  pushd $$dir ; \
513
	  "$(SUPP_PREFIX)/bin/autoconf"; \
579
	  "$(SUPP_PREFIX)/bin/autoconf"; \
514
	  "$(SUPP_PREFIX)/bin/automake"; \
580
	  "$(SUPP_PREFIX)/bin/automake"; \
515
	  "$(SUPP_PREFIX)/bin/autoheader"; \
581
	  "$(SUPP_PREFIX)/bin/autoheader"; \
516
	  popd ; \
582
	  popd ; \
517
	done; \
583
	done; \
518
	popd; \
584
	popd; \
519
	[ -d stamps ] || mkdir stamps ;
585
	[ -d stamps ] || mkdir stamps ;
520
	touch stamps/regen-binutils;
586
	touch stamps/regen-binutils;
521
587
522
.PHONY: build-binutils build-binutils-force
588
.PHONY: build-binutils build-binutils-force
523
build-binutils: stamps/build-binutils
589
build-binutils: stamps/build-binutils
524
build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
590
build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
525
	cd binutils-$(BINUTILS_VERSION) ; \
591
	cd binutils-$(BINUTILS_VERSION) ; \
526
	./configure   --enable-maintainer-mode		\
592
	./configure   --enable-maintainer-mode		\
527
	--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls		\
593
	--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls		\
528
	--disable-shared --disable-werror				\
594
	--disable-shared --disable-werror				\
529
	--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) &&	\
595
	--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) &&	\
530
	$(MAKE) all-bfd TARGET-bfd=headers; \
596
	$(MAKE) all-bfd TARGET-bfd=headers; \
531
	rm bfd/Makefile; \
597
	rm bfd/Makefile; \
532
	make configure-bfd; \
598
	make configure-bfd; \
533
	$(MAKE)
599
	$(MAKE)
534
	[ -d stamps ] || mkdir stamps ;
600
	[ -d stamps ] || mkdir stamps ;
535
	touch stamps/build-binutils;
601
	touch stamps/build-binutils;
536
602
537
.PHONY: install-binutils install-binutils-force
603
.PHONY: install-binutils install-binutils-force
538
install-binutils: stamps/install-binutils
604
install-binutils: stamps/install-binutils
539
install-binutils-force stamps/install-binutils: stamps/build-binutils
605
install-binutils-force stamps/install-binutils: stamps/build-binutils
540
	cd binutils-$(BINUTILS_VERSION) && \
606
	cd binutils-$(BINUTILS_VERSION) && \
541
	$(MAKE) installdirs install-host install-target
607
	$(MAKE) installdirs install-host install-target
542
	[ -d stamps ] || mkdir stamps ;
608
	[ -d stamps ] || mkdir stamps ;
543
	touch stamps/install-binutils;
609
	touch stamps/install-binutils;
544
610
545
611
546
.PHONY: clean-binutils
612
.PHONY: clean-binutils
547
clean-binutils:
613
clean-binutils:
548
	rm -rf build/binutils stamps/*-binutils binutils-*
614
	rm -rf build/binutils stamps/*-binutils binutils-*
549
615
550
.PHONY: realclean-binutils
616
.PHONY: realclean-binutils
551
realclean-binutils: clean-binutils
617
realclean-binutils: clean-binutils
552
	rm downloads/$(BINUTILS_ARCHIVE)
618
	rm downloads/$(BINUTILS_ARCHIVE)
553
619
554
620
555
########## DFU PROGRAMMER ###########
621
########## DFU PROGRAMMER ###########
556
622
557
.PHONY: download-dfu download-dfu-force
623
.PHONY: download-dfu download-dfu-force
558
download-dfu: downloads/$(DFU_ARCHIVE)
624
download-dfu: downloads/$(DFU_ARCHIVE)
559
download-dfu-force downloads/$(DFU_ARCHIVE):
625
download-dfu-force downloads/$(DFU_ARCHIVE):
560
	[ -d downloads ] || mkdir downloads ;
626
	[ -d downloads ] || mkdir downloads ;
561
	cd downloads && curl -LO $(DFU_URL)
627
	cd downloads && curl -LO $(DFU_URL)
562
628
563
.PHONY: extract-dfu extract-dfu-force
629
.PHONY: extract-dfu extract-dfu-force
564
extract-dfu: stamps/extract-dfu
630
extract-dfu: stamps/extract-dfu
565
extract-dfu-force stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
631
extract-dfu-force stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
566
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
632
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
567
	[ "$$t1" = "$(DFU_MD5)" ] || \
633
	[ "$$t1" = "$(DFU_MD5)" ] || \
568
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
634
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
569
	tar -zxf $< ;
635
	tar -zxf $< ;
570
	[ -d stamps ] || mkdir stamps ;
636
	[ -d stamps ] || mkdir stamps ;
571
	touch stamps/extract-dfu;
637
	touch stamps/extract-dfu;
572
638
573
.PHONY: build-dfu build-dfu-force
639
.PHONY: build-dfu build-dfu-force
574
build-dfu: stamps/build-dfu
640
build-dfu: stamps/build-dfu
575
build-dfu-force stamps/build-dfu: stamps/extract-dfu
641
build-dfu-force stamps/build-dfu: stamps/extract-dfu
576
	mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
642
	mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
577
	../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
643
	../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
578
	$(MAKE) -j$(PROCS)
644
	$(MAKE) -j$(PROCS)
579
	[ -d stamps ] || mkdir stamps
645
	[ -d stamps ] || mkdir stamps
580
	touch stamps/build-dfu;
646
	touch stamps/build-dfu;
581
647
582
.PHONY: install-dfu install-dfu-force
648
.PHONY: install-dfu install-dfu-force
583
install-dfu: stamps/install-dfu
649
install-dfu: stamps/install-dfu
584
install-dfu-force stamps/install-dfu: stamps/build-dfu
650
install-dfu-force stamps/install-dfu: stamps/build-dfu
585
	cd build/dfu-programmer && \
651
	cd build/dfu-programmer && \
586
	$(MAKE) install
652
	$(MAKE) install
587
	[ -d stamps ] || mkdir stamps
653
	[ -d stamps ] || mkdir stamps
588
	touch stamps/install-dfu;
654
	touch stamps/install-dfu;
589
655
590
.PHONY: clean-dfu
656
.PHONY: clean-dfu
591
clean-dfu:
657
clean-dfu:
592
	rm -rf build/dfu stamps/*-dfu dfu-*
658
	rm -rf build/dfu stamps/*-dfu dfu-*
593
659
594
.PHONY: realclean-dfu
660
.PHONY: realclean-dfu
595
realclean-dfu: clean-dfu
661
realclean-dfu: clean-dfu
596
	rm downloads/$(DFU_ARCHIVE)
662
	rm downloads/$(DFU_ARCHIVE)
597
663
598
664
599
################ Bootstrap GCC ################
665
################ Bootstrap GCC ################
600
666
601
.PHONY: download-gcc download-gcc-force
667
.PHONY: download-gcc download-gcc-force
602
download-gcc: downloads/$(GCC_ARCHIVE)
668
download-gcc: downloads/$(GCC_ARCHIVE)
603
download-gcc-force downloads/$(GCC_ARCHIVE):
669
download-gcc-force downloads/$(GCC_ARCHIVE):
604
	[ -d downloads ] || mkdir downloads ;
670
	[ -d downloads ] || mkdir downloads ;
605
	cd downloads && curl -LO $(GCC_URL)
671
	cd downloads && curl -LO $(GCC_URL)
606
672
607
.PHONY: extract-gcc extract-gcc-force
673
.PHONY: extract-gcc extract-gcc-force
608
extract-gcc: stamps/extract-gcc
674
extract-gcc: stamps/extract-gcc
609
extract-gcc-force stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
675
extract-gcc-force stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
610
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
676
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
611
	[ "$$t1" = "$(GCC_MD5)" ] || \
677
	[ "$$t1" = "$(GCC_MD5)" ] || \
612
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
678
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
613
	tar -jxf $< ;
679
	tar -jxf $< ;
614
	[ -d stamps ] || mkdir stamps ;
680
	[ -d stamps ] || mkdir stamps ;
615
	touch stamps/extract-gcc;
681
	touch stamps/extract-gcc;
616
682
617
.PHONY: patch-gcc patch-gcc-force
683
.PHONY: patch-gcc patch-gcc-force
618
patch-gcc: stamps/patch-gcc
684
patch-gcc: stamps/patch-gcc
619
patch-gcc-force stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
685
patch-gcc-force stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
620
	pushd gcc-$(GCC_VERSION) ; \
686
	pushd gcc-$(GCC_VERSION) ; \
621
	for f in ../source/avr32/gcc/*.patch; do \
687
	for f in ../source/avr32/gcc/*.patch; do \
622
	patch -N -p0 <$${f} ; \
688
	patch -N -p0 <$${f} ; \
623
	done ; \
689
	done ; \
624
	popd ;
690
	popd ;
625
	[ -d stamps ] || mkdir stamps
691
	[ -d stamps ] || mkdir stamps
626
	touch stamps/patch-gcc;
692
	touch stamps/patch-gcc;
627
693
628
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections			\
694
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections			\
629
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g	\
695
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g	\
630
-Os -fno-unroll-loops"
696
-Os -fno-unroll-loops"
631
697
632
.PHONY: build-gcc build-gcc-force
698
.PHONY: build-gcc build-gcc-force
633
build-gcc: stamps/build-gcc
699
build-gcc: stamps/build-gcc
634
build-gcc-force stamps/build-gcc: stamps/install-binutils stamps/patch-gcc
700
build-gcc-force stamps/build-gcc: stamps/install-binutils stamps/patch-gcc
635
	mkdir -p build/gcc && cd build/gcc && \
701
	mkdir -p build/gcc && cd build/gcc && \
636
	pushd ../../gcc-$(GCC_VERSION) ; \
702
	pushd ../../gcc-$(GCC_VERSION) ; \
637
	make clean ; \
703
	make clean ; \
638
	popd ; \
704
	popd ; \
639
	../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)"		\
705
	../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)"		\
640
	--target=$(TARGET) --enable-languages="c" --with-gnu-ld		\
706
	--target=$(TARGET) --enable-languages="c" --with-gnu-ld		\
641
	--with-gnu-as --with-newlib --disable-nls --disable-libssp	\
707
	--with-gnu-as --with-newlib --disable-nls --disable-libssp	\
642
	--with-dwarf2 --enable-sjlj-exceptions				\
708
	--with-dwarf2 --enable-sjlj-exceptions				\
643
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch	\
709
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch	\
644
	--disable-shared						\
710
	--disable-shared						\
645
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
711
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
646
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET)				\
712
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET)				\
647
	--with-sysroot="$(PREFIX)/$(TARGET)"				\
713
	--with-sysroot="$(PREFIX)/$(TARGET)"				\
648
	--with-build-sysroot="$(PREFIX)/$(TARGET)"			\
714
	--with-build-sysroot="$(PREFIX)/$(TARGET)"			\
649
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
715
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
650
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)				\
716
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)				\
651
	LDFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
717
	LDFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
652
	CPPFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
718
	CPPFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
653
	--with-bugurl=$(BUG_URL) \
719
	--with-bugurl=$(BUG_URL) \
654
	--with-pkgversion=$(PKG_VERSION) && \
720
	--with-pkgversion=$(PKG_VERSION) && \
655
	$(MAKE) -j$(PROCS)
721
	$(MAKE) -j$(PROCS)
656
	[ -d stamps ] || mkdir stamps
722
	[ -d stamps ] || mkdir stamps
657
	touch stamps/build-gcc;
723
	touch stamps/build-gcc;
658
724
659
.PHONY: install-gcc install-gcc-force
725
.PHONY: install-gcc install-gcc-force
660
install-gcc: stamps/install-gcc
726
install-gcc: stamps/install-gcc
661
install-gcc-force stamps/install-gcc: stamps/build-gcc
727
install-gcc-force stamps/install-gcc: stamps/build-gcc
662
	cd build/gcc && \
728
	cd build/gcc && \
663
	$(MAKE) installdirs install-target && \
729
	$(MAKE) installdirs install-target && \
664
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
730
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
665
	[ -d stamps ] || mkdir stamps
731
	[ -d stamps ] || mkdir stamps
666
	touch stamps/install-gcc;
732
	touch stamps/install-gcc;
667
733
668
.PHONY: clean-gcc
734
.PHONY: clean-gcc
669
clean-gcc:
735
clean-gcc:
670
	rm -rf build/gcc stamps/*-gcc gcc-*
736
	rm -rf build/gcc stamps/*-gcc gcc-*
671
737
672
.PHONY: realclean-gcc
738
.PHONY: realclean-gcc
673
realclean-gcc: clean-gcc
739
realclean-gcc: clean-gcc
674
	rm downloads/$(GCC_ARCHIVE)
740
	rm downloads/$(GCC_ARCHIVE)
675
741
676
742
677
################ Final GCC ################
743
################ Final GCC ################
678
744
679
.PHONY: build-final-gcc build-final-gcc-force
745
.PHONY: build-final-gcc build-final-gcc-force
680
build-final-gcc: stamps/build-final-gcc
746
build-final-gcc: stamps/build-final-gcc
681
build-final-gcc-force stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/patch-gcc
747
build-final-gcc-force stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/patch-gcc
682
	mkdir -p build/final-gcc && cd build/final-gcc && \
748
	mkdir -p build/final-gcc && cd build/final-gcc && \
683
	pushd ../../gcc-$(GCC_VERSION) ; \
749
	pushd ../../gcc-$(GCC_VERSION) ; \
684
	make clean ; \
750
	make clean ; \
685
	popd ; \
751
	popd ; \
686
	../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
752
	../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
687
	--target=$(TARGET) $(DEPENDENCIES) --enable-languages="c,c++" --with-gnu-ld \
753
	--target=$(TARGET) $(DEPENDENCIES) --enable-languages="c,c++" --with-gnu-ld \
688
	--with-gnu-as --with-newlib --disable-nls --disable-libssp \
754
	--with-gnu-as --with-newlib --disable-nls --disable-libssp \
689
	--with-dwarf2 --enable-sjlj-exceptions \
755
	--with-dwarf2 --enable-sjlj-exceptions \
690
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch \
756
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch \
691
	--disable-shared --enable-__cxa_atexit \
757
	--disable-shared --enable-__cxa_atexit \
692
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
758
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
693
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET) \
759
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET) \
694
	--with-sysroot=$(PREFIX)/$(TARGET) \
760
	--with-sysroot=$(PREFIX)/$(TARGET) \
695
	--with-build-sysroot=$(PREFIX)/$(TARGET) \
761
	--with-build-sysroot=$(PREFIX)/$(TARGET) \
696
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
762
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
697
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) \
763
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) \
698
	LDFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
764
	LDFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
699
	CPPFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
765
	CPPFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
700
	--with-bugurl=$(BUG_URL) \
766
	--with-bugurl=$(BUG_URL) \
701
	--with-pkgversion=$(PKG_VERSION) && \
767
	--with-pkgversion=$(PKG_VERSION) && \
702
	$(MAKE) -j$(PROCS)
768
	$(MAKE) -j$(PROCS)
703
	[ -d stamps ] || mkdir stamps
769
	[ -d stamps ] || mkdir stamps
704
	touch stamps/build-final-gcc;
770
	touch stamps/build-final-gcc;
705
771
706
.PHONY: install-final-gcc install-final-gcc-force
772
.PHONY: install-final-gcc install-final-gcc-force
707
install-final-gcc: stamps/install-final-gcc
773
install-final-gcc: stamps/install-final-gcc
708
install-final-gcc-force stamps/install-final-gcc: stamps/build-final-gcc
774
install-final-gcc-force stamps/install-final-gcc: stamps/build-final-gcc
709
	cd build/final-gcc && \
775
	cd build/final-gcc && \
710
	$(MAKE) installdirs install-target && \
776
	$(MAKE) installdirs install-target && \
711
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
777
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
712
	[ -d stamps ] || mkdir stamps
778
	[ -d stamps ] || mkdir stamps
713
	touch stamps/install-final-gcc;
779
	touch stamps/install-final-gcc;
714
780
715
.PHONY: clean-final-gcc
781
.PHONY: clean-final-gcc
716
clean-final-gcc: clean-gcc
782
clean-final-gcc: clean-gcc
717
	rm -rf build/final-gcc stamps/*-final-gcc
783
	rm -rf build/final-gcc stamps/*-final-gcc
718
784
719
.PHONY: realclean-final-gcc
785
.PHONY: realclean-final-gcc
720
realclean-final-gcc: realclean-gcc
786
realclean-final-gcc: realclean-gcc
721
787
722
788
723
########## GDB ###########
789
########## GDB ###########
724
790
725
.PHONY: download-gdb download-gdb-force
791
.PHONY: download-gdb download-gdb-force
726
download-gdb: downloads/$(GDB_ARCHIVE)
792
download-gdb: downloads/$(GDB_ARCHIVE)
727
download-gdb-force downloads/$(GDB_ARCHIVE):
793
download-gdb-force downloads/$(GDB_ARCHIVE):
728
	[ -d downloads ] || mkdir downloads ;
794
	[ -d downloads ] || mkdir downloads ;
729
	cd downloads && curl -LO $(GDB_URL)
795
	cd downloads && curl -LO $(GDB_URL)
730
796
731
.PHONY: extract-gdb extract-gdb-force
797
.PHONY: extract-gdb extract-gdb-force
732
extract-gdb: stamps/extract-gdb
798
extract-gdb: stamps/extract-gdb
733
extract-gdb-force stamps/extract-gdb: downloads/$(GDB_ARCHIVE)
799
extract-gdb-force stamps/extract-gdb: downloads/$(GDB_ARCHIVE)
734
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
800
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
735
	[ "$$t1" = "$(GDB_MD5)" ] || \
801
	[ "$$t1" = "$(GDB_MD5)" ] || \
736
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
802
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
737
	tar -jxf $< ;
803
	tar -jxf $< ;
738
	[ -d stamps ] || mkdir stamps ;
804
	[ -d stamps ] || mkdir stamps ;
739
	touch stamps/extract-gdb;
805
	touch stamps/extract-gdb;
740
806
741
.PHONY: patch-gdb patch-gdb-force
807
.PHONY: patch-gdb patch-gdb-force
742
patch-gdb: stamps/patch-gdb
808
patch-gdb: stamps/patch-gdb
743
patch-gdb-force stamps/patch-gdb: stamps/extract-gdb stamps/extract-avr32patches
809
patch-gdb-force stamps/patch-gdb: stamps/extract-gdb stamps/extract-avr32patches
744
	pushd gdb-$(GDB_VERSION) ; \
810
	pushd gdb-$(GDB_VERSION) ; \
745
	for f in ../source/avr32/gdb/*.patch; do \
811
	for f in ../source/avr32/gdb/*.patch; do \
746
	patch -N -p0 <$${f} ; \
812
	patch -N -p0 <$${f} ; \
747
	done ; \
813
	done ; \
748
	popd ; \
814
	popd ; \
749
	[ -d stamps ] || mkdir stamps
815
	[ -d stamps ] || mkdir stamps
750
	touch stamps/patch-gdb;
816
	touch stamps/patch-gdb;
751
817
752
.PHONY: regen-gdb regen-gdb-force
818
.PHONY: regen-gdb regen-gdb-force
753
regen-gdb: stamps/regen-gdb
819
regen-gdb: stamps/regen-gdb
754
regen-gdb-force stamps/regen-gdb: stamps/patch-gdb stamps/install-supp-tools
820
regen-gdb-force stamps/regen-gdb: stamps/patch-gdb stamps/install-supp-tools
755
	pushd gdb-$(GDB_VERSION) ; \
821
	pushd gdb-$(GDB_VERSION) ; \
756
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
822
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
757
	"$(SUPP_PREFIX)/bin/autoconf" ; \
823
	"$(SUPP_PREFIX)/bin/autoconf" ; \
758
	"$(SUPP_PREFIX)/bin/automake" ; \
824
	"$(SUPP_PREFIX)/bin/automake" ; \
759
	"$(SUPP_PREFIX)/bin/autoheader" ; \
825
	"$(SUPP_PREFIX)/bin/autoheader" ; \
760
	for dir in bfd opcodes gdb; do \
826
	for dir in bfd opcodes gdb; do \
761
	  pushd $$dir ; \
827
	  pushd $$dir ; \
762
	  echo "JESS 1: $$dir" >&2 ; \
828
	  echo "JESS 1: $$dir" >&2 ; \
763
	  "$(SUPP_PREFIX)/bin/autoconf"; \
829
	  "$(SUPP_PREFIX)/bin/autoconf"; \
764
	  "$(SUPP_PREFIX)/bin/automake"; \
830
	  "$(SUPP_PREFIX)/bin/automake"; \
765
	  "$(SUPP_PREFIX)/bin/autoheader"; \
831
	  "$(SUPP_PREFIX)/bin/autoheader"; \
766
	  echo "JESS 2: $$dir" >&2 ; \
832
	  echo "JESS 2: $$dir" >&2 ; \
767
	  popd ; \
833
	  popd ; \
768
	done; \
834
	done; \
769
	popd; \
835
	popd; \
770
	[ -d stamps ] || mkdir stamps ;
836
	[ -d stamps ] || mkdir stamps ;
771
	touch stamps/regen-gdb;
837
	touch stamps/regen-gdb;
772
838
773
.PHONY: build-gdb build-gdb-force
839
.PHONY: build-gdb build-gdb-force
774
build-gdb: stamps/build-gdb
840
build-gdb: stamps/build-gdb
775
build-gdb-force stamps/build-gdb: stamps/regen-gdb stamps/install-supp-tools
841
build-gdb-force stamps/build-gdb: stamps/regen-gdb stamps/install-supp-tools
776
	echo "JESS 3" >&2 ; \
842
	echo "JESS 3" >&2 ; \
777
	mkdir -p build/gdb && cd build/gdb && \
843
	mkdir -p build/gdb && cd build/gdb && \
778
	../../gdb-$(GDB_VERSION)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
844
	../../gdb-$(GDB_VERSION)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
779
	$(MAKE) -j$(PROCS)
845
	$(MAKE) -j$(PROCS)
780
	$(MAKE) installdirs install-host install-target
846
	$(MAKE) installdirs install-host install-target
781
	[ -d stamps ] || mkdir stamps
847
	[ -d stamps ] || mkdir stamps
782
	touch stamps/build-gdb;
848
	touch stamps/build-gdb;
783
849
784
.PHONY: install-gdb install-gdb-force
850
.PHONY: install-gdb install-gdb-force
785
install-gdb: stamps/install-gdb
851
install-gdb: stamps/install-gdb
786
install-gdb-force stamps/install-gdb: stamps/build-gdb
852
install-gdb-force stamps/install-gdb: stamps/build-gdb
787
	cd build/gdb && \
853
	cd build/gdb && \
788
	$(MAKE) install
854
	$(MAKE) install
789
	[ -d stamps ] || mkdir stamps
855
	[ -d stamps ] || mkdir stamps
790
	touch stamps/install-gdb;
856
	touch stamps/install-gdb;
791
857
792
.PHONY: clean-gdb
858
.PHONY: clean-gdb
793
clean-gdb:
859
clean-gdb:
794
	rm -rf build/gdb stamps/*-gdb gdb-*
860
	rm -rf build/gdb stamps/*-gdb gdb-*
795
861
796
.PHONY: realclean-gdb
862
.PHONY: realclean-gdb
797
realclean-gdb: clean-gdb
863
realclean-gdb: clean-gdb
798
	rm downloads/$(GDB_ARCHIVE)
864
	rm downloads/$(GDB_ARCHIVE)
799
865
800
################ NON-WORKING/NON-ADJUSTED TARGETS ################
866
################ NON-WORKING/NON-ADJUSTED TARGETS ################
801
867
802
868
803
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
869
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
804
	pushd gcc-$(GCC_VERSION)-$(CS_BASE) ; \
870
	pushd gcc-$(GCC_VERSION)-$(CS_BASE) ; \
805
	patch -N -p1 < ../patches/gcc-optsize.patch ; \
871
	patch -N -p1 < ../patches/gcc-optsize.patch ; \
806
	popd ;
872
	popd ;
807
873
808
gmp: gmp-$(CS_BASE)/ sudomode
874
gmp: gmp-$(CS_BASE)/ sudomode
809
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
875
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
810
	pushd ../../gmp-$(CS_BASE) ; \
876
	pushd ../../gmp-$(CS_BASE) ; \
811
	make clean ; \
877
	make clean ; \
812
	popd ; \
878
	popd ; \
813
	sudo -u $(SUDO_USER) ../../gmp-$(CS_BASE)/configure --disable-shared && \
879
	sudo -u $(SUDO_USER) ../../gmp-$(CS_BASE)/configure --disable-shared && \
814
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
880
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
815
	$(MAKE) install
881
	$(MAKE) install
816
882
817
mpc: mpc-$(MPC_VERSION)/ sudomode
883
mpc: mpc-$(MPC_VERSION)/ sudomode
818
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
884
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
819
	pushd ../../mpc-$(MPC_VERSION) ; \
885
	pushd ../../mpc-$(MPC_VERSION) ; \
820
	make clean ; \
886
	make clean ; \
821
	popd ; \
887
	popd ; \
822
	sudo -u $(SUDO_USER) ../../mpc-$(MPC_VERSION)/configure --disable-shared && \
888
	sudo -u $(SUDO_USER) ../../mpc-$(MPC_VERSION)/configure --disable-shared && \
823
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
889
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
824
	$(MAKE) install
890
	$(MAKE) install
825
891
826
mpc-$(MPC_VERSION) : $(LOCAL_BASE)/mpc-$(CS_VERSION).tar.bz2
892
mpc-$(MPC_VERSION) : $(LOCAL_BASE)/mpc-$(CS_VERSION).tar.bz2
827
ifeq ($(USER),root)
893
ifeq ($(USER),root)
828
	sudo -u $(SUDO_USER) tar -jxf $<
894
	sudo -u $(SUDO_USER) tar -jxf $<
829
else
895
else
830
	tar -jxf $<
896
	tar -jxf $<
831
endif
897
endif
832
898
833
mpfr: gmp mpfr-$(CS_BASE)/ sudomode
899
mpfr: gmp mpfr-$(CS_BASE)/ sudomode
834
	sudo -u $(SUDO_USER) mkdir -p build/mpfr && cd build/mpfr && \
900
	sudo -u $(SUDO_USER) mkdir -p build/mpfr && cd build/mpfr && \
835
	pushd ../../mpfr-$(CS_BASE) ; \
901
	pushd ../../mpfr-$(CS_BASE) ; \
836
	make clean ; \
902
	make clean ; \
837
	popd ; \
903
	popd ; \
838
	sudo -u $(SUDO_USER) ../../mpfr-$(CS_BASE)/configure LDFLAGS="-Wl,-search_paths_first" --disable-shared && \
904
	sudo -u $(SUDO_USER) ../../mpfr-$(CS_BASE)/configure LDFLAGS="-Wl,-search_paths_first" --disable-shared && \
839
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
905
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
840
	$(MAKE) install
906
	$(MAKE) install
841
907
842
cross-gdb: gdb-$(CS_BASE)/
908
cross-gdb: gdb-$(CS_BASE)/
843
	mkdir -p build/gdb && cd build/gdb && \
909
	mkdir -p build/gdb && cd build/gdb && \
844
	pushd ../../gdb-$(CS_BASE) ; \
910
	pushd ../../gdb-$(CS_BASE) ; \
845
	make clean ; \
911
	make clean ; \
846
	popd ; \
912
	popd ; \
847
	../../gdb-$(CS_BASE)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
913
	../../gdb-$(CS_BASE)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
848
	$(MAKE) -j$(PROCS) && \
914
	$(MAKE) -j$(PROCS) && \
849
	$(MAKE) installdirs install-host install-target && \
915
	$(MAKE) installdirs install-host install-target && \
850
	mkdir -p "$(PREFIX)/man/man1" && \
916
	mkdir -p "$(PREFIX)/man/man1" && \
851
	cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
917
	cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
852
918
853
.PHONY : clean
919
.PHONY : clean
854
clean:
920
clean:
855
	rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp
921
	rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp