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