Subversion Repositories avr32-toolchain

Rev

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