author | tschatzl |
Tue, 04 Sep 2018 12:18:35 +0200 | |
changeset 51625 | c265860d5d45 |
parent 50472 | ee1a0ddb2590 |
child 52357 | e2478be9c682 |
permissions | -rw-r--r-- |
18021 | 1 |
# |
48839 | 2 |
# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
18021 | 3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
# |
|
5 |
# This code is free software; you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
|
7 |
# published by the Free Software Foundation. Oracle designates this |
|
8 |
# particular file as subject to the "Classpath" exception as provided |
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
|
10 |
# |
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
# accompanied this code). |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License version |
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
# |
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
24 |
# |
|
25 |
||
26 |
########################################################################################## |
|
27 |
# |
|
28 |
# Workhorse makefile for creating ONE cross compiler |
|
20363 | 29 |
# Needs either to be from BUILD -> BUILD OR have |
18021 | 30 |
# BUILD -> HOST prebuilt |
31 |
# |
|
20363 | 32 |
# NOTE: There is a bug here. We don't limit the |
33 |
# PATH when building BUILD -> BUILD, which means that |
|
18021 | 34 |
# if you configure after you've once build the BUILD->BUILD |
35 |
# compiler THAT one will be picked up as the compiler for itself. |
|
36 |
# This is not so great, especially if you did a partial delete |
|
20363 | 37 |
# of the target tree. |
18021 | 38 |
# |
39 |
# Fix this... |
|
40 |
# |
|
41 |
||
42 |
$(info TARGET=$(TARGET)) |
|
43 |
$(info HOST=$(HOST)) |
|
44 |
$(info BUILD=$(BUILD)) |
|
45 |
||
20363 | 46 |
ARCH := $(word 1,$(subst -, ,$(TARGET))) |
50472 | 47 |
|
48 |
ifeq ($(TARGET), arm-linux-gnueabihf) |
|
49 |
ARCH=armhfp |
|
50 |
endif |
|
51 |
||
48839 | 52 |
$(info ARCH=$(ARCH)) |
18021 | 53 |
|
49204
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
54 |
ifeq ($(BASE_OS), OEL6) |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
55 |
OEL_URL := http://yum.oracle.com/repo/OracleLinux/OL6/4/base/$(ARCH)/ |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
56 |
LINUX_VERSION := OEL6.4 |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
57 |
else ifeq ($(BASE_OS), Fedora27) |
50472 | 58 |
ifeq ($(ARCH), aarch64) |
59 |
FEDORA_TYPE=fedora-secondary |
|
60 |
else |
|
61 |
FEDORA_TYPE=fedora/linux |
|
62 |
endif |
|
63 |
OEL_URL := https://dl.fedoraproject.org/pub/$(FEDORA_TYPE)/releases/27/Everything/$(ARCH)/os/Packages/ |
|
49204
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
64 |
LINUX_VERSION := Fedora 27 |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
65 |
else |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
66 |
$(error Unknown base OS $(BASE_OS)) |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
67 |
endif |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
68 |
|
18021 | 69 |
########################################################################################## |
70 |
# Define external dependencies |
|
71 |
||
72 |
# Latest that could be made to work. |
|
48839 | 73 |
GCC_VER := 7.3.0 |
74 |
ifeq ($(GCC_VER), 7.3.0) |
|
75 |
gcc_ver := gcc-7.3.0 |
|
76 |
binutils_ver := binutils-2.30 |
|
77 |
ccache_ver := ccache-3.3.6 |
|
78 |
mpfr_ver := mpfr-3.1.5 |
|
79 |
gmp_ver := gmp-6.1.2 |
|
80 |
mpc_ver := mpc-1.0.3 |
|
81 |
gdb_ver := gdb-8.1 |
|
82 |
else ifeq ($(GCC_VER), 4.9.2) |
|
83 |
gcc_ver := gcc-4.9.2 |
|
84 |
binutils_ver := binutils-2.25 |
|
85 |
ccache_ver := ccache-3.2.1 |
|
86 |
mpfr_ver := mpfr-3.0.1 |
|
87 |
gmp_ver := gmp-4.3.2 |
|
88 |
mpc_ver := mpc-1.0.1 |
|
89 |
gdb_ver := gdb-7.12.1 |
|
90 |
else |
|
91 |
$(error Unsupported GCC version) |
|
92 |
endif |
|
18021 | 93 |
|
48839 | 94 |
GCC := http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.xz |
95 |
BINUTILS := http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.xz |
|
96 |
CCACHE := https://samba.org/ftp/ccache/$(ccache_ver).tar.xz |
|
20363 | 97 |
MPFR := http://www.mpfr.org/${mpfr_ver}/${mpfr_ver}.tar.bz2 |
98 |
GMP := http://ftp.gnu.org/pub/gnu/gmp/${gmp_ver}.tar.bz2 |
|
48839 | 99 |
MPC := http://ftp.gnu.org/pub/gnu/mpc/${mpc_ver}.tar.gz |
100 |
GDB := http://ftp.gnu.org/gnu/gdb/${gdb_ver}.tar.xz |
|
101 |
||
49204
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
102 |
# RPMs used by all BASE_OS |
20363 | 103 |
RPM_LIST := \ |
104 |
kernel-headers \ |
|
34100
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
105 |
glibc glibc-headers glibc-devel \ |
20363 | 106 |
cups-libs cups-devel \ |
107 |
libX11 libX11-devel \ |
|
108 |
xorg-x11-proto-devel \ |
|
109 |
alsa-lib alsa-lib-devel \ |
|
110 |
libXext libXext-devel \ |
|
111 |
libXtst libXtst-devel \ |
|
112 |
libXrender libXrender-devel \ |
|
113 |
freetype freetype-devel \ |
|
114 |
libXt libXt-devel \ |
|
115 |
libSM libSM-devel \ |
|
116 |
libICE libICE-devel \ |
|
117 |
libXi libXi-devel \ |
|
118 |
libXdmcp libXdmcp-devel \ |
|
119 |
libXau libXau-devel \ |
|
34592 | 120 |
libgcc \ |
42425 | 121 |
zlib zlib-devel \ |
47433
6331ad007664
8189119: Devkit for Linux needs to include fontconfig-devel
erikj
parents:
47253
diff
changeset
|
122 |
libffi libffi-devel \ |
48839 | 123 |
fontconfig fontconfig-devel \ |
124 |
systemtap-sdt-devel \ |
|
125 |
# |
|
18021 | 126 |
|
127 |
########################################################################################## |
|
128 |
# Define common directories and files |
|
129 |
||
130 |
# Ensure we have 32-bit libs also for x64. We enable mixed-mode. |
|
131 |
ifeq (x86_64,$(ARCH)) |
|
20363 | 132 |
LIBDIRS := lib64 lib |
133 |
CFLAGS_lib := -m32 |
|
18021 | 134 |
else |
20363 | 135 |
LIBDIRS := lib |
18021 | 136 |
endif |
137 |
||
138 |
# Define directories |
|
48839 | 139 |
RESULT := $(OUTPUT_ROOT)/result |
140 |
BUILDDIR := $(OUTPUT_ROOT)/$(HOST)/$(TARGET) |
|
20363 | 141 |
PREFIX := $(RESULT)/$(HOST) |
142 |
TARGETDIR := $(PREFIX)/$(TARGET) |
|
23428
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
143 |
SYSROOT := $(TARGETDIR)/sysroot |
48839 | 144 |
DOWNLOAD := $(OUTPUT_ROOT)/download |
145 |
DOWNLOAD_RPMS := $(DOWNLOAD)/rpms |
|
146 |
SRCDIR := $(OUTPUT_ROOT)/src |
|
18021 | 147 |
|
148 |
# Marker file for unpacking rpms |
|
20363 | 149 |
rpms := $(SYSROOT)/rpms_unpacked |
18021 | 150 |
|
20363 | 151 |
# Need to patch libs that are linker scripts to use non-absolute paths |
152 |
libs := $(SYSROOT)/libs_patched |
|
18021 | 153 |
|
48839 | 154 |
################################################################################ |
155 |
# Download RPMs |
|
156 |
download-rpms: |
|
157 |
mkdir -p $(DOWNLOAD_RPMS) |
|
158 |
# Only run this if rpm dir is empty. |
|
159 |
ifeq ($(wildcard $(DOWNLOAD_RPMS)/*.rpm), ) |
|
160 |
cd $(DOWNLOAD_RPMS) && \ |
|
161 |
wget -r -np -nd $(patsubst %, -A "*%*.rpm", $(RPM_LIST)) $(OEL_URL) |
|
162 |
endif |
|
163 |
||
18021 | 164 |
########################################################################################## |
165 |
# Unpack source packages |
|
166 |
||
20363 | 167 |
# Generate downloading + unpacking of sources. |
18021 | 168 |
define Download |
20363 | 169 |
$(1)_DIR = $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1)))))) |
170 |
$(1)_CFG = $$($(1)_DIR)/configure |
|
171 |
$(1)_FILE = $(DOWNLOAD)/$(notdir $($(1))) |
|
18021 | 172 |
|
20363 | 173 |
$$($(1)_CFG) : $$($(1)_FILE) |
174 |
mkdir -p $$(SRCDIR) |
|
48839 | 175 |
tar -C $$(SRCDIR) -xf $$< |
20363 | 176 |
$$(foreach p,$$(abspath $$(wildcard $$(notdir $$($(1)_DIR)).patch)), \ |
177 |
echo PATCHING $$(p) ; \ |
|
178 |
patch -d $$($(1)_DIR) -p1 -i $$(p) ; \ |
|
179 |
) |
|
180 |
touch $$@ |
|
18021 | 181 |
|
20363 | 182 |
$$($(1)_FILE) : |
183 |
wget -P $(DOWNLOAD) $$($(1)) |
|
18021 | 184 |
endef |
185 |
||
186 |
# Download and unpack all source packages |
|
48839 | 187 |
$(foreach p,GCC BINUTILS CCACHE MPFR GMP MPC GDB,$(eval $(call Download,$(p)))) |
18021 | 188 |
|
189 |
########################################################################################## |
|
190 |
# Unpack RPMS |
|
191 |
||
48839 | 192 |
ifeq ($(ARCH),x86_64) |
193 |
RPM_ARCHS := x86_64 noarch |
|
194 |
ifeq ($(BUILD),$(HOST)) |
|
195 |
ifeq ($(TARGET),$(HOST)) |
|
196 |
# When building the native compiler for x86_64, enable mixed mode. |
|
197 |
RPM_ARCHS += i386 i686 |
|
198 |
endif |
|
199 |
endif |
|
49204
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
200 |
else ifeq ($(ARCH),i686) |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
201 |
RPM_ARCHS := i386 i686 noarch |
50472 | 202 |
else ifeq ($(ARCH), armhfp) |
203 |
RPM_ARCHS := $(ARCH) armv7hl noarch |
|
48839 | 204 |
else |
49204
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
205 |
RPM_ARCHS := $(ARCH) noarch |
48839 | 206 |
endif |
207 |
||
208 |
RPM_FILE_LIST := $(sort $(foreach a, $(RPM_ARCHS), \ |
|
209 |
$(wildcard $(patsubst %,$(DOWNLOAD_RPMS)/%*$a.rpm,$(RPM_LIST))) \ |
|
210 |
)) |
|
211 |
||
20363 | 212 |
# Note. For building linux you should install rpm2cpio. |
18021 | 213 |
define unrpm |
48839 | 214 |
$(SYSROOT)/$(notdir $(1)).unpacked : $(1) |
20363 | 215 |
$$(rpms) : $(SYSROOT)/$(notdir $(1)).unpacked |
18021 | 216 |
endef |
217 |
||
20363 | 218 |
%.unpacked : |
219 |
$(info Unpacking target rpms and libraries from $<) |
|
220 |
@(mkdir -p $(@D); \ |
|
221 |
cd $(@D); \ |
|
222 |
rpm2cpio $< | \ |
|
223 |
cpio --extract --make-directories \ |
|
224 |
-f \ |
|
225 |
"./usr/share/doc/*" \ |
|
226 |
"./usr/share/man/*" \ |
|
227 |
"./usr/X11R6/man/*" \ |
|
228 |
"*/X11/locale/*" \ |
|
229 |
|| die ; ) |
|
230 |
touch $@ |
|
18021 | 231 |
|
232 |
$(foreach p,$(RPM_FILE_LIST),$(eval $(call unrpm,$(p)))) |
|
233 |
||
234 |
########################################################################################## |
|
235 |
||
23428
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
236 |
# Note: MUST create a <sysroot>/usr/lib even if not really needed. |
20363 | 237 |
# gcc will use a path relative to it to resolve lib64. (x86_64). |
238 |
# we're creating multi-lib compiler with 32bit libc as well, so we should |
|
18021 | 239 |
# have it anyway, but just to make sure... |
240 |
# Patch libc.so and libpthread.so to force linking against libraries in sysroot |
|
241 |
# and not the ones installed on the build machine. |
|
20363 | 242 |
$(libs) : $(rpms) |
243 |
@echo Patching libc and pthreads |
|
244 |
@(for f in `find $(SYSROOT) -name libc.so -o -name libpthread.so`; do \ |
|
245 |
(cat $$f | sed -e 's|/usr/lib64/||g' \ |
|
246 |
-e 's|/usr/lib/||g' \ |
|
247 |
-e 's|/lib64/||g' \ |
|
248 |
-e 's|/lib/||g' ) > $$f.tmp ; \ |
|
249 |
mv $$f.tmp $$f ; \ |
|
250 |
done) |
|
251 |
@mkdir -p $(SYSROOT)/usr/lib |
|
252 |
@touch $@ |
|
18021 | 253 |
|
254 |
########################################################################################## |
|
42425 | 255 |
# Create links for ffi header files so that they become visible by default when using the |
256 |
# devkit. |
|
48839 | 257 |
ifeq ($(ARCH), x86_64) |
258 |
$(SYSROOT)/usr/include/ffi.h: $(rpms) |
|
259 |
cd $(@D) && rm -f $(@F) && ln -s ../lib/libffi-*/include/$(@F) . |
|
42425 | 260 |
|
48839 | 261 |
$(SYSROOT)/usr/include/ffitarget.h: $(rpms) |
262 |
cd $(@D) && rm -f $(@F) && ln -s ../lib/libffi-*/include/$(@F) . |
|
42425 | 263 |
|
48839 | 264 |
SYSROOT_LINKS += $(SYSROOT)/usr/include/ffi.h $(SYSROOT)/usr/include/ffitarget.h |
265 |
endif |
|
42425 | 266 |
|
267 |
########################################################################################## |
|
18021 | 268 |
|
269 |
# Define marker files for each source package to be compiled |
|
48839 | 270 |
$(foreach t,binutils mpfr gmp mpc gcc ccache gdb,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done)) |
18021 | 271 |
|
272 |
########################################################################################## |
|
273 |
||
274 |
# Default base config |
|
20363 | 275 |
CONFIG = --target=$(TARGET) \ |
276 |
--host=$(HOST) --build=$(BUILD) \ |
|
277 |
--prefix=$(PREFIX) |
|
18021 | 278 |
|
20363 | 279 |
PATHEXT = $(RESULT)/$(BUILD)/bin: |
18021 | 280 |
|
20363 | 281 |
PATHPRE = PATH=$(PATHEXT)$(PATH) |
48839 | 282 |
NUM_CORES := $(shell cat /proc/cpuinfo | grep -c processor) |
283 |
BUILDPAR = -j$(NUM_CORES) |
|
18021 | 284 |
|
285 |
# Default commands to when making |
|
20363 | 286 |
MAKECMD = |
287 |
INSTALLCMD = install |
|
18021 | 288 |
|
289 |
||
20363 | 290 |
declare_tools = CC$(1)=$(2)gcc LD$(1)=$(2)ld AR$(1)=$(2)ar AS$(1)=$(2)as RANLIB$(1)=$(2)ranlib CXX$(1)=$(2)g++ OBJDUMP$(1)=$(2)objdump |
18021 | 291 |
|
292 |
ifeq ($(HOST),$(BUILD)) |
|
20363 | 293 |
ifeq ($(HOST),$(TARGET)) |
294 |
TOOLS = $(call declare_tools,_FOR_TARGET,) |
|
295 |
endif |
|
18021 | 296 |
endif |
297 |
||
20363 | 298 |
TOOLS ?= $(call declare_tools,_FOR_TARGET,$(TARGET)-) |
18021 | 299 |
|
300 |
########################################################################################## |
|
301 |
||
20363 | 302 |
# Create a TARGET bfd + libiberty only. |
18021 | 303 |
# Configure one or two times depending on mulitlib arch. |
20363 | 304 |
# If multilib, the second should be 32-bit, and we resolve |
18021 | 305 |
# CFLAG_<name> to most likely -m32. |
306 |
define mk_bfd |
|
20363 | 307 |
$$(info Libs for $(1)) |
308 |
$$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \ |
|
309 |
: CFLAGS += $$(CFLAGS_$(1)) |
|
310 |
$$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \ |
|
311 |
: LIBDIRS = --libdir=$(TARGETDIR)/$(1) |
|
18021 | 312 |
|
20363 | 313 |
bfdlib += $$(TARGETDIR)/$$(binutils_ver)-$(subst /,-,$(1)).done |
314 |
bfdmakes += $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile |
|
18021 | 315 |
endef |
316 |
||
317 |
# Create one set of bfds etc for each multilib arch |
|
318 |
$(foreach l,$(LIBDIRS),$(eval $(call mk_bfd,$(l)))) |
|
319 |
||
320 |
# Only build these two libs. |
|
20363 | 321 |
$(bfdlib) : MAKECMD = all-libiberty all-bfd |
322 |
$(bfdlib) : INSTALLCMD = install-libiberty install-bfd |
|
18021 | 323 |
|
20363 | 324 |
# Building targets libbfd + libiberty. HOST==TARGET, i.e not |
325 |
# for a cross env. |
|
326 |
$(bfdmakes) : CONFIG = --target=$(TARGET) \ |
|
327 |
--host=$(TARGET) --build=$(BUILD) \ |
|
328 |
--prefix=$(TARGETDIR) \ |
|
329 |
--with-sysroot=$(SYSROOT) \ |
|
330 |
$(LIBDIRS) |
|
18021 | 331 |
|
20363 | 332 |
$(bfdmakes) : TOOLS = $(call declare_tools,_FOR_TARGET,$(TARGET)-) $(call declare_tools,,$(TARGET)-) |
18021 | 333 |
|
334 |
########################################################################################## |
|
335 |
||
20363 | 336 |
$(gcc) \ |
337 |
$(binutils) \ |
|
338 |
$(gmp) \ |
|
339 |
$(mpfr) \ |
|
340 |
$(mpc) \ |
|
341 |
$(bfdmakes) \ |
|
342 |
$(ccache) : ENVS += $(TOOLS) |
|
18021 | 343 |
|
344 |
# libdir to work around hateful bfd stuff installing into wrong dirs... |
|
20363 | 345 |
# ensure we have 64 bit bfd support in the HOST library. I.e our |
18021 | 346 |
# compiler on i686 will know 64 bit symbols, BUT later |
20363 | 347 |
# we build just the libs again for TARGET, then with whatever the arch |
18021 | 348 |
# wants. |
349 |
$(BUILDDIR)/$(binutils_ver)/Makefile : CONFIG += --enable-64-bit-bfd --libdir=$(PREFIX)/$(word 1,$(LIBDIRS)) |
|
350 |
||
351 |
# Makefile creation. Simply run configure in build dir. |
|
20363 | 352 |
$(bfdmakes) \ |
353 |
$(BUILDDIR)/$(binutils_ver)/Makefile \ |
|
354 |
: $(BINUTILS_CFG) |
|
355 |
$(info Configuring $@. Log in $(@D)/log.config) |
|
356 |
@mkdir -p $(@D) |
|
357 |
( \ |
|
358 |
cd $(@D) ; \ |
|
359 |
$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \ |
|
360 |
$(BINUTILS_CFG) \ |
|
361 |
$(CONFIG) \ |
|
362 |
--with-sysroot=$(SYSROOT) \ |
|
363 |
--disable-nls \ |
|
364 |
--program-prefix=$(TARGET)- \ |
|
365 |
--enable-multilib \ |
|
48839 | 366 |
--enable-gold \ |
367 |
--enable-plugins \ |
|
20363 | 368 |
) > $(@D)/log.config 2>&1 |
369 |
@echo 'done' |
|
18021 | 370 |
|
20363 | 371 |
$(BUILDDIR)/$(mpfr_ver)/Makefile \ |
372 |
: $(MPFR_CFG) |
|
373 |
$(info Configuring $@. Log in $(@D)/log.config) |
|
374 |
@mkdir -p $(@D) |
|
375 |
( \ |
|
376 |
cd $(@D) ; \ |
|
377 |
$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \ |
|
378 |
$(MPFR_CFG) \ |
|
379 |
$(CONFIG) \ |
|
380 |
--program-prefix=$(TARGET)- \ |
|
381 |
--enable-shared=no \ |
|
382 |
--with-gmp=$(PREFIX) \ |
|
383 |
) > $(@D)/log.config 2>&1 |
|
384 |
@echo 'done' |
|
18021 | 385 |
|
20363 | 386 |
$(BUILDDIR)/$(gmp_ver)/Makefile \ |
387 |
: $(GMP_CFG) |
|
388 |
$(info Configuring $@. Log in $(@D)/log.config) |
|
389 |
@mkdir -p $(@D) |
|
390 |
( \ |
|
391 |
cd $(@D) ; \ |
|
392 |
$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \ |
|
393 |
$(GMP_CFG) \ |
|
394 |
--host=$(HOST) --build=$(BUILD) \ |
|
395 |
--prefix=$(PREFIX) \ |
|
396 |
--disable-nls \ |
|
397 |
--program-prefix=$(TARGET)- \ |
|
398 |
--enable-shared=no \ |
|
399 |
--with-mpfr=$(PREFIX) \ |
|
400 |
) > $(@D)/log.config 2>&1 |
|
401 |
@echo 'done' |
|
18021 | 402 |
|
20363 | 403 |
$(BUILDDIR)/$(mpc_ver)/Makefile \ |
404 |
: $(MPC_CFG) |
|
405 |
$(info Configuring $@. Log in $(@D)/log.config) |
|
406 |
@mkdir -p $(@D) |
|
407 |
( \ |
|
408 |
cd $(@D) ; \ |
|
409 |
$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \ |
|
410 |
$(MPC_CFG) \ |
|
411 |
$(CONFIG) \ |
|
412 |
--program-prefix=$(TARGET)- \ |
|
413 |
--enable-shared=no \ |
|
414 |
--with-mpfr=$(PREFIX) \ |
|
415 |
--with-gmp=$(PREFIX) \ |
|
416 |
) > $(@D)/log.config 2>&1 |
|
417 |
@echo 'done' |
|
18021 | 418 |
|
419 |
# Only valid if glibc target -> linux |
|
420 |
# proper destructor handling for c++ |
|
421 |
ifneq (,$(findstring linux,$(TARGET))) |
|
20363 | 422 |
$(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --enable-__cxa_atexit |
18021 | 423 |
endif |
424 |
||
50472 | 425 |
ifeq ($(ARCH), armhfp) |
426 |
$(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --with-float=hard |
|
427 |
endif |
|
428 |
||
18021 | 429 |
# Want: |
20363 | 430 |
# c,c++ |
431 |
# shared libs |
|
432 |
# multilib (-m32/-m64 on x64) |
|
433 |
# skip native language. |
|
434 |
# and link and assemble with the binutils we created |
|
435 |
# earlier, so --with-gnu* |
|
436 |
$(BUILDDIR)/$(gcc_ver)/Makefile \ |
|
437 |
: $(GCC_CFG) |
|
438 |
$(info Configuring $@. Log in $(@D)/log.config) |
|
439 |
mkdir -p $(@D) |
|
440 |
( \ |
|
441 |
cd $(@D) ; \ |
|
442 |
$(PATHPRE) $(ENVS) $(GCC_CFG) $(EXTRA_CFLAGS) \ |
|
443 |
$(CONFIG) \ |
|
444 |
--with-sysroot=$(SYSROOT) \ |
|
445 |
--enable-languages=c,c++ \ |
|
446 |
--enable-shared \ |
|
447 |
--disable-nls \ |
|
448 |
--with-gnu-as \ |
|
449 |
--with-gnu-ld \ |
|
450 |
--with-mpfr=$(PREFIX) \ |
|
451 |
--with-gmp=$(PREFIX) \ |
|
452 |
--with-mpc=$(PREFIX) \ |
|
453 |
) > $(@D)/log.config 2>&1 |
|
454 |
@echo 'done' |
|
18021 | 455 |
|
456 |
# need binutils for gcc |
|
20363 | 457 |
$(gcc) : $(binutils) |
18021 | 458 |
|
459 |
# as of 4.3 or so need these for doing config |
|
460 |
$(BUILDDIR)/$(gcc_ver)/Makefile : $(gmp) $(mpfr) $(mpc) |
|
20363 | 461 |
$(mpfr) : $(gmp) |
462 |
$(mpc) : $(gmp) $(mpfr) |
|
18021 | 463 |
|
48839 | 464 |
################################################################################ |
465 |
# Build gdb but only where host and target match |
|
466 |
ifeq ($(HOST), $(TARGET)) |
|
467 |
$(BUILDDIR)/$(gdb_ver)/Makefile: $(GDB_CFG) |
|
468 |
$(info Configuring $@. Log in $(@D)/log.config) |
|
469 |
mkdir -p $(@D) |
|
470 |
( \ |
|
471 |
cd $(@D) ; \ |
|
472 |
$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" $(GDB_CFG) \ |
|
473 |
$(CONFIG) \ |
|
474 |
--with-sysroot=$(SYSROOT) \ |
|
475 |
) > $(@D)/log.config 2>&1 |
|
476 |
@echo 'done' |
|
477 |
||
478 |
$(gdb): $(gcc) |
|
49204
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
479 |
else |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
480 |
$(BUILDDIR)/$(gdb_ver)/Makefile: |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
481 |
$(info Faking $@, not used when cross-compiling) |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
482 |
mkdir -p $(@D) |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
483 |
echo "install:" > $@ |
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
484 |
@echo 'done' |
48839 | 485 |
endif |
486 |
||
18021 | 487 |
########################################################################################## |
20363 | 488 |
# very straightforward. just build a ccache. it is only for host. |
489 |
$(BUILDDIR)/$(ccache_ver)/Makefile \ |
|
490 |
: $(CCACHE_CFG) |
|
491 |
$(info Configuring $@. Log in $(@D)/log.config) |
|
492 |
@mkdir -p $(@D) |
|
493 |
@( \ |
|
494 |
cd $(@D) ; \ |
|
495 |
$(PATHPRE) $(ENVS) $(CCACHE_CFG) \ |
|
496 |
$(CONFIG) \ |
|
497 |
) > $(@D)/log.config 2>&1 |
|
498 |
@echo 'done' |
|
18021 | 499 |
|
20363 | 500 |
gccpatch = $(TARGETDIR)/gcc-patched |
18021 | 501 |
|
502 |
########################################################################################## |
|
20363 | 503 |
# For some reason cpp is not created as a target-compiler |
18021 | 504 |
ifeq ($(HOST),$(TARGET)) |
20363 | 505 |
$(gccpatch) : $(gcc) link_libs |
506 |
@echo -n 'Creating compiler symlinks...' |
|
507 |
@for f in cpp; do \ |
|
508 |
if [ ! -e $(PREFIX)/bin/$(TARGET)-$$f ]; \ |
|
509 |
then \ |
|
510 |
cd $(PREFIX)/bin && \ |
|
48839 | 511 |
ln -fs $$f $(TARGET)-$$f ; \ |
20363 | 512 |
fi \ |
513 |
done |
|
514 |
@touch $@ |
|
515 |
@echo 'done' |
|
18021 | 516 |
|
20363 | 517 |
########################################################################################## |
518 |
# Ugly at best. Seems that when we compile host->host compiler, that are NOT |
|
519 |
# the BUILD compiler, the result will not try searching for libs in package root. |
|
520 |
# "Solve" this by create links from the target libdirs to where they are. |
|
521 |
link_libs: |
|
522 |
@echo -n 'Creating library symlinks...' |
|
523 |
@$(foreach l,$(LIBDIRS), \ |
|
524 |
for f in `cd $(PREFIX)/$(l) && ls`; do \ |
|
525 |
if [ ! -e $(TARGETDIR)/$(l)/$$f ]; then \ |
|
526 |
mkdir -p $(TARGETDIR)/$(l) && \ |
|
527 |
cd $(TARGETDIR)/$(l)/ && \ |
|
48839 | 528 |
ln -fs $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f; \ |
20363 | 529 |
fi \ |
530 |
done;) |
|
531 |
@echo 'done' |
|
18021 | 532 |
else |
20363 | 533 |
$(gccpatch) : |
534 |
@echo 'done' |
|
18021 | 535 |
endif |
536 |
||
537 |
########################################################################################## |
|
20363 | 538 |
# Build in two steps. |
18021 | 539 |
# make <default> |
20363 | 540 |
# make install. |
18021 | 541 |
# Use path to our build hosts cross tools |
20363 | 542 |
# Always need to build cross tools for build host self. |
543 |
$(TARGETDIR)/%.done : $(BUILDDIR)/%/Makefile |
|
544 |
$(info Building $(basename $@). Log in $(<D)/log.build) |
|
545 |
$(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $(<D) $(MAKECMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.build 2>&1 |
|
546 |
@echo -n 'installing...' |
|
547 |
$(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $(<D) $(INSTALLCMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.install 2>&1 |
|
48839 | 548 |
@mkdir -p $(@D) |
20363 | 549 |
@touch $@ |
550 |
@echo 'done' |
|
18021 | 551 |
|
552 |
########################################################################################## |
|
553 |
||
23428
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
554 |
$(PREFIX)/devkit.info: FRC |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
555 |
@echo 'Creating devkit.info in the root of the kit' |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
556 |
rm -f $@ |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
557 |
touch $@ |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
558 |
echo '# This file describes to configure how to interpret the contents of this' >> $@ |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
559 |
echo '# devkit' >> $@ |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
560 |
echo '' >> $@ |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
561 |
echo 'DEVKIT_NAME="$(gcc_ver) - $(LINUX_VERSION)"' >> $@ |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
562 |
echo 'DEVKIT_TOOLCHAIN_PATH="$$DEVKIT_ROOT/bin"' >> $@ |
49204
564802b01ded
8199451: Create linux-aarch64 cross-compilation devkit, and fix cross-compilation
ihse
parents:
48839
diff
changeset
|
563 |
echo 'DEVKIT_SYSROOT="$$DEVKIT_ROOT/$(TARGET)/sysroot"' >> $@ |
48839 | 564 |
echo 'DEVKIT_EXTRA_PATH="$$DEVKIT_ROOT/bin"' >> $@ |
565 |
||
566 |
########################################################################################## |
|
567 |
# Copy these makefiles into the root of the kit |
|
568 |
$(PREFIX)/Makefile: ./Makefile |
|
569 |
rm -rf $@ |
|
570 |
cp $< $@ |
|
571 |
||
572 |
$(PREFIX)/Tools.gmk: ./Tools.gmk |
|
573 |
rm -rf $@ |
|
574 |
cp $< $@ |
|
575 |
||
576 |
THESE_MAKEFILES := $(PREFIX)/Makefile $(PREFIX)/Tools.gmk |
|
23428
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
577 |
|
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
578 |
########################################################################################## |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
579 |
|
34100
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
580 |
ifeq ($(TARGET), $(HOST)) |
48839 | 581 |
# To build with dtrace support, the build needs access to the dtrace executable from the |
582 |
# sysroot. Generally we don't want to add binaries in the sysroot to the path, but |
|
583 |
# luckily this seems to execute well enough on a different host Linux distro, so symlink |
|
584 |
# it into the main bin dir. |
|
585 |
$(PREFIX)/bin/dtrace: |
|
586 |
@echo 'Creating dtrace soft link' |
|
587 |
ln -s ../$(HOST)/sysroot/usr/bin/dtrace $@ |
|
588 |
||
34100
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
589 |
$(PREFIX)/bin/%: |
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
590 |
@echo 'Creating missing $* soft link' |
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
591 |
ln -s $(TARGET)-$* $@ |
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
592 |
|
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
593 |
missing-links := $(addprefix $(PREFIX)/bin/, \ |
49357
aaedb8343784
8198243: Add build time check for global operator new/delete in object files
erikj
parents:
48839
diff
changeset
|
594 |
addr2line ar as c++ c++filt dwp elfedit g++ gcc gcc-$(GCC_VER) gprof ld ld.bfd \ |
aaedb8343784
8198243: Add build time check for global operator new/delete in object files
erikj
parents:
48839
diff
changeset
|
595 |
ld.gold nm objcopy objdump ranlib readelf size strings strip) |
34100
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
596 |
endif |
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
597 |
|
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
598 |
########################################################################################## |
e3293031f83d
8143236: Update devkit creation makefiles for linux
erikj
parents:
33029
diff
changeset
|
599 |
|
20363 | 600 |
bfdlib : $(bfdlib) |
601 |
binutils : $(binutils) |
|
602 |
rpms : $(rpms) |
|
603 |
libs : $(libs) |
|
604 |
sysroot : rpms libs |
|
605 |
gcc : sysroot $(gcc) $(gccpatch) |
|
48839 | 606 |
gdb : $(gdb) |
607 |
all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links) $(SYSROOT_LINKS) \ |
|
608 |
$(THESE_MAKEFILES) gdb |
|
18021 | 609 |
|
20363 | 610 |
# this is only built for host. so separate. |
611 |
ccache : $(ccache) |
|
18021 | 612 |
|
23428
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
613 |
# Force target |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
614 |
FRC: |
3c8a05bf4656
8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents:
21759
diff
changeset
|
615 |
|
20363 | 616 |
.PHONY : gcc all binutils bfdlib link_libs rpms libs sysroot |