summaryrefslogtreecommitdiffstats
path: root/build
blob: 2e9dc20d14de17a2e6fe5fae8d1aaa96bc2beb80 (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
216
217
218
#!/usr/bin/make -f

base_version = $$(printf '%s\n' '$(OPK_SOURCE)' | sed 's/^gcc-//')

common_opts = \
	--with-pkgversion='GCC for ProteanOS' \
	--program-suffix="-$(base_version)" \
	--enable-linker-build-id \
	--with-system-zlib \
	--disable-multilib \
	--without-included-gettext \
	--with-nls \
	--with-sysroot="$${OPK_SYSROOT:-/}" \
	--enable-clocale=gnu

full_opts = \
	$(common_opts) \
	--enable-shared \
	--enable-threads=posix \
	--enable-languages=c,c++

bootstrap1_opts = \
	$(common_opts) \
	--without-headers \
	--with-newlib \
	--disable-shared \
	--disable-threads \
	--enable-languages=c,c++ \
	--disable-libgomp \
	--disable-libmudflap \
	--disable-libssp

include ../targets.mk
target = $$(printf '%s' '$@' | sed 's/^[a-z]*-//')
builddir = obj-$(target)
destdir = dest-$(target)

nop:
	@:

$(configure_targets):
	if [ 'x$(OPK_HOST_PLAT)' = 'xbootstrap1' ]; then \
		oh-autoconfigure -B "$(builddir)" -t "$(target)" -- \
		$(bootstrap1_opts); \
	else \
		oh-autoconfigure -B "$(builddir)" -t "$(target)" -- \
		$(full_opts); \
	fi
	touch $@

configure: $(configure_targets)
	touch $@

$(build_targets): configure
	libsubdir="/usr/lib/$(target)/gcc-$(base_version)" && \
	oh-autobuild -B "$(builddir)" -T bootstrap-lean -- -j $${JOBS:-1} \
		libsubdir="$${libsubdir}" \
		libexecsubdir="$${libsubdir}" \
		libsubincludedir="$${libsubdir}/include" \
		fincludedir="$${libsubdir}/finclude" \
		toolexeclibdir="/usr/lib/$(target)" \
		MULTIOSDIR=
	touch $@

build: $(build_targets)
	touch $@

$(install_targets): build
	# The -T option is necessary because otherwise:
	#   * oh-autoinstall checks for an "install" target by running make with
	#     the -n option,
	#   * Many commands in GCC makefiles contain the "$(MAKE)" macro
	#     expansion, and
	#   * GNU Make executes any commands that contain "$(MAKE)", even if -n
	#     is specified.
	# See also: <http://gcc.gnu.org/ml/gcc/2013-04/msg00171.html>.
	libsubdir="/usr/lib/$(target)/gcc-$(base_version)" && \
	oh-autoinstall -B "$(builddir)" -d "$(destdir)" -T install -- \
		gxx_include_dir=/usr/include/c++-4.7 \
		host_installdir=/usr/include/$(target)/c++-4.7/bits \
		libsubdir="$${libsubdir}" \
		libexecsubdir="$${libsubdir}" \
		libsubincludedir="$${libsubdir}/include" \
		fincludedir="$${libsubdir}/finclude" \
		toolexeclibdir="/usr/lib/$(target)" \
		MULTIOSDIR=
	# Change the target architecture prefix of files in /usr/bin.
	rm -f $(destdir)/usr/bin/*-gcc-$(base_version).*
	for f in c++ g++ gcc gcc-ar gcc-nm gcc-ranlib; do \
		rm -f $(destdir)/usr/bin/$${f}-$(base_version); \
		mv $(destdir)/usr/bin/*-$${f}-$(base_version) \
			$(destdir)/usr/bin/$(target)-$$(printf '%s' \
				$(destdir)/usr/bin/*-$${f}-$(base_version) | \
				sed "s/^.*-\($${f}\)/\1/"); \
		ln -sf $(target)-$$(printf '%s' \
				$(destdir)/usr/bin/*-$${f}-$(base_version) | \
				sed "s/^.*-\($${f}\)/\1/") \
			$(destdir)/usr/bin/$$(printf '%s' \
				$(destdir)/usr/bin/*-$${f}-$(base_version) | \
				sed "s/^.*-\($${f}\)/\1/"); \
	done
	# Remove the internal libiberty.a.
	rm -f $(destdir)/usr/lib/$(target)/libiberty.a
	# Move libstdc++.so link.
	rm -f $(destdir)/usr/lib/$(target)/libstdc++.so
	ln -sf /usr/lib/$(target)/libstdc++.so.6 \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/libstdc++.so
	# Move libstdc++.a and libsupc++.a.
	mv $(destdir)/usr/lib/$(target)/libstdc++.a \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	mv $(destdir)/usr/lib/$(target)/libsupc++.a \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	# Move libmudflap.so and libmudflapth.so links.
	rm -f $(destdir)/usr/lib/$(target)/libmudflap.so
	ln -sf /usr/lib/$(target)/libmudflap.so.0 \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/libmudflap.so
	rm -f $(destdir)/usr/lib/$(target)/libmudflapth.so
	ln -sf /usr/lib/$(target)/libmudflapth.so.0 \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/libmudflapth.so
	# Move libmudflap.a and libmudflapth.a.
	mv $(destdir)/usr/lib/$(target)/libmudflap.a \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	mv $(destdir)/usr/lib/$(target)/libmudflapth.a \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	# Move libssp.so link.
	rm -f $(destdir)/usr/lib/$(target)/libssp.so
	ln -sf /usr/lib/$(target)/libssp.so.0 \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/libssp.so
	# Move libssp.a and libssp_nonshared.a.
	mv $(destdir)/usr/lib/$(target)/libssp.a \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	mv $(destdir)/usr/lib/$(target)/libssp_nonshared.a \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	# Move libgcc_s.so.1 under /lib.
	mkdir -p $(destdir)/lib/$(target)
	mv $(destdir)/usr/lib/$(target)/libgcc_s.so.1 $(destdir)/lib/$(target)
	# Move libgcc_s.so link.
	rm -f $(destdir)/usr/lib/$(target)/libgcc_s.so
	ln -sf /lib/$(target)/libgcc_s.so.1 \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/libgcc_s.so
	# Remove libquadmath files.
	rm -f $(destdir)/usr/lib/$(target)/libquadmath.*
	# Move libgomp.so link.
	rm -f $(destdir)/usr/lib/$(target)/libgomp.so
	ln -sf /usr/lib/$(target)/libgomp.so.1 \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/libgomp.so
	# Move libgomp.a and libgomp.spec.
	mv $(destdir)/usr/lib/$(target)/libgomp.a \
		$(destdir)/usr/lib/$(target)/libgomp.spec \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	# Move libitm.so link.
	rm -f $(destdir)/usr/lib/$(target)/libitm.so
	ln -sf /usr/lib/$(target)/libitm.so.1 \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/libitm.so
	# Move libitm.a and libitm.spec.
	mv $(destdir)/usr/lib/$(target)/libitm.a \
		$(destdir)/usr/lib/$(target)/libitm.spec \
		$(destdir)/usr/lib/$(target)/gcc-$(base_version)/
	# Remove libtool archives.
	libdir=/usr/lib/$(target) && \
	rm -f \
		$(destdir)$${libdir}/libmudflap.la \
		$(destdir)$${libdir}/libmudflapth.la \
		$(destdir)$${libdir}/libssp.la \
		$(destdir)$${libdir}/libssp_nonshared.la \
		$(destdir)$${libdir}/gcc-$(base_version)/liblto_plugin.la \
		$(destdir)$${libdir}/libquadmath.la \
		$(destdir)$${libdir}/libgomp.la \
		$(destdir)$${libdir}/libitm.la \
		$(destdir)$${libdir}/libstdc++.la \
		$(destdir)$${libdir}/libsupc++.la
	# Remove the info directory node.
	rm -f $(destdir)/usr/share/info/dir
	# Remove empty documentation files.
	find $(destdir)/usr/share/man -type f -a -size 0c -a \
		-exec rm -f '{}' ';'
	find $(destdir)/usr/share/info -type f -a -size 0c -a \
		-exec rm -f '{}' ';'
	# TODO: Provide these files in a fixincludes package (arch:any,
	# target-specific?).
	rm -Rf $(destdir)/usr/lib/$(target)/gcc-$(base_version)/install-tools/
	# TODO: Provide these files in a libstdc++-*-dbg package.
	rm -f $(destdir)/usr/lib/$(target)/libstdc++.so.*-gdb.py
	rm -Rf $(destdir)/usr/share/gcc-*/python/libstdcxx/
	# TODO: Provide these files in a doc package.
	rm -Rf $(destdir)/usr/share/man/ $(destdir)/usr/share/info/
	# TODO: Provide these files in a gcc-*-plugin-dev package.
	rm -Rf $(destdir)/usr/lib/$(target)/gcc-$(base_version)/plugin/
	oh-fixperms -d "$(destdir)"
	oh-strip -d "$(destdir)"
	OPK_PACKAGES="\
		gcc-$(base_version)-$(target) \
		cpp-$(base_version)-$(target) \
		g++-$(base_version)-$(target) \
		"; \
	if [ "x$(target)" = 'x$(OPK_HOST_ARCH)' ]; then \
		OPK_PACKAGES="$${OPK_PACKAGES} \
		libgcc.1 \
		libssp.0 \
		libgomp.1 \
		libitm.1 \
		libmudflap.0 \
		libmudflap.0-$(base_version)-dev \
		libstdc++.6 \
		libstdc++.6-$(base_version)-dev \
		gcc-$(base_version)-locales \
		"; \
	fi; \
	export OPK_PACKAGES; \
	oh-installfiles -d "$(destdir)"

install: $(install_targets)

# POSIX.1-2008:
#   If the pathname does not begin with a '/' it shall be treated as relative to
#   the current working directory of the process, not relative to the directory
#   containing the makefile.
include ../source.mk