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