Subversion Repositories avr32-toolchain

Rev

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