1# 2# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. 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 29# Needs either to be from BUILD -> BUILD OR have 30# BUILD -> HOST prebuilt 31# 32# NOTE: There is a bug here. We don't limit the 33# PATH when building BUILD -> BUILD, which means that 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 37# of the target tree. 38# 39# Fix this... 40# 41 42$(info TARGET=$(TARGET)) 43$(info HOST=$(HOST)) 44$(info BUILD=$(BUILD)) 45 46ARCH := $(word 1,$(subst -, ,$(TARGET))) 47 48ifeq ($(TARGET), arm-linux-gnueabihf) 49 ARCH=armhfp 50endif 51 52$(info ARCH=$(ARCH)) 53 54ifeq ($(BASE_OS), OEL6) 55 BASE_URL := http://yum.oracle.com/repo/OracleLinux/OL6/4/base/$(ARCH)/ 56 LINUX_VERSION := OEL6.4 57else ifeq ($(BASE_OS), Fedora) 58 DEFAULT_OS_VERSION := 27 59 ifeq ($(BASE_OS_VERSION), ) 60 BASE_OS_VERSION := $(DEFAULT_OS_VERSION) 61 endif 62 ifeq ($(filter x86_64 armhfp, $(ARCH)), ) 63 FEDORA_TYPE := fedora-secondary 64 else 65 FEDORA_TYPE := fedora/linux 66 endif 67 ARCHIVED := $(shell [ $(BASE_OS_VERSION) -lt $(DEFAULT_OS_VERSION) ] && echo true) 68 ifeq ($(ARCHIVED),true) 69 BASE_URL := https://archives.fedoraproject.org/pub/archive/$(FEDORA_TYPE)/releases/$(BASE_OS_VERSION)/Everything/$(ARCH)/os/Packages/ 70 else 71 BASE_URL := https://dl.fedoraproject.org/pub/$(FEDORA_TYPE)/releases/$(BASE_OS_VERSION)/Everything/$(ARCH)/os/Packages/ 72 endif 73 LINUX_VERSION := Fedora_$(BASE_OS_VERSION) 74else 75 $(error Unknown base OS $(BASE_OS)) 76endif 77 78########################################################################################## 79# Define external dependencies 80 81# Latest that could be made to work. 82GCC_VER := 7.3.0 83ifeq ($(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 91else 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 99else 100 $(error Unsupported GCC version) 101endif 102 103GCC := http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.xz 104BINUTILS := http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.xz 105CCACHE := https://samba.org/ftp/ccache/$(ccache_ver).tar.xz 106MPFR := http://www.mpfr.org/${mpfr_ver}/${mpfr_ver}.tar.bz2 107GMP := http://ftp.gnu.org/pub/gnu/gmp/${gmp_ver}.tar.bz2 108MPC := http://ftp.gnu.org/pub/gnu/mpc/${mpc_ver}.tar.gz 109GDB := http://ftp.gnu.org/gnu/gdb/${gdb_ver}.tar.xz 110 111# RPMs used by all BASE_OS 112RPM_LIST := \ 113 kernel-headers \ 114 glibc glibc-headers glibc-devel \ 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 \ 122 libXrandr libXrandr-devel \ 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 \ 130 libgcc \ 131 zlib zlib-devel \ 132 libffi libffi-devel \ 133 fontconfig fontconfig-devel \ 134 systemtap-sdt-devel \ 135 # 136 137########################################################################################## 138# Define common directories and files 139 140# Ensure we have 32-bit libs also for x64. We enable mixed-mode. 141ifeq (x86_64,$(ARCH)) 142 LIBDIRS := lib64 lib 143 CFLAGS_lib := -m32 144else 145 LIBDIRS := lib 146endif 147 148# Define directories 149BUILDDIR := $(OUTPUT_ROOT)/$(HOST)/$(TARGET) 150TARGETDIR := $(PREFIX)/$(TARGET) 151SYSROOT := $(TARGETDIR)/sysroot 152DOWNLOAD := $(OUTPUT_ROOT)/download 153DOWNLOAD_RPMS := $(DOWNLOAD)/rpms/$(TARGET)-$(LINUX_VERSION) 154SRCDIR := $(OUTPUT_ROOT)/src 155 156# Marker file for unpacking rpms 157rpms := $(SYSROOT)/rpms_unpacked 158 159# Need to patch libs that are linker scripts to use non-absolute paths 160libs := $(SYSROOT)/libs_patched 161 162################################################################################ 163# Download RPMs 164download-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) && \ 169 wget -r -np -nd $(patsubst %, -A "*%*.rpm", $(RPM_LIST)) $(BASE_URL) 170 endif 171 172########################################################################################## 173# Unpack source packages 174 175# Generate downloading + unpacking of sources. 176define Download 177 $(1)_DIR = $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1)))))) 178 $(1)_CFG = $$($(1)_DIR)/configure 179 $(1)_FILE = $(DOWNLOAD)/$(notdir $($(1))) 180 181 $$($(1)_CFG) : $$($(1)_FILE) 182 mkdir -p $$(SRCDIR) 183 tar -C $$(SRCDIR) -xf $$< 184 $$(foreach p,$$(abspath $$(wildcard $$(notdir $$($(1)_DIR)).patch)), \ 185 echo PATCHING $$(p) ; \ 186 patch -d $$($(1)_DIR) -p1 -i $$(p) ; \ 187 ) 188 touch $$@ 189 190 $$($(1)_FILE) : 191 wget -P $(DOWNLOAD) $$($(1)) 192endef 193 194# Download and unpack all source packages 195$(foreach p,GCC BINUTILS CCACHE MPFR GMP MPC GDB,$(eval $(call Download,$(p)))) 196 197########################################################################################## 198# Unpack RPMS 199 200RPM_ARCHS := $(ARCH) noarch 201ifeq ($(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 208else ifeq ($(ARCH),i686) 209 RPM_ARCHS += i386 210else ifeq ($(ARCH), armhfp) 211 RPM_ARCHS += armv7hl 212endif 213 214RPM_FILE_LIST := $(sort $(foreach a, $(RPM_ARCHS), \ 215 $(wildcard $(patsubst %,$(DOWNLOAD_RPMS)/%*$a.rpm,$(RPM_LIST))) \ 216)) 217 218# Note. For building linux you should install rpm2cpio. 219define unrpm 220 $(SYSROOT)/$(notdir $(1)).unpacked : $(1) 221 $$(rpms) : $(SYSROOT)/$(notdir $(1)).unpacked 222endef 223 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 $@ 237 238$(foreach p,$(RPM_FILE_LIST),$(eval $(call unrpm,$(p)))) 239 240########################################################################################## 241 242# Note: MUST create a <sysroot>/usr/lib even if not really needed. 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 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. 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 $@ 259 260########################################################################################## 261# Create links for ffi header files so that they become visible by default when using the 262# devkit. 263ifeq ($(ARCH), x86_64) 264 $(SYSROOT)/usr/include/ffi.h: $(rpms) 265 cd $(@D) && rm -f $(@F) && ln -s ../lib/libffi-*/include/$(@F) . 266 267 $(SYSROOT)/usr/include/ffitarget.h: $(rpms) 268 cd $(@D) && rm -f $(@F) && ln -s ../lib/libffi-*/include/$(@F) . 269 270 SYSROOT_LINKS += $(SYSROOT)/usr/include/ffi.h $(SYSROOT)/usr/include/ffitarget.h 271endif 272 273########################################################################################## 274 275# Define marker files for each source package to be compiled 276$(foreach t,binutils mpfr gmp mpc gcc ccache gdb,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done)) 277 278########################################################################################## 279 280# Default base config 281CONFIG = --target=$(TARGET) \ 282 --host=$(HOST) --build=$(BUILD) \ 283 --prefix=$(PREFIX) 284 285PATHEXT = $(PREFIX)/bin: 286 287PATHPRE = PATH=$(PATHEXT)$(PATH) 288NUM_CORES := $(shell cat /proc/cpuinfo | grep -c processor) 289BUILDPAR = -j$(NUM_CORES) 290 291# Default commands to when making 292MAKECMD = 293INSTALLCMD = install 294 295 296declare_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 297 298ifeq ($(HOST),$(BUILD)) 299 ifeq ($(HOST),$(TARGET)) 300 TOOLS = $(call declare_tools,_FOR_TARGET,) 301 endif 302endif 303 304TOOLS ?= $(call declare_tools,_FOR_TARGET,$(TARGET)-) 305 306########################################################################################## 307 308# Create a TARGET bfd + libiberty only. 309# Configure one or two times depending on mulitlib arch. 310# If multilib, the second should be 32-bit, and we resolve 311# CFLAG_<name> to most likely -m32. 312define mk_bfd 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) 318 319 bfdlib += $$(TARGETDIR)/$$(binutils_ver)-$(subst /,-,$(1)).done 320 bfdmakes += $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile 321endef 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. 327$(bfdlib) : MAKECMD = all-libiberty all-bfd 328$(bfdlib) : INSTALLCMD = install-libiberty install-bfd 329 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) 337 338$(bfdmakes) : TOOLS = $(call declare_tools,_FOR_TARGET,$(TARGET)-) $(call declare_tools,,$(TARGET)-) 339 340########################################################################################## 341 342$(gcc) \ 343 $(binutils) \ 344 $(gmp) \ 345 $(mpfr) \ 346 $(mpc) \ 347 $(bfdmakes) \ 348 $(ccache) : ENVS += $(TOOLS) 349 350# libdir to work around hateful bfd stuff installing into wrong dirs... 351# ensure we have 64 bit bfd support in the HOST library. I.e our 352# compiler on i686 will know 64 bit symbols, BUT later 353# we build just the libs again for TARGET, then with whatever the arch 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. 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 \ 372 --enable-gold \ 373 --enable-plugins \ 374 ) > $(@D)/log.config 2>&1 375 @echo 'done' 376 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' 391 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' 408 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' 424 425# Only valid if glibc target -> linux 426# proper destructor handling for c++ 427ifneq (,$(findstring linux,$(TARGET))) 428 $(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --enable-__cxa_atexit 429endif 430 431ifeq ($(ARCH), armhfp) 432 $(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --with-float=hard 433endif 434 435ifneq ($(filter ppc64 ppc64le s390x, $(ARCH)), ) 436 # We only support 64-bit on these platforms anyway 437 CONFIG += --disable-multilib 438endif 439 440# Want: 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' 466 467# need binutils for gcc 468$(gcc) : $(binutils) 469 470# as of 4.3 or so need these for doing config 471$(BUILDDIR)/$(gcc_ver)/Makefile : $(gmp) $(mpfr) $(mpc) 472$(mpfr) : $(gmp) 473$(mpc) : $(gmp) $(mpfr) 474 475################################################################################ 476# Build gdb but only where host and target match 477ifeq ($(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) 490else 491 $(BUILDDIR)/$(gdb_ver)/Makefile: 492 $(info Faking $@, not used when cross-compiling) 493 mkdir -p $(@D) 494 echo "install:" > $@ 495 @echo 'done' 496endif 497 498########################################################################################## 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' 510 511gccpatch = $(TARGETDIR)/gcc-patched 512 513########################################################################################## 514# For some reason cpp is not created as a target-compiler 515ifeq ($(HOST),$(TARGET)) 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 && \ 522 ln -fs $$f $(TARGET)-$$f ; \ 523 fi \ 524 done 525 @touch $@ 526 @echo 'done' 527 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)/ && \ 539 ln -fs $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f; \ 540 fi \ 541 done;) 542 @echo 'done' 543else 544 $(gccpatch) : 545 @echo 'done' 546endif 547 548########################################################################################## 549# Build in two steps. 550# make <default> 551# make install. 552# Use path to our build hosts cross tools 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 559 @mkdir -p $(@D) 560 @touch $@ 561 @echo 'done' 562 563########################################################################################## 564 565$(PREFIX)/devkit.info: 566 @echo 'Creating devkit.info in the root of the kit' 567 rm -f $@ 568 touch $@ 569 echo '# This file describes to configure how to interpret the contents of this' >> $@ 570 echo '# devkit' >> $@ 571 echo '' >> $@ 572 echo 'DEVKIT_NAME="$(gcc_ver) - $(LINUX_VERSION)"' >> $@ 573 echo 'DEVKIT_TOOLCHAIN_PATH="$$DEVKIT_ROOT/bin"' >> $@ 574 echo 'DEVKIT_SYSROOT="$$DEVKIT_ROOT/$(TARGET)/sysroot"' >> $@ 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 587THESE_MAKEFILES := $(PREFIX)/Makefile $(PREFIX)/Tools.gmk 588 589########################################################################################## 590 591ifeq ($(TARGET), $(HOST)) 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 600 $(PREFIX)/bin/%: 601 @echo 'Creating missing $* soft link' 602 ln -s $(TARGET)-$* $@ 603 604 missing-links := $(addprefix $(PREFIX)/bin/, \ 605 addr2line ar as c++ c++filt dwp elfedit g++ gcc gcc-$(GCC_VER) gprof ld ld.bfd \ 606 ld.gold nm objcopy objdump ranlib readelf size strings strip) 607endif 608 609########################################################################################## 610 611bfdlib : $(bfdlib) 612binutils : $(binutils) 613rpms : $(rpms) 614libs : $(libs) 615sysroot : rpms libs 616gcc : sysroot $(gcc) $(gccpatch) 617gdb : $(gdb) 618all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links) $(SYSROOT_LINKS) \ 619 $(THESE_MAKEFILES) gdb 620 621# this is only built for host. so separate. 622ccache : $(ccache) 623 624.PHONY : gcc all binutils bfdlib link_libs rpms libs sysroot 625