Subversion Repositories avr32-toolchain

Rev

Rev 15 | Rev 19 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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