Subversion Repositories avr32-toolchain

Rev

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