summaryrefslogtreecommitdiffstats
path: root/rules/crosstool.make
blob: 6b8cdb0568ed9cf125c208fabe71fa8727568df6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# -*-makefile-*-
# $Id: template,v 1.14 2004/07/01 16:08:08 rsc Exp $
#
# Copyright (C) 2004 by Robert Schwebel
#          
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# We provide this package
#
PACKAGES-$(PTXCONF_CROSSTOOL) += crosstool

#
# Paths and names
#
ifdef PTXCONF_CROSSTOOL_VERSION_0_32
CROSSTOOL_VERSION	= 0.32
endif
ifdef PTXCONF_CROSSTOOL_VERSION_0_38
CROSSTOOL_VERSION       = 0.38
endif
CROSSTOOL		= crosstool-$(CROSSTOOL_VERSION)
CROSSTOOL_SUFFIX	= tar.gz
CROSSTOOL_URL		= http://www.kegel.com/crosstool/$(CROSSTOOL).$(CROSSTOOL_SUFFIX)
CROSSTOOL_SOURCE	= $(SRCDIR)/$(CROSSTOOL).$(CROSSTOOL_SUFFIX)
CROSSTOOL_DIR		= $(CROSS_BUILDDIR)/$(CROSSTOOL)

-include $(call package_depfile)

# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------

crosstool_get: $(STATEDIR)/crosstool.get

crosstool_get_deps = $(CROSSTOOL_SOURCE)

$(STATEDIR)/crosstool.get: $(crosstool_get_deps)
	@$(call targetinfo, $@)
	@$(call get_patches, $(CROSSTOOL))
	@$(call touch, $@)

$(CROSSTOOL_SOURCE):
	@$(call targetinfo, $@)
	@$(call get, $(CROSSTOOL_URL))

# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------

crosstool_extract: $(STATEDIR)/crosstool.extract

crosstool_extract_deps = $(STATEDIR)/crosstool.get

$(STATEDIR)/crosstool.extract: $(crosstool_extract_deps)
	@$(call targetinfo, $@)
	@$(call clean, $(CROSSTOOL_DIR))
	@$(call extract, $(CROSSTOOL_SOURCE), $(CROSS_BUILDDIR))
	@$(call patchin, $(CROSSTOOL),$(CROSSTOOL_DIR))
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

crosstool_prepare: $(STATEDIR)/crosstool.prepare

#
# dependencies
#
crosstool_prepare_deps = $(STATEDIR)/crosstool.extract

CROSSTOOL_PATH	=  PATH=$(CROSS_PATH)

#
# Configuration
#

# FIXME: where do we get this from? 
CROSSTOOL_TARGET_CFLAGS		=  -O

# BSP: I like --with-cpu=strongarm on my x86...
ifdef PTXCONF_ARCH_ARM
CROSSTOOL_GCC_EXTRA_CONFIG	=  "--with-float=soft --with-cpu=strongarm"
endif

ifdef PTXCONF_OPT_PPC405
CROSSTOOL_GCC_EXTRA_CONFIG	= "--with-cpu=405 --enable-cxx-flags=-mcpu=405"
CROSSTOOL_TARGET_CFLAGS		= "-O -mcpu=405"
endif

CROSSTOOL_GCCLANG		=  c
ifdef PTXCONF_CROSSTOOL_GCCLANG_CC
CROSSTOOL_GCCLANG		+= ,c++
endif
CROSSTOOL_GCCLANG		:= $(subst $(quote),,$(CROSSTOOL_GCCLANG)) 
CROSSTOOL_GCCLANG		:= `echo $(CROSSTOOL_GCCLANG) | perl -p -e 's/\s//g'`

ifdef PTXCONF_SOFTFLOAT
CROSSTOOL_GLIBC_EXTRA_CONFIG 	+= --without-fp
endif

ifdef PTXCONF_GLIBC
CROSSTOOL_LIBC_DIR		= $(GLIBC)
CROSSTOOL_LIBC			= glibc
else
ifdef PTXCONF_UCLIBC
CROSSTOOL_LIBC_DIR		= $(UCLIBC)
CROSSTOOL_LIBC			= uclibc
endif
endif

#
# Environment 
#
CROSSTOOL_ENV	=  export ptx_http_proxy=$(PTXCONF_SETUP_HTTP_PROXY); \
	export ptx_ftp_proxy=$(PTXCONF_SETUP_FTP_PROXY); \
	eval export \
	$${ptx_http_proxy:+http_proxy=$${ptx_http_proxy}} \
	$${ptx_ftp_proxy:+ftp_proxy=$${ptx_ftp_proxy}};
CROSSTOOL_ENV 	+= TARBALLS_DIR=$(SRCDIR)
CROSSTOOL_ENV	+= RESULT_TOP=$(call remove_quotes,$(PTXCONF_PREFIX))
CROSSTOOL_ENV	+= GCC_LANGUAGES="$(CROSSTOOL_GCCLANG)"
CROSSTOOL_ENV	+= KERNELCONFIG=$(call remove_quotes,$(CROSSTOOL_DIR)/$(PTXCONF_CROSSTOOL_KERNELCONFIG))
CROSSTOOL_ENV	+= TARGET=$(call remove_quotes,$(PTXCONF_GNU_TARGET))
CROSSTOOL_ENV	+= TARGET_CFLAGS="$(call remove_quotes,$(CROSSTOOL_TARGET_CFLAGS))"
CROSSTOOL_ENV	+= GCC_EXTRA_CONFIG=$(CROSSTOOL_GCC_EXTRA_CONFIG)
CROSSTOOL_ENV	+= GLIBC_EXTRA_CONFIG=$(CROSSTOOL_GLIBC_EXTRA_CONFIG)
CROSSTOOL_ENV	+= BINUTILS_DIR=binutils-$(PTXCONF_BINUTILS_VERSION)
CROSSTOOL_ENV	+= GCC_DIR=gcc-$(GCC_VERSION)
CROSSTOOL_ENV	+= LIBC_DIR=$(CROSSTOOL_LIBC_DIR)
CROSSTOOL_ENV	+= C_LIBRARY=$(CROSSTOOL_LIBC)
ifdef PTXCONF_UCLIBC
CROSSTOOL_ENV	+= UCLIBCCONFIG=$(CROSSTOOL_DIR)/uclibc_config
endif
CROSSTOOL_ENV	+= LINUX_DIR=linux-$(KERNEL_VERSION)
CROSSTOOL_ENV	+= GLIBCTHREADS_FILENAME=glibc-linuxthreads-$(GLIBC_VERSION)

$(STATEDIR)/crosstool.prepare: $(crosstool_prepare_deps)
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Compile
# ----------------------------------------------------------------------------

#
# Crosstool installs on 'compile', so we put everything into the install
# target. 
#

crosstool_compile: $(STATEDIR)/crosstool.compile

$(STATEDIR)/crosstool.compile: $(STATEDIR)/crosstool.prepare
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

crosstool_install: $(STATEDIR)/crosstool.install

crosstool_install_deps = $(STATEDIR)/crosstool.compile

$(STATEDIR)/crosstool.install: $(crosstool_install_deps)
	@$(call targetinfo, $@)
ifdef PTXCONF_UCLIBC
	grep -e PTXCONF_UC_ $(PTXDIST_WORKSPACE)/.config > $(CROSSTOOL_DIR)/uclibc_config
	perl -i -p -e 's/PTXCONF_UC_//g' $(CROSSTOOL_DIR)/uclibc_config
endif

#
# We set all the stuff crosstool expects in it's environment
#
	(	cd $(CROSSTOOL_DIR); 					\
		set -ex; 						\
		mkdir -p $(call remove_quotes,$(PTXCONF_PREFIX)); 	\
		$(CROSSTOOL_ENV) sh $(CROSSTOOL_DIR)/all.sh --notest; 	\
		echo "done" 						\
		exit 1;							\
	)
ifdef PTXCONF_CROSSTOOL_VERSION_0_32
	touch $(call remove_quotes,$(PTXCONF_PREFIX)/$(PTXCONF_GNU_TARGET)/gcc-$(GCC_VERSION)-$(CROSSTOOL_LIBC_DIR)/$(PTXCONF_GNU_TARGET)/include/linux/autoconf.h)
endif
ifdef PTXCONF_CROSSTOOL_VERSION_0_38
	touch $(call remove_quotes,$(PTXCONF_PREFIX)/gcc-$(GCC_VERSION)-$(CROSSTOOL_LIBC_DIR)/$(PTXCONF_GNU_TARGET)/$(PTXCONF_GNU_TARGET)/include/linux/autoconf.h)
endif
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

crosstool_targetinstall: $(STATEDIR)/crosstool.targetinstall

crosstool_targetinstall_deps = $(STATEDIR)/crosstool.install

$(STATEDIR)/crosstool.targetinstall: $(crosstool_targetinstall_deps)
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Clean
# ----------------------------------------------------------------------------

crosstool_clean:
	rm -rf $(STATEDIR)/crosstool.*
	rm -rf $(CROSSTOOL_DIR)

# vim: syntax=make