Subversion Repositories avr32-toolchain

Rev

Rev 13 | Rev 17 | 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
12 jasmin 73
BUILD_DIR := $(CURDIR)/build
10 jasmin 74
 
9 jasmin 75
ifeq ($(strip $(BUG_URL)),)
4 jasmin 76
BUG_URL = https://github.com/jsnyder/avr32-toolchain
9 jasmin 77
endif
78
PKG_VERSION = "AVR 32 bit GNU Toolchain-$(AVR_PATCH_REV)-$(TOOL_REV)"
4 jasmin 79
 
80
 
81
#### PRIMARY TOOLCHAIN URLS #####
82
 
83
GCC_ARCHIVE = gcc-$(GCC_VERSION).tar.bz2
84
GCC_URL = http://mirror.anl.gov/pub/gnu/gcc/gcc-$(GCC_VERSION)/$(GCC_ARCHIVE)
85
GCC_MD5 = fe1ca818fc6d2caeffc9051fe67ff103
86
 
7 jasmin 87
GDB_ARCHIVE = gdb-$(GDB_VERSION_DLOAD).tar.bz2
4 jasmin 88
GDB_URL = http://mirror.anl.gov/pub/gnu/gdb/$(GDB_ARCHIVE)
7 jasmin 89
GDB_MD5 = 3564f308f3e4d4f2750891bc2ce9b214
4 jasmin 90
 
91
BINUTILS_ARCHIVE = binutils-$(BINUTILS_VERSION).tar.bz2
92
BINUTILS_URL = http://mirror.anl.gov/pub/gnu/binutils/$(BINUTILS_ARCHIVE)
93
BINUTILS_MD5 = 2b9dc8f2b7dbd5ec5992c6e29de0b764
94
 
95
NEWLIB_ARCHIVE = newlib-$(NEWLIB_VERSION).tar.gz
96
NEWLIB_URL = ftp://sources.redhat.com/pub/newlib/$(NEWLIB_ARCHIVE)
97
NEWLIB_MD5 = bf8f1f9e3ca83d732c00a79a6ef29bc4
98
 
99
AVR32PATCHES_ARCHIVE = avr32-gnu-toolchain-$(AVR_PATCH_REV)-source.zip
100
AVR32PATCHES_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32PATCHES_ARCHIVE)
101
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
15 jasmin 102
install_dir_avr32patches := source/avr32
4 jasmin 103
 
104
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
105
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
106
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
107
 
108
DFU_ARCHIVE = dfu-programmer-$(DFU_VERSION).tar.gz
109
DFU_URL = http://surfnet.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/$(DFU_VERSION)/$(DFU_ARCHIVE)
110
DFU_MD5 = 707dcd0f957a74e92456ea6919faa772
111
 
112
 
113
##### SUPPORT TOOLS VERSIONS / URLS ######
114
AUTOCONF_VERSION = 2.64
115
AUTOMAKE_VERSION = 1.11
116
MPC_VERSION = 0.8.1
117
 
118
AUTOCONF_ARCHIVE = autoconf-$(AUTOCONF_VERSION).tar.bz2
119
AUTOCONF_URL = http://mirror.anl.gov/pub/gnu/autoconf/$(AUTOCONF_ARCHIVE)
120
AUTOCONF_MD5 = ef400d672005e0be21e0d20648169074
121
 
122
AUTOMAKE_ARCHIVE = automake-$(AUTOMAKE_VERSION).tar.bz2
123
AUTOMAKE_URL = http://mirror.anl.gov/pub/gnu/automake/$(AUTOMAKE_ARCHIVE)
124
AUTOMAKE_MD5 = 4db4efe027e26b33930a7e151de19d0f
125
 
126
 
13 jasmin 127
ALL_TOOLS := gcc gdb binutils newlib avr32patches avr32headers dfu autoconf automake
4 jasmin 128
 
13 jasmin 129
 
130
 
4 jasmin 131
.PHONY: install-tools
7 jasmin 132
install-tools: install-binutils install-final-gcc install-newlib install-headers
4 jasmin 133
 
134
.PHONY: install-cross
135
install-cross: install-tools install-note
136
 
137
 
138
.PHONY: sudomode
139
sudomode:
140
ifneq ($(USER),root)
141
	@echo Please run this target with sudo!
142
	@echo e.g.: sudo make targetname
143
	@exit 1
144
endif
145
 
146
 
147
.PHONY: tst
148
tst:
9 jasmin 149
	@echo "PREFIX=$(PREFIX)"
150
	@echo "PKG_VERSION=$(PKG_VERSION)"
151
	@echo "BUG_URL=$(BUG_URL)"
4 jasmin 152
 
10 jasmin 153
 
154
############ MACROS for the lazy people ;-) ############
155
 
13 jasmin 156
## in silent mode (make -s),, print whats ging on
10 jasmin 157
ifeq ($(strip $(MAKEFLAGS)),s)
158
define quiet_text
159
	@echo "$1"
160
endef
161
else
162
define quiet_text
163
endef
164
endif
165
 
13 jasmin 166
## the stamp name
167
define name_stamp
168
$(STAMP_DIR)/$(1)
169
endef
170
 
10 jasmin 171
## remove a stamp
172
define rm_stamp
173
	rm -f $(STAMP_DIR)/$(1)
174
endef
175
 
12 jasmin 176
## remove all stamps
177
define rm_stamps
178
	rm -f $(STAMP_DIR)/*-$(1)
179
endef
180
 
10 jasmin 181
## create the stamp directory if not existing and the stamp
182
define make_stamp
183
	@[ -d $(STAMP_DIR) ] || mkdir $(STAMP_DIR)
184
	date > $(STAMP_DIR)/$(1)
185
endef
186
 
15 jasmin 187
## delete empty directories
188
define del_empty-directories
13 jasmin 189
	@find . -type d -empty | xargs rm -rf
190
endef
11 jasmin 191
 
15 jasmin 192
## delete all empty directories
193
## need to do this several times. to remove empty sub directories
194
define del_all_empty-directories
195
	$(call del_empty-directories)
196
	$(call del_empty-directories)
197
	$(call del_empty-directories)
198
endef
199
 
200
 
13 jasmin 201
## to make the following macros more simply, we need the variables
202
## with the tool name in lowercase. I could have changed the original
203
## definition, but I don't want to break the make convention of upper
204
## case definitions for such user defined variables.
205
 
206
define LOWER_TOOL_VARS
207
UP_$(1) := $(shell echo "$(1)" | tr '[a-z]' '[A-Z]')
208
$(1)_VERSION := $$($$(UP_$(1))_VERSION)
209
$(1)_ARCHIVE := $$($$(UP_$(1))_ARCHIVE)
210
$(1)_URL := $$($$(UP_$(1))_URL)
211
$(1)_MD5 := $$($$(UP_$(1))_MD5)
212
endef
213
 
214
$(foreach tool,$(ALL_TOOLS),$(eval $(call LOWER_TOOL_VARS,$(tool))))
215
 
216
 
10 jasmin 217
## create the download rule and force download rule
218
define DOWNLOAD_template
13 jasmin 219
download-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
15 jasmin 220
download-$(1)-f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE):
221
	[ -d $(DOWNLOAD_DIR) ] || mkdir -p $(DOWNLOAD_DIR)
13 jasmin 222
	cd $(DOWNLOAD_DIR) && curl -LO $$($(1)_URL)
12 jasmin 223
 
13 jasmin 224
download-$(1)_TEXT := "Removing $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)"
12 jasmin 225
download-$(1)-remove:
13 jasmin 226
	$(call quiet_text,$$(download-$(1)_TEXT))
227
	rm -f $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
12 jasmin 228
 
229
PHONY += download-$(1) download-$(1)-f download-$(1)-remove
10 jasmin 230
endef
231
 
232
## extract commands
233
EXT_BZ2 := tar -jxf
234
EXT_TGZ := tar -xf
235
EXT_ZIP := unzip -o
236
 
237
## create the extract rule and force extract rule
238
define EXTRACT_template
13 jasmin 239
extract-$(1)_TEXT := "Extracting $$($(1)_ARCHIVE)"
240
 
10 jasmin 241
extract-$(1): $(STAMP_DIR)/extract-$(1)
13 jasmin 242
extract-$(1)-f $(STAMP_DIR)/extract-$(1): $(DOWNLOAD_DIR)/$$($(1)_ARCHIVE)
12 jasmin 243
	@(rm -rf $(1)-*; \
10 jasmin 244
	t1=`openssl md5 $$< | cut -f 2 -d " " -` && \
13 jasmin 245
	[ "$$$$t1" = "$$($(1)_MD5)" ] || \
10 jasmin 246
	( echo "Bad Checksum! Please remove the following file and retry: $$<" && false ))
13 jasmin 247
	$(call quiet_text,$$(extract-$(1)_TEXT))
15 jasmin 248
	$($(2)) $$< $(3)
10 jasmin 249
	$(call make_stamp,extract-$(1))
12 jasmin 250
 
251
extract-$(1)-remove:
252
	rm -rf $(1)-*
253
	$(call rm_stamp,extract-$(1))
254
 
255
PHONY += extract-$(1) extract-$(1)-f extract-$(1)-remove
10 jasmin 256
endef
257
 
15 jasmin 258
## create the patch rule
259
define PATCH_template
260
patch-$(1)_TEXT := "Patching $$($(1)_ARCHIVE)"
261
patch-$(1): $(STAMP_DIR)/patch-$(1)
262
$(STAMP_DIR)/patch-$(1): $(STAMP_DIR)/extract-$(1) $(STAMP_DIR)/extract-avr32patches
263
	$(call quiet_text,$$(patch-$(1)_TEXT))
264
	@(pushd $(1)-$$($(1)_VERSION) ; \
265
	for f in ../$(install_dir_avr32patches)/$(1)/*.patch; do \
266
	patch -N -p0 < $$$${f} ; \
267
	done ; \
268
	popd)
269
	$(call make_stamp,patch-$(1))
270
 
271
patch-$(1)-remove: extract-$(1)-remove
272
	$(call rm_stamp,patch-$(1))
273
 
274
PHONY += patch-$(1) patch-$(1)-remove
275
endef
276
 
277
 
278
#.PHONY: regen-binutils regen-binutils-force
279
#regen-binutils: stamps/regen-binutils
280
#regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
281
#	pushd binutils-$(BINUTILS_VERSION) ; \
282
#	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
283
#	"$(SUPP_PREFIX)/bin/autoconf" ; \
284
#	"$(SUPP_PREFIX)/bin/automake" ; \
285
#	"$(SUPP_PREFIX)/bin/autoheader" ; \
286
#	for dir in bfd opcodes binutils gas ld; do \
287
#	  pushd $$dir ; \
288
#	  "$(SUPP_PREFIX)/bin/autoconf"; \
289
#	  "$(SUPP_PREFIX)/bin/automake"; \
290
#	  "$(SUPP_PREFIX)/bin/autoheader"; \
291
#	  popd ; \
292
#	done; \
293
#	popd; \
294
#	[ -d stamps ] || mkdir stamps ;
295
#	touch stamps/regen-binutils;
296
 
297
 
12 jasmin 298
## create the configure rule and force configure rule
299
define CONF_template
13 jasmin 300
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)"
12 jasmin 301
conf-$(1): $(STAMP_DIR)/conf-$(1)
302
conf-$(1)-f $(STAMP_DIR)/conf-$(1): $(STAMP_DIR)/$(2)-$(1) $(BUILD_DIR)/$(1)
303
	@rm -rf $(BUILD_DIR)/$(1)/*
13 jasmin 304
	$(call quiet_text,$$(conf-$(1)_TEXT))
12 jasmin 305
	cd $(BUILD_DIR)/$(1) && \
13 jasmin 306
	../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts)
12 jasmin 307
	$(call make_stamp,conf-$(1))
308
 
309
conf-$(1)-remove:
310
	$(call rm_stamp,conf-$(1))
311
 
312
PHONY += conf-$(1) conf-$(1)-f conf-$(1)-remove
313
endef
314
 
315
## create the build rule and force build rule
316
define BUILD_template
13 jasmin 317
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)"
12 jasmin 318
build-$(1): $(STAMP_DIR)/build-$(1)
319
build-$(1)-f $(STAMP_DIR)/build-$(1): $(STAMP_DIR)/conf-$(1)
13 jasmin 320
	$(call quiet_text,$$(build-$(1)_TEXT))
12 jasmin 321
	cd $(BUILD_DIR)/$(1) && \
322
	$(MAKE) clean && $(MAKE) -j$(PROCS)
323
	$(call make_stamp,build-$(1))
324
 
325
build-$(1)-remove:
326
	rm -rf $(BUILD_DIR)/$(1)
327
	$(call rm_stamp,build-$(1))
328
 
329
PHONY += build-$(1) build-$(1)-f build-$(1)-remove
330
endef
331
 
332
## create the install rule and force install rule
333
define INSTALL_template
13 jasmin 334
install-$(1)_TEXT := "Installing $(1) $$($(1)_VERSION)"
12 jasmin 335
install-$(1): $(STAMP_DIR)/install-$(1)
336
install-$(1)-f $(STAMP_DIR)/install-$(1): $(STAMP_DIR)/build-$(1)
13 jasmin 337
	$(call quiet_text,$$(install-$(1)_TEXT))
12 jasmin 338
	cd $(BUILD_DIR)/$(1) && \
339
	$(MAKE) install
340
	$(call make_stamp,install-$(1))
341
 
13 jasmin 342
uninstall-$(1)_TEXT := "Uninstalling $(1) $$($(1)_VERSION)"
12 jasmin 343
uninstall-$(1):
13 jasmin 344
	$(call quiet_text,$$(uninstall-$(1)_TEXT))
12 jasmin 345
	[ -f $(BUILD_DIR)/$(1)/Makefile ] && \
13 jasmin 346
	[ -f $(call name_stamp,install-$(1)) ] && \
12 jasmin 347
	cd $(BUILD_DIR)/$(1) && \
348
	$(MAKE) uninstall || true
349
	$(call rm_stamp,install-$(1))
350
 
351
PHONY += install-$(1) install-$(1)-f uninstall-$(1)
352
endef
353
 
354
## create the clean rule and realclean rule
355
define CLEAN_template
13 jasmin 356
clean-$(1)_TEXT := "Cleaning $(1) $$($(1)_VERSION)"
357
clean-$(1)-text:
358
	$(call quiet_text,$$(clean-$(1)_TEXT))
12 jasmin 359
 
15 jasmin 360
clean-$(1): clean-$(1)-text uninstall-$(1) extract-$(1)-remove patch-$(1)-remove \
361
            build-$(1)-remove conf-$(1)-remove
13 jasmin 362
	$(call del_all_empty-directories)
363
 
12 jasmin 364
realclean-$(1): clean-$(1) download-$(1)-remove
13 jasmin 365
	$(call del_all_empty-directories)
12 jasmin 366
 
13 jasmin 367
PHONY += clean-$(1) realclean-$(1) clean-$(1)-text
12 jasmin 368
endef
369
 
15 jasmin 370
## create some dummy rules for the clean rule
371
define DUMMY_patch_remove
372
patch-$(1)-remove:
373
PHONY += patch-$(1)-remove
374
endef
375
define DUMMY_conf_remove
376
conf-$(1)-remove:
377
PHONY += conf-$(1)-remove
378
endef
379
define DUMMY_build_remove
380
build-$(1)-remove:
381
PHONY += build-$(1)-remove
382
endef
12 jasmin 383
 
384
 
385
$(BUILD_DIR)/%:
386
	mkdir -p $@
387
 
13 jasmin 388
 
12 jasmin 389
############# SUPP: AUTOCONF ############
390
 
11 jasmin 391
$(eval $(call DOWNLOAD_template,autoconf))
392
$(eval $(call EXTRACT_template,autoconf,EXT_BZ2))
12 jasmin 393
autoconf_conf_opts = --prefix="$(SUPP_PREFIX)"
394
$(eval $(call CONF_template,autoconf,extract))
395
$(eval $(call BUILD_template,autoconf))
396
$(eval $(call INSTALL_template,autoconf))
397
$(eval $(call CLEAN_template,autoconf))
10 jasmin 398
 
12 jasmin 399
 
400
############ SUPP: AUTOMAKE ############
401
 
402
$(eval $(call DOWNLOAD_template,automake))
403
$(eval $(call EXTRACT_template,automake,EXT_BZ2))
404
automake_conf_opts = --prefix="$(SUPP_PREFIX)"
405
$(eval $(call CONF_template,automake,extract))
406
$(eval $(call BUILD_template,automake))
407
$(eval $(call INSTALL_template,automake))
408
$(eval $(call CLEAN_template,automake))
409
 
410
 
15 jasmin 411
############# AVR32 PATCHES ############
412
 
413
$(eval $(call DOWNLOAD_template,avr32patches))
414
$(eval $(call EXTRACT_template,avr32patches,EXT_ZIP))
415
 
416
## use the uninstall-XXX rule to remove the patches directory
417
PHONY += uninstall-avr32patches
418
uninstall-avr32patches:
419
	rm -rf $(install_dir_avr32patches)
420
 
421
$(eval $(call CLEAN_template,avr32patches))
422
 
423
 
424
############# AVR32 HEADERS ############
425
$(eval $(call DOWNLOAD_template,avr32headers))
426
 
427
###### FIXME: Need to add a dependency to "stamps/install-final-gcc"
428
install_path_avr32headers := $(PREFIX)/$(TARGET)/include/
429
avr32headers_unzip_opt := -d "$(install_path_avr32headers)"
430
$(eval $(call EXTRACT_template,avr32headers,EXT_ZIP,$(avr32headers_unzip_opt)))
431
 
432
## use the uninstall-XXX rule to remove the patches directory
433
install_dir_avr32headers := $(install_path_avr32headers)/avr32
434
PHONY += uninstall-avr32headers
435
uninstall-avr32headers:
436
	rm -rf $(install_dir_avr32headers)
437
 
438
$(eval $(call CLEAN_template,avr32headers))
439
 
440
 
441
################ BINUTILS ################
442
 
443
$(eval $(call DOWNLOAD_template,binutils))
444
$(eval $(call EXTRACT_template,binutils,EXT_BZ2))
445
$(eval $(call PATCH_template,binutils))
446
#$(eval $(call REGEN_template,binutils))
447
binutils_conf_opts = \
448
--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
$(eval $(call CONF_template,binutils,extract))
453
$(eval $(call BUILD_template,binutils))
454
$(eval $(call INSTALL_template,binutils))
455
$(eval $(call CLEAN_template,binutils))
456
 
457
 
458
# we need to satisfy the rules, generated by the CLEAN_template, if they not exist
459
patch_remove_dummy_tools := autoconf automake avr32patches avr32headers
460
$(foreach tool,$(patch_remove_dummy_tools),$(eval $(call DUMMY_patch_remove,$(tool))))
461
conf_remove_dummy_tools := avr32patches avr32headers
462
$(foreach tool,$(conf_remove_dummy_tools),$(eval $(call DUMMY_conf_remove,$(tool))))
463
build_remove_dummy_tools := avr32patches avr32headers
464
$(foreach tool,$(build_remove_dummy_tools),$(eval $(call DUMMY_build_remove,$(tool))))
465
 
466
 
10 jasmin 467
.PHONY: $(PHONY)
468
 
469
 
470
.PHONY: tst2 tst3
471
tst2:
472
	$(call make_stamp,JES)
473
tst3:
474
	$(call rm_stamp,JES)
475
 
476
 
15 jasmin 477
.PHONY: help
478
help:
479
	@echo ""
480
	@echo "The following targets are available:"
481
	@echo ""
482
	@echo "download-XXX	: download the required package"
483
	@echo "extract-XXX	: extract the downloaded package"
484
	@echo "conf-XXX	: configure the extracted package"
485
	@echo "build-XXX	: build the configured package"
486
	@echo "install-XXX	: install the build package"
487
	@echo "uninstall-XXX	: uninstall the installed package"
488
	@echo "clean-XXX	: clean the package source and build tree"
489
	@echo "realclean-XXX	: same as clean-XXX, but remove the downloaded"
490
	@echo "		  package, too"
491
	@echo ""
492
	@echo "XXX can be one of the following: "
493
	@echo "$(ALL_TOOLS)"
494
	@echo ""
495
	@echo "The above targets will be executed in the right order and only if"
496
	@echo "they need to be be really built. If you want to rebuild one of then"
497
	@echo "manualy, you can use the aaaa-XXX-f target (e.g.: build-autoconf-f,"
498
	@echo "download-automake-f). Please note, that not all steps are available for"
499
	@echo "all tools (e.g.: install-avr32patches is not available)."
500
	@echo ""
501
	@echo ""
502
 
503
 
4 jasmin 504
.PHONY: install-note
505
install-note: install-tools
506
	@echo
507
	@echo ====== INSTALLATION NOTE ======
508
	@echo Your tools have now been installed at the following prefix:
509
	@echo $(PREFIX)
510
	@echo
511
	@echo Please be sure to add something similar to the following to your .bash_profile, .zshrc, etc:
512
	@echo export PATH=$(PREFIX)/bin:'$$PATH'
513
 
514
 
7 jasmin 515
.PHONY: install-supp-tools install-supp-tools-force
516
install-supp-tools: stamps/install-supp-tools
517
install-supp-tools-force stamps/install-supp-tools: stamps/install-autoconf stamps/install-automake
518
	[ -d stamps ] || mkdir stamps ;
519
	touch stamps/install-supp-tools;
4 jasmin 520
 
7 jasmin 521
.PHONY: clean-supp-tools
522
clean-supp-tools: clean-autoconf clean-automake
523
	rm stamps/install-supp-tools;
4 jasmin 524
 
7 jasmin 525
.PHONY: realclean-supp-tools
526
realclean-supp-tools: realclean-autoconf realclean-automake
527
	rm stamps/install-supp-tools;
4 jasmin 528
 
529
 
530
 
12 jasmin 531
 
532
 
533
############ SUPP: AUTOMAKE ############
534
 
535
##.PHONY: download-automake download-automake-force
536
##download-automake: downloads/$(AUTOMAKE_ARCHIVE)
537
##download-automake-force downloads/$(AUTOMAKE_ARCHIVE):
10 jasmin 538
##	[ -d downloads ] || mkdir downloads ;
12 jasmin 539
##	cd downloads && curl -LO $(AUTOMAKE_URL)
4 jasmin 540
 
12 jasmin 541
##.PHONY: extract-automake extract-automake-force
542
##extract-automake: stamps/extract-automake
543
##extract-automake-force stamps/extract-automake: downloads/$(AUTOMAKE_ARCHIVE)
10 jasmin 544
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
12 jasmin 545
##	[ "$$t1" = "$(AUTOMAKE_MD5)" ] || \
10 jasmin 546
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
547
##	tar -jxf $< ;
548
##	[ -d stamps ] || mkdir stamps ;
12 jasmin 549
##	touch stamps/extract-automake;
4 jasmin 550
 
12 jasmin 551
##.PHONY: build-automake build-automake-force
552
##build-automake: stamps/build-automake
553
##build-automake-force stamps/build-automake: stamps/extract-automake stamps/install-autoconf
554
##	mkdir -p build/automake && cd build/automake && \
555
##	../../automake-$(AUTOMAKE_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
556
##	$(MAKE) -j$(PROCS)
557
##	[ -d stamps ] || mkdir stamps
558
##	touch stamps/build-automake;
4 jasmin 559
 
12 jasmin 560
##.PHONY: install-automake install-automake-force
561
##install-automake: stamps/install-automake
562
##install-automake-force stamps/install-automake: stamps/build-automake
563
##	cd build/automake && \
564
##	$(MAKE) install
565
##	[ -d stamps ] || mkdir stamps
566
##	touch stamps/install-automake;
4 jasmin 567
 
12 jasmin 568
##.PHONY: clean-automake
569
##clean-automake:
570
##	rm -rf build/automake stamps/*-automake automake-*
4 jasmin 571
 
12 jasmin 572
##.PHONY: realclean-automake
573
##realclean-automake: clean-automake
574
##	rm downloads/$(AUTOMAKE_ARCHIVE)
4 jasmin 575
 
7 jasmin 576
 
4 jasmin 577
############# AVR32 PATCHES ############
578
 
15 jasmin 579
##.PHONY: download-avr32patches download-avr32patches-force
580
##download-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
581
##download-avr32patches-force downloads/$(AVR32PATCHES_ARCHIVE):
582
##	cd downloads && curl -LO $(AVR32PATCHES_URL)
4 jasmin 583
 
15 jasmin 584
##.PHONY: extract-avr32patches extract-avr32patches-force
585
##extract-avr32patches: stamps/extract-avr32patches
586
##extract-avr32patches-force stamps/extract-avr32patches: downloads/$(AVR32PATCHES_ARCHIVE)
587
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
588
##	[ "$$t1" = "$(AVR32PATCHES_MD5)" ] || \
589
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
590
##	unzip -o $<
591
##	[ -d stamps ] || mkdir stamps
592
##	touch stamps/extract-avr32patches;
4 jasmin 593
 
15 jasmin 594
##.PHONY: clean-avr32patches
595
##clean-avr32patches:
596
##	rm -rf stamps/*-avr32patches source
4 jasmin 597
 
15 jasmin 598
##.PHONY: realclean-avr32patches
599
##realclean-avr32patches: clean-avr32patches
600
##	rm downloads/$(AVR32PATCHES_ARCHIVE)
7 jasmin 601
 
602
 
4 jasmin 603
############# AVR32 HEADERS ############
604
 
15 jasmin 605
##.PHONY: download-avr32headers download-avr32headers-force
606
##download-avr32headers: downloads/$(AVR32HEADERS_ARCHIVE)
607
##download-avr32headers-force downloads/$(AVR32HEADERS_ARCHIVE):
608
##	cd downloads && curl -LO $(AVR32HEADERS_URL)
4 jasmin 609
 
15 jasmin 610
##.PHONY: install-headers install-headers-force
611
##install-headers: stamps/install-headers
612
##install-headers-force stamps/install-headers: downloads/$(AVR32HEADERS_ARCHIVE) stamps/install-final-gcc
613
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
614
##	[ "$$t1" = "$(AVR32HEADERS_MD5)" ] || \
615
##	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
616
##	unzip -o $< -d "$(PREFIX)/$(TARGET)/include/" && \
617
##	[ -d stamps ] || mkdir stamps
618
##	touch stamps/install-headers;
4 jasmin 619
 
15 jasmin 620
##.PHONY: clean-headers
621
##clean-headers:
622
##	rm -rf stamps/*-headers $(PREFIX)/$(TARGET)/include/avr32
4 jasmin 623
 
15 jasmin 624
##.PHONY: realclean-headers
625
##realclean-headers: clean-headers
626
##	rm downloads/$(AVR32HEADERS_ARCHIVE)
7 jasmin 627
 
628
 
4 jasmin 629
################ NEWLIB ################
630
 
7 jasmin 631
.PHONY: download-newlib download-newlib-force
632
download-newlib: downloads/$(NEWLIB_ARCHIVE)
633
download-newlib-force downloads/$(NEWLIB_ARCHIVE):
4 jasmin 634
	[ -d downloads ] || mkdir downloads ;
635
	cd downloads && curl -LO $(NEWLIB_URL)
636
 
7 jasmin 637
.PHONY: extract-newlib extract-newlib-force
638
extract-newlib: stamps/extract-newlib
639
extract-newlib-force stamps/extract-newlib : downloads/$(NEWLIB_ARCHIVE)
4 jasmin 640
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
641
	[ "$$t1" = "$(NEWLIB_MD5)" ] || \
642
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
643
	tar -xf $<
644
	[ -d stamps ] || mkdir stamps
645
	touch stamps/extract-newlib;
646
 
647
 
7 jasmin 648
.PHONY: patch-newlib patch-newlib-force
649
patch-newlib: stamps/patch-newlib
650
patch-newlib-force stamps/patch-newlib: stamps/extract-newlib stamps/extract-avr32patches
4 jasmin 651
	pushd newlib-$(NEWLIB_VERSION) ; \
652
	for f in ../source/avr32/newlib/*.patch; do \
653
	patch -N -p0 <$${f} ; \
654
	done ; \
655
	popd ;
656
	[ -d stamps ] || mkdir stamps
657
	touch stamps/patch-newlib;
658
 
7 jasmin 659
.PHONY: regen-newlib regen-newlib-force
660
regen-newlib: stamps/regen-newlib
661
regen-newlib-force stamps/regen-newlib: stamps/patch-newlib stamps/install-supp-tools
4 jasmin 662
	pushd newlib-$(NEWLIB_VERSION) ; \
663
	"$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake" ; \
664
	for dir in newlib/libc/machine/avr32 newlib/libc/machine newlib/libc/sys/avr32 newlib/libc/sys; do \
665
	  pushd $$dir ; \
666
	  "$(SUPP_PREFIX)/bin/aclocal" -I ../.. -I ../../.. -I ../../../.. ; \
667
	  "$(SUPP_PREFIX)/bin/autoconf"; "$(SUPP_PREFIX)/bin/automake"; \
668
	  popd ; \
669
	done; \
670
	popd;
671
	[ -d stamps ] || mkdir stamps
672
	touch stamps/regen-newlib;
673
 
674
NEWLIB_FLAGS="-ffunction-sections -fdata-sections	\
675
-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g -Os	\
676
-fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=128	\
677
-DSMALL_MEMORY"
678
 
7 jasmin 679
.PHONY: build-newlib build-newlib-force
680
build-newlib: stamps/build-newlib
681
build-newlib-force stamps/build-newlib: stamps/regen-newlib stamps/install-binutils stamps/install-gcc
4 jasmin 682
	mkdir -p build/newlib && cd build/newlib && \
683
	pushd ../../newlib-$(NEWLIB_VERSION) ; \
684
	make clean ; \
685
	popd ; \
686
	../../newlib-$(NEWLIB_VERSION)/configure --prefix=$(PREFIX)	\
687
	--with-build-time-tools=$(PREFIX)				\
688
	--target=$(TARGET) --disable-newlib-supplied-syscalls		\
689
	--disable-libgloss --disable-nls --disable-shared		\
690
	--enable-newlib-io-long-long --enable-newlib-io-long-double	\
691
	--enable-target-optspace --enable-newlib-io-pos-args		\
692
	--enable-newlib-reent-small  && \
693
	$(MAKE) -j$(PROCS) CFLAGS_FOR_TARGET=$(NEWLIB_FLAGS) CCASFLAGS=$(NEWLIB_FLAGS) && \
694
	[ -d stamps ] || mkdir stamps
695
	touch stamps/build-newlib;
696
 
7 jasmin 697
.PHONY: install-newlib install-newlib-force
698
install-newlib: stamps/install-newlib
699
install-newlib-force stamps/install-newlib: stamps/build-newlib
4 jasmin 700
	cd build/newlib && \
701
	$(MAKE) install
702
	[ -d stamps ] || mkdir stamps
703
	touch stamps/install-newlib;
704
 
7 jasmin 705
.PHONY: clean-newlib
706
clean-newlib:
707
	rm -rf build/newlib stamps/*-newlib newlib-*
708
 
709
.PHONY: realclean-newlib
710
realclean-newlib: clean-newlib
711
	rm downloads/$(NEWLIB_ARCHIVE)
712
 
713
 
4 jasmin 714
################ BINUTILS ################
715
 
15 jasmin 716
##.PHONY: download-binutils download-binutils-force
717
##download-binutils: downloads/$(BINUTILS_ARCHIVE)
718
##download-binutils-force downloads/$(BINUTILS_ARCHIVE):
719
##	[ -d downloads ] || mkdir downloads ;
720
##	cd downloads && curl -LO $(BINUTILS_URL)
4 jasmin 721
 
15 jasmin 722
##.PHONY: extract-binutils extract-binutils-force
723
##extract-binutils: stamps/extract-binutils
724
##extract-binutils-force stamps/extract-binutils: downloads/$(BINUTILS_ARCHIVE)
725
##	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
726
##	[ "$$t1" = "$(BINUTILS_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-binutils;
4 jasmin 731
 
15 jasmin 732
##.PHONY: patch-binutils patch-binutils-force
733
##patch-binutils: stamps/patch-binutils
734
##patch-binutils-force stamps/patch-binutils: stamps/extract-binutils stamps/extract-avr32patches
735
##	pushd binutils-$(BINUTILS_VERSION) ; \
736
##	for f in ../source/avr32/binutils/*.patch; do \
737
##	patch -N -p0 <$${f} ; \
738
##	done ; \
739
##	popd ; \
740
##	[ -d stamps ] || mkdir stamps
741
##	touch stamps/patch-binutils;
4 jasmin 742
 
15 jasmin 743
##.PHONY: regen-binutils regen-binutils-force
744
##regen-binutils: stamps/regen-binutils
745
##regen-binutils-force stamps/regen-binutils: stamps/patch-binutils stamps/install-supp-tools
746
##	pushd binutils-$(BINUTILS_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 binutils gas ld; do \
752
##	  pushd $$dir ; \
753
##	  "$(SUPP_PREFIX)/bin/autoconf"; \
754
##	  "$(SUPP_PREFIX)/bin/automake"; \
755
##	  "$(SUPP_PREFIX)/bin/autoheader"; \
756
##	  popd ; \
757
##	done; \
758
##	popd; \
759
##	[ -d stamps ] || mkdir stamps ;
760
##	touch stamps/regen-binutils;
4 jasmin 761
 
15 jasmin 762
##.PHONY: build-binutils build-binutils-force
763
##build-binutils: stamps/build-binutils
764
##build-binutils-force stamps/build-binutils: stamps/regen-binutils stamps/install-supp-tools
765
##	cd binutils-$(BINUTILS_VERSION) ; \
766
##	./configure   --enable-maintainer-mode		\
767
##	--prefix="$(PREFIX)" --target=$(TARGET) --disable-nls		\
768
##	--disable-shared --disable-werror				\
769
##	--with-sysroot="$(PREFIX)/$(TARGET)" --with-bugurl=$(BUG_URL) &&	\
770
##	$(MAKE) all-bfd TARGET-bfd=headers; \
771
##	rm bfd/Makefile; \
772
##	make configure-bfd; \
773
##	$(MAKE)
774
##	[ -d stamps ] || mkdir stamps ;
775
##	touch stamps/build-binutils;
4 jasmin 776
 
15 jasmin 777
##.PHONY: install-binutils install-binutils-force
778
##install-binutils: stamps/install-binutils
779
##install-binutils-force stamps/install-binutils: stamps/build-binutils
780
##	cd binutils-$(BINUTILS_VERSION) && \
781
##	$(MAKE) installdirs install-host install-target
782
##	[ -d stamps ] || mkdir stamps ;
783
##	touch stamps/install-binutils;
4 jasmin 784
 
7 jasmin 785
 
15 jasmin 786
##.PHONY: clean-binutils
787
##clean-binutils:
788
##	rm -rf build/binutils stamps/*-binutils binutils-*
7 jasmin 789
 
15 jasmin 790
##.PHONY: realclean-binutils
791
##realclean-binutils: clean-binutils
792
##	rm downloads/$(BINUTILS_ARCHIVE)
7 jasmin 793
 
794
 
4 jasmin 795
########## DFU PROGRAMMER ###########
796
 
7 jasmin 797
.PHONY: download-dfu download-dfu-force
798
download-dfu: downloads/$(DFU_ARCHIVE)
799
download-dfu-force downloads/$(DFU_ARCHIVE):
4 jasmin 800
	[ -d downloads ] || mkdir downloads ;
801
	cd downloads && curl -LO $(DFU_URL)
802
 
7 jasmin 803
.PHONY: extract-dfu extract-dfu-force
804
extract-dfu: stamps/extract-dfu
805
extract-dfu-force stamps/extract-dfu: downloads/$(DFU_ARCHIVE)
4 jasmin 806
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
807
	[ "$$t1" = "$(DFU_MD5)" ] || \
808
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
809
	tar -zxf $< ;
810
	[ -d stamps ] || mkdir stamps ;
811
	touch stamps/extract-dfu;
812
 
7 jasmin 813
.PHONY: build-dfu build-dfu-force
814
build-dfu: stamps/build-dfu
815
build-dfu-force stamps/build-dfu: stamps/extract-dfu
4 jasmin 816
	mkdir -p build/dfu-programmer && cd build/dfu-programmer && \
817
	../../dfu-programmer-$(DFU_VERSION)/configure --prefix="$(PREFIX)" && \
818
	$(MAKE) -j$(PROCS)
819
	[ -d stamps ] || mkdir stamps
820
	touch stamps/build-dfu;
821
 
7 jasmin 822
.PHONY: install-dfu install-dfu-force
823
install-dfu: stamps/install-dfu
824
install-dfu-force stamps/install-dfu: stamps/build-dfu
4 jasmin 825
	cd build/dfu-programmer && \
826
	$(MAKE) install
827
	[ -d stamps ] || mkdir stamps
828
	touch stamps/install-dfu;
829
 
7 jasmin 830
.PHONY: clean-dfu
831
clean-dfu:
832
	rm -rf build/dfu stamps/*-dfu dfu-*
4 jasmin 833
 
7 jasmin 834
.PHONY: realclean-dfu
835
realclean-dfu: clean-dfu
836
	rm downloads/$(DFU_ARCHIVE)
837
 
838
 
4 jasmin 839
################ Bootstrap GCC ################
840
 
7 jasmin 841
.PHONY: download-gcc download-gcc-force
842
download-gcc: downloads/$(GCC_ARCHIVE)
843
download-gcc-force downloads/$(GCC_ARCHIVE):
4 jasmin 844
	[ -d downloads ] || mkdir downloads ;
845
	cd downloads && curl -LO $(GCC_URL)
846
 
7 jasmin 847
.PHONY: extract-gcc extract-gcc-force
848
extract-gcc: stamps/extract-gcc
849
extract-gcc-force stamps/extract-gcc: downloads/$(GCC_ARCHIVE)
4 jasmin 850
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
851
	[ "$$t1" = "$(GCC_MD5)" ] || \
852
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
853
	tar -jxf $< ;
854
	[ -d stamps ] || mkdir stamps ;
855
	touch stamps/extract-gcc;
856
 
7 jasmin 857
.PHONY: patch-gcc patch-gcc-force
858
patch-gcc: stamps/patch-gcc
859
patch-gcc-force stamps/patch-gcc: stamps/extract-gcc stamps/extract-avr32patches
4 jasmin 860
	pushd gcc-$(GCC_VERSION) ; \
861
	for f in ../source/avr32/gcc/*.patch; do \
862
	patch -N -p0 <$${f} ; \
863
	done ; \
864
	popd ;
865
	[ -d stamps ] || mkdir stamps
866
	touch stamps/patch-gcc;
867
 
868
CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections			\
869
-fomit-frame-pointer -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -g	\
870
-Os -fno-unroll-loops"
871
 
7 jasmin 872
.PHONY: build-gcc build-gcc-force
873
build-gcc: stamps/build-gcc
874
build-gcc-force stamps/build-gcc: stamps/install-binutils stamps/patch-gcc
4 jasmin 875
	mkdir -p build/gcc && cd build/gcc && \
876
	pushd ../../gcc-$(GCC_VERSION) ; \
877
	make clean ; \
878
	popd ; \
879
	../../gcc-$(GCC_VERSION)/configure --prefix="$(PREFIX)"		\
880
	--target=$(TARGET) --enable-languages="c" --with-gnu-ld		\
881
	--with-gnu-as --with-newlib --disable-nls --disable-libssp	\
882
	--with-dwarf2 --enable-sjlj-exceptions				\
883
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch	\
884
	--disable-shared						\
885
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
886
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET)				\
887
	--with-sysroot="$(PREFIX)/$(TARGET)"				\
888
	--with-build-sysroot="$(PREFIX)/$(TARGET)"			\
889
	--with-build-time-tools="$(PREFIX)/$(TARGET)/bin"		\
890
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)				\
891
	LDFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
892
	CPPFLAGS_FOR_TARGET="--sysroot=\"$(PREFIX)/$(TARGET)\""		\
893
	--with-bugurl=$(BUG_URL) \
894
	--with-pkgversion=$(PKG_VERSION) && \
895
	$(MAKE) -j$(PROCS)
896
	[ -d stamps ] || mkdir stamps
897
	touch stamps/build-gcc;
898
 
7 jasmin 899
.PHONY: install-gcc install-gcc-force
900
install-gcc: stamps/install-gcc
901
install-gcc-force stamps/install-gcc: stamps/build-gcc
4 jasmin 902
	cd build/gcc && \
903
	$(MAKE) installdirs install-target && \
904
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
905
	[ -d stamps ] || mkdir stamps
906
	touch stamps/install-gcc;
907
 
7 jasmin 908
.PHONY: clean-gcc
909
clean-gcc:
910
	rm -rf build/gcc stamps/*-gcc gcc-*
4 jasmin 911
 
7 jasmin 912
.PHONY: realclean-gcc
913
realclean-gcc: clean-gcc
914
	rm downloads/$(GCC_ARCHIVE)
915
 
916
 
4 jasmin 917
################ Final GCC ################
918
 
7 jasmin 919
.PHONY: build-final-gcc build-final-gcc-force
920
build-final-gcc: stamps/build-final-gcc
921
build-final-gcc-force stamps/build-final-gcc: stamps/install-binutils stamps/install-gcc stamps/install-newlib stamps/patch-gcc
4 jasmin 922
	mkdir -p build/final-gcc && cd build/final-gcc && \
923
	pushd ../../gcc-$(GCC_VERSION) ; \
924
	make clean ; \
925
	popd ; \
926
	../../gcc-$(GCC_VERSION)/configure --prefix=$(PREFIX) \
927
	--target=$(TARGET) $(DEPENDENCIES) --enable-languages="c,c++" --with-gnu-ld \
928
	--with-gnu-as --with-newlib --disable-nls --disable-libssp \
929
	--with-dwarf2 --enable-sjlj-exceptions \
930
	--enable-version-specific-runtime-libs --disable-libstdcxx-pch \
931
	--disable-shared --enable-__cxa_atexit \
932
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
933
	--enable-cxx-flags=$(CFLAGS_FOR_TARGET) \
934
	--with-sysroot=$(PREFIX)/$(TARGET) \
935
	--with-build-sysroot=$(PREFIX)/$(TARGET) \
936
	--with-build-time-tools=$(PREFIX)/$(TARGET)/bin \
937
	CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) \
938
	LDFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
939
	CPPFLAGS_FOR_TARGET="--sysroot=$(PREFIX)/$(TARGET)" \
940
	--with-bugurl=$(BUG_URL) \
941
	--with-pkgversion=$(PKG_VERSION) && \
942
	$(MAKE) -j$(PROCS)
943
	[ -d stamps ] || mkdir stamps
944
	touch stamps/build-final-gcc;
945
 
7 jasmin 946
.PHONY: install-final-gcc install-final-gcc-force
947
install-final-gcc: stamps/install-final-gcc
948
install-final-gcc-force stamps/install-final-gcc: stamps/build-final-gcc
4 jasmin 949
	cd build/final-gcc && \
950
	$(MAKE) installdirs install-target && \
951
	$(MAKE) -C gcc install-common install-cpp install- install-driver install-headers install-man
952
	[ -d stamps ] || mkdir stamps
953
	touch stamps/install-final-gcc;
954
 
7 jasmin 955
.PHONY: clean-final-gcc
956
clean-final-gcc: clean-gcc
957
	rm -rf build/final-gcc stamps/*-final-gcc
4 jasmin 958
 
7 jasmin 959
.PHONY: realclean-final-gcc
960
realclean-final-gcc: realclean-gcc
961
 
962
 
963
########## GDB ###########
964
 
965
.PHONY: download-gdb download-gdb-force
966
download-gdb: downloads/$(GDB_ARCHIVE)
967
download-gdb-force downloads/$(GDB_ARCHIVE):
968
	[ -d downloads ] || mkdir downloads ;
969
	cd downloads && curl -LO $(GDB_URL)
970
 
971
.PHONY: extract-gdb extract-gdb-force
972
extract-gdb: stamps/extract-gdb
973
extract-gdb-force stamps/extract-gdb: downloads/$(GDB_ARCHIVE)
974
	@(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
975
	[ "$$t1" = "$(GDB_MD5)" ] || \
976
	( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
977
	tar -jxf $< ;
978
	[ -d stamps ] || mkdir stamps ;
979
	touch stamps/extract-gdb;
980
 
981
.PHONY: patch-gdb patch-gdb-force
982
patch-gdb: stamps/patch-gdb
983
patch-gdb-force stamps/patch-gdb: stamps/extract-gdb stamps/extract-avr32patches
984
	pushd gdb-$(GDB_VERSION) ; \
985
	for f in ../source/avr32/gdb/*.patch; do \
986
	patch -N -p0 <$${f} ; \
987
	done ; \
988
	popd ; \
989
	[ -d stamps ] || mkdir stamps
990
	touch stamps/patch-gdb;
991
 
992
.PHONY: regen-gdb regen-gdb-force
993
regen-gdb: stamps/regen-gdb
994
regen-gdb-force stamps/regen-gdb: stamps/patch-gdb stamps/install-supp-tools
995
	pushd gdb-$(GDB_VERSION) ; \
996
	"$(SUPP_PREFIX)/bin/aclocal" -I config ; \
997
	"$(SUPP_PREFIX)/bin/autoconf" ; \
998
	"$(SUPP_PREFIX)/bin/automake" ; \
999
	"$(SUPP_PREFIX)/bin/autoheader" ; \
1000
	for dir in bfd opcodes gdb; do \
1001
	  pushd $$dir ; \
1002
	  echo "JESS 1: $$dir" >&2 ; \
1003
	  "$(SUPP_PREFIX)/bin/autoconf"; \
1004
	  "$(SUPP_PREFIX)/bin/automake"; \
1005
	  "$(SUPP_PREFIX)/bin/autoheader"; \
1006
	  echo "JESS 2: $$dir" >&2 ; \
1007
	  popd ; \
1008
	done; \
1009
	popd; \
1010
	[ -d stamps ] || mkdir stamps ;
1011
	touch stamps/regen-gdb;
1012
 
1013
.PHONY: build-gdb build-gdb-force
1014
build-gdb: stamps/build-gdb
1015
build-gdb-force stamps/build-gdb: stamps/regen-gdb stamps/install-supp-tools
1016
	echo "JESS 3" >&2 ; \
1017
	mkdir -p build/gdb && cd build/gdb && \
1018
	../../gdb-$(GDB_VERSION)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
1019
	$(MAKE) -j$(PROCS)
1020
	$(MAKE) installdirs install-host install-target
1021
	[ -d stamps ] || mkdir stamps
1022
	touch stamps/build-gdb;
1023
 
1024
.PHONY: install-gdb install-gdb-force
1025
install-gdb: stamps/install-gdb
1026
install-gdb-force stamps/install-gdb: stamps/build-gdb
1027
	cd build/gdb && \
1028
	$(MAKE) install
1029
	[ -d stamps ] || mkdir stamps
1030
	touch stamps/install-gdb;
1031
 
1032
.PHONY: clean-gdb
1033
clean-gdb:
1034
	rm -rf build/gdb stamps/*-gdb gdb-*
1035
 
1036
.PHONY: realclean-gdb
1037
realclean-gdb: clean-gdb
1038
	rm downloads/$(GDB_ARCHIVE)
1039
 
4 jasmin 1040
################ NON-WORKING/NON-ADJUSTED TARGETS ################
1041
 
1042
 
1043
gcc-optsize-patch: gcc-$(GCC_VERSION)-$(CS_BASE)/
1044
	pushd gcc-$(GCC_VERSION)-$(CS_BASE) ; \
1045
	patch -N -p1 < ../patches/gcc-optsize.patch ; \
1046
	popd ;
1047
 
1048
gmp: gmp-$(CS_BASE)/ sudomode
1049
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
1050
	pushd ../../gmp-$(CS_BASE) ; \
1051
	make clean ; \
1052
	popd ; \
1053
	sudo -u $(SUDO_USER) ../../gmp-$(CS_BASE)/configure --disable-shared && \
1054
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
1055
	$(MAKE) install
1056
 
1057
mpc: mpc-$(MPC_VERSION)/ sudomode
1058
	sudo -u $(SUDO_USER) mkdir -p build/gmp && cd build/gmp ; \
1059
	pushd ../../mpc-$(MPC_VERSION) ; \
1060
	make clean ; \
1061
	popd ; \
1062
	sudo -u $(SUDO_USER) ../../mpc-$(MPC_VERSION)/configure --disable-shared && \
1063
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
1064
	$(MAKE) install
1065
 
1066
mpc-$(MPC_VERSION) : $(LOCAL_BASE)/mpc-$(CS_VERSION).tar.bz2
1067
ifeq ($(USER),root)
1068
	sudo -u $(SUDO_USER) tar -jxf $<
1069
else
1070
	tar -jxf $<
1071
endif
1072
 
1073
mpfr: gmp mpfr-$(CS_BASE)/ sudomode
1074
	sudo -u $(SUDO_USER) mkdir -p build/mpfr && cd build/mpfr && \
1075
	pushd ../../mpfr-$(CS_BASE) ; \
1076
	make clean ; \
1077
	popd ; \
1078
	sudo -u $(SUDO_USER) ../../mpfr-$(CS_BASE)/configure LDFLAGS="-Wl,-search_paths_first" --disable-shared && \
1079
	sudo -u $(SUDO_USER) $(MAKE) -j$(PROCS) all && \
1080
	$(MAKE) install
1081
 
1082
cross-gdb: gdb-$(CS_BASE)/
1083
	mkdir -p build/gdb && cd build/gdb && \
1084
	pushd ../../gdb-$(CS_BASE) ; \
1085
	make clean ; \
1086
	popd ; \
1087
	../../gdb-$(CS_BASE)/configure --prefix="$(PREFIX)" --target=$(TARGET) --disable-werror && \
1088
	$(MAKE) -j$(PROCS) && \
1089
	$(MAKE) installdirs install-host install-target && \
1090
	mkdir -p "$(PREFIX)/man/man1" && \
1091
	cp ../../gdb-$(CS_BASE)/gdb/gdb.1 "$(PREFIX)/man/man1/arm-none-eabi-gdb.1"
1092
 
1093
.PHONY : clean
1094
clean:
1095
	rm -rf build *-$(CS_BASE) binutils-* gcc-* gdb-* newlib-* mpc-* $(LOCAL_BASE) dfu-programmer-* autoconf-* automake-* stamps/* source supp