# # Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. #
########################################################################################## # # Workhorse makefile for creating ONE cross compiler # Needs either to be from BUILD -> BUILD OR have # BUILD -> HOST prebuilt # # NOTE: There is a bug here. We don't limit the # PATH when building BUILD -> BUILD, which means that # if you configure after you've once build the BUILD->BUILD # compiler THAT one will be picked up as the compiler for itself. # This is not so great, especially if you did a partial delete # of the target tree. # # Fix this... #
# Marker file for unpacking rpms
rpms := $(SYSROOT)/rpms_unpacked
# Need to patch libs that are linker scripts to use non-absolute paths
libs := $(SYSROOT)/libs_patched
################################################################################ # Download RPMs
download-rpms:
mkdir -p $(DOWNLOAD_RPMS) # Only run this if rpm dir is empty. ifeq ($(wildcard $(DOWNLOAD_RPMS)/*.rpm), )
cd $(DOWNLOAD_RPMS) && \
wget -r -np -nd $(patsubst %, -A "*%*.rpm", $(RPM_LIST)) $(BASE_URL) endif
# Note. For building linux you should install rpm2cpio. define unrpm
$(SYSROOT)/$(notdir $(1)).unpacked : $(1)
$$(rpms) : $(SYSROOT)/$(notdir $(1)).unpacked endef
# Note: MUST create a <sysroot>/usr/lib even if not really needed. # gcc will use a path relative to it to resolve lib64. (x86_64). # we're creating multi-lib compiler with 32bit libc as well, so we should # have it anyway, but just to make sure... # Patch libc.so and libpthread.so to force linking against libraries in sysroot # and not the ones installed on the build machine.
$(libs) : $(rpms)
@echo Patching libc and pthreads
@(for f in `find $(SYSROOT) -name libc.so -o -name libpthread.so`; do \
(cat $$f | sed -e 's|/usr/lib64/||g' \
-e 's|/usr/lib/||g' \
-e 's|/lib64/||g' \
-e 's|/lib/||g' ) > $$f.tmp ; \
mv $$f.tmp $$f ; \ done)
@mkdir -p $(SYSROOT)/usr/lib
@touch $@
########################################################################################## # Create links for ffi header files so that they become visible by default when using the # devkit. ifeq ($(ARCH), x86_64)
$(SYSROOT)/usr/include/ffi.h: $(rpms)
cd $(@D) && rm -f $(@F) && ln -s ../lib/libffi-*/include/$(@F) .
# Create a TARGET bfd + libiberty only. # Configure one or two times depending on mulitlib arch. # If multilib, the second should be 32-bit, and we resolve # CFLAG_<name> to most likely -m32. define mk_bfd
$$(info Libs for $(1))
$$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
: CFLAGS += $$(CFLAGS_$(1))
$$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
: LIBDIRS = --libdir=$(TARGETDIR)/$(1)
# libdir to work around hateful bfd stuff installing into wrong dirs... # ensure we have 64 bit bfd support in the HOST library. I.e our # compiler on i686 will know 64 bit symbols, BUT later # we build just the libs again for TARGET, then with whatever the arch # wants.
$(BUILDDIR)/$(binutils_ver)/Makefile : CONFIG += --enable-64-bit-bfd --libdir=$(PREFIX)/$(word 1,$(LIBDIRS))
# Makefile creation. Simply run configure in build dir. # Setting CFLAGS to -O2 generates a much faster ld.
$(bfdmakes) \
$(BUILDDIR)/$(binutils_ver)/Makefile \
: $(BINUTILS_CFG)
$(info Configuring $@. Log in $(@D)/log.config)
@mkdir -p $(@D)
( \
cd $(@D) ; \
$(PATHPRE) $(ENVS) CFLAGS="-O2 $(CFLAGS)" \
$(BINUTILS_CFG) \
$(CONFIG) \
--with-sysroot=$(SYSROOT) \
--disable-nls \
--program-prefix=$(TARGET)- \
--enable-multilib \
--enable-gold=default \
--enable-threads \
--enable-plugins \
) > $(@D)/log.config 2>&1
@echo'done'
# Only valid if glibc target -> linux # proper destructor handling for c++ ifneq (,$(findstring linux,$(TARGET)))
$(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --enable-__cxa_atexit endif
ifneq ($(filter ppc64 ppc64le s390x, $(ARCH)), ) # We only support 64-bit on these platforms anyway
CONFIG += --disable-multilib endif
# Want: # c,c++ # shared libs # multilib (-m32/-m64 on x64) # skip native language. # and link and assemble with the binutils we created # earlier, so --with-gnu*
$(BUILDDIR)/$(gcc_ver)/Makefile \
: $(GCC_CFG)
$(info Configuring $@. Log in $(@D)/log.config)
mkdir -p $(@D)
( \
cd $(@D) ; \
$(PATHPRE) $(ENVS) $(GCC_CFG) $(EXTRA_CFLAGS) \
$(CONFIG) \
--with-sysroot=$(SYSROOT) \
--enable-languages=c,c++ \
--enable-shared \
--disable-nls \
--with-gnu-as \
--with-gnu-ld \
--with-mpfr=$(PREFIX) \
--with-gmp=$(PREFIX) \
--with-mpc=$(PREFIX) \
) > $(@D)/log.config 2>&1
@echo'done'
# need binutils for gcc
$(gcc) : $(binutils)
# as of 4.3 or so need these for doing config
$(BUILDDIR)/$(gcc_ver)/Makefile : $(gmp) $(mpfr) $(mpc)
$(mpfr) : $(gmp)
$(mpc) : $(gmp) $(mpfr)
################################################################################ # Build gdb but only where host and target match ifeq ($(HOST), $(TARGET))
$(BUILDDIR)/$(gdb_ver)/Makefile: $(GDB_CFG)
$(info Configuring $@. Log in $(@D)/log.config)
mkdir -p $(@D)
( \
cd $(@D) ; \
$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" $(GDB_CFG) \
$(CONFIG) \
--with-sysroot=$(SYSROOT) \
) > $(@D)/log.config 2>&1
@echo'done'
$(gdb): $(gcc) else
$(BUILDDIR)/$(gdb_ver)/Makefile:
$(info Faking $@, not used when cross-compiling)
mkdir -p $(@D) echo"install:" > $@
@echo'done' endif
########################################################################################## # very straightforward. just build a ccache. it is only for host.
$(BUILDDIR)/$(ccache_ver)/Makefile \
: $(CCACHE_CFG)
$(info Configuring $@. Log in $(@D)/log.config)
@mkdir -p $(@D)
@( \
cd $(@D) ; \
$(PATHPRE) $(ENVS) $(CCACHE_CFG) \
$(CONFIG) \
) > $(@D)/log.config 2>&1
@echo'done'
gccpatch = $(TARGETDIR)/gcc-patched
########################################################################################## # For some reason cpp is not created as a target-compiler ifeq ($(HOST),$(TARGET))
$(gccpatch) : $(gcc) link_libs
@echo -n 'Creating compiler symlinks...'
@for f in cpp; do \ if [ ! -e $(PREFIX)/bin/$(TARGET)-$$f ]; \ then \
cd $(PREFIX)/bin && \
ln -fs $$f $(TARGET)-$$f ; \ fi \ done
@touch $@
@echo'done'
########################################################################################## # Ugly at best. Seems that when we compile host->host compiler, that are NOT # the BUILD compiler, the result will not try searching for libs in package root. # "Solve" this by create links from the target libdirs to where they are.
link_libs:
@echo -n 'Creating library symlinks...'
@$(foreach l,$(LIBDIRS), \ for f in `cd $(PREFIX)/$(l) && ls`; do \ if [ ! -e $(TARGETDIR)/$(l)/$$f ]; then \
mkdir -p $(TARGETDIR)/$(l) && \
cd $(TARGETDIR)/$(l)/ && \
ln -fs $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f; \ fi \ done;)
@echo'done' else
$(gccpatch) :
@echo'done' endif
########################################################################################## # Build in two steps. # make <default> # make install. # Use path to our build hosts cross tools # Always need to build cross tools for build host self.
$(TARGETDIR)/%.done : $(BUILDDIR)/%/Makefile
$(info Building $(basename $@). Log in $(<D)/log.build)
$(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $(<D) $(MAKECMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.build 2>&1
@echo -n 'installing...'
$(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $(<D) $(INSTALLCMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.install 2>&1
@mkdir -p $(@D)
@touch $@
@echo'done'
$(PREFIX)/devkit.info:
@echo'Creating devkit.info in the root of the kit' rm -f $@
touch $@ echo'# This file describes to configure how to interpret the contents of this' >> $@ echo'# devkit' >> $@ echo'' >> $@ echo'DEVKIT_NAME="$(gcc_ver) - $(LINUX_VERSION)"' >> $@ echo'DEVKIT_TOOLCHAIN_PATH="$$DEVKIT_ROOT/bin"' >> $@ echo'DEVKIT_SYSROOT="$$DEVKIT_ROOT/$(TARGET)/sysroot"' >> $@ echo'DEVKIT_EXTRA_PATH="$$DEVKIT_ROOT/bin"' >> $@
########################################################################################## # Copy these makefiles into the root of the kit
$(PREFIX)/Makefile: ./Makefile rm -rf $@ cp $< $@
ifeq ($(TARGET), $(HOST)) # To build with dtrace support, the build needs access to the dtrace executable from the # sysroot. Generally we don't want to add binaries in the sysroot to the path, but # luckily this seems to execute well enough on a different host Linux distro, so symlink # it into the main bin dir.
$(PREFIX)/bin/dtrace:
@echo'Creating dtrace soft link'
ln -s ../$(HOST)/sysroot/usr/bin/dtrace $@
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.