make/devkit/Tools.gmk

Thu, 27 Dec 2018 11:47:57 +0800

author
aoqi
date
Thu, 27 Dec 2018 11:47:57 +0800
changeset 2316
64a3eeabf6e5
parent 2215
7a73b8b4ac8a
parent 1133
50aaf272884f
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.
kevinw@2215 52 gcc_ver := gcc-4.8.2
kevinw@2215 53 binutils_ver := binutils-2.24
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
kevinw@2215 67 LINUX_VERSION := OEL5.5
aoqi@0 68 RPM_LIST := \
aoqi@0 69 kernel-headers \
aoqi@0 70 glibc-2 glibc-headers glibc-devel \
aoqi@0 71 cups-libs cups-devel \
aoqi@0 72 libX11 libX11-devel \
aoqi@0 73 xorg-x11-proto-devel \
aoqi@0 74 alsa-lib alsa-lib-devel \
aoqi@0 75 libXext libXext-devel \
aoqi@0 76 libXtst libXtst-devel \
aoqi@0 77 libXrender libXrender-devel \
aoqi@0 78 freetype freetype-devel \
aoqi@0 79 libXt libXt-devel \
aoqi@0 80 libSM libSM-devel \
aoqi@0 81 libICE libICE-devel \
aoqi@0 82 libXi libXi-devel \
aoqi@0 83 libXdmcp libXdmcp-devel \
aoqi@0 84 libXau libXau-devel \
aoqi@0 85 libgcc
aoqi@0 86
aoqi@0 87
aoqi@0 88 ifeq ($(ARCH),x86_64)
aoqi@0 89 RPM_DIR ?= $(RPM_DIR_x86_64)
aoqi@0 90 RPM_ARCHS := x86_64
aoqi@0 91 ifeq ($(BUILD),$(HOST))
aoqi@0 92 ifeq ($(TARGET),$(HOST))
aoqi@0 93 # When building the native compiler for x86_64, enable mixed mode.
aoqi@0 94 RPM_ARCHS += i386 i686
aoqi@0 95 endif
aoqi@0 96 endif
aoqi@0 97 else
aoqi@0 98 RPM_DIR ?= $(RPM_DIR_i686)
aoqi@0 99 RPM_ARCHS := i386 i686
aoqi@0 100 endif
aoqi@0 101
aoqi@0 102 # Sort to remove duplicates
aoqi@0 103 RPM_FILE_LIST := $(sort $(foreach a,$(RPM_ARCHS),$(wildcard $(patsubst %,$(RPM_DIR)/%*$a.rpm,$(RPM_LIST)))))
aoqi@0 104
aoqi@0 105 ifeq ($(RPM_FILE_LIST),)
aoqi@0 106 $(error Found no RPMs, RPM_DIR must point to list of directories to search for RPMs)
aoqi@0 107 endif
aoqi@0 108
aoqi@0 109 ##########################################################################################
aoqi@0 110 # Define common directories and files
aoqi@0 111
aoqi@0 112 # Ensure we have 32-bit libs also for x64. We enable mixed-mode.
aoqi@0 113 ifeq (x86_64,$(ARCH))
aoqi@0 114 LIBDIRS := lib64 lib
aoqi@0 115 CFLAGS_lib := -m32
aoqi@0 116 else
aoqi@0 117 LIBDIRS := lib
aoqi@0 118 endif
aoqi@0 119
aoqi@0 120 # Define directories
aoqi@0 121 RESULT := $(OUTPUT_ROOT)/result
aoqi@0 122 BUILDDIR := $(OUTPUT_ROOT)/$(HOST)/$(TARGET)
aoqi@0 123 PREFIX := $(RESULT)/$(HOST)
aoqi@0 124 TARGETDIR := $(PREFIX)/$(TARGET)
kevinw@2215 125 SYSROOT := $(TARGETDIR)/sysroot
aoqi@0 126 DOWNLOAD := $(OUTPUT_ROOT)/download
aoqi@0 127 SRCDIR := $(OUTPUT_ROOT)/src
aoqi@0 128
aoqi@0 129 # Marker file for unpacking rpms
aoqi@0 130 rpms := $(SYSROOT)/rpms_unpacked
aoqi@0 131
aoqi@0 132 # Need to patch libs that are linker scripts to use non-absolute paths
aoqi@0 133 libs := $(SYSROOT)/libs_patched
aoqi@0 134
aoqi@0 135 ##########################################################################################
aoqi@0 136 # Unpack source packages
aoqi@0 137
aoqi@0 138 # Generate downloading + unpacking of sources.
aoqi@0 139 define Download
aoqi@0 140 $(1)_DIR = $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1))))))
aoqi@0 141 $(1)_CFG = $$($(1)_DIR)/configure
aoqi@0 142 $(1)_FILE = $(DOWNLOAD)/$(notdir $($(1)))
aoqi@0 143
aoqi@0 144 $$($(1)_CFG) : $$($(1)_FILE)
aoqi@0 145 mkdir -p $$(SRCDIR)
aoqi@0 146 tar -C $$(SRCDIR) -x$$(if $$(findstring .gz, $$<),z,j)f $$<
aoqi@0 147 $$(foreach p,$$(abspath $$(wildcard $$(notdir $$($(1)_DIR)).patch)), \
aoqi@0 148 echo PATCHING $$(p) ; \
aoqi@0 149 patch -d $$($(1)_DIR) -p1 -i $$(p) ; \
aoqi@0 150 )
aoqi@0 151 touch $$@
aoqi@0 152
aoqi@0 153 $$($(1)_FILE) :
aoqi@0 154 wget -P $(DOWNLOAD) $$($(1))
aoqi@0 155 endef
aoqi@0 156
aoqi@0 157 # Download and unpack all source packages
aoqi@0 158 $(foreach p,GCC BINUTILS CCACHE MPFR GMP MPC,$(eval $(call Download,$(p))))
aoqi@0 159
aoqi@0 160 ##########################################################################################
aoqi@0 161 # Unpack RPMS
aoqi@0 162
aoqi@0 163 # Note. For building linux you should install rpm2cpio.
aoqi@0 164 define unrpm
aoqi@0 165 $(SYSROOT)/$(notdir $(1)).unpacked \
aoqi@0 166 : $(1)
aoqi@0 167 $$(rpms) : $(SYSROOT)/$(notdir $(1)).unpacked
aoqi@0 168 endef
aoqi@0 169
aoqi@0 170 %.unpacked :
aoqi@0 171 $(info Unpacking target rpms and libraries from $<)
aoqi@0 172 @(mkdir -p $(@D); \
aoqi@0 173 cd $(@D); \
aoqi@0 174 rpm2cpio $< | \
aoqi@0 175 cpio --extract --make-directories \
aoqi@0 176 -f \
aoqi@0 177 "./usr/share/doc/*" \
aoqi@0 178 "./usr/share/man/*" \
aoqi@0 179 "./usr/X11R6/man/*" \
aoqi@0 180 "*/X11/locale/*" \
aoqi@0 181 || die ; )
aoqi@0 182 touch $@
aoqi@0 183
aoqi@0 184 $(foreach p,$(RPM_FILE_LIST),$(eval $(call unrpm,$(p))))
aoqi@0 185
aoqi@0 186 ##########################################################################################
aoqi@0 187
kevinw@2215 188 # Note: MUST create a <sysroot>/usr/lib even if not really needed.
aoqi@0 189 # gcc will use a path relative to it to resolve lib64. (x86_64).
aoqi@0 190 # we're creating multi-lib compiler with 32bit libc as well, so we should
aoqi@0 191 # have it anyway, but just to make sure...
aoqi@0 192 # Patch libc.so and libpthread.so to force linking against libraries in sysroot
aoqi@0 193 # and not the ones installed on the build machine.
aoqi@0 194 $(libs) : $(rpms)
aoqi@0 195 @echo Patching libc and pthreads
aoqi@0 196 @(for f in `find $(SYSROOT) -name libc.so -o -name libpthread.so`; do \
aoqi@0 197 (cat $$f | sed -e 's|/usr/lib64/||g' \
aoqi@0 198 -e 's|/usr/lib/||g' \
aoqi@0 199 -e 's|/lib64/||g' \
aoqi@0 200 -e 's|/lib/||g' ) > $$f.tmp ; \
aoqi@0 201 mv $$f.tmp $$f ; \
aoqi@0 202 done)
aoqi@0 203 @mkdir -p $(SYSROOT)/usr/lib
aoqi@0 204 @touch $@
aoqi@0 205
aoqi@0 206 ##########################################################################################
aoqi@0 207
aoqi@0 208 # Define marker files for each source package to be compiled
aoqi@0 209 $(foreach t,binutils mpfr gmp mpc gcc ccache,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done))
aoqi@0 210
aoqi@0 211 ##########################################################################################
aoqi@0 212
aoqi@0 213 # Default base config
aoqi@0 214 CONFIG = --target=$(TARGET) \
aoqi@0 215 --host=$(HOST) --build=$(BUILD) \
aoqi@0 216 --prefix=$(PREFIX)
aoqi@0 217
aoqi@0 218 PATHEXT = $(RESULT)/$(BUILD)/bin:
aoqi@0 219
aoqi@0 220 PATHPRE = PATH=$(PATHEXT)$(PATH)
aoqi@0 221 BUILDPAR = -j16
aoqi@0 222
aoqi@0 223 # Default commands to when making
aoqi@0 224 MAKECMD =
aoqi@0 225 INSTALLCMD = install
aoqi@0 226
aoqi@0 227
aoqi@0 228 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 229
aoqi@0 230 ifeq ($(HOST),$(BUILD))
aoqi@0 231 ifeq ($(HOST),$(TARGET))
aoqi@0 232 TOOLS = $(call declare_tools,_FOR_TARGET,)
aoqi@0 233 endif
aoqi@0 234 endif
aoqi@0 235
aoqi@0 236 TOOLS ?= $(call declare_tools,_FOR_TARGET,$(TARGET)-)
aoqi@0 237
aoqi@0 238 ##########################################################################################
aoqi@0 239
aoqi@0 240 # Create a TARGET bfd + libiberty only.
aoqi@0 241 # Configure one or two times depending on mulitlib arch.
aoqi@0 242 # If multilib, the second should be 32-bit, and we resolve
aoqi@0 243 # CFLAG_<name> to most likely -m32.
aoqi@0 244 define mk_bfd
aoqi@0 245 $$(info Libs for $(1))
aoqi@0 246 $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
aoqi@0 247 : CFLAGS += $$(CFLAGS_$(1))
aoqi@0 248 $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
aoqi@0 249 : LIBDIRS = --libdir=$(TARGETDIR)/$(1)
aoqi@0 250
aoqi@0 251 bfdlib += $$(TARGETDIR)/$$(binutils_ver)-$(subst /,-,$(1)).done
aoqi@0 252 bfdmakes += $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile
aoqi@0 253 endef
aoqi@0 254
aoqi@0 255 # Create one set of bfds etc for each multilib arch
aoqi@0 256 $(foreach l,$(LIBDIRS),$(eval $(call mk_bfd,$(l))))
aoqi@0 257
aoqi@0 258 # Only build these two libs.
aoqi@0 259 $(bfdlib) : MAKECMD = all-libiberty all-bfd
aoqi@0 260 $(bfdlib) : INSTALLCMD = install-libiberty install-bfd
aoqi@0 261
aoqi@0 262 # Building targets libbfd + libiberty. HOST==TARGET, i.e not
aoqi@0 263 # for a cross env.
aoqi@0 264 $(bfdmakes) : CONFIG = --target=$(TARGET) \
aoqi@0 265 --host=$(TARGET) --build=$(BUILD) \
aoqi@0 266 --prefix=$(TARGETDIR) \
aoqi@0 267 --with-sysroot=$(SYSROOT) \
aoqi@0 268 $(LIBDIRS)
aoqi@0 269
aoqi@0 270 $(bfdmakes) : TOOLS = $(call declare_tools,_FOR_TARGET,$(TARGET)-) $(call declare_tools,,$(TARGET)-)
aoqi@0 271
aoqi@0 272 ##########################################################################################
aoqi@0 273
aoqi@0 274 $(gcc) \
aoqi@0 275 $(binutils) \
aoqi@0 276 $(gmp) \
aoqi@0 277 $(mpfr) \
aoqi@0 278 $(mpc) \
aoqi@0 279 $(bfdmakes) \
aoqi@0 280 $(ccache) : ENVS += $(TOOLS)
aoqi@0 281
aoqi@0 282 # libdir to work around hateful bfd stuff installing into wrong dirs...
aoqi@0 283 # ensure we have 64 bit bfd support in the HOST library. I.e our
aoqi@0 284 # compiler on i686 will know 64 bit symbols, BUT later
aoqi@0 285 # we build just the libs again for TARGET, then with whatever the arch
aoqi@0 286 # wants.
aoqi@0 287 $(BUILDDIR)/$(binutils_ver)/Makefile : CONFIG += --enable-64-bit-bfd --libdir=$(PREFIX)/$(word 1,$(LIBDIRS))
aoqi@0 288
aoqi@0 289 # Makefile creation. Simply run configure in build dir.
aoqi@0 290 $(bfdmakes) \
aoqi@0 291 $(BUILDDIR)/$(binutils_ver)/Makefile \
aoqi@0 292 : $(BINUTILS_CFG)
aoqi@0 293 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 294 @mkdir -p $(@D)
aoqi@0 295 ( \
aoqi@0 296 cd $(@D) ; \
aoqi@0 297 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 298 $(BINUTILS_CFG) \
aoqi@0 299 $(CONFIG) \
aoqi@0 300 --with-sysroot=$(SYSROOT) \
aoqi@0 301 --disable-nls \
aoqi@0 302 --program-prefix=$(TARGET)- \
aoqi@0 303 --enable-multilib \
aoqi@0 304 ) > $(@D)/log.config 2>&1
aoqi@0 305 @echo 'done'
aoqi@0 306
aoqi@0 307 $(BUILDDIR)/$(mpfr_ver)/Makefile \
aoqi@0 308 : $(MPFR_CFG)
aoqi@0 309 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 310 @mkdir -p $(@D)
aoqi@0 311 ( \
aoqi@0 312 cd $(@D) ; \
aoqi@0 313 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 314 $(MPFR_CFG) \
aoqi@0 315 $(CONFIG) \
aoqi@0 316 --program-prefix=$(TARGET)- \
aoqi@0 317 --enable-shared=no \
aoqi@0 318 --with-gmp=$(PREFIX) \
aoqi@0 319 ) > $(@D)/log.config 2>&1
aoqi@0 320 @echo 'done'
aoqi@0 321
aoqi@0 322 $(BUILDDIR)/$(gmp_ver)/Makefile \
aoqi@0 323 : $(GMP_CFG)
aoqi@0 324 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 325 @mkdir -p $(@D)
aoqi@0 326 ( \
aoqi@0 327 cd $(@D) ; \
aoqi@0 328 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 329 $(GMP_CFG) \
aoqi@0 330 --host=$(HOST) --build=$(BUILD) \
aoqi@0 331 --prefix=$(PREFIX) \
aoqi@0 332 --disable-nls \
aoqi@0 333 --program-prefix=$(TARGET)- \
aoqi@0 334 --enable-shared=no \
aoqi@0 335 --with-mpfr=$(PREFIX) \
aoqi@0 336 ) > $(@D)/log.config 2>&1
aoqi@0 337 @echo 'done'
aoqi@0 338
aoqi@0 339 $(BUILDDIR)/$(mpc_ver)/Makefile \
aoqi@0 340 : $(MPC_CFG)
aoqi@0 341 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 342 @mkdir -p $(@D)
aoqi@0 343 ( \
aoqi@0 344 cd $(@D) ; \
aoqi@0 345 $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" \
aoqi@0 346 $(MPC_CFG) \
aoqi@0 347 $(CONFIG) \
aoqi@0 348 --program-prefix=$(TARGET)- \
aoqi@0 349 --enable-shared=no \
aoqi@0 350 --with-mpfr=$(PREFIX) \
aoqi@0 351 --with-gmp=$(PREFIX) \
aoqi@0 352 ) > $(@D)/log.config 2>&1
aoqi@0 353 @echo 'done'
aoqi@0 354
aoqi@0 355 # Only valid if glibc target -> linux
aoqi@0 356 # proper destructor handling for c++
aoqi@0 357 ifneq (,$(findstring linux,$(TARGET)))
aoqi@0 358 $(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --enable-__cxa_atexit
aoqi@0 359 endif
aoqi@0 360
aoqi@0 361 # Want:
aoqi@0 362 # c,c++
aoqi@0 363 # shared libs
aoqi@0 364 # multilib (-m32/-m64 on x64)
aoqi@0 365 # skip native language.
aoqi@0 366 # and link and assemble with the binutils we created
aoqi@0 367 # earlier, so --with-gnu*
aoqi@0 368 $(BUILDDIR)/$(gcc_ver)/Makefile \
aoqi@0 369 : $(GCC_CFG)
aoqi@0 370 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 371 mkdir -p $(@D)
aoqi@0 372 ( \
aoqi@0 373 cd $(@D) ; \
aoqi@0 374 $(PATHPRE) $(ENVS) $(GCC_CFG) $(EXTRA_CFLAGS) \
aoqi@0 375 $(CONFIG) \
aoqi@0 376 --with-sysroot=$(SYSROOT) \
aoqi@0 377 --enable-languages=c,c++ \
aoqi@0 378 --enable-shared \
aoqi@0 379 --enable-multilib \
aoqi@0 380 --disable-nls \
aoqi@0 381 --with-gnu-as \
aoqi@0 382 --with-gnu-ld \
aoqi@0 383 --with-mpfr=$(PREFIX) \
aoqi@0 384 --with-gmp=$(PREFIX) \
aoqi@0 385 --with-mpc=$(PREFIX) \
aoqi@0 386 ) > $(@D)/log.config 2>&1
aoqi@0 387 @echo 'done'
aoqi@0 388
aoqi@0 389 # need binutils for gcc
aoqi@0 390 $(gcc) : $(binutils)
aoqi@0 391
aoqi@0 392 # as of 4.3 or so need these for doing config
aoqi@0 393 $(BUILDDIR)/$(gcc_ver)/Makefile : $(gmp) $(mpfr) $(mpc)
aoqi@0 394 $(mpfr) : $(gmp)
aoqi@0 395 $(mpc) : $(gmp) $(mpfr)
aoqi@0 396
aoqi@0 397 ##########################################################################################
aoqi@0 398 # very straightforward. just build a ccache. it is only for host.
aoqi@0 399 $(BUILDDIR)/$(ccache_ver)/Makefile \
aoqi@0 400 : $(CCACHE_CFG)
aoqi@0 401 $(info Configuring $@. Log in $(@D)/log.config)
aoqi@0 402 @mkdir -p $(@D)
aoqi@0 403 @( \
aoqi@0 404 cd $(@D) ; \
aoqi@0 405 $(PATHPRE) $(ENVS) $(CCACHE_CFG) \
aoqi@0 406 $(CONFIG) \
aoqi@0 407 ) > $(@D)/log.config 2>&1
aoqi@0 408 @echo 'done'
aoqi@0 409
aoqi@0 410 gccpatch = $(TARGETDIR)/gcc-patched
aoqi@0 411
aoqi@0 412 ##########################################################################################
aoqi@0 413 # For some reason cpp is not created as a target-compiler
aoqi@0 414 ifeq ($(HOST),$(TARGET))
aoqi@0 415 $(gccpatch) : $(gcc) link_libs
aoqi@0 416 @echo -n 'Creating compiler symlinks...'
aoqi@0 417 @for f in cpp; do \
aoqi@0 418 if [ ! -e $(PREFIX)/bin/$(TARGET)-$$f ]; \
aoqi@0 419 then \
aoqi@0 420 cd $(PREFIX)/bin && \
aoqi@0 421 ln -s $$f $(TARGET)-$$f ; \
aoqi@0 422 fi \
aoqi@0 423 done
aoqi@0 424 @touch $@
aoqi@0 425 @echo 'done'
aoqi@0 426
aoqi@0 427 ##########################################################################################
aoqi@0 428 # Ugly at best. Seems that when we compile host->host compiler, that are NOT
aoqi@0 429 # the BUILD compiler, the result will not try searching for libs in package root.
aoqi@0 430 # "Solve" this by create links from the target libdirs to where they are.
aoqi@0 431 link_libs:
aoqi@0 432 @echo -n 'Creating library symlinks...'
aoqi@0 433 @$(foreach l,$(LIBDIRS), \
aoqi@0 434 for f in `cd $(PREFIX)/$(l) && ls`; do \
aoqi@0 435 if [ ! -e $(TARGETDIR)/$(l)/$$f ]; then \
aoqi@0 436 mkdir -p $(TARGETDIR)/$(l) && \
aoqi@0 437 cd $(TARGETDIR)/$(l)/ && \
aoqi@0 438 ln -s $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f; \
aoqi@0 439 fi \
aoqi@0 440 done;)
aoqi@0 441 @echo 'done'
aoqi@0 442 else
aoqi@0 443 $(gccpatch) :
aoqi@0 444 @echo 'done'
aoqi@0 445 endif
aoqi@0 446
aoqi@0 447 ##########################################################################################
aoqi@0 448 # Build in two steps.
aoqi@0 449 # make <default>
aoqi@0 450 # make install.
aoqi@0 451 # Use path to our build hosts cross tools
aoqi@0 452 # Always need to build cross tools for build host self.
aoqi@0 453 $(TARGETDIR)/%.done : $(BUILDDIR)/%/Makefile
aoqi@0 454 $(info Building $(basename $@). Log in $(<D)/log.build)
aoqi@0 455 $(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $(<D) $(MAKECMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.build 2>&1
aoqi@0 456 @echo -n 'installing...'
aoqi@0 457 $(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $(<D) $(INSTALLCMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.install 2>&1
aoqi@0 458 @touch $@
aoqi@0 459 @echo 'done'
aoqi@0 460
aoqi@0 461 ##########################################################################################
aoqi@0 462
kevinw@2215 463 $(PREFIX)/devkit.info: FRC
kevinw@2215 464 @echo 'Creating devkit.info in the root of the kit'
kevinw@2215 465 rm -f $@
kevinw@2215 466 touch $@
kevinw@2215 467 echo '# This file describes to configure how to interpret the contents of this' >> $@
kevinw@2215 468 echo '# devkit' >> $@
kevinw@2215 469 echo '' >> $@
kevinw@2215 470 echo 'DEVKIT_NAME="$(gcc_ver) - $(LINUX_VERSION)"' >> $@
kevinw@2215 471 echo 'DEVKIT_TOOLCHAIN_PATH="$$DEVKIT_ROOT/bin"' >> $@
kevinw@2215 472 echo 'DEVKIT_SYSROOT="$$DEVKIT_ROOT/$$host/sysroot"' >> $@
kevinw@2215 473
kevinw@2215 474 ##########################################################################################
kevinw@2215 475
aoqi@0 476 bfdlib : $(bfdlib)
aoqi@0 477 binutils : $(binutils)
aoqi@0 478 rpms : $(rpms)
aoqi@0 479 libs : $(libs)
aoqi@0 480 sysroot : rpms libs
aoqi@0 481 gcc : sysroot $(gcc) $(gccpatch)
kevinw@2215 482 all : binutils gcc bfdlib $(PREFIX)/devkit.info
aoqi@0 483
aoqi@0 484 # this is only built for host. so separate.
aoqi@0 485 ccache : $(ccache)
aoqi@0 486
kevinw@2215 487 # Force target
kevinw@2215 488 FRC:
kevinw@2215 489
aoqi@0 490 .PHONY : gcc all binutils bfdlib link_libs rpms libs sysroot

mercurial