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