Subversion Repositories avr32-toolchain

Rev

Rev 19 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19 Rev 21
Line 21... Line 21...
21
# THE SOFTWARE.
21
# THE SOFTWARE.
22
#
22
#
23
# This Makefile is based on the one from here:
23
# This Makefile is based on the one from here:
24
#    https://github.com/jsnyder/avr32-toolchain/blob/master/Makefile
24
#    https://github.com/jsnyder/avr32-toolchain/blob/master/Makefile
25
#    Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org>
25
#    Copyright (C) 2011 by James Snyder <jbsnyder@fanplastic.org>
-
 
26
#
-
 
27
-
 
28
26
29
-
 
30
###############################################################################
27
#
31
#
-
 
32
# The origial version couldn't handle delta building of parts, which is
-
 
33
# required during patch development. I didn't want to fix all the different
-
 
34
# make steps seperately. So I decided to use an new approach, which I never
28
# This makefile uses macros to generate the different rules for the different
35
# tried before. I used make macros to generate the different rules for the
-
 
36
# different tools.
29
# tools. This saves a lot of work, when a new tool is added. Moreover, bugfixes
37
# This saved me a lot of work, when a new tool is added. Moreover, bugfixes
-
 
38
# have to be done only one place. Enhancments of the targets need to be done
30
# have to be done only one place.
39
# on only one place.
-
 
40
# The drawback of this approach is a little mor complexity when writing shell
-
 
41
# scripts within the make macro. You need a lot of '$' for escaping.
-
 
42
#
-
 
43
# I have tested most of the targets with a lot of compinations, but there might
-
 
44
# one which is not working. Please send me a bug report, if you find such a
-
 
45
# combination.
-
 
46
#
-
 
47
# The development SVN repository can be found at
-
 
48
#  http://web.anw.at/websvn/listing.php?repname=avr32-toolchain
31
#
49
#
32
# NOTE: Currently ONLY binutils is finished!
50
# NOTE: Currently ONLY binutils is finished!
33
#
51
#
-
 
52
###############################################################################
-
 
53
34
54
35
55
36
#### PRIMARY TOOLCHAIN VERSIONS #####
56
#### PRIMARY TOOLCHAIN VERSIONS #####
37
57
38
GCC_VERSION       = 4.4.3
58
GCC_VERSION       = 4.4.3
Line 53... Line 73...
53
73
54
TODAY = $(shell date "+%Y%m%d")
74
TODAY = $(shell date "+%Y%m%d")
55
GIT_REV	    = $(shell git rev-parse --verify HEAD --short 2> /dev/null)
75
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 " ")
76
SVN_REV	    = $(shell head -1 ReleaseNotes 2> /dev/null | cut -f 1 -d " ")
57
77
-
 
78
PREFIX_RELEASE ?= /opt/avr/avr32-tools
-
 
79
58
ifeq ($(strip $(GIT_REV)),)
80
ifeq ($(strip $(GIT_REV)),)
59
ifeq ($(strip $(SVN_REV)),)
81
ifeq ($(strip $(SVN_REV)),)
60
PREFIX     ?= $(HOME)/avr32-tools-$(TODAY)
82
PREFIX     ?= $(HOME)/avr32-tools-$(TODAY)
61
TOOL_REV   = $(TODAY)
83
TOOL_REV   = $(TODAY)
62
else
84
else
Line 75... Line 97...
75
PROCS  ?= $(shell sysctl hw.ncpu | awk '{print $$2}')
97
PROCS  ?= $(shell sysctl hw.ncpu | awk '{print $$2}')
76
else
98
else
77
PROCS  ?= 2
99
PROCS  ?= 2
78
endif
100
endif
79
101
-
 
102
-
 
103
RELEASE_VERSION ?= no
-
 
104
PREFIX_RELEASE ?= /opt/avr/avr32-tools
-
 
105
-
 
106
ifneq ($(RELEASE_VERSION),no)
-
 
107
FULL_STATIC = y
-
 
108
PREFIX = $(PREFIX_RELEASE)-$(RELEASE_VERSION)
-
 
109
endif
-
 
110
-
 
111
-
 
112
# enable complete static linking
-
 
113
FULL_STATIC ?= no
-
 
114
80
# enable maintainer-mode with yes
115
# enable maintainer-mode with yes
81
M_MODE ?= no
116
M_MODE ?= no
82
117
83
# enable binutils autotool file regeneration with yes
118
# enable binutils autotool file regeneration with yes
84
BINUTILS_REGEN ?= no
119
BINUTILS_REGEN ?= no
Line 126... Line 161...
126
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
161
AVR32PATCHES_MD5 = 69a03828a328068f25d457cfd8341857
127
install_dir_avr32patches := source/avr32
162
install_dir_avr32patches := source/avr32
128
163
129
NEWPATCHESBINUTILS_ARCHIVE = binutils-2.22-avr32-full.patch
164
NEWPATCHESBINUTILS_ARCHIVE = binutils-2.22-avr32-full.patch
130
NEWPATCHESBINUTILS_URL=http://avr.anw.at/avr32/patches/binutils/2_22/$(NEWPATCHESBINUTILS_ARCHIVE)
165
NEWPATCHESBINUTILS_URL=http://avr.anw.at/avr32/patches/binutils/2_22/$(NEWPATCHESBINUTILS_ARCHIVE)
131
NEWPATCHESBINUTILS_MD5 = aca9dd1aaeda63fa1a0cc4c68b94fa6f
166
NEWPATCHESBINUTILS_MD5 = 09c091b9acb369fd39fb21d0334bb9a6
132
install_dir_newpatchesbinutils := source/avr32/binutils
167
install_dir_newpatchesbinutils := source/avr32/binutils
133
168
134
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
169
AVR32HEADERS_ARCHIVE = avr32-headers-$(AVR_HEADER_REV).zip
135
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
170
AVR32HEADERS_URL=http://www.atmel.com/dyn/resources/prod_documents/$(AVR32HEADERS_ARCHIVE)
136
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
171
AVR32HEADERS_MD5 = 3293d70a46e460d342e1f939b8e0d228
Line 214... Line 249...
214
define del_empty-directories
249
define del_empty-directories
215
	@find . -type d -empty -not -path "*.git*" -not -path "*.svn*" -delete
250
	@find . -type d -empty -not -path "*.git*" -not -path "*.svn*" -delete
216
endef
251
endef
217
252
218
## delete all empty directories
253
## delete all empty directories
219
## need to do this several times. to remove empty sub directories
254
## need to do this several times to remove all empty sub directories
220
define del_all_empty-directories
255
define del_all_empty-directories
221
	$(call del_empty-directories)
256
	$(call del_empty-directories)
222
	$(call del_empty-directories)
257
	$(call del_empty-directories)
223
	$(call del_empty-directories)
258
	$(call del_empty-directories)
224
	$(call del_empty-directories)
259
	$(call del_empty-directories)
Line 355... Line 390...
355
PHONY += regen-$(1) regen-$(1)-f regen-$(1)-remove
390
PHONY += regen-$(1) regen-$(1)-f regen-$(1)-remove
356
endef
391
endef
357
392
358
## create the configure rule and force configure rule
393
## create the configure rule and force configure rule
359
define CONF_template
394
define CONF_template
360
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)"
-
 
361
conf-$(1): $(call name_stamp,conf-$(1))
-
 
362
-
 
363
# we need configure parameters!
395
# we need configure parameters!
364
ifeq ($$(strip $$($(1)_conf_opts)),)
396
ifeq ($$(strip $$($(1)_conf_opts)),)
365
$$(error "Configure options '$(1)_conf_opts' not defined")
397
$$(error "Configure options '$(1)_conf_opts' not defined")
366
endif
398
endif
367
399
-
 
400
conf-$(1)_TEXT := "Configuring $(1) $$($(1)_VERSION)"
-
 
401
conf-$(1): $(call name_stamp,conf-$(1))
-
 
402
368
conf-$(1)-f $(call name_stamp,conf-$(1)): $(call name_stamp,$(2)-$(1)) $$($(1)_conf_deps)
403
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))
404
	@(rm -rf $(BUILD_DIR)/$(1) ; mkdir -p $(BUILD_DIR)/$(1))
370
	$(call quiet_text,$$(conf-$(1)_TEXT))
405
	$(call quiet_text,$$(conf-$(1)_TEXT))
371
	cd $(BUILD_DIR)/$(1) && \
406
	cd $(BUILD_DIR)/$(1) && \
-
 
407
	$$($(1)_conf_env) \
372
	../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts)
408
	../../$(1)-$$($(1)_VERSION)/configure $$($(1)_conf_opts)
373
	$(call make_stamp,conf-$(1))
409
	$(call make_stamp,conf-$(1))
374
410
375
conf-$(1)-remove:
411
conf-$(1)-remove:
376
	$(call rm_stamp,conf-$(1))
412
	$(call rm_stamp,conf-$(1))
Line 393... Line 429...
393
429
394
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)"
430
build-$(1)_TEXT := "Building $(1) $$($(1)_VERSION)"
395
$(call name_stamp,build-$(1)): $(call name_stamp,conf-$(1))
431
$(call name_stamp,build-$(1)): $(call name_stamp,conf-$(1))
396
	$(call quiet_text,$$(build-$(1)_TEXT))
432
	$(call quiet_text,$$(build-$(1)_TEXT))
397
	cd $(BUILD_DIR)/$(1) && \
433
	cd $(BUILD_DIR)/$(1) && \
-
 
434
	$$($(1)_build_env) \
398
	$$($(1)_build_cmds)
435
	$$($(1)_build_cmds)
399
	$(call make_stamp,build-$(1))
436
	$(call make_stamp,build-$(1))
400
437
401
build-$(1)-clean_TEXT := "Cleaning $(1) $$($(1)_VERSION)"
438
build-$(1)-clean_TEXT := "Cleaning $(1) $$($(1)_VERSION)"
402
build-$(1)-clean:
439
build-$(1)-clean:
Line 575... Line 612...
575
612
576
################ BINUTILS ################
613
################ BINUTILS ################
577
614
578
$(eval $(call DOWNLOAD_template,binutils))
615
$(eval $(call DOWNLOAD_template,binutils))
579
$(eval $(call EXTRACT_template,binutils,EXT_BZ2))
616
$(eval $(call EXTRACT_template,binutils,EXT_BZ2))
580
binutils_patch_level := -p1
617
#binutils_patch_level := -p1
581
$(eval $(call PATCH_template,binutils))
618
$(eval $(call PATCH_template,binutils))
582
binutils_regen_dirs := bfd opcodes binutils gas ld
619
binutils_regen_dirs := bfd opcodes binutils gas ld
583
$(eval $(call REGEN_template,binutils,patch))
620
$(eval $(call REGEN_template,binutils,patch))
584
621
585
ifneq ($(M_MODE),no)
622
ifneq ($(M_MODE),no)
586
binutils_maintainer_mode := --enable-maintainer-mode
623
binutils_maintainer_mode := --enable-maintainer-mode
587
endif
624
endif
588
625
-
 
626
# do not add a ' ' between after ":="
589
ifneq ($(BINUTILS_REGEN),no)
627
ifneq ($(BINUTILS_REGEN),no)
590
binutils_conf_depend :=regen
628
binutils_conf_depend :=regen
591
else	
629
else	
592
binutils_conf_depend :=patch
630
binutils_conf_depend :=patch
593
endif
631
endif
Line 598... Line 636...
598
  --disable-shared --disable-werror \
636
  --disable-shared --disable-werror \
599
  --enable-ld=yes --enable-gold=no \
637
  --enable-ld=yes --enable-gold=no \
600
  --with-pkgversion=$(PKG_VERSION) \
638
  --with-pkgversion=$(PKG_VERSION) \
601
  --with-sysroot="$(PREFIX)/$(TARGET)"
639
  --with-sysroot="$(PREFIX)/$(TARGET)"
602
#  --with-bugurl=$(BUG_URL)
640
#  --with-bugurl=$(BUG_URL)
603
-
 
604
$(eval $(call CONF_template,binutils,$(binutils_conf_depend)))
641
$(eval $(call CONF_template,binutils,$(binutils_conf_depend)))
-
 
642
-
 
643
ifneq ($(FULL_STATIC),no)
-
 
644
binutils_fulls_static := AM_LDFLAGS=-all-static
-
 
645
endif
605
#binutils_build_cmds := ???
646
#binutils_build_cmds := ???
606
#binutils_build_clean_cmds := ???
647
#binutils_build_clean_cmds := ???
-
 
648
binutils_build_env := $(binutils_fulls_static)
607
$(eval $(call BUILD_template,binutils))
649
$(eval $(call BUILD_template,binutils))
608
$(eval $(call INSTALL_template,binutils))
650
$(eval $(call INSTALL_template,binutils))
609
$(eval $(call CLEAN_template,binutils))
651
$(eval $(call CLEAN_template,binutils))
610
652
611
653
612
.PHONY: $(PHONY)
654
.PHONY: $(PHONY)
613
655
614
656
615
657
616
658
617
.PHONY: tst tst2 tst3
659
.PHONY: tst
618
tst:
660
tst:
619
	@echo "PREFIX=$(PREFIX)"
661
	@echo "PREFIX=$(PREFIX)"
620
	@echo "PKG_VERSION=$(PKG_VERSION)"
662
	@echo "PKG_VERSION=$(PKG_VERSION)"
621
	@echo "BUG_URL=$(BUG_URL)"
663
	@echo "BUG_URL=$(BUG_URL)"
622
tst2:
-
 
623
	$(call make_stamp,JES)
-
 
624
tst3:
-
 
625
	$(call rm_stamp,JES)
-
 
626
664
627
.PHONY: help
665
.PHONY: help
628
help:
666
help:
629
	@echo ""
667
	@echo ""
630
	@echo "The following targets are available:"
668
	@echo "The following targets are available:"
Line 659... Line 697...
659
	@echo "The installation prefix can be set by"
697
	@echo "The installation prefix can be set by"
660
	@echo " PREFIX=.... make aaa-XXX"
698
	@echo " PREFIX=.... make aaa-XXX"
661
	@echo "And the package version with"
699
	@echo "And the package version with"
662
	@echo " PKG_VERSION=\"AVR 32 bit GNU Toolchain-XXX\""
700
	@echo " PKG_VERSION=\"AVR 32 bit GNU Toolchain-XXX\""
663
	@echo ""
701
	@echo ""
-
 
702
	@echo "Build a full static release with"
-
 
703
	@echo " RELEASE_VERSION=0.1.0"
-
 
704
	@echo "The prefix for the release can changed with"
-
 
705
	@echo " PREFIX_RELEASE=/usr/local/avr/avr32-tools"
-
 
706
	@echo ""
664
	@echo "Maintainers may use"
707
	@echo "Maintainers may use"
665
	@echo " M_MODE=y or BINUTILS_REGEN=y"
708
	@echo " M_MODE=y, BINUTILS_REGEN=y, FULL_STATIC=y"
666
	@echo "Please have a look to the Makefile for details"
709
	@echo "Please have a look to the Makefile for details"
667
	@echo ""
710
	@echo ""
668
711
-
 
712
# do not remove the empty line, will add the required \n
669
define print_target
713
define print_target
670
	@echo "$(1)"
714
	@echo "$(1)"
671
715
672
endef
716
endef
673
717