Subversion Repositories avr32-toolchain

Rev

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