Subversion Repositories avr32-toolchain

Rev

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

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