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