Subversion Repositories avr32-toolchain

Rev

Rev 9 | Rev 11 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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