Subversion Repositories avr32-toolchain

Rev

Rev 4 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 23
Line 1... Line 1...
1
# AVR32 Toolchain Makefile
1
# AVR32 Toolchain Makefile
2
#
2
#
3
# Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org>
3
# Copyright (C) 2012 by Jasmin Jessich <jasmin.jessich@frequentis.com>
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
Line 17... Line 17...
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
#
-
 
23
# This Makefile is based on the one from here:
-
 
24
#    https://github.com/jsnyder/avr32-toolchain/blob/master/Makefile
-
 
25
#    Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org>
-
 
26
#
-
 
27
-
 
28
-
 
29
-
 
30
###############################################################################
-
 
31
#
-
 
32
# The origial version couldn't handle delta building of parts, which is
-
 
33
# required during patch development. I didn't want to fix all the different
-
 
34
# make steps seperately. So I decided to use an new approach, which I never
-
 
35
# tried before. I used make macros to generate the different rules for the
-
 
36
# different tools.
-
 
37
# This saved me a lot of work, when a new tool is added. Moreover, bugfixes
-
 
38
# have to be done only one place. Enhancments of the targets need to be done
-
 
39
# on only one place.
-
 
40
# The drawback of this approach is a little mor complexity when writing shell
-
 
41
# scripts within the make macro. You need a lot of '$' for escaping.
-
 
42
#
-
 
43
# I have tested most of the targets with a lot of compinations, but there might
-
 
44
# one which is not working. Please send me a bug report, if you find such a
-
 
45
# combination.
-
 
46
#
-
 
47
# The development SVN repository can be found at
-
 
48
#  http://web.anw.at/websvn/listing.php?repname=avr32-toolchain
-
 
49
#
-
 
50
# NOTE: Currently ONLY binutils is finished!
-
 
51
#
-
 
52
###############################################################################
-
 
53
-
 
54
22
55
23
#### PRIMARY TOOLCHAIN VERSIONS #####
56
#### PRIMARY TOOLCHAIN VERSIONS #####
24
57
25
GCC_VERSION      = 4.4.3
58
GCC_VERSION       = 4.4.3
26
GDB_VERSION      = 6.7.1
59
GDB_VERSION       = 6.7.1
-
 
60
GDB_VERSION_DLOAD = $(GDB_VERSION)a
27
BINUTILS_VERSION = 2.20.1
61
#BINUTILS_VERSION  = 2.20.1
-
 
62
BINUTILS_VERSION  = 2.22
28
NEWLIB_VERSION   = 1.16.0
63
NEWLIB_VERSION    = 1.16.0
29
DFU_VERSION      = 0.5.4
64
DFU_VERSION       = 0.5.4
30
AVR_PATCH_REV	 = 3.2.3.261
65
AVR_PATCH_REV	  = 3.2.3.261
31
AVR_HEADER_REV   = 3.2.3.258
66
AVR_HEADER_REV    = 3.2.3.258
32
67
33
68
34
#### PATHS AND ENVIRONMENT VARIABLES #####
69
#### PATHS AND ENVIRONMENT VARIABLES #####
35
70
36
SHELL       = /bin/bash
71
SHELL       = /bin/bash
37
TARGET      = avr32
72
TARGET      = avr32
38
73
39
TODAY = $(shell date "+%Y%m%d")
74
TODAY = $(shell date "+%Y%m%d")
40
GIT_REV	    = $(shell git rev-parse --verify HEAD --short)
75
GIT_REV	    = $(shell git rev-parse --verify HEAD --short 2> /dev/null)
-
 
76
SVN_REV	    = $(shell head -1 ReleaseNotes 2> /dev/null | cut -f 1 -d " ")
-
 
77
-
 
78
PREFIX_RELEASE ?= /opt/avr/avr32-tools
41
79
42
ifeq ($(strip $(GIT_REV)),)
80
ifeq ($(strip $(GIT_REV)),)
-
 
81
ifeq ($(strip $(SVN_REV)),)
43
PREFIX     ?= $(HOME)/avr32-tools-$(TODAY)
82
PREFIX     ?= $(HOME)/avr32-tools-$(TODAY)
-
 
83
TOOL_REV   = $(TODAY)
-
 
84
else
-
 
85
PREFIX     ?= $(HOME)/avr32-tools-$(SVN_REV)
-
 
86
TOOL_REV   = $(SVN_REV)
-
 
87
BUG_URL = jasmin@anw.at
-
 
88
endif
44
else
89
else
45
PREFIX     ?= $(HOME)/avr32-tools-$(GIT_REV)
90
PREFIX     ?= $(HOME)/avr32-tools-$(GIT_REV)
-
 
91
TOOL_REV   = $(GIT_REV)
46
endif
92
endif
47
93
48
ifeq ($(UNAME), Linux)
94
ifeq ($(UNAME), Linux)
49
PROCS  ?= $(shell grep -c ^processor /proc/cpuinfo)
95
PROCS  ?= $(shell grep -c ^processor /proc/cpuinfo)
50
else ifeq ($(UNAME), Darwin)
96
else ifeq ($(UNAME), Darwin)
51
PROCS  ?= $(shell sysctl hw.ncpu | awk '{print $$2}')
97
PROCS  ?= $(shell sysctl hw.ncpu | awk '{print $$2}')
52
else
98
else
53
PROCS  ?= 2
99
PROCS  ?= 2
54
endif
100
endif
55
101
-
 
102
-
 
103
RELEASE_VERSION ?= no
-
 
104
PREFIX_RELEASE ?= /opt/avr/avr32-tools
-
 
105
-
 
106
ifneq ($(RELEASE_VERSION),no)
-
 
107
FULL_STATIC = y
-
 
108
PREFIX = $(PREFIX_RELEASE)-$(RELEASE_VERSION)
-
 
109
endif
-
 
110
-
 
111
-
 
112
# enable complete static linking
-
 
113
FULL_STATIC ?= no
-
 
114
-
 
115
# enable maintainer-mode with yes
-
 
116
M_MODE ?= no
-
 
117
-
 
118
# enable binutils autotool file regeneration with yes
-
 
119
BINUTILS_REGEN ?= no
-
 
120
-
 
121
56
SUPP_PREFIX = $(CURDIR)/supp
122
SUPP_PREFIX = $(CURDIR)/supp
57
PATH       := ${PREFIX}/bin:${SUPP_PREFIX}/bin:${PATH}
123
PATH       := ${PREFIX}/bin:${SUPP_PREFIX}/bin:${PATH}
58
AUTOCONF    = $(SUPP_PREFIX)/bin/autoconf
124
AUTOCONF    = $(SUPP_PREFIX)/bin/autoconf
59
AUTOMAKE    = $(SUPP_PREFIX)/bin/automake
125
AUTOMAKE    = $(SUPP_PREFIX)/bin/automake
60
126
-
 
127
STAMP_DIR  := $(CURDIR)/stamps
-
 
128
DOWNLOAD_DIR := $(CURDIR)/downloads
-
 
129
BUILD_DIR := $(CURDIR)/build
-
 
130
-
 
131
ifeq ($(strip $(BUG_URL)),)
61
BUG_URL = https://github.com/jsnyder/avr32-toolchain
132
BUG_URL = https://github.com/jsnyder/avr32-toolchain
-
 
133
endif
62
PKG_VERSION = "AVR 32 bit GNU Toolchain-$(AVR_PATCH_REV)-$(GIT_REV)"
134
#PKG_VERSION ?= "AVR 32 bit GNU Toolchain-$(AVR_PATCH_REV)-$(TOOL_REV)"
-
 
135
PKG_VERSION ?= "AVR 32 bit GNU Toolchain-$(TOOL_REV)"
63
136
64
137
65
#### PRIMARY TOOLCHAIN URLS #####
138
#### PRIMARY TOOLCHAIN URLS #####
66
139
67
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
140
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
68
GCC_URL = http://mirror.anl.gov/pub/gnu/gcc/gcc-$(GCC_VERSION)/$(GCC_ARCHIVE)
141
GCC_URL = http://mirror.anl.gov/pub/gnu/gcc/gcc-$(GCC_VERSION)/$(GCC_ARCHIVE)
69
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
142
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
70
143
71
GDB_ARCHIVE = gdb-$(GDB_VERSION).tar.bz2
144
GDB_ARCHIVE = gdb-$(GDB_VERSION_DLOAD).tar.bz2
72
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
145
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
73
GDB_MD5 = 30a6bf36eded4ae5a152d7d71b86dc14
146
GDB_MD5 = 3564f308f3e4d4f2750891bc2ce9b214
74
147
75
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
148
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
76
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
149
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
-
 
150
# V 2.20.1
77
BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
151
#BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
-
 
152
# V 2.22
-
 
153
BINUTILS_MD5 = ee0f10756c84979622b992a4a61ea3f5
78
154
79
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
155
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
80
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
156
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
81
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
157
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
82
158
83
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
159
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
84
AVR32PATCHES_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32PATCHES_ARCHIVE)
160
AVR32PATCHES_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32PATCHES_ARCHIVE)
85
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
161
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
-
 
162
install_dir_avr32patches := source/avr32
-
 
163
-
 
164
NEWPATCHESBINUTILS_ARCHIVE = binutils-2.22-avr32-full.patch
-
 
165
NEWPATCHESBINUTILS_URL=http://avr.anw.at/avr32/patches/binutils/2_22/$(NEWPATCHESBINUTILS_ARCHIVE)
-
 
166
NEWPATCHESBINUTILS_MD5 = 09c091b9acb369fd39fb21d0334bb9a6
-
 
167
install_dir_newpatchesbinutils := source/avr32/binutils
86
168
87
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
169
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
88
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
170
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
89
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
171
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
90
172
Line 93... Line 175...
93
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
175
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
94
176
95
177
96
##### SUPPORT TOOLS VERSIONS / URLS ######
178
##### SUPPORT TOOLS VERSIONS / URLS ######
97
AUTOCONF_VERSION = 2.64
179
AUTOCONF_VERSION = 2.64
98
AUTOMAKE_VERSION = 1.11
180
#AUTOMAKE_VERSION = 1.11
-
 
181
AUTOMAKE_VERSION = 1.11.1
-
 
182
LIBTOOL_VERSION = 2.2.6b
-
 
183
DEJAGNU_VERSION = 1.5
99
MPC_VERSION = 0.8.1
184
MPC_VERSION = 0.8.1
100
185
101
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
186
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
102
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
187
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
103
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
188
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
104
189
105
AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2
190
AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2
106
AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE)
191
AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE)
-
 
192
# V 1.11
107
AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f
193
#AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f
-
 
194
# V 1.11.1
-
 
195
AUTOMAKE_MD5 = c2972c4d9b3e29c03d5f2af86249876f
108
196
-
 
197
LIBTOOL_ARCHIVE = libtool-$(LIBTOOL_VERSION).tar.gz
-
 
198
LIBTOOL_URL = http://mirror.anl.gov/pub/gnu/libtool/$(LIBTOOL_ARCHIVE)
-
 
199
LIBTOOL_MD5 = 07da460450490148c6d2df0f21481a25
109
200
-
 
201
DEJAGNU_ARCHIVE = dejagnu-$(DEJAGNU_VERSION).tar.gz
-
 
202
DEJAGNU_URL = http://mirror.anl.gov/pub/gnu/dejagnu/$(DEJAGNU_ARCHIVE)
-
 
203
DEJAGNU_MD5 = 3df1cbca885e751e22d3ebd1ac64dc3c
110
204
111
.PHONY: install-tools
205
SUPP_TOOLS := autoconf automake libtool
-
 
206
SUPP_TOOLS_TEST := dejagnu
112
install-tools: stamps/install-binutils stamps/install-final-gcc stamps/install-newlib stamps/install-headers
207
ALL_TOOLS := gcc gdb binutils newlib avr32patches avr32headers dfu \
-
 
208
             newpatchesbinutils \
-
 
209
             $(SUPP_TOOLS) $(SUPP_TOOLS_TEST)
113
210
-
 
211
114
.PHONY: install-cross
212
all: install-cross
115
install-cross: install-tools install-note
-
 
116
213
117
214
-
 
215
############ MACROS for the lazy people ;-) ############
-
 
216
-
 
217
## in silent mode (make -s),, print whats ging on
-
 
218
ifeq ($(strip $(MAKEFLAGS)),s)
118
.PHONY: sudomode
219
define quiet_text
119
sudomode:
220
	@echo "$1"
120
ifneq ($(USER),root)
221
endef
121
	@echo Please run this target with sudo!
222
else
122
	@echo e.g.: sudo make targetname
223
define quiet_text
123
	@exit 1
224
endef
124
endif
225
endif
125
226
-
 
227
## the stamp name
-
 
228
define name_stamp
-
 
229
$(STAMP_DIR)/$(1)
-
 
230
endef
-
 
231
-
 
232
## remove a stamp
-
 
233
define rm_stamp
-
 
234
	rm -f $(STAMP_DIR)/$(1)
-
 
235
endef
-
 
236
-
 
237
## remove all stamps
-
 
238
define rm_stamps
-
 
239
	rm -f $(STAMP_DIR)/*-$(1)
-
 
240
endef
-
 
241
-
 
242
## create the stamp directory if not existing and the stamp
-
 
243
define make_stamp
-
 
244
	@[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR)
-
 
245
	date > $(STAMP_DIR)/$(1)
-
 
246
endef
-
 
247
-
 
248
## delete empty directories
-
 
249
define del_empty-directories
-
 
250
	@find . -type d -empty -not -path "*.git*" -not -path "*.svn*" -delete
-
 
251
endef
-
 
252
-
 
253
## delete all empty directories
-
 
254
## need to do this several times to remove all empty sub directories
-
 
255
define del_all_empty-directories
-
 
256
	$(call del_empty-directories)
-
 
257
	$(call del_empty-directories)
-
 
258
	$(call del_empty-directories)
-
 
259
	$(call del_empty-directories)
-
 
260
	$(call del_empty-directories)
-
 
261
endef
-
 
262
-
 
263
-
 
264
## to make the following macros more simply, we need the variables
-
 
265
## with the tool name in lowercase. I could have changed the original
-
 
266
## definition, but I don't want to break the make convention of upper
-
 
267
## case definitions for such user defined variables.
-
 
268
-
 
269
define LOWER_TOOL_VARS
-
 
270
UP_$(1) := $(shell echo "$(1)" | tr '[a-z]' '[A-Z]')
-
 
271
$(1)_VERSION := $$($$(UP_$(1))_VERSION)
-
 
272
$(1)_ARCHIVE := $$($$(UP_$(1))_ARCHIVE)
-
 
273
$(1)_URL := $$($$(UP_$(1))_URL)
-
 
274
$(1)_MD5 := $$($$(UP_$(1))_MD5)
-
 
275
endef
-
 
276
-
 
277
$(foreach tool,$(ALL_TOOLS),$(eval $(call LOWER_TOOL_VARS,$(tool))))
-
 
278
-
 
279
## create the download rule and force download rule
-
 
280
define DOWNLOAD_template
-
 
281
download-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
-
 
282
download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE):
-
 
283
	[ -d $(DOWNLOAD_DIR) ] || mkdir -p $(DOWNLOAD_DIR)
-
 
284
	cd $(DOWNLOAD_DIR) && curl -LO $$($(1)_URL)
-
 
285
-
 
286
download-$(1)_TEXT := "Removing $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)"
-
 
287
download-$(1)-remove:
-
 
288
	$(call quiet_text,$$(download-$(1)_TEXT))
-
 
289
	rm -f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
-
 
290
-
 
291
available_targets += download-$(1) download-$(1)-f download-$(1)-remove
-
 
292
-
 
293
PHONY += download-$(1) download-$(1)-f download-$(1)-remove
-
 
294
endef
-
 
295
-
 
296
## extract commands
-
 
297
EXT_BZ2 := tar -jxf
-
 
298
EXT_TGZ := tar -xf
-
 
299
EXT_ZIP := unzip -o
-
 
300
-
 
301
## create the extract rule and force extract rule
-
 
302
define EXTRACT_template
-
 
303
$(1)_extract_cmds ?= $($(2)) $$< $(3)
-
 
304
-
 
305
extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)"
-
 
306
extract-$(1): $(call name_stamp,extract-$(1))
-
 
307
extract-$(1)-f $(call name_stamp,extract-$(1)): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
-
 
308
	@(rm -rf $(1)-*; \
-
 
309
	t1=`openssl md5 $$< | cut -f 2 -d " " -` && \
-
 
310
	[ "$$$$t1" = "$$($(1)_MD5)" ] || \
-
 
311
	( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
-
 
312
	$(call quiet_text,$$(extract-$(1)_TEXT))
-
 
313
	$$($(1)_extract_cmds)
-
 
314
	$(call make_stamp,extract-$(1))
-
 
315
-
 
316
extract-$(1)-remove:
-
 
317
	rm -rf $(1)-*
-
 
318
	$(call rm_stamp,extract-$(1))
-
 
319
-
 
320
clean_extract_$(1)_rule := extract-$(1)-remove
-
 
321
-
 
322
available_targets += extract-$(1) extract-$(1)-f extract-$(1)-remove
-
 
323
-
 
324
PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove
-
 
325
endef
-
 
326
-
 
327
## create the patch rule
-
 
328
define PATCH_template
-
 
329
$(1)_patch_level ?= -p0
-
 
330
-
 
331
patch-$(1)_TEXT := "Patching $$($(1)_ARCHIVE)"
-
 
332
patch-$(1): $(call name_stamp,patch-$(1))
-
 
333
$(call name_stamp,patch-$(1)): $(call name_stamp,extract-$(1)) $(call name_stamp,extract-avr32patches) \
-
 
334
                               $(call name_stamp,extract-newpatchesbinutils)
-
 
335
	$(call quiet_text,$$(patch-$(1)_TEXT))
-
 
336
	@(pushd $(1)-$$($(1)_VERSION) ; \
-
 
337
	for f in ../$(install_dir_avr32patches)/$(1)/*.patch; do \
-
 
338
	echo "Patching using: $$$${f}" ; \
-
 
339
	patch -N $$($(1)_patch_level) --no-backup-if-mismatch -i $$$${f} ; \
-
 
340
	if [ $$$$? -ne 0 ] ; then exit -1 ; fi ; \
-
 
341
	done ; \
-
 
342
	popd)
-
 
343
	$(call make_stamp,patch-$(1))
126
344
127
.PHONY: tst
345
patch-$(1)-remove: extract-$(1)-remove
128
tst:
-
 
129
	@echo $(PREFIX)
346
	$(call rm_stamp,patch-$(1))
130
347
131
.PHONY: install-note
-
 
132
install-note: install-tools
-
 
133
	@echo
-
 
134
	@echo ====== INSTALLATION NOTE ======
-
 
135
	@echo Your tools have now been installed at the following prefix:
-
 
136
	@echo $(PREFIX)
-
 
137
	@echo
-
 
138
	@echo Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
-
 
139
	@echo export PATH=$(PREFIX)/bin:'$$PATH'
348
clean_patch_$(1)_rule := patch-$(1)-remove
140
349
-
 
350
available_targets += patch-$(1) patch-$(1)-remove
-
 
351
-
 
352
PHONY += patch-$(1) patch-$(1)-remove
-
 
353
endef
-
 
354
-
 
355
## one rule for all required support tools
-
 
356
install-supp-tools_targets := $(foreach tool,$(SUPP_TOOLS),$(call name_stamp,install-$(tool)))
-
 
357
install-supp-tools: $(install-supp-tools_targets)
-
 
358
-
 
359
clean-supp-tools: $(foreach tool,$(SUPP_TOOLS),clean-$(tool))
-
 
360
-
 
361
available_targets += install-supp-tools clean-supp-tools
-
 
362
-
 
363
PHONY += install-supp-tools clean-supp-tools
-
 
364
-
 
365
## create the regen rule
-
 
366
## it is used to regenerate the auto tools result files
-
 
367
define REGEN_template
-
 
368
regen-$(1)_TEXT := "Regenerate auto tool files for $$($(1)_ARCHIVE)"
-
 
369
regen-$(1): $(call name_stamp,regen-$(1))
-
 
370
regen-$(1)-f $(call name_stamp,regen-$(1)): $(call name_stamp,$(2)-$(1)) \
-
 
371
                                            $(install-supp-tools_targets)
-
 
372
	$(call quiet_text,$$(regen-$(1)_TEXT))
-
 
373
	@(pushd $(1)-$$($(1)_VERSION) ; \
-
 
374
	PATH=$(SUPP_PREFIX)/bin:$$$${PATH} $(SUPP_PREFIX)/bin/autoreconf -v ; \
-
 
375
	for dir in $$($(1)_regen_dirs) ; do \
-
 
376
	  pushd $$$$dir ; \
-
 
377
	  PATH=$(SUPP_PREFIX)/bin:$$$${PATH} $(SUPP_PREFIX)/bin/autoreconf -v ; \
-
 
378
	  popd ; \
-
 
379
	done; \
-
 
380
	popd)
-
 
381
	$(call make_stamp,regen-$(1))
141
382
142
.PHONY: download-gdb
383
regen-$(1)-remove:
143
downloads/$(GDB_ARCHIVE) download-gdb:
-
 
144
	[ -d downloads ] || mkdir downloads ;
-
 
145
	cd downloads && curl -LO $(GDB_URL)
384
	$(call rm_stamp,regen-$(1))
146
385
-
 
386
clean_regen_$(1)_rule := regen-$(1)-remove
147
387
-
 
388
available_targets += regen-$(1) regen-$(1)-f regen-$(1)-remove
148
389
-
 
390
PHONY += regen-$(1) regen-$(1)-f regen-$(1)-remove
-
 
391
endef
149
392
-
 
393
## create the configure rule and force configure rule
150
.PHONY: install-supp-tools
394
define CONF_template
151
install-supp-tools stamps/install-supp-tools: install-autoconf install-automake
395
# we need configure parameters!
152
	[ -d stamps ] || mkdir stamps ;
396
ifeq ($$(strip $$($(1)_conf_opts)),)
153
	touch stamps/install-supp-tools;
397
$$(error "Configure options '$(1)_conf_opts' not defined")
-
 
398
endif
154
399
-
 
400
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)"
-
 
401
conf-$(1): $(call name_stamp,conf-$(1))
155
402
-
 
403
conf-$(1)-f $(call name_stamp,conf-$(1)): $(call name_stamp,$(2)-$(1)) $$($(1)_conf_deps)
-
 
404
	@(rm -rf $(BUILD_DIR)/$(1) ; mkdir -p $(BUILD_DIR)/$(1))
-
 
405
	$(call quiet_text,$$(conf-$(1)_TEXT))
-
 
406
	cd $(BUILD_DIR)/$(1) && \
-
 
407
	$$($(1)_conf_env) \
-
 
408
	../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts)
-
 
409
	$(call make_stamp,conf-$(1))
-
 
410
-
 
411
conf-$(1)-remove:
-
 
412
	$(call rm_stamp,conf-$(1))
-
 
413
-
 
414
clean_conf_$(1)_rule := conf-$(1)-remove
-
 
415
-
 
416
available_targets += conf-$(1) conf-$(1)-f conf-$(1)-remove
-
 
417
-
 
418
PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove
-
 
419
endef
-
 
420
156
############# SUPP: AUTOCONF ############
421
## create the build rule and force build rule
-
 
422
define BUILD_template
-
 
423
build-$(1): $(call name_stamp,build-$(1))
-
 
424
build-$(1)-f: build-$(1)-clean build-$(1)
-
 
425
-
 
426
# default commands overrideable
-
 
427
$(1)_build_cmds ?= $(MAKE) -j$(PROCS)
-
 
428
$(1)_build_clean_cmds ?= $(MAKE) clean
-
 
429
-
 
430
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)"
-
 
431
$(call name_stamp,build-$(1)): $(call name_stamp,conf-$(1))
-
 
432
	$(call quiet_text,$$(build-$(1)_TEXT))
-
 
433
	cd $(BUILD_DIR)/$(1) && \
-
 
434
	$$($(1)_build_env) \
-
 
435
	$$($(1)_build_cmds)
-
 
436
	$(call make_stamp,build-$(1))
-
 
437
-
 
438
build-$(1)-clean_TEXT := "Cleaning $(1) $$($(1)_VERSION)"
-
 
439
build-$(1)-clean:
-
 
440
	$(call quiet_text,$$(build-$(1)-clean_TEXT))
-
 
441
	cd $(BUILD_DIR)/$(1) && \
-
 
442
	$$($(1)_build_clean_cmds)
-
 
443
	$(call rm_stamp,build-$(1))
-
 
444
-
 
445
build-$(1)-remove:
-
 
446
	rm -rf $(BUILD_DIR)/$(1)
-
 
447
	$(call rm_stamp,build-$(1))
-
 
448
-
 
449
clean_build_$(1)_rule := build-$(1)-remove
-
 
450
-
 
451
available_targets += build-$(1) build-$(1)-f build-$(1)-clean build-$(1)-remove
-
 
452
-
 
453
PHONY += build-$(1) build-$(1)-f build-$(1)-clean build-$(1)-remove
-
 
454
endef
-
 
455
-
 
456
## create the install rule and force install rule
-
 
457
define INSTALL_template
-
 
458
install-$(1)_TEXT := "Installing $(1) $$($(1)_VERSION)"
-
 
459
install-$(1): $(call name_stamp,install-$(1))
-
 
460
install-$(1)-f $(call name_stamp,install-$(1)): $(call name_stamp,build-$(1))
-
 
461
	$(call quiet_text,$$(install-$(1)_TEXT))
-
 
462
	cd $(BUILD_DIR)/$(1) && \
-
 
463
	$(MAKE) install
-
 
464
	$(call make_stamp,install-$(1))
157
465
-
 
466
uninstall-$(1)_TEXT := "Uninstalling $(1) $$($(1)_VERSION)"
158
.PHONY: download-autoconf
467
uninstall-$(1):
159
downloads/$(AUTOCONF_ARCHIVE) download-autoconf:
468
	$(call quiet_text,$$(uninstall-$(1)_TEXT))
160
	[ -d downloads ] || mkdir downloads ;
469
	[ -f $(BUILD_DIR)/$(1)/Makefile ] && \
161
	cd downloads && curl -LO $(AUTOCONF_URL)
470
	[ -f $(call name_stamp,install-$(1)) ] && \
-
 
471
	cd $(BUILD_DIR)/$(1) && \
-
 
472
	$(MAKE) uninstall || true
-
 
473
	$(call rm_stamp,install-$(1))
162
474
163
.PHONY: extract-autoconf
-
 
164
extract-autoconf stamps/extract-autoconf: downloads/$(AUTOCONF_ARCHIVE)
-
 
165
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
475
clean_uninstall_$(1)_rule := uninstall-$(1)
166
	[ "$$t1" = "$(AUTOCONF_MD5)" ] || \
-
 
167
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
168
	tar -jxf $< ;
-
 
169
	[ -d stamps ] || mkdir stamps ;
-
 
170
	touch stamps/extract-autoconf;
-
 
171
476
172
.PHONY: build-autoconf
-
 
173
build-autoconf stamps/build-autoconf: stamps/extract-autoconf
477
available_targets += install-$(1) install-$(1)-f uninstall-$(1)
174
	mkdir -p build/autoconf && cd build/autoconf && \
-
 
175
	../../autoconf-$(AUTOCONF_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
-
 
176
	$(MAKE) -j$(PROCS)
-
 
177
	[ -d stamps ] || mkdir stamps
-
 
178
	touch stamps/build-autoconf;
-
 
179
478
180
.PHONY: install-autoconf
-
 
181
install-autoconf stamps/install-autoconf:  stamps/build-autoconf
479
PHONY += install-$(1) install-$(1)-f uninstall-$(1)
182
	cd build/autoconf && \
-
 
183
	$(MAKE) install
480
endef
184
	[ -d stamps ] || mkdir stamps
-
 
185
	touch stamps/install-autoconf;
-
 
186
481
-
 
482
## create the clean rule and realclean rule
-
 
483
define CLEAN_template
-
 
484
clean-$(1)_TEXT := "Cleaning $(1) $$($(1)_VERSION)"
-
 
485
clean-$(1)-text:
-
 
486
	$(call quiet_text,$$(clean-$(1)_TEXT))
187
487
-
 
488
clean-$(1): clean-$(1)-text $$(clean_uninstall_$(1)_rule) $$(clean_extract_$(1)_rule) \
-
 
489
            $$(clean_patch_$(1)_rule) $$(clean_regen_$(1)_rule) $$(clean_build_$(1)_rule) \
-
 
490
            $$(clean_conf_$(1)_rule)
-
 
491
	$(call del_all_empty-directories)
188
492
189
############ SUPP: AUTOMAKE ############
493
clean_rules += clean-$(1)
190
494
191
.PHONY: download-automake
-
 
192
downloads/$(AUTOMAKE_ARCHIVE) download-automake:
495
realclean-$(1): clean-$(1) download-$(1)-remove
193
	[ -d downloads ] || mkdir downloads ;
496
	$(call del_all_empty-directories)
194
	cd downloads && curl -LO $(AUTOMAKE_URL)
-
 
195
497
196
.PHONY: extract-automake
-
 
197
extract-automake stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
-
 
198
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
-
 
199
	[ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
-
 
200
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
201
	tar -jxf $< ;
-
 
202
	[ -d stamps ] || mkdir stamps ;
-
 
203
	touch stamps/extract-automake;
498
realclean_rules += realclean-$(1)
204
499
205
.PHONY: build-automake
-
 
206
build-automake stamps/build-automake: stamps/extract-automake stamps/install-autoconf
-
 
207
	mkdir -p build/automake && cd build/automake && \
500
available_targets += clean-$(1) realclean-$(1)
208
	../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
-
 
209
	$(MAKE) -j$(PROCS)
-
 
210
	[ -d stamps ] || mkdir stamps
-
 
211
	touch stamps/build-automake;
-
 
212
501
213
.PHONY: install-automake
-
 
214
install-automake stamps/install-automake:  stamps/build-automake
502
PHONY += clean-$(1) realclean-$(1) clean-$(1)-text
215
	cd build/automake && \
-
 
216
	$(MAKE) install
503
endef
217
	[ -d stamps ] || mkdir stamps
-
 
218
	touch stamps/install-automake;
-
 
219
504
220
505
-
 
506
############# SUPP: AUTOCONF ############
-
 
507
-
 
508
$(eval $(call DOWNLOAD_template,autoconf))
-
 
509
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2))
-
 
510
autoconf_conf_opts := --prefix="$(SUPP_PREFIX)"
-
 
511
$(eval $(call CONF_template,autoconf,extract))
-
 
512
$(eval $(call BUILD_template,autoconf))
-
 
513
$(eval $(call INSTALL_template,autoconf))
-
 
514
$(eval $(call CLEAN_template,autoconf))
-
 
515
-
 
516
-
 
517
############ SUPP: AUTOMAKE ############
-
 
518
-
 
519
$(eval $(call DOWNLOAD_template,automake))
-
 
520
$(eval $(call EXTRACT_template,automake,EXT_BZ2))
-
 
521
automake_conf_opts := --prefix="$(SUPP_PREFIX)"
-
 
522
# automake needs the new autoconf allready installed
-
 
523
automake_conf_deps := $(call name_stamp,install-autoconf)
-
 
524
$(eval $(call CONF_template,automake,extract))
-
 
525
$(eval $(call BUILD_template,automake))
-
 
526
$(eval $(call INSTALL_template,automake))
-
 
527
$(eval $(call CLEAN_template,automake))
-
 
528
-
 
529
-
 
530
############ SUPP: LIBTOOL ############
-
 
531
-
 
532
$(eval $(call DOWNLOAD_template,libtool))
-
 
533
$(eval $(call EXTRACT_template,libtool,EXT_TGZ))
-
 
534
libtool_conf_opts := --prefix="$(SUPP_PREFIX)"
-
 
535
# libtool needs the new autoconf/automake allready installed
-
 
536
libtool_conf_deps := $(call name_stamp,install-autoconf) \
-
 
537
                     $(call name_stamp,install-automake)
-
 
538
$(eval $(call CONF_template,libtool,extract))
-
 
539
$(eval $(call BUILD_template,libtool))
-
 
540
$(eval $(call INSTALL_template,libtool))
-
 
541
$(eval $(call CLEAN_template,libtool))
-
 
542
-
 
543
-
 
544
############ SUPP-TEST: DEJAGNU ############
-
 
545
-
 
546
$(eval $(call DOWNLOAD_template,dejagnu))
-
 
547
$(eval $(call EXTRACT_template,dejagnu,EXT_TGZ))
-
 
548
dejagnu_conf_opts := --prefix="$(SUPP_PREFIX)"
-
 
549
# dejagnu needs the new autoconf/automake allready installed
-
 
550
dejagnu_conf_deps := $(call name_stamp,install-autoconf) \
-
 
551
                     $(call name_stamp,install-automake)
-
 
552
$(eval $(call CONF_template,dejagnu,extract))
-
 
553
$(eval $(call BUILD_template,dejagnu))
-
 
554
$(eval $(call INSTALL_template,dejagnu))
-
 
555
$(eval $(call CLEAN_template,dejagnu))
-
 
556
221
557
222
############# AVR32 PATCHES ############
558
############# AVR32 PATCHES ############
223
559
-
 
560
$(eval $(call DOWNLOAD_template,avr32patches))
-
 
561
$(eval $(call EXTRACT_template,avr32patches,EXT_ZIP))
-
 
562
-
 
563
## use the uninstall-XXX rule to remove the patches directory
224
.PHONY: download-avr32patches
564
PHONY += uninstall-avr32patches
-
 
565
uninstall-avr32patches:
-
 
566
	rm -rf $(install_dir_avr32patches)
-
 
567
225
downloads/$(AVR32PATCHES_ARCHIVE) download-avr32patches:
568
clean_uninstall_avr32patches_rule = uninstall-avr32patches
-
 
569
226
	cd downloads && curl -LO $(AVR32PATCHES_URL)
570
$(eval $(call CLEAN_template,avr32patches))
227
571
-
 
572
-
 
573
############# NEWPATCHESBINUTILS ############
-
 
574
-
 
575
$(eval $(call DOWNLOAD_template,newpatchesbinutils))
228
.PHONY: extract-avr32patches
576
newpatchesbinutils_extract_cmds := \
-
 
577
@([ -d $(install_dir_newpatchesbinutils) ] && \
229
extract-avr32patches stamps/extract-avr32patches : downloads/$(AVR32PATCHES_ARCHIVE)
578
  mv $(install_dir_newpatchesbinutils) $(install_dir_newpatchesbinutils).x ; \
230
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
579
  mkdir -p $(install_dir_newpatchesbinutils) ; \
-
 
580
  cp $(DOWNLOAD_DIR)/$(NEWPATCHESBINUTILS_ARCHIVE) $(install_dir_newpatchesbinutils) \
-
 
581
)
231
	[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
582
$(eval $(call EXTRACT_template,newpatchesbinutils))
-
 
583
232
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
584
## use the uninstall-XXX rule to remove the patches directory
233
	unzip -o $<
585
PHONY += uninstall-avr32patches
234
	[ -d stamps ] || mkdir stamps
586
uninstall-newpatchesbinutils:
235
	touch stamps/extract-avr32patches;
587
	rm -rf $(install_dir_newpatchesbinutils)
-
 
588
-
 
589
clean_uninstall_newpatchesbinutils_rule = uninstall-newpatchesbinutils
-
 
590
-
 
591
$(eval $(call CLEAN_template,newpatchesbinutils))
236
592
237
593
238
############# AVR32 HEADERS ############
594
############# AVR32 HEADERS ############
-
 
595
$(eval $(call DOWNLOAD_template,avr32headers))
239
596
-
 
597
###### FIXME: Need to add a dependency to "stamps/install-final-gcc"
-
 
598
install_path_avr32headers := $(PREFIX)/$(TARGET)/include
-
 
599
avr32headers_unzip_opt := -d "$(install_path_avr32headers)"
-
 
600
$(eval $(call EXTRACT_template,avr32headers,EXT_ZIP,$(avr32headers_unzip_opt)))
-
 
601
-
 
602
## use the uninstall-XXX rule to remove the patches directory
-
 
603
install_dir_avr32headers := $(install_path_avr32headers)/avr32
240
.PHONY: download-avr32headers
604
PHONY += uninstall-avr32headers
241
downloads/$(AVR32HEADERS_ARCHIVE) download-avr32headers:
605
uninstall-avr32headers:
242
	cd downloads && curl -LO $(AVR32HEADERS_URL)
606
	rm -rf $(install_dir_avr32headers)
243
607
-
 
608
clean_uninstall_avr32headers_rule = uninstall-avr32headers
-
 
609
-
 
610
$(eval $(call CLEAN_template,avr32headers))
-
 
611
-
 
612
-
 
613
################ BINUTILS ################
-
 
614
-
 
615
$(eval $(call DOWNLOAD_template,binutils))
-
 
616
$(eval $(call EXTRACT_template,binutils,EXT_BZ2))
-
 
617
#binutils_patch_level := -p1
-
 
618
$(eval $(call PATCH_template,binutils))
-
 
619
binutils_regen_dirs := bfd opcodes binutils gas ld
-
 
620
$(eval $(call REGEN_template,binutils,patch))
-
 
621
-
 
622
ifneq ($(M_MODE),no)
-
 
623
binutils_maintainer_mode := --enable-maintainer-mode
-
 
624
endif
-
 
625
-
 
626
# do not add a ' ' between after ":="
-
 
627
ifneq ($(BINUTILS_REGEN),no)
-
 
628
binutils_conf_depend :=regen
-
 
629
else	
-
 
630
binutils_conf_depend :=patch
-
 
631
endif
-
 
632
-
 
633
binutils_conf_opts := \
-
 
634
  $(binutils_maintainer_mode) \
-
 
635
  --prefix="$(PREFIX)" --target=$(TARGET) --disable-nls \
-
 
636
  --disable-shared --disable-werror \
-
 
637
  --enable-ld=yes --enable-gold=no \
-
 
638
  --with-pkgversion=$(PKG_VERSION) \
-
 
639
  --with-sysroot="$(PREFIX)/$(TARGET)"
-
 
640
#  --with-bugurl=$(BUG_URL)
-
 
641
$(eval $(call CONF_template,binutils,$(binutils_conf_depend)))
-
 
642
-
 
643
ifneq ($(FULL_STATIC),no)
-
 
644
binutils_fulls_static := AM_LDFLAGS=-all-static
-
 
645
endif
-
 
646
#binutils_build_cmds := ???
-
 
647
#binutils_build_clean_cmds := ???
-
 
648
binutils_build_env := $(binutils_fulls_static)
-
 
649
$(eval $(call BUILD_template,binutils))
-
 
650
$(eval $(call INSTALL_template,binutils))
-
 
651
$(eval $(call CLEAN_template,binutils))
-
 
652
-
 
653
-
 
654
.PHONY: $(PHONY)
-
 
655
-
 
656
-
 
657
-
 
658
-
 
659
.PHONY: tst
-
 
660
tst:
-
 
661
	@echo "PREFIX=$(PREFIX)"
-
 
662
	@echo "PKG_VERSION=$(PKG_VERSION)"
-
 
663
	@echo "BUG_URL=$(BUG_URL)"
-
 
664
-
 
665
.PHONY: help
-
 
666
help:
-
 
667
	@echo ""
-
 
668
	@echo "The following targets are available:"
-
 
669
	@echo ""
-
 
670
	@echo "download-XXX	: download the required package"
-
 
671
	@echo "extract-XXX	: extract the downloaded package"
-
 
672
	@echo "conf-XXX	: configure the extracted package"
-
 
673
	@echo "build-XXX	: build the configured package"
-
 
674
	@echo "install-XXX	: install the build package"
-
 
675
	@echo "uninstall-XXX	: uninstall the installed package"
-
 
676
	@echo "clean-XXX	: clean the package source and build tree"
-
 
677
	@echo "realclean-XXX	: same as clean-XXX, but remove the downloaded"
-
 
678
	@echo "		  package, too"
-
 
679
	@echo ""
-
 
680
	@echo "XXX can be one of the following:"
-
 
681
	@echo "$(ALL_TOOLS)"
-
 
682
	@echo "supp-tools"
-
 
683
	@echo ""
-
 
684
	@echo "The above targets will be executed in the right order and only if"
-
 
685
	@echo "they need to be be really built. If you want to rebuild one of them"
-
 
686
	@echo "manualy, you can use the aaaa-XXX-f target (e.g.: build-autoconf-f,"
-
 
687
	@echo "download-automake-f). Please note, that not all steps are available for"
-
 
688
	@echo "all tools (e.g.: install-avr32patches is not available)."
-
 
689
	@echo ""
-
 
690
	@echo "clean		: clean all; execute all clean-XXX rules"
-
 
691
	@echo "realclean	: same as clean, but remove all downloaded"
-
 
692
	@echo "                  packages, too (execute all realclean-XXX rules)"
-
 
693
	@echo ""
-
 
694
	@echo "help		: this inforamtion"
-
 
695
	@echo "helpx		: this inforamtion + available targets"
-
 
696
	@echo ""
-
 
697
	@echo "The installation prefix can be set by"
-
 
698
	@echo " PREFIX=.... make aaa-XXX"
-
 
699
	@echo "And the package version with"
-
 
700
	@echo " PKG_VERSION=\"AVR 32 bit GNU Toolchain-XXX\""
-
 
701
	@echo ""
-
 
702
	@echo "Build a full static release with"
-
 
703
	@echo " RELEASE_VERSION=0.1.0"
-
 
704
	@echo "The prefix for the release can changed with"
-
 
705
	@echo " PREFIX_RELEASE=/usr/local/avr/avr32-tools"
-
 
706
	@echo ""
-
 
707
	@echo "Maintainers may use"
-
 
708
	@echo " M_MODE=y, BINUTILS_REGEN=y, FULL_STATIC=y"
-
 
709
	@echo "Please have a look to the Makefile for details"
-
 
710
	@echo ""
-
 
711
-
 
712
# do not remove the empty line, will add the required \n
-
 
713
define print_target
-
 
714
	@echo "$(1)"
-
 
715
-
 
716
endef
-
 
717
-
 
718
.PHONY: helpx
-
 
719
helpx: help
-
 
720
	@echo "Available targets:"
-
 
721
	$(foreach target,$(available_targets),$(call print_target,$(target)))
-
 
722
	@echo ""
-
 
723
-
 
724
.PHONY: install-note
-
 
725
install-note: install-tools
-
 
726
	@echo ""
-
 
727
	@echo "====== INSTALLATION NOTE ======"
-
 
728
	@echo "Your tools have now been installed at the following prefix:"
-
 
729
	@echo "$(PREFIX)"
-
 
730
	@echo
-
 
731
	@echo "Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:"
-
 
732
	@echo '  export PATH="$(PREFIX)/bin:$$PATH"'
-
 
733
	@echo
-
 
734
-
 
735
.PHONY: install-tools
-
 
736
install-tools: install-binutils
-
 
737
# FIXME: other currently not finished
-
 
738
# install-final-gcc install-newlib install-headers
-
 
739
244
.PHONY: install-headers
740
.PHONY: install-cross
-
 
741
install-cross: install-tools install-note
-
 
742
-
 
743
.PHONY : clean realclean
-
 
744
clean: $(clean_rules)
-
 
745
-
 
746
realclean: $(realclean_rules)
-
 
747
-
 
748
-
 
749
-
 
750
#################################################################
-
 
751
#################################################################
-
 
752
####                                                        ######
-
 
753
####                                                        ######
-
 
754
####                                                        ######
-
 
755
####      FROM HERE ON OLD CODE OF ORIGINAL MAKEFILE        ######
-
 
756
####      COMPLETELY UNSUPPORTED AND FOR PATTERN FOR        ######
-
 
757
####      ADDITIONAL WORK ONLY                              ######
-
 
758
####                                                        ######
-
 
759
####                                                        ######
-
 
760
####                                                        ######
-
 
761
#################################################################
-
 
762
#################################################################
-
 
763
-
 
764
-
 
765
-
 
766
-
 
767
############ SUPP: AUTOMAKE ############
-
 
768
-
 
769
##.PHONY: download-automake download-automake-force
-
 
770
##download-automake: downloads/$(AUTOMAKE_ARCHIVE)
-
 
771
##download-automake-force downloads/$(AUTOMAKE_ARCHIVE):
-
 
772
##	[ -d downloads ] || mkdir downloads ;
-
 
773
##	cd downloads && curl -LO $(AUTOMAKE_URL)
-
 
774
-
 
775
##.PHONY: extract-automake extract-automake-force
-
 
776
##extract-automake: stamps/extract-automake
-
 
777
##extract-automake-force stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
-
 
778
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
-
 
779
##	[ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
-
 
780
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
781
##	tar -jxf $< ;
-
 
782
##	[ -d stamps ] || mkdir stamps ;
-
 
783
##	touch stamps/extract-automake;
-
 
784
-
 
785
##.PHONY: build-automake build-automake-force
-
 
786
##build-automake: stamps/build-automake
-
 
787
##build-automake-force stamps/build-automake: stamps/extract-automake stamps/install-autoconf
-
 
788
##	mkdir -p build/automake && cd build/automake && \
-
 
789
##	../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
-
 
790
##	$(MAKE) -j$(PROCS)
-
 
791
##	[ -d stamps ] || mkdir stamps
-
 
792
##	touch stamps/build-automake;
-
 
793
-
 
794
##.PHONY: install-automake install-automake-force
-
 
795
##install-automake: stamps/install-automake
-
 
796
##install-automake-force stamps/install-automake: stamps/build-automake
-
 
797
##	cd build/automake && \
-
 
798
##	$(MAKE) install
-
 
799
##	[ -d stamps ] || mkdir stamps
-
 
800
##	touch stamps/install-automake;
-
 
801
-
 
802
##.PHONY: clean-automake
-
 
803
##clean-automake:
-
 
804
##	rm -rf build/automake stamps/*-automake automake-*
-
 
805
-
 
806
##.PHONY: realclean-automake
-
 
807
##realclean-automake: clean-automake
-
 
808
##	rm downloads/$(AUTOMAKE_ARCHIVE)
-
 
809
-
 
810
-
 
811
############# AVR32 PATCHES ############
-
 
812
-
 
813
##.PHONY: download-avr32patches download-avr32patches-force
-
 
814
##download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
-
 
815
##download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
-
 
816
##	cd downloads && curl -LO $(AVR32PATCHES_URL)
-
 
817
-
 
818
##.PHONY: extract-avr32patches extract-avr32patches-force
-
 
819
##extract-avr32patches: stamps/extract-avr32patches
-
 
820
##extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
-
 
821
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
-
 
822
##	[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
-
 
823
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
824
##	unzip -o $<
-
 
825
##	[ -d stamps ] || mkdir stamps
-
 
826
##	touch stamps/extract-avr32patches;
-
 
827
-
 
828
##.PHONY: clean-avr32patches
-
 
829
##clean-avr32patches:
-
 
830
##	rm -rf stamps/*-avr32patches source
-
 
831
-
 
832
##.PHONY: realclean-avr32patches
-
 
833
##realclean-avr32patches: clean-avr32patches
-
 
834
##	rm downloads/$(AVR32PATCHES_ARCHIVE)
-
 
835
-
 
836
-
 
837
############# AVR32 HEADERS ############
-
 
838
-
 
839
##.PHONY: download-avr32headers download-avr32headers-force
-
 
840
##download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
-
 
841
##download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
-
 
842
##	cd downloads && curl -LO $(AVR32HEADERS_URL)
-
 
843
-
 
844
##.PHONY: install-headers install-headers-force
-
 
845
##install-headers: stamps/install-headers
245
install-headers stamps/install-headers : downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
846
##install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
246
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
847
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
247
	[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
848
##	[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
248
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
849
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
249
	unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
850
##	unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
250
	[ -d stamps ] || mkdir stamps
851
##	[ -d stamps ] || mkdir stamps
251
	touch stamps/install-headers;
852
##	touch stamps/install-headers;
-
 
853
-
 
854
##.PHONY: clean-headers
-
 
855
##clean-headers:
-
 
856
##	rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
-
 
857
-
 
858
##.PHONY: realclean-headers
-
 
859
##realclean-headers: clean-headers
-
 
860
##	rm downloads/$(AVR32HEADERS_ARCHIVE)
252
861
253
862
254
################ NEWLIB ################
863
################ NEWLIB ################
255
864
256
.PHONY: download-newlib
865
.PHONY: download-newlib download-newlib-force
257
downloads/$(NEWLIB_ARCHIVE) download-newlib:
866
download-newlib: downloads/$(NEWLIB_ARCHIVE)
-
 
867
download-newlib-force downloads/$(NEWLIB_ARCHIVE):
258
	[ -d downloads ] || mkdir downloads ;
868
	[ -d downloads ] || mkdir downloads ;
259
	cd downloads && curl -LO $(NEWLIB_URL)
869
	cd downloads && curl -LO $(NEWLIB_URL)
260
870
261
.PHONY: prep-newlib
871
.PHONY: extract-newlib extract-newlib-force
262
prep-newlib stamps/prep-newlib: stamps/regen-newlib
-
 
263
	[ -d stamps ] || mkdir stamps
-
 
264
	touch stamps/prep-newlib;
872
extract-newlib: stamps/extract-newlib
265
-
 
266
-
 
267
.PHONY: extract-newlib
-
 
268
extract-newlib stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
873
extract-newlib-force stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
269
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
874
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
270
	[ "$$t1" = "$(NEWLIB_MD5)" ] || \
875
	[ "$$t1" = "$(NEWLIB_MD5)" ] || \
271
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
876
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
272
	tar -xf $<
877
	tar -xf $<
273
	[ -d stamps ] || mkdir stamps
878
	[ -d stamps ] || mkdir stamps
274
	touch stamps/extract-newlib;
879
	touch stamps/extract-newlib;
275
880
276
881
277
.PHONY: patch-newlib
882
.PHONY: patch-newlib patch-newlib-force
-
 
883
patch-newlib: stamps/patch-newlib
278
patch-newlib stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
884
patch-newlib-force stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
279
	pushd newlib-$(NEWLIB_VERSION) ; \
885
	pushd newlib-$(NEWLIB_VERSION) ; \
280
	for f in ../source/avr32/newlib/*.patch; do \
886
	for f in ../source/avr32/newlib/*.patch; do \
281
	patch -N -p0 <$${f} ; \
887
	patch -N -p0 <$${f} ; \
282
	done ; \
888
	done ; \
283
	popd ;
889
	popd ;
284
	[ -d stamps ] || mkdir stamps
890
	[ -d stamps ] || mkdir stamps
285
	touch stamps/patch-newlib;
891
	touch stamps/patch-newlib;
286
892
287
.PHONY: regen-newlib
893
.PHONY: regen-newlib regen-newlib-force
-
 
894
regen-newlib: stamps/regen-newlib
288
regen-newlib stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
895
regen-newlib-force stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
289
	pushd newlib-$(NEWLIB_VERSION) ; \
896
	pushd newlib-$(NEWLIB_VERSION) ; \
290
	"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
897
	"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
291
	for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
898
	for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
292
	  pushd $$dir ; \
899
	  pushd $$dir ; \
293
	  "$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
900
	  "$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
Line 301... Line 908...
301
NEWLIB_FLAGS="-ffunction-sections -fdata-sections	\
908
NEWLIB_FLAGS="-ffunction-sections -fdata-sections	\
302
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os	\
909
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os	\
303
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128	\
910
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128	\
304
-DSMALL_MEMORY"
911
-DSMALL_MEMORY"
305
912
306
.PHONY: cross-newlib
913
.PHONY: build-newlib build-newlib-force
-
 
914
build-newlib: stamps/build-newlib
307
build-newlib stamps/build-newlib: stamps/prep-newlib stamps/install-binutils stamps/install-gcc
915
build-newlib-force stamps/build-newlib: stamps/regen-newlib stamps/install-binutils stamps/install-gcc
308
	mkdir -p build/newlib && cd build/newlib && \
916
	mkdir -p build/newlib && cd build/newlib && \
309
	pushd ../../newlib-$(NEWLIB_VERSION) ; \
917
	pushd ../../newlib-$(NEWLIB_VERSION) ; \
310
	make clean ; \
918
	make clean ; \
311
	popd ; \
919
	popd ; \
312
	../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX)	\
920
	../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX)	\
Line 318... Line 926...
318
	--enable-newlib-reent-small  && \
926
	--enable-newlib-reent-small  && \
319
	$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
927
	$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
320
	[ -d stamps ] || mkdir stamps
928
	[ -d stamps ] || mkdir stamps
321
	touch stamps/build-newlib;
929
	touch stamps/build-newlib;
322
930
323
.PHONY: install-newlib
931
.PHONY: install-newlib install-newlib-force
-
 
932
install-newlib: stamps/install-newlib
324
install-newlib stamps/install-newlib: stamps/build-newlib
933
install-newlib-force stamps/install-newlib: stamps/build-newlib
325
	cd build/newlib && \
934
	cd build/newlib && \
326
	$(MAKE) install
935
	$(MAKE) install
327
	[ -d stamps ] || mkdir stamps
936
	[ -d stamps ] || mkdir stamps
328
	touch stamps/install-newlib;
937
	touch stamps/install-newlib;
329
938
330
################ BINUTILS ################
-
 
331
-
 
332
.PHONY: download-binutils
939
.PHONY: clean-newlib
333
downloads/$(BINUTILS_ARCHIVE) download-binutils:
-
 
334
	[ -d downloads ] || mkdir downloads ;
-
 
335
	cd downloads && curl -LO $(BINUTILS_URL)
-
 
336
-
 
337
.PHONY: prep-binutils
940
clean-newlib:
338
prep-binutils stamps/prep-binutils: stamps/regen-binutils
941
	rm -rf build/newlib stamps/*-newlib newlib-*
339
	[ -d stamps ] || mkdir stamps;
-
 
340
	touch stamps/prep-binutils;
-
 
341
942
342
.PHONY: extract-binutils
943
.PHONY: realclean-newlib
343
extract-binutils stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
-
 
344
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
-
 
345
	[ "$$t1" = "$(BINUTILS_MD5)" ] || \
-
 
346
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
347
	tar -jxf $< ;
-
 
348
	[ -d stamps ] || mkdir stamps ;
944
realclean-newlib: clean-newlib
349
	touch stamps/extract-binutils;
945
	rm downloads/$(NEWLIB_ARCHIVE)
350
946
351
.PHONY: patch-binutils
-
 
352
patch-binutils stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
-
 
353
	pushd binutils-$(BINUTILS_VERSION) ; \
-
 
354
	for f in ../source/avr32/binutils/*.patch; do \
-
 
355
	patch -N -p0 <$${f} ; \
-
 
356
	done ; \
-
 
357
	popd ; \
-
 
358
	[ -d stamps ] || mkdir stamps
-
 
359
	touch stamps/patch-binutils;
-
 
360
947
361
.PHONY: regen-binutils
-
 
362
regen-binutils stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
-
 
363
	pushd binutils-$(BINUTILS_VERSION) ; \
948
################ BINUTILS ################
364
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
-
 
365
	"$(SUPP_PREFIX)/bin/autoconf" ; \
-
 
366
	"$(SUPP_PREFIX)/bin/automake" ; \
-
 
367
	"$(SUPP_PREFIX)/bin/autoheader" ; \
-
 
368
	for dir in bfd opcodes binutils gas ld; do \
-
 
369
	  pushd $$dir ; \
-
 
370
	  "$(SUPP_PREFIX)/bin/autoconf"; \
-
 
371
	  "$(SUPP_PREFIX)/bin/automake"; \
-
 
372
	  "$(SUPP_PREFIX)/bin/autoheader"; \
-
 
373
	  popd ; \
-
 
374
	done; \
-
 
375
	popd; \
-
 
376
	[ -d stamps ] || mkdir stamps ;
-
 
377
	touch stamps/regen-binutils;
-
 
378
949
-
 
950
##.PHONY: download-binutils download-binutils-force
-
 
951
##download-binutils: downloads/$(BINUTILS_ARCHIVE)
-
 
952
##download-binutils-force downloads/$(BINUTILS_ARCHIVE):
-
 
953
##	[ -d downloads ] || mkdir downloads ;
-
 
954
##	cd downloads && curl -LO $(BINUTILS_URL)
-
 
955
-
 
956
##.PHONY: extract-binutils extract-binutils-force
-
 
957
##extract-binutils: stamps/extract-binutils
-
 
958
##extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
-
 
959
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
-
 
960
##	[ "$$t1" = "$(BINUTILS_MD5)" ] || \
-
 
961
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
962
##	tar -jxf $< ;
-
 
963
##	[ -d stamps ] || mkdir stamps ;
-
 
964
##	touch stamps/extract-binutils;
-
 
965
-
 
966
##.PHONY: patch-binutils patch-binutils-force
-
 
967
##patch-binutils: stamps/patch-binutils
-
 
968
##patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
-
 
969
##	pushd binutils-$(BINUTILS_VERSION) ; \
-
 
970
##	for f in ../source/avr32/binutils/*.patch; do \
-
 
971
##	patch -N -p0 <$${f} ; \
-
 
972
##	done ; \
-
 
973
##	popd ; \
-
 
974
##	[ -d stamps ] || mkdir stamps
-
 
975
##	touch stamps/patch-binutils;
-
 
976
-
 
977
##.PHONY: regen-binutils regen-binutils-force
-
 
978
##regen-binutils: stamps/regen-binutils
-
 
979
##regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
-
 
980
##	pushd binutils-$(BINUTILS_VERSION) ; \
-
 
981
##	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
-
 
982
##	"$(SUPP_PREFIX)/bin/autoconf" ; \
-
 
983
##	"$(SUPP_PREFIX)/bin/automake" ; \
-
 
984
##	"$(SUPP_PREFIX)/bin/autoheader" ; \
-
 
985
##	for dir in bfd opcodes binutils gas ld; do \
-
 
986
##	  pushd $$dir ; \
-
 
987
##	  "$(SUPP_PREFIX)/bin/autoconf"; \
-
 
988
##	  "$(SUPP_PREFIX)/bin/automake"; \
-
 
989
##	  "$(SUPP_PREFIX)/bin/autoheader"; \
-
 
990
##	  popd ; \
-
 
991
##	done; \
-
 
992
##	popd; \
-
 
993
##	[ -d stamps ] || mkdir stamps ;
-
 
994
##	touch stamps/regen-binutils;
-
 
995
379
.PHONY: build-binutils
996
##.PHONY: build-binutils build-binutils-force
-
 
997
##build-binutils: stamps/build-binutils
380
build-binutils stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
998
##build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
381
	cd binutils-$(BINUTILS_VERSION) ; \
999
##	cd binutils-$(BINUTILS_VERSION) ; \
382
	./configure   --enable-maintainer-mode		\
1000
##	./configure   --enable-maintainer-mode		\
383
	--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls		\
1001
##	--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls		\
384
	--disable-shared --disable-werror				\
1002
##	--disable-shared --disable-werror				\
385
	--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) &&	\
1003
##	--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) &&	\
386
	$(MAKE) all-bfd TARGET-bfd=headers; \
1004
##	$(MAKE) all-bfd TARGET-bfd=headers; \
387
	rm bfd/Makefile; \
1005
##	rm bfd/Makefile; \
388
	make configure-bfd; \
1006
##	make configure-bfd; \
389
	$(MAKE)
1007
##	$(MAKE)
390
	[ -d stamps ] || mkdir stamps ;
1008
##	[ -d stamps ] || mkdir stamps ;
391
	touch stamps/build-binutils;
1009
##	touch stamps/build-binutils;
-
 
1010
-
 
1011
##.PHONY: install-binutils install-binutils-force
-
 
1012
##install-binutils: stamps/install-binutils
-
 
1013
##install-binutils-force stamps/install-binutils: stamps/build-binutils
-
 
1014
##	cd binutils-$(BINUTILS_VERSION) && \
-
 
1015
##	$(MAKE) installdirs install-host install-target
-
 
1016
##	[ -d stamps ] || mkdir stamps ;
-
 
1017
##	touch stamps/install-binutils;
-
 
1018
-
 
1019
-
 
1020
##.PHONY: clean-binutils
-
 
1021
##clean-binutils:
-
 
1022
##	rm -rf build/binutils stamps/*-binutils binutils-*
-
 
1023
-
 
1024
##.PHONY: realclean-binutils
-
 
1025
##realclean-binutils: clean-binutils
-
 
1026
##	rm downloads/$(BINUTILS_ARCHIVE)
392
1027
393
.PHONY: install-binutils
-
 
394
install-binutils stamps/install-binutils: stamps/build-binutils
-
 
395
	cd binutils-$(BINUTILS_VERSION) && \
-
 
396
	$(MAKE) installdirs install-host install-target
-
 
397
	[ -d stamps ] || mkdir stamps ;
-
 
398
	touch stamps/install-binutils;
-
 
399
1028
400
########## DFU PROGRAMMER ###########
1029
########## DFU PROGRAMMER ###########
401
1030
402
.PHONY: download-dfu
1031
.PHONY: download-dfu download-dfu-force
403
downloads/$(DFU_ARCHIVE) download-dfu:
1032
download-dfu: downloads/$(DFU_ARCHIVE)
-
 
1033
download-dfu-force downloads/$(DFU_ARCHIVE):
404
	[ -d downloads ] || mkdir downloads ;
1034
	[ -d downloads ] || mkdir downloads ;
405
	cd downloads && curl -LO $(DFU_URL)
1035
	cd downloads && curl -LO $(DFU_URL)
406
1036
407
.PHONY: extract-dfu
1037
.PHONY: extract-dfu extract-dfu-force
-
 
1038
extract-dfu: stamps/extract-dfu
408
extract-dfu stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
1039
extract-dfu-force stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
409
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
1040
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
410
	[ "$$t1" = "$(DFU_MD5)" ] || \
1041
	[ "$$t1" = "$(DFU_MD5)" ] || \
411
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
1042
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
412
	tar -zxf $< ;
1043
	tar -zxf $< ;
413
	[ -d stamps ] || mkdir stamps ;
1044
	[ -d stamps ] || mkdir stamps ;
414
	touch stamps/extract-dfu;
1045
	touch stamps/extract-dfu;
415
1046
416
.PHONY: build-dfu
1047
.PHONY: build-dfu build-dfu-force
-
 
1048
build-dfu: stamps/build-dfu
417
build-dfu stamps/build-dfu: stamps/extract-dfu
1049
build-dfu-force stamps/build-dfu: stamps/extract-dfu
418
	mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
1050
	mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
419
	../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
1051
	../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
420
	$(MAKE) -j$(PROCS)
1052
	$(MAKE) -j$(PROCS)
421
	[ -d stamps ] || mkdir stamps
1053
	[ -d stamps ] || mkdir stamps
422
	touch stamps/build-dfu;
1054
	touch stamps/build-dfu;
423
1055
424
.PHONY: install-dfu
1056
.PHONY: install-dfu install-dfu-force
-
 
1057
install-dfu: stamps/install-dfu
425
install-dfu stamps/install-dfu:  stamps/build-dfu
1058
install-dfu-force stamps/install-dfu: stamps/build-dfu
426
	cd build/dfu-programmer && \
1059
	cd build/dfu-programmer && \
427
	$(MAKE) install
1060
	$(MAKE) install
428
	[ -d stamps ] || mkdir stamps
1061
	[ -d stamps ] || mkdir stamps
429
	touch stamps/install-dfu;
1062
	touch stamps/install-dfu;
430
1063
-
 
1064
.PHONY: clean-dfu
-
 
1065
clean-dfu:
-
 
1066
	rm -rf build/dfu stamps/*-dfu dfu-*
-
 
1067
-
 
1068
.PHONY: realclean-dfu
-
 
1069
realclean-dfu: clean-dfu
-
 
1070
	rm downloads/$(DFU_ARCHIVE)
-
 
1071
431
1072
432
################ Bootstrap GCC ################
1073
################ Bootstrap GCC ################
433
1074
434
.PHONY: download-gcc
1075
.PHONY: download-gcc download-gcc-force
435
downloads/$(GCC_ARCHIVE) download-gcc:
1076
download-gcc: downloads/$(GCC_ARCHIVE)
-
 
1077
download-gcc-force downloads/$(GCC_ARCHIVE):
436
	[ -d downloads ] || mkdir downloads ;
1078
	[ -d downloads ] || mkdir downloads ;
437
	cd downloads && curl -LO $(GCC_URL)
1079
	cd downloads && curl -LO $(GCC_URL)
438
1080
439
.PHONY: prep-gcc
1081
.PHONY: extract-gcc extract-gcc-force
440
prep-gcc stamps/prep-gcc: stamps/patch-gcc
1082
extract-gcc: stamps/extract-gcc
441
	[ -d stamps ] || mkdir stamps;
-
 
442
	touch stamps/prep-gcc;
-
 
443
-
 
444
.PHONY: extract-gcc
-
 
445
extract-gcc stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
1083
extract-gcc-force stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
446
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
1084
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
447
	[ "$$t1" = "$(GCC_MD5)" ] || \
1085
	[ "$$t1" = "$(GCC_MD5)" ] || \
448
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
1086
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
449
	tar -jxf $< ;
1087
	tar -jxf $< ;
450
	[ -d stamps ] || mkdir stamps ;
1088
	[ -d stamps ] || mkdir stamps ;
451
	touch stamps/extract-gcc;
1089
	touch stamps/extract-gcc;
452
1090
453
.PHONY: patch-gcc
1091
.PHONY: patch-gcc patch-gcc-force
-
 
1092
patch-gcc: stamps/patch-gcc
454
patch-gcc stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
1093
patch-gcc-force stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
455
	pushd gcc-$(GCC_VERSION) ; \
1094
	pushd gcc-$(GCC_VERSION) ; \
456
	for f in ../source/avr32/gcc/*.patch; do \
1095
	for f in ../source/avr32/gcc/*.patch; do \
457
	patch -N -p0 <$${f} ; \
1096
	patch -N -p0 <$${f} ; \
458
	done ; \
1097
	done ; \
459
	popd ;
1098
	popd ;
Line 462... Line 1101...
462
1101
463
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections			\
1102
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections			\
464
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g	\
1103
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g	\
465
-Os -fno-unroll-loops"
1104
-Os -fno-unroll-loops"
466
1105
467
.PHONY: build-gcc
1106
.PHONY: build-gcc build-gcc-force
-
 
1107
build-gcc: stamps/build-gcc
468
build-gcc stamps/build-gcc: stamps/install-binutils stamps/prep-gcc
1108
build-gcc-force stamps/build-gcc: stamps/install-binutils stamps/patch-gcc
469
	mkdir -p build/gcc && cd build/gcc && \
1109
	mkdir -p build/gcc && cd build/gcc && \
470
	pushd ../../gcc-$(GCC_VERSION) ; \
1110
	pushd ../../gcc-$(GCC_VERSION) ; \
471
	make clean ; \
1111
	make clean ; \
472
	popd ; \
1112
	popd ; \
473
	../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)"		\
1113
	../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)"		\
Line 488... Line 1128...
488
	--with-pkgversion=$(PKG_VERSION) && \
1128
	--with-pkgversion=$(PKG_VERSION) && \
489
	$(MAKE) -j$(PROCS)
1129
	$(MAKE) -j$(PROCS)
490
	[ -d stamps ] || mkdir stamps
1130
	[ -d stamps ] || mkdir stamps
491
	touch stamps/build-gcc;
1131
	touch stamps/build-gcc;
492
1132
493
.PHONY: install-gcc
1133
.PHONY: install-gcc install-gcc-force
-
 
1134
install-gcc: stamps/install-gcc
494
install-gcc stamps/install-gcc:  stamps/build-gcc
1135
install-gcc-force stamps/install-gcc: stamps/build-gcc
495
	cd build/gcc && \
1136
	cd build/gcc && \
496
	$(MAKE) installdirs install-target && \
1137
	$(MAKE) installdirs install-target && \
497
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
1138
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
498
	[ -d stamps ] || mkdir stamps
1139
	[ -d stamps ] || mkdir stamps
499
	touch stamps/install-gcc;
1140
	touch stamps/install-gcc;
500
1141
-
 
1142
.PHONY: clean-gcc
-
 
1143
clean-gcc:
-
 
1144
	rm -rf build/gcc stamps/*-gcc gcc-*
-
 
1145
-
 
1146
.PHONY: realclean-gcc
-
 
1147
realclean-gcc: clean-gcc
-
 
1148
	rm downloads/$(GCC_ARCHIVE)
501
1149
502
################ Final GCC ################
-
 
503
1150
504
.PHONY: prep-final-gcc
-
 
505
prep-final-gcc stamps/prep-final-gcc: stamps/patch-gcc stamps/prep-gcc
-
 
506
	[ -d stamps ] || mkdir stamps;
1151
################ Final GCC ################
507
	touch stamps/prep-final-gcc;
-
 
508
1152
509
.PHONY: build-final-gcc
1153
.PHONY: build-final-gcc build-final-gcc-force
-
 
1154
build-final-gcc: stamps/build-final-gcc
510
build-final-gcc stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/prep-final-gcc
1155
build-final-gcc-force stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/patch-gcc
511
	mkdir -p build/final-gcc && cd build/final-gcc && \
1156
	mkdir -p build/final-gcc && cd build/final-gcc && \
512
	pushd ../../gcc-$(GCC_VERSION) ; \
1157
	pushd ../../gcc-$(GCC_VERSION) ; \
513
	make clean ; \
1158
	make clean ; \
514
	popd ; \
1159
	popd ; \
515
	../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
1160
	../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
Line 530... Line 1175...
530
	--with-pkgversion=$(PKG_VERSION) && \
1175
	--with-pkgversion=$(PKG_VERSION) && \
531
	$(MAKE) -j$(PROCS)
1176
	$(MAKE) -j$(PROCS)
532
	[ -d stamps ] || mkdir stamps
1177
	[ -d stamps ] || mkdir stamps
533
	touch stamps/build-final-gcc;
1178
	touch stamps/build-final-gcc;
534
1179
535
.PHONY: install-final-gcc
1180
.PHONY: install-final-gcc install-final-gcc-force
-
 
1181
install-final-gcc: stamps/install-final-gcc
536
install-final-gcc stamps/install-final-gcc: stamps/build-final-gcc
1182
install-final-gcc-force stamps/install-final-gcc: stamps/build-final-gcc
537
	cd build/final-gcc && \
1183
	cd build/final-gcc && \
538
	$(MAKE) installdirs install-target && \
1184
	$(MAKE) installdirs install-target && \
539
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
1185
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
540
	[ -d stamps ] || mkdir stamps
1186
	[ -d stamps ] || mkdir stamps
541
	touch stamps/install-final-gcc;
1187
	touch stamps/install-final-gcc;
542
1188
-
 
1189
.PHONY: clean-final-gcc
-
 
1190
clean-final-gcc: clean-gcc
-
 
1191
	rm -rf build/final-gcc stamps/*-final-gcc
-
 
1192
-
 
1193
.PHONY: realclean-final-gcc
-
 
1194
realclean-final-gcc: realclean-gcc
-
 
1195
-
 
1196
-
 
1197
########## GDB ###########
-
 
1198
-
 
1199
.PHONY: download-gdb download-gdb-force
-
 
1200
download-gdb: downloads/$(GDB_ARCHIVE)
-
 
1201
download-gdb-force downloads/$(GDB_ARCHIVE):
-
 
1202
	[ -d downloads ] || mkdir downloads ;
-
 
1203
	cd downloads && curl -LO $(GDB_URL)
-
 
1204
-
 
1205
.PHONY: extract-gdb extract-gdb-force
-
 
1206
extract-gdb: stamps/extract-gdb
-
 
1207
extract-gdb-force stamps/extract-gdb: downloads/$(GDB_ARCHIVE)
-
 
1208
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
-
 
1209
	[ "$$t1" = "$(GDB_MD5)" ] || \
-
 
1210
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
-
 
1211
	tar -jxf $< ;
-
 
1212
	[ -d stamps ] || mkdir stamps ;
-
 
1213
	touch stamps/extract-gdb;
-
 
1214
-
 
1215
.PHONY: patch-gdb patch-gdb-force
-
 
1216
patch-gdb: stamps/patch-gdb
-
 
1217
patch-gdb-force stamps/patch-gdb: stamps/extract-gdb stamps/extract-avr32patches
-
 
1218
	pushd gdb-$(GDB_VERSION) ; \
-
 
1219
	for f in ../source/avr32/gdb/*.patch; do \
-
 
1220
	patch -N -p0 <$${f} ; \
-
 
1221
	done ; \
-
 
1222
	popd ; \
-
 
1223
	[ -d stamps ] || mkdir stamps
-
 
1224
	touch stamps/patch-gdb;
-
 
1225
-
 
1226
.PHONY: regen-gdb regen-gdb-force
-
 
1227
regen-gdb: stamps/regen-gdb
-
 
1228
regen-gdb-force stamps/regen-gdb: stamps/patch-gdb stamps/install-supp-tools
-
 
1229
	pushd gdb-$(GDB_VERSION) ; \
-
 
1230
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
-
 
1231
	"$(SUPP_PREFIX)/bin/autoconf" ; \
-
 
1232
	"$(SUPP_PREFIX)/bin/automake" ; \
-
 
1233
	"$(SUPP_PREFIX)/bin/autoheader" ; \
-
 
1234
	for dir in bfd opcodes gdb; do \
-
 
1235
	  pushd $$dir ; \
-
 
1236
	  echo "JESS 1: $$dir" >&2 ; \
-
 
1237
	  "$(SUPP_PREFIX)/bin/autoconf"; \
-
 
1238
	  "$(SUPP_PREFIX)/bin/automake"; \
-
 
1239
	  "$(SUPP_PREFIX)/bin/autoheader"; \
-
 
1240
	  echo "JESS 2: $$dir" >&2 ; \
-
 
1241
	  popd ; \
-
 
1242
	done; \
-
 
1243
	popd; \
-
 
1244
	[ -d stamps ] || mkdir stamps ;
-
 
1245
	touch stamps/regen-gdb;
-
 
1246
-
 
1247
.PHONY: build-gdb build-gdb-force
-
 
1248
build-gdb: stamps/build-gdb
-
 
1249
build-gdb-force stamps/build-gdb: stamps/regen-gdb stamps/install-supp-tools
-
 
1250
	echo "JESS 3" >&2 ; \
-
 
1251
	mkdir -p build/gdb && cd build/gdb && \
-
 
1252
	../../gdb-$(GDB_VERSION)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
-
 
1253
	$(MAKE) -j$(PROCS)
-
 
1254
	$(MAKE) installdirs install-host install-target
-
 
1255
	[ -d stamps ] || mkdir stamps
-
 
1256
	touch stamps/build-gdb;
-
 
1257
-
 
1258
.PHONY: install-gdb install-gdb-force
-
 
1259
install-gdb: stamps/install-gdb
-
 
1260
install-gdb-force stamps/install-gdb: stamps/build-gdb
-
 
1261
	cd build/gdb && \
-
 
1262
	$(MAKE) install
-
 
1263
	[ -d stamps ] || mkdir stamps
-
 
1264
	touch stamps/install-gdb;
-
 
1265
-
 
1266
.PHONY: clean-gdb
-
 
1267
clean-gdb:
-
 
1268
	rm -rf build/gdb stamps/*-gdb gdb-*
-
 
1269
-
 
1270
.PHONY: realclean-gdb
-
 
1271
realclean-gdb: clean-gdb
-
 
1272
	rm downloads/$(GDB_ARCHIVE)
543
1273
544
################ NON-WORKING/NON-ADJUSTED TARGETS ################
1274
################ NON-WORKING/NON-ADJUSTED TARGETS ################
545
1275
546
1276
547
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
1277
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
Line 592... Line 1322...
592
	$(MAKE) -j$(PROCS) && \
1322
	$(MAKE) -j$(PROCS) && \
593
	$(MAKE) installdirs install-host install-target && \
1323
	$(MAKE) installdirs install-host install-target && \
594
	mkdir -p "$(PREFIX)/man/man1" && \
1324
	mkdir -p "$(PREFIX)/man/man1" && \
595
	cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
1325
	cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
596
1326
597
.PHONY : clean
-
 
598
clean:
-
 
599
	rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp
-