Subversion Repositories avr32-toolchain

Rev

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