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