summaryrefslogtreecommitdiffstats
path: root/rules/cross-gcc-first.make
blob: c7b5cf819b1ce3bbf19d207ba358858a9efd7fdc (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
# -*-makefile-*-
# $Id$
#
# Copyright (C) 2006 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
#
CROSS_PACKAGES-$(PTXCONF_CROSS_GCC_FIRST) += cross-gcc-first

#
# Paths and names
#
CROSS_GCC_FIRST_VERSION		:= $(call remove_quotes,$(PTXCONF_CROSS_GCC_FIRST_VERSION))
CROSS_GCC_FIRST			:= gcc-$(CROSS_GCC_FIRST_VERSION)
CROSS_GCC_FIRST_SUFFIX	 	:= tar.bz2
CROSS_GCC_FIRST_URL	 	:= $(PTXCONF_SETUP_GNUMIRROR)/gcc/$(CROSS_GCC_FIRST)/$(CROSS_GCC_FIRST).$(CROSS_GCC_FIRST_SUFFIX)
CROSS_GCC_FIRST_SOURCE		:= $(SRCDIR)/$(CROSS_GCC_FIRST).$(CROSS_GCC_FIRST_SUFFIX)
CROSS_GCC_FIRST_DIR		:= $(CROSS_BUILDDIR)/$(CROSS_GCC_FIRST)
CROSS_GCC_FIRST_BUILDDIR	:= $(CROSS_GCC_FIRST_DIR)-first-build

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

cross-gcc-first_get: $(STATEDIR)/cross-gcc-first.get

$(STATEDIR)/cross-gcc-first.get: $(cross-gcc-first_get_deps_default)
	@$(call targetinfo, $@)
	@$(call touch, $@)

$(CROSS_GCC_FIRST_SOURCE):
	@$(call targetinfo, $@)
	@$(call get, CROSS_GCC_FIRST)

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

cross-gcc-first_extract: $(STATEDIR)/cross-gcc-first.extract

$(STATEDIR)/cross-gcc-first.extract: $(cross-gcc-first_extract_deps_default)
	@$(call targetinfo, $@)
	@$(call clean, $(CROSS_GCC_FIRST_DIR))
	@$(call clean, $(CROSS_GCC_FIRST_BUILDDIR))
	@$(call extract, CROSS_GCC_FIRST, $(CROSS_BUILDDIR))
	@$(call patchin, CROSS_GCC_FIRST, $(CROSS_GCC_FIRST_DIR))
	mkdir -p $(CROSS_GCC_FIRST_BUILDDIR)
	@$(call touch, $@)

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

cross-gcc-first_prepare: $(STATEDIR)/cross-gcc-first.prepare

CROSS_GCC_FIRST_PATH	:= PATH=$(CROSS_PATH)
CROSS_GCC_FIRST_ENV	:= $(HOSTCC_ENV)

#
# autoconf
#
CROSS_GCC_FIRST_AUTOCONF :=  \
	--host=$(GNU_HOST) \
	--target=$(call remove_quotes,$(PTXCONF_GNU_TARGET)) \
	--prefix=$(PTXCONF_PREFIX) \
	--with-sysroot=$(SYSROOT) \
	$(call remove_quotes,$(PTXCONF_CROSS_GCC_FIRST_EXTRA_CONFIG)) \
	\
        --disable-nls \
	--disable-multilib \
        --enable-symvers=gnu \
        --enable-__cxa_atexit \
	--enable-serial-configure \
	\
        --disable-shared \
	--disable-threads \
        --enable-languages=c

$(STATEDIR)/cross-gcc-first.prepare: $(cross-gcc-first_prepare_deps_default)
	@$(call targetinfo, $@)
	@$(call clean, $(CROSS_GCC_FIRST_BUILDDIR)/config.cache)
	cd $(CROSS_GCC_FIRST_BUILDDIR) && \
		$(CROSS_GCC_FIRST_PATH) $(CROSS_GCC_FIRST_ENV) \
		$(CROSS_GCC_FIRST_DIR)/configure $(CROSS_GCC_FIRST_AUTOCONF)
	@$(call touch, $@)

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

# From crosstool:
#
# HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
#       gcc/config/t-libunwind so -lc is removed from the link for
#       libgcc_s.so, as we do not have a target -lc yet.
#       This is not as ugly as it appears to be ;-) All symbols get resolved
#       during the glibc build, and we provide a proper libgcc_s.so for the
#       cross toolchain during the final gcc build.
#
#       As we cannot modify the source tree, nor override SHLIB_LC itself
#       during configure or make, we have to edit the resultant
#       gcc/libgcc.mk itself to remove -lc from the link.
#       This causes us to have to jump through some hoops...
#
#       To produce libgcc.mk to edit we firstly require libiberty.a,
#       so we configure then build it.
#       Next we have to configure gcc, create libgcc.mk then edit it...
#       So much easier if we just edit the source tree, but hey...

cross-gcc-first_compile: $(STATEDIR)/cross-gcc-first.compile

$(STATEDIR)/cross-gcc-first.compile: $(cross-gcc-first_compile_deps_default)
	@$(call targetinfo, $@)

	export $(CROSS_GCC_FIRST_PATH); \
	cd $(CROSS_GCC_FIRST_BUILDDIR) && \
		if test -d $(CROSS_GCC_FIRST_DIR)/libdecnumber; then \
			$(MAKE) configure-libdecnumber && \
			$(MAKE) $(PARALLELMFLAGS) all-libdecnumber; \
		fi

	cd $(CROSS_GCC_FIRST_BUILDDIR) && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) configure-gcc

	cd $(CROSS_GCC_FIRST_BUILDDIR) && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) configure-libcpp

	cd $(CROSS_GCC_FIRST_BUILDDIR) && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) configure-build-libiberty

	cd $(CROSS_GCC_FIRST_BUILDDIR) && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) $(PARALLELMFLAGS) all-libcpp

	cd $(CROSS_GCC_FIRST_BUILDDIR) && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) $(PARALLELMFLAGS) all-build-libiberty

	cd $(CROSS_GCC_FIRST_BUILDDIR)/gcc && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) $(PARALLELMFLAGS) libgcc.mk


	if test '!' -f $(CROSS_GCC_FIRST_BUILDDIR)/gcc/libgcc.mk-ORIG; then \
		cp -p $(CROSS_GCC_FIRST_BUILDDIR)/gcc/libgcc.mk \
			$(CROSS_GCC_FIRST_BUILDDIR)/gcc/libgcc.mk-ORIG; \
	fi

	sed 's@-lc@@g' < $(CROSS_GCC_FIRST_BUILDDIR)/gcc/libgcc.mk-ORIG \
		> $(CROSS_GCC_FIRST_BUILDDIR)/gcc/libgcc.mk

	cd $(CROSS_GCC_FIRST_BUILDDIR)/gcc && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) tree-check.h

	cd $(CROSS_GCC_FIRST_BUILDDIR) && $(CROSS_GCC_FIRST_PATH) \
		$(MAKE) $(PARALLELMFLAGS) all-gcc

	@$(call touch, $@)

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

cross-gcc-first_install: $(STATEDIR)/cross-gcc-first.install

$(STATEDIR)/cross-gcc-first.install: $(cross-gcc-first_install_deps_default)
	@$(call targetinfo, $@)
	cd $(CROSS_GCC_FIRST_BUILDDIR) && \
		$(CROSS_GCC_FIRST_PATH) $(MAKE) install-gcc
	@$(call touch, $@)

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

cross-gcc-first_clean:
	rm -rf $(STATEDIR)/cross-gcc-first.*
	rm -rf $(CROSS_GCC_FIRST_DIR)
	rm -rf $(CROSS_GCC_FIRST_BUILDDIR)

# vim: syntax=make