make/devkit/Tools.gmk

Thu, 31 Aug 2017 15:40:18 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:40:18 +0800
changeset 1133
50aaf272884f
parent 912
a667caba1e84
parent 0
75a576e87639
child 2316
64a3eeabf6e5
permissions
-rw-r--r--

merge

aoqi@0 1 #
aoqi@0 2 # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 #
aoqi@0 5 # This code is free software; you can redistribute it and/or modify it
aoqi@0 6 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 # published by the Free Software Foundation. Oracle designates this
aoqi@0 8 # particular file as subject to the "Classpath" exception as provided
aoqi@0 9 # by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 #
aoqi@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 # accompanied this code).
aoqi@0 16 #
aoqi@0 17 # You should have received a copy of the GNU General Public License version
aoqi@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 #
aoqi@0 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 # or visit www.oracle.com if you need additional information or have any
aoqi@0 23 # questions.
aoqi@0 24 #
aoqi@0 25
aoqi@0 26 ##########################################################################################
aoqi@0 27 #
aoqi@0 28 # Workhorse makefile for creating ONE cross compiler
aoqi@0 29 # Needs either to be from BUILD -> BUILD OR have
aoqi@0 30 # BUILD -> HOST prebuilt
aoqi@0 31 #
aoqi@0 32 # NOTE: There is a bug here. We don't limit the
aoqi@0 33 # PATH when building BUILD -> BUILD, which means that
aoqi@0 34 # if you configure after you've once build the BUILD->BUILD
aoqi@0 35 # compiler THAT one will be picked up as the compiler for itself.
aoqi@0 36 # This is not so great, especially if you did a partial delete
aoqi@0 37 # of the target tree.
aoqi@0 38 #
aoqi@0 39 # Fix this...
aoqi@0 40 #
aoqi@0 41
aoqi@0 42 $(info TARGET=$(TARGET))
aoqi@0 43 $(info HOST=$(HOST))
aoqi@0 44 $(info BUILD=$(BUILD))
aoqi@0 45
aoqi@0 46 ARCH := $(word 1,$(subst -, ,$(TARGET)))
aoqi@0 47
aoqi@0 48 ##########################################################################################
aoqi@0 49 # Define external dependencies
aoqi@0 50
aoqi@0 51 # Latest that could be made to work.
aoqi@0 52 gcc_ver := gcc-4.7.3
aoqi@0 53 binutils_ver := binutils-2.22
aoqi@0 54 ccache_ver := ccache-3.1.9
aoqi@0 55 mpfr_ver := mpfr-3.0.1
aoqi@0 56 gmp_ver := gmp-4.3.2
aoqi@0 57 mpc_ver := mpc-1.0.1
aoqi@0 58
aoqi@0 59 GCC := http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.bz2
aoqi@0 60 BINUTILS := http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.bz2
aoqi@0 61 CCACHE := http://samba.org/ftp/ccache/$(ccache_ver).tar.gz
aoqi@0 62 MPFR := http://www.mpfr.org/${mpfr_ver}/${mpfr_ver}.tar.bz2
aoqi@0 63 GMP := http://ftp.gnu.org/pub/gnu/gmp/${gmp_ver}.tar.bz2
aoqi@0 64 MPC := http://www.multiprecision.org/mpc/download/${mpc_ver}.tar.gz
aoqi@0 65
aoqi@0 66 # RPMs in OEL5.5
aoqi@0 67 RPM_LIST := \
aoqi@0 68 kernel-headers \
aoqi@0 69 glibc-2 glibc-headers glibc-devel \
aoqi@0 70 cups-libs cups-devel \
aoqi@0 71 libX11 libX11-devel \
aoqi@0 72 xorg-x11-proto-devel \
aoqi@0 73 alsa-lib alsa-lib-devel \
aoqi@0 74 libXext libXext-devel \
aoqi@0 75 libXtst libXtst-devel \
aoqi@0 76 libXrender libXrender-devel \
aoqi@0 77 freetype freetype-devel \
aoqi@0 78 libXt libXt-devel \
aoqi@0 79 libSM libSM-devel \
aoqi@0 80 libICE libICE-devel \
aoqi@0 81 libXi libXi-devel \
aoqi@0 82 libXdmcp libXdmcp-devel \
aoqi@0 83 libXau libXau-devel \
aoqi@0 84 libgcc
aoqi@0 85
aoqi@0 86
aoqi@0 87 ifeq ($(ARCH),x86_64)
aoqi@0 88 RPM_DIR ?= $(RPM_DIR_x86_64)
aoqi@0 89 RPM_ARCHS := x86_64
aoqi@0 90 ifeq ($(BUILD),$(HOST))
aoqi@0 91 ifeq ($(TARGET),$(HOST))
aoqi@0 92 # When building the native compiler for x86_64, enable mixed mode.
aoqi@0 93 RPM_ARCHS += i386 i686
aoqi@0 94 endif
aoqi@0 95 endif
aoqi@0 96 else
aoqi@0 97 RPM_DIR ?= $(RPM_DIR_i686)
aoqi@0 98 RPM_ARCHS := i386 i686
aoqi@0 99 endif
aoqi@0 100
aoqi@0 101 # Sort to remove duplicates
aoqi@0 102 RPM_FILE_LIST := $(sort $(foreach a,$(RPM_ARCHS),$(wildcard $(patsubst %,$(RPM_DIR)/%*$a.rpm,$(RPM_LIST)))))
aoqi@0 103
aoqi@0 104 ifeq ($(RPM_FILE_LIST),)
aoqi@0 105 $(error Found no RPMs, RPM_DIR must point to list of directories to search for RPMs)
aoqi@0 106 endif
aoqi@0 107
aoqi@0 108 ##########################################################################################
aoqi@0 109 # Define common directories and files
aoqi@0 110
aoqi@0 111 # Ensure we have 32-bit libs also for x64. We enable mixed-mode.
aoqi@0 112 ifeq (x86_64,$(ARCH))
aoqi@0 113 LIBDIRS := lib64 lib
aoqi@0 114 CFLAGS_lib := -m32
aoqi@0 115 else
aoqi@0 116 LIBDIRS := lib
aoqi@0 117 endif
aoqi@0 118
aoqi@0 119 # Define directories
aoqi@0 120 RESULT := $(OUTPUT_ROOT)/result
aoqi@0 121 BUILDDIR := $(OUTPUT_ROOT)/$(HOST)/$(TARGET)
aoqi@0 122 PREFIX := $(RESULT)/$(HOST)
aoqi@0 123 TARGETDIR := $(PREFIX)/$(TARGET)
aoqi@0 124 SYSROOT := $(TARGETDIR)/sys-root
aoqi@0 125 DOWNLOAD := $(OUTPUT_ROOT)/download
aoqi@0 126 SRCDIR := $(OUTPUT_ROOT)/src
aoqi@0 127
aoqi@0 128 # Marker file for unpacking rpms
aoqi@0 129 rpms := $(SYSROOT)/rpms_unpacked
aoqi@0 130
aoqi@0 131 # Need to patch libs that are linker scripts to use non-absolute paths
aoqi@0 132 libs := $(SYSROOT)/libs_patched
aoqi@0 133
aoqi@0 134 ##########################################################################################
aoqi@0 135 # Unpack source packages
aoqi@0 136
aoqi@0 137 # Generate downloading + unpacking of sources.
aoqi@0 138 define Download
aoqi@0 139 $(1)_DIR = $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1))))))
aoqi@0 140 $(1)_CFG = $$($(1)_DIR)/configure
aoqi@0 141 $(1)_FILE = $(DOWNLOAD)/$(notdir $($(1)))
aoqi@0 142
aoqi@0 143 $$($(1)_CFG) : $$($(1)_FILE)
aoqi@0 144 mkdir -p $$(SRCDIR)
aoqi@0 145 tar -C $$(SRCDIR) -x$$(if $$(findstring .gz, $$<),z,j)f $$<
aoqi@0 146 $$(foreach p,$$(abspath $$(wildcard $$(notdir $$($(1)_DIR)).patch)), \
aoqi@0 147 echo PATCHING $$(p) ; \
aoqi@0 148 patch -d $$($(1)_DIR) -p1 -i $$(p) ; \
aoqi@0 149 )
aoqi@0 150 touch $$@
aoqi@0 151
aoqi@0 152 $$($(1)_FILE) :
aoqi@0 153 wget -P $(DOWNLOAD) $$($(1))
aoqi@0 154 endef
aoqi@0 155
aoqi@0 156 # Download and unpack all source packages
aoqi@0 157 $(foreach p,GCC BINUTILS CCACHE MPFR GMP MPC,$(eval $(call Download,$(p))))
aoqi@0 158
aoqi@0 159 ##########################################################################################
aoqi@0 160 # Unpack RPMS
aoqi@0 161
aoqi@0 162 # Note. For building linux you should install rpm2cpio.
aoqi@0 163 define unrpm
aoqi@0 164 $(SYSROOT)/$(notdir $(1)).unpacked \
aoqi@0 165 : $(1)
aoqi@0 166 $$(rpms) : $(SYSROOT)/$(notdir $(1)).unpacked
aoqi@0 167 endef
aoqi@0 168
aoqi@0 169 %.unpacked :
aoqi@0 170 $(info Unpacking target rpms and libraries from $<)
aoqi@0 171 @(mkdir -p $(@D); \
aoqi@0 172 cd $(@D); \
aoqi@0 173 rpm2cpio $< | \
aoqi@0 174 cpio --extract --make-directories \
aoqi@0 175 -f \
aoqi@0 176 "./usr/share/doc/*" \
aoqi@0 177 "./usr/share/man/*" \
aoqi@0 178 "./usr/X11R6/man/*" \
aoqi@0 179 "*/X11/locale/*" \
aoqi@0 180 || die ; )
aoqi@0 181 touch $@
aoqi@0 182
aoqi@0 183 $(foreach p,$(RPM_FILE_LIST),$(eval $(call unrpm,$(p))))
aoqi@0 184
aoqi@0 185 ##########################################################################################
aoqi@0 186
aoqi@0 187 # Note: MUST create a <sys-root>/usr/lib even if not really needed.
aoqi@0 188 # gcc will use a path relative to it to resolve lib64. (x86_64).
aoqi@0 189 # we're creating multi-lib compiler with 32bit libc as well, so we should
aoqi@0 190 # have it anyway, but just to make sure...
aoqi@0 191 # Patch libc.so and libpthread.so to force linking against libraries in sysroot
aoqi@0 192 # and not the ones installed on the build machine.
aoqi@0 193 $(libs) : $(rpms)
aoqi@0 194 @echo Patching libc and pthreads
aoqi@0 195 @(for f in `find $(SYSROOT) -name libc.so -o -name libpthread.so`; do \
aoqi@0 196 (cat $$f | sed -e 's|/usr/lib64/||g' \
aoqi@0 197 -e 's|/usr/lib/||g' \
aoqi@0 198 -e 's|/lib64/||g' \
aoqi@0 199 -e 's|/lib/||g' ) > $$f.tmp ; \
aoqi@0 200 mv $$f.tmp $$f ; \
aoqi@0 201 done)
aoqi@0 202 @mkdir -p $(SYSROOT)/usr/lib
aoqi@0 203 @touch $@
aoqi@0 204
aoqi@0 205 ##########################################################################################
aoqi@0 206
aoqi@0 207 # Define marker files for each source package to be compiled
aoqi@0 208 $(foreach t,binutils mpfr gmp mpc gcc ccache,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done))
aoqi@0 209
aoqi@0 210 ##########################################################################################
aoqi@0 211
aoqi@0 212 # Default base config
aoqi@0 213 CONFIG = --target=$(TARGET) \
aoqi@0 214 --host=$(HOST) --build=$(BUILD) \
aoqi@0 215 --prefix=$(PREFIX)
aoqi@0 216
aoqi@0 217 PATHEXT = $(RESULT)/$(BUILD)/bin:
aoqi@0 218
aoqi@0 219 PATHPRE = PATH=$(PATHEXT)$(PATH)
aoqi@0 220 BUILDPAR = -j16
aoqi@0 221
aoqi@0 222 # Default commands to when making
aoqi@0 223 MAKECMD =
aoqi@0 224 INSTALLCMD = install
aoqi@0 225
aoqi@0 226
aoqi@0 227 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
aoqi@0 228
aoqi@0 229 ifeq ($(HOST),$(BUILD))
aoqi@0 230 ifeq ($(HOST),$(TARGET))
aoqi@0 231 TOOLS = $(call declare_tools,_FOR_TARGET,)
aoqi@0 232 endif
aoqi@0 233 endif
aoqi@0 234
aoqi@0 235 TOOLS ?= $(call declare_tools,_FOR_TARGET,$(TARGET)-)
aoqi@0 236
aoqi@0 237 ##########################################################################################
aoqi@0 238
aoqi@0 239 # Create a TARGET bfd + libiberty only.
aoqi@0 240 # Configure one or two times depending on mulitlib arch.
aoqi@0 241 # If multilib, the second should be 32-bit, and we resolve
aoqi@0 242 # CFLAG_<name> to most likely -m32.
aoqi@0 243 define mk_bfd
aoqi@0 244 $$(info Libs for $(1))
aoqi@0 245 $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
aoqi@0 246 : CFLAGS += $$(CFLAGS_$(1))
aoqi@0 247 $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
aoqi@0 248 : LIBDIRS = --libdir=$(TARGETDIR)/$(1)
aoqi@0 249
aoqi@0 250 bfdlib += $$(TARGETDIR)/$$(binutils_ver)-$(subst /,-,$(1)).done
aoqi@0 251 bfdmakes += $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile
aoqi@0 252 endef
aoqi@0 253
aoqi@0 254 # Create one set of bfds etc for each multilib arch
aoqi@0 255 $(foreach l,$(LIBDIRS),$(eval $(call mk_bfd,$(l))))
aoqi@0 256
aoqi@0 257 # Only build these two libs.
aoqi@0 258 $(bfdlib) : MAKECMD = all-libiberty all-bfd
aoqi@0 259 $(bfdlib) : INSTALLCMD = install-libiberty install-bfd
aoqi@0 260
aoqi@0 261 # Building targets libbfd + libiberty. HOST==TARGET, i.e not
aoqi@0 262 # for a cross env.
aoqi@0 263 $(bfdmakes) : CONFIG = --target=$(TARGET) \
aoqi@0 264 --host=$(TARGET) --build=$(BUILD) \
aoqi@0 265 --prefix=$(TARGETDIR) \
aoqi@0 266 --with-sysroot=$(SYSROOT) \
aoqi@0 267 $(LIBDIRS)
aoqi@0 268
aoqi@0 269 $(bfdmakes) : TOOLS = $(call declare_tools,_FOR_TARGET,$(TARGET)-) $(call declare_tools,,$(TARGET)-)
aoqi@0 270
aoqi@0 271 ##########################################################################################
aoqi@0 272
aoqi@0 273 $(gcc) \
aoqi@0 274 $(binutils) \
aoqi@0 275 $(gmp) \
aoqi@0 276 $(mpfr) \
aoqi@0 277 $(mpc) \
aoqi@0 278 $(bfdmakes) \
aoqi@0 279 $(ccache) : ENVS += $(TOOLS)
aoqi@0 280
aoqi@0 281 # libdir to work around hateful bfd stuff installing into wrong dirs...
aoqi@0 282 # ensure we have 64 bit bfd support in the HOST library. I.e our
aoqi@0 283 # compiler on i686 will know 64 bit symbols, BUT later
aoqi@0 284 # we build just the libs again for TARGET, then with whatever the arch
aoqi@0 285 # wants.
aoqi@0 286 $(BUILDDIR)/$(binutils_ver)/Makefile : CONFIG += --enable-64-bit-bfd --libdir=$(PREFIX)/$(word 1,$(LIBDIRS))
aoqi@0 287
aoqi@0 288 # Makefile creation. Simply run configure in build dir.
aoqi@0 289 $(bfdmakes) \
aoqi@0 290 $(BUILDDIR)/$(binutils_ver)/Makefile \
aoqi@0 291 : $(BINUTILS_CFG)
aoqi@0 292 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 293 @mkdir -p $(@D)
aoqi@0 294 ( \
aoqi@0 295 cd $(@D) ; \
aoqi@0 296 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 297 $(BINUTILS_CFG) \
aoqi@0 298 $(CONFIG) \
aoqi@0 299 --with-sysroot=$(SYSROOT) \
aoqi@0 300 --disable-nls \
aoqi@0 301 --program-prefix=$(TARGET)- \
aoqi@0 302 --enable-multilib \
aoqi@0 303 ) > $(@D)/log.config 2>&1
aoqi@0 304 @echo 'done'
aoqi@0 305
aoqi@0 306 $(BUILDDIR)/$(mpfr_ver)/Makefile \
aoqi@0 307 : $(MPFR_CFG)
aoqi@0 308 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 309 @mkdir -p $(@D)
aoqi@0 310 ( \
aoqi@0 311 cd $(@D) ; \
aoqi@0 312 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 313 $(MPFR_CFG) \
aoqi@0 314 $(CONFIG) \
aoqi@0 315 --program-prefix=$(TARGET)- \
aoqi@0 316 --enable-shared=no \
aoqi@0 317 --with-gmp=$(PREFIX) \
aoqi@0 318 ) > $(@D)/log.config 2>&1
aoqi@0 319 @echo 'done'
aoqi@0 320
aoqi@0 321 $(BUILDDIR)/$(gmp_ver)/Makefile \
aoqi@0 322 : $(GMP_CFG)
aoqi@0 323 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 324 @mkdir -p $(@D)
aoqi@0 325 ( \
aoqi@0 326 cd $(@D) ; \
aoqi@0 327 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 328 $(GMP_CFG) \
aoqi@0 329 --host=$(HOST) --build=$(BUILD) \
aoqi@0 330 --prefix=$(PREFIX) \
aoqi@0 331 --disable-nls \
aoqi@0 332 --program-prefix=$(TARGET)- \
aoqi@0 333 --enable-shared=no \
aoqi@0 334 --with-mpfr=$(PREFIX) \
aoqi@0 335 ) > $(@D)/log.config 2>&1
aoqi@0 336 @echo 'done'
aoqi@0 337
aoqi@0 338 $(BUILDDIR)/$(mpc_ver)/Makefile \
aoqi@0 339 : $(MPC_CFG)
aoqi@0 340 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 341 @mkdir -p $(@D)
aoqi@0 342 ( \
aoqi@0 343 cd $(@D) ; \
aoqi@0 344 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 345 $(MPC_CFG) \
aoqi@0 346 $(CONFIG) \
aoqi@0 347 --program-prefix=$(TARGET)- \
aoqi@0 348 --enable-shared=no \
aoqi@0 349 --with-mpfr=$(PREFIX) \
aoqi@0 350 --with-gmp=$(PREFIX) \
aoqi@0 351 ) > $(@D)/log.config 2>&1
aoqi@0 352 @echo 'done'
aoqi@0 353
aoqi@0 354 # Only valid if glibc target -> linux
aoqi@0 355 # proper destructor handling for c++
aoqi@0 356 ifneq (,$(findstring linux,$(TARGET)))
aoqi@0 357 $(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --enable-__cxa_atexit
aoqi@0 358 endif
aoqi@0 359
aoqi@0 360 # Want:
aoqi@0 361 # c,c++
aoqi@0 362 # shared libs
aoqi@0 363 # multilib (-m32/-m64 on x64)
aoqi@0 364 # skip native language.
aoqi@0 365 # and link and assemble with the binutils we created
aoqi@0 366 # earlier, so --with-gnu*
aoqi@0 367 $(BUILDDIR)/$(gcc_ver)/Makefile \
aoqi@0 368 : $(GCC_CFG)
aoqi@0 369 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 370 mkdir -p $(@D)
aoqi@0 371 ( \
aoqi@0 372 cd $(@D) ; \
aoqi@0 373 $(PATHPRE) $(ENVS) $(GCC_CFG) $(EXTRA_CFLAGS) \
aoqi@0 374 $(CONFIG) \
aoqi@0 375 --with-sysroot=$(SYSROOT) \
aoqi@0 376 --enable-languages=c,c++ \
aoqi@0 377 --enable-shared \
aoqi@0 378 --enable-multilib \
aoqi@0 379 --disable-nls \
aoqi@0 380 --with-gnu-as \
aoqi@0 381 --with-gnu-ld \
aoqi@0 382 --with-mpfr=$(PREFIX) \
aoqi@0 383 --with-gmp=$(PREFIX) \
aoqi@0 384 --with-mpc=$(PREFIX) \
aoqi@0 385 ) > $(@D)/log.config 2>&1
aoqi@0 386 @echo 'done'
aoqi@0 387
aoqi@0 388 # need binutils for gcc
aoqi@0 389 $(gcc) : $(binutils)
aoqi@0 390
aoqi@0 391 # as of 4.3 or so need these for doing config
aoqi@0 392 $(BUILDDIR)/$(gcc_ver)/Makefile : $(gmp) $(mpfr) $(mpc)
aoqi@0 393 $(mpfr) : $(gmp)
aoqi@0 394 $(mpc) : $(gmp) $(mpfr)
aoqi@0 395
aoqi@0 396 ##########################################################################################
aoqi@0 397 # very straightforward. just build a ccache. it is only for host.
aoqi@0 398 $(BUILDDIR)/$(ccache_ver)/Makefile \
aoqi@0 399 : $(CCACHE_CFG)
aoqi@0 400 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 401 @mkdir -p $(@D)
aoqi@0 402 @( \
aoqi@0 403 cd $(@D) ; \
aoqi@0 404 $(PATHPRE) $(ENVS) $(CCACHE_CFG) \
aoqi@0 405 $(CONFIG) \
aoqi@0 406 ) > $(@D)/log.config 2>&1
aoqi@0 407 @echo 'done'
aoqi@0 408
aoqi@0 409 gccpatch = $(TARGETDIR)/gcc-patched
aoqi@0 410
aoqi@0 411 ##########################################################################################
aoqi@0 412 # For some reason cpp is not created as a target-compiler
aoqi@0 413 ifeq ($(HOST),$(TARGET))
aoqi@0 414 $(gccpatch) : $(gcc) link_libs
aoqi@0 415 @echo -n 'Creating compiler symlinks...'
aoqi@0 416 @for f in cpp; do \
aoqi@0 417 if [ ! -e $(PREFIX)/bin/$(TARGET)-$$f ]; \
aoqi@0 418 then \
aoqi@0 419 cd $(PREFIX)/bin && \
aoqi@0 420 ln -s $$f $(TARGET)-$$f ; \
aoqi@0 421 fi \
aoqi@0 422 done
aoqi@0 423 @touch $@
aoqi@0 424 @echo 'done'
aoqi@0 425
aoqi@0 426 ##########################################################################################
aoqi@0 427 # Ugly at best. Seems that when we compile host->host compiler, that are NOT
aoqi@0 428 # the BUILD compiler, the result will not try searching for libs in package root.
aoqi@0 429 # "Solve" this by create links from the target libdirs to where they are.
aoqi@0 430 link_libs:
aoqi@0 431 @echo -n 'Creating library symlinks...'
aoqi@0 432 @$(foreach l,$(LIBDIRS), \
aoqi@0 433 for f in `cd $(PREFIX)/$(l) && ls`; do \
aoqi@0 434 if [ ! -e $(TARGETDIR)/$(l)/$$f ]; then \
aoqi@0 435 mkdir -p $(TARGETDIR)/$(l) && \
aoqi@0 436 cd $(TARGETDIR)/$(l)/ && \
aoqi@0 437 ln -s $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f; \
aoqi@0 438 fi \
aoqi@0 439 done;)
aoqi@0 440 @echo 'done'
aoqi@0 441 else
aoqi@0 442 $(gccpatch) :
aoqi@0 443 @echo 'done'
aoqi@0 444 endif
aoqi@0 445
aoqi@0 446 ##########################################################################################
aoqi@0 447 # Build in two steps.
aoqi@0 448 # make <default>
aoqi@0 449 # make install.
aoqi@0 450 # Use path to our build hosts cross tools
aoqi@0 451 # Always need to build cross tools for build host self.
aoqi@0 452 $(TARGETDIR)/%.done : $(BUILDDIR)/%/Makefile
aoqi@0 453 $(info Building $(basename $@). Log in $(<D)/log.build)
aoqi@0 454 $(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $(<D) $(MAKECMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.build 2>&1
aoqi@0 455 @echo -n 'installing...'
aoqi@0 456 $(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $(<D) $(INSTALLCMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.install 2>&1
aoqi@0 457 @touch $@
aoqi@0 458 @echo 'done'
aoqi@0 459
aoqi@0 460 ##########################################################################################
aoqi@0 461
aoqi@0 462 bfdlib : $(bfdlib)
aoqi@0 463 binutils : $(binutils)
aoqi@0 464 rpms : $(rpms)
aoqi@0 465 libs : $(libs)
aoqi@0 466 sysroot : rpms libs
aoqi@0 467 gcc : sysroot $(gcc) $(gccpatch)
aoqi@0 468 all : binutils gcc bfdlib
aoqi@0 469
aoqi@0 470 # this is only built for host. so separate.
aoqi@0 471 ccache : $(ccache)
aoqi@0 472
aoqi@0 473 .PHONY : gcc all binutils bfdlib link_libs rpms libs sysroot

mercurial