overhaul build process with litecross, next-gen top-level makefile
This commit is contained in:
parent
b453751480
commit
ee1ebda23e
|
@ -3,4 +3,8 @@
|
||||||
/output/
|
/output/
|
||||||
/binutils-*/
|
/binutils-*/
|
||||||
/gcc-*/
|
/gcc-*/
|
||||||
/musl/
|
/musl-*/
|
||||||
|
/gmp-*/
|
||||||
|
/mpc-*/
|
||||||
|
/mpfr-*/
|
||||||
|
/build-*/
|
||||||
|
|
199
Makefile
199
Makefile
|
@ -2,154 +2,137 @@
|
||||||
OUTPUT = $(PWD)/output
|
OUTPUT = $(PWD)/output
|
||||||
SOURCES = sources
|
SOURCES = sources
|
||||||
|
|
||||||
|
CONFIG_SUB_REV = 3d5db9ebe860
|
||||||
BINUTILS_VER = 2.25.1
|
BINUTILS_VER = 2.25.1
|
||||||
GCC_VER = 5.2.0
|
GCC_VER = 5.2.0
|
||||||
MUSL_TAG = master
|
MUSL_VER = 1.1.14
|
||||||
|
GMP_VER = 6.1.0
|
||||||
|
MPC_VER = 1.0.3
|
||||||
|
MPFR_VER = 3.1.4
|
||||||
|
|
||||||
GNU_SITE = http://ftp.gnu.org/pub/gnu
|
GNU_SITE = https://ftp.gnu.org/pub/gnu
|
||||||
GCC_SITE = $(GNU_SITE)/gcc
|
GCC_SITE = $(GNU_SITE)/gcc
|
||||||
BINUTILS_SITE = $(GNU_SITE)/binutils
|
BINUTILS_SITE = $(GNU_SITE)/binutils
|
||||||
|
GMP_SITE = $(GNU_SITE)/gmp
|
||||||
|
MPC_SITE = $(GNU_SITE)/mpc
|
||||||
|
MPFR_SITE = $(GNU_SITE)/mpfr
|
||||||
|
|
||||||
COMMON_CONFIG = --disable-werror \
|
MUSL_SITE = https://www.musl-libc.org/releases
|
||||||
--target=$(TARGET) --prefix=$(OUTPUT) \
|
MUSL_REPO = git://git.musl-libc.org/musl
|
||||||
--with-sysroot=$(OUTPUT)/$(TARGET)
|
|
||||||
|
|
||||||
BINUTILS_CONFIG = $(COMMON_CONFIG)
|
BUILD_DIR = build-$(TARGET)
|
||||||
GCC_CONFIG = $(COMMON_CONFIG) --enable-tls \
|
|
||||||
--disable-libmudflap --disable-libsanitizer
|
|
||||||
|
|
||||||
GCC0_VARS = CFLAGS="-O0 -g0" CXXFLAGS="-O0 -g0"
|
|
||||||
GCC0_CONFIG = $(GCC_CONFIG) \
|
|
||||||
--with-newlib --disable-libssp --disable-threads \
|
|
||||||
--disable-shared --disable-libgomp --disable-libatomic \
|
|
||||||
--disable-libquadmath --disable-decimal-float --disable-nls \
|
|
||||||
--enable-languages=c
|
|
||||||
|
|
||||||
GCC0_BDIR = $(PWD)/gcc-$(GCC_VER)/build0/gcc
|
|
||||||
GCC0_CC = $(GCC0_BDIR)/xgcc -B $(GCC0_BDIR)
|
|
||||||
|
|
||||||
MUSL_CONFIG = CC="$(GCC0_CC)" --prefix=
|
|
||||||
|
|
||||||
-include config.mak
|
-include config.mak
|
||||||
|
|
||||||
ifeq ($(TARGET),)
|
SRC_DIRS = gcc-$(GCC_VER) binutils-$(BINUTILS_VER) musl-$(MUSL_VER) \
|
||||||
$(error TARGET must be set via config.mak or command line)
|
$(if $(GMP_VER),gmp-$(GMP_VER)) \
|
||||||
endif
|
$(if $(MPC_VER),mpc-$(MPC_VER)) \
|
||||||
|
$(if $(MPFR_VER),mpfr-$(MPFR_VER))
|
||||||
|
|
||||||
all: install_binutils install_musl install_gcc
|
all:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf gcc-$(GCC_VER) binutils-$(BINUTILS_VER) musl
|
rm -rf gcc-* binutils-* musl-* gmp-* mpc-* mpfr-* build-*
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -rf sources
|
rm -rf sources
|
||||||
|
|
||||||
.PHONY: extract_binutils extract_gcc clone_musl
|
|
||||||
.PHONY: configure_binutils configure_gcc0 configure_gcc configure_musl
|
|
||||||
.PHONY: build_binutils build_gcc0 build_gcc build_musl
|
|
||||||
.PHONY: install_binutils install_gcc install_musl
|
|
||||||
|
|
||||||
extract_binutils: binutils-$(BINUTILS_VER)/.mcm_extracted
|
# Rules for downloading and verifying sources. Treat an external SOURCES path as
|
||||||
extract_gcc: gcc-$(GCC_VER)/.mcm_extracted
|
# immutable and do not try to download anything into it.
|
||||||
clone_musl: musl/.mcm_cloned
|
|
||||||
|
|
||||||
configure_binutils: binutils-$(BINUTILS_VER)/.mcm_configured
|
ifeq ($(SOURCES),sources)
|
||||||
configure_gcc0: gcc-$(GCC_VER)/build0/.mcm_configured
|
|
||||||
configure_gcc: gcc-$(GCC_VER)/build/.mcm_configured
|
|
||||||
configure_musl: musl/.mcm_configured
|
|
||||||
|
|
||||||
build_binutils: binutils-$(BINUTILS_VER)/.mcm_built
|
|
||||||
build_gcc0: gcc-$(GCC_VER)/build0/.mcm_built
|
|
||||||
build_gcc: gcc-$(GCC_VER)/build/.mcm_built
|
|
||||||
build_musl: musl/.mcm_built
|
|
||||||
|
|
||||||
install_binutils: binutils-$(BINUTILS_VER)/.mcm_installed
|
|
||||||
install_gcc: gcc-$(GCC_VER)/build/.mcm_installed
|
|
||||||
install_musl: musl/.mcm_installed
|
|
||||||
|
|
||||||
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/gmp*)): SITE = $(GMP_SITE)
|
||||||
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/mpc*)): SITE = $(MPC_SITE)
|
||||||
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/mpfr*)): SITE = $(MPFR_SITE)
|
||||||
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/binutils*)): SITE = $(BINUTILS_SITE)
|
||||||
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/gcc*)): SITE = $(GCC_SITE)/$(basename $(basename $(notdir $@)))
|
||||||
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/musl*)): SITE = $(MUSL_SITE)
|
||||||
|
|
||||||
$(SOURCES):
|
$(SOURCES):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
$(SOURCES)/config.sub: | $(SOURCES)
|
$(SOURCES)/config.sub: | $(SOURCES)
|
||||||
wget -O $@ 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
|
mkdir -p $@.tmp
|
||||||
|
cd $@.tmp && wget -c -O $(notdir $@) "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=$(CONFIG_SUB_REV)"
|
||||||
|
cd $@.tmp && touch $(notdir $@)
|
||||||
|
cd $@.tmp && sha1sum -c $(PWD)/hashes/$(notdir $@).$(CONFIG_SUB_REV).sha1
|
||||||
|
mv $@.tmp/$(notdir $@) $@
|
||||||
|
rm -rf $@.tmp
|
||||||
|
|
||||||
$(SOURCES)/binutils-%: | $(SOURCES)
|
$(SOURCES)/%: hashes/%.sha1 | $(SOURCES)
|
||||||
wget -c -O $@.part $(BINUTILS_SITE)/$(notdir $@)
|
mkdir -p $@.tmp
|
||||||
mv $@.part $@
|
cd $@.tmp && wget -c -O $(notdir $@) $(SITE)/$(notdir $@)
|
||||||
|
cd $@.tmp && touch $(notdir $@)
|
||||||
|
cd $@.tmp && sha1sum -c $(PWD)/hashes/$(notdir $@).sha1
|
||||||
|
mv $@.tmp/$(notdir $@) $@
|
||||||
|
rm -rf $@.tmp
|
||||||
|
|
||||||
$(SOURCES)/gcc-%: | $(SOURCES)
|
endif
|
||||||
wget -c -O $@.part $(GCC_SITE)/$(basename $(basename $(notdir $@)))/$(notdir $@)
|
|
||||||
mv $@.part $@
|
|
||||||
|
|
||||||
|
|
||||||
|
# Rules for extracting and patching sources, or checking them out from git.
|
||||||
|
|
||||||
binutils-$(BINUTILS_VER)/.mcm_extracted: $(SOURCES)/binutils-$(BINUTILS_VER).tar.bz2 $(SOURCES)/config.sub
|
musl-git-%:
|
||||||
tar jxvf $<
|
rm -rf $@.tmp
|
||||||
cat patches/binutils-$(BINUTILS_VER)/* | ( cd binutils-$(BINUTILS_VER) && patch -p1 )
|
git clone -b $(patsubst musl-git-%,%,$@) $(MUSL_REPO) $@.tmp
|
||||||
cp $(SOURCES)/config.sub binutils-$(BINUTILS_VER)
|
cd $@.tmp && git fsck
|
||||||
touch $@
|
mv $@.tmp $@
|
||||||
|
|
||||||
binutils-$(BINUTILS_VER)/.mcm_configured: binutils-$(BINUTILS_VER)/.mcm_extracted
|
%: $(SOURCES)/%.tar.gz | $(SOURCES)/config.sub
|
||||||
test -e binutils-$(BINUTILS_VER)/config.status || ( cd binutils-$(BINUTILS_VER) && ./configure $(BINUTILS_CONFIG) )
|
rm -rf $@.tmp
|
||||||
touch $@
|
mkdir $@.tmp
|
||||||
|
( cd $@.tmp && tar zxvf - ) < $<
|
||||||
|
test ! -d patches/$@ || cat patches/$@/* | ( cd $@.tmp/$@ && patch -p1 )
|
||||||
|
test ! -f $@.tmp/$@/config.sub || cp -f $(SOURCES)/config.sub $@.tmp/$@
|
||||||
|
rm -rf $@
|
||||||
|
touch $@.tmp/$@
|
||||||
|
mv $@.tmp/$@ $@
|
||||||
|
rm -rf $@.tmp
|
||||||
|
|
||||||
binutils-$(BINUTILS_VER)/.mcm_built: binutils-$(BINUTILS_VER)/.mcm_configured
|
%: $(SOURCES)/%.tar.bz2 | $(SOURCES)/config.sub
|
||||||
cd binutils-$(BINUTILS_VER) && $(MAKE)
|
rm -rf $@.tmp
|
||||||
touch $@
|
mkdir $@.tmp
|
||||||
|
( cd $@.tmp && tar jxvf - ) < $<
|
||||||
binutils-$(BINUTILS_VER)/.mcm_installed: binutils-$(BINUTILS_VER)/.mcm_built
|
test ! -d patches/$@ || cat patches/$@/* | ( cd $@.tmp/$@ && patch -p1 )
|
||||||
cd binutils-$(BINUTILS_VER) && $(MAKE) install
|
test ! -f $@.tmp/$@/config.sub || cp -f $(SOURCES)/config.sub $@.tmp/$@
|
||||||
touch $@
|
rm -rf $@
|
||||||
|
touch $@.tmp/$@
|
||||||
|
mv $@.tmp/$@ $@
|
||||||
|
rm -rf $@.tmp
|
||||||
|
|
||||||
|
|
||||||
|
# Rules for building.
|
||||||
|
|
||||||
|
ifeq ($(TARGET),)
|
||||||
|
|
||||||
gcc-$(GCC_VER)/.mcm_extracted: $(SOURCES)/gcc-$(GCC_VER).tar.bz2 $(SOURCES)/config.sub
|
all:
|
||||||
tar jxvf $<
|
@echo TARGET must be set via config.mak or command line.
|
||||||
cat patches/gcc-$(GCC_VER)/* | ( cd gcc-$(GCC_VER) && patch -p1 )
|
@exit 1
|
||||||
cp $(SOURCES)/config.sub gcc-$(GCC_VER)
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
gcc-$(GCC_VER)/build0/.mcm_configured: gcc-$(GCC_VER)/.mcm_extracted | binutils-$(BINUTILS_VER)/.mcm_installed
|
else
|
||||||
mkdir -p gcc-$(GCC_VER)/build0
|
|
||||||
test -e gcc-$(GCC_VER)/build0/config.status || ( cd gcc-$(GCC_VER)/build0 && $(GCC0_VARS) ../configure $(GCC0_CONFIG) )
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
gcc-$(GCC_VER)/build0/.mcm_built: gcc-$(GCC_VER)/build0/.mcm_configured
|
$(BUILD_DIR):
|
||||||
cd gcc-$(GCC_VER)/build0 && $(MAKE)
|
mkdir -p $@
|
||||||
touch $@
|
|
||||||
|
|
||||||
gcc-$(GCC_VER)/build/.mcm_configured: gcc-$(GCC_VER)/.mcm_extracted | binutils-$(BINUTILS_VER)/.mcm_installed musl/.mcm_installed
|
$(BUILD_DIR)/Makefile: | $(BUILD_DIR)
|
||||||
mkdir -p gcc-$(GCC_VER)/build
|
ln -sf ../litecross/Makefile $@
|
||||||
test -e gcc-$(GCC_VER)/build/config.status || ( cd gcc-$(GCC_VER)/build && ../configure $(GCC_CONFIG) )
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
gcc-$(GCC_VER)/build/.mcm_built: gcc-$(GCC_VER)/build/.mcm_configured
|
$(BUILD_DIR)/config.mak: | $(BUILD_DIR)
|
||||||
cd gcc-$(GCC_VER)/build && $(MAKE)
|
printf >$@ -- '%s\n' \
|
||||||
touch $@
|
"MUSL_SRCDIR = ../musl-$(MUSL_VER)" \
|
||||||
|
"GCC_SRCDIR = ../gcc-$(GCC_VER)" \
|
||||||
|
"BINUTILS_SRCDIR = ../binutils-$(BINUTILS_VER)" \
|
||||||
|
$(if $(GMP_VER),"GMP_SRCDIR = ../gmp-$(GMP_VER)") \
|
||||||
|
$(if $(MPC_VER),"MPC_SRCDIR = ../mpc-$(MPC_VER)") \
|
||||||
|
$(if $(MPFR_VER),"MPFR_SRCDIR = ../mpfr-$(MPFR_VER)") \
|
||||||
|
"-include ../config.mak"
|
||||||
|
|
||||||
gcc-$(GCC_VER)/build/.mcm_installed: gcc-$(GCC_VER)/build/.mcm_built
|
all: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
|
||||||
cd gcc-$(GCC_VER)/build && $(MAKE) install
|
cd $(BUILD_DIR) && $(MAKE) $@
|
||||||
touch $@
|
|
||||||
|
|
||||||
|
install: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
|
||||||
|
cd $(BUILD_DIR) && $(MAKE) OUTPUT=$(OUTPUT) $@
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
musl/.mcm_cloned:
|
|
||||||
test -d musl || git clone -b $(MUSL_TAG) git://git.musl-libc.org/musl musl
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
musl/.mcm_configured: musl/.mcm_cloned gcc-$(GCC_VER)/build0/.mcm_built
|
|
||||||
cd musl && ./configure $(MUSL_CONFIG)
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
musl/.mcm_built: musl/.mcm_configured
|
|
||||||
cd musl && $(MAKE) AR=$(OUTPUT)/bin/$(TARGET)-ar RANLIB=$(OUTPUT)/bin/$(TARGET)-ranlib
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
musl/.mcm_installed: musl/.mcm_built
|
|
||||||
cd musl && $(MAKE) install DESTDIR=$(OUTPUT)/$(TARGET)
|
|
||||||
ln -sfn . $(OUTPUT)/$(TARGET)/usr
|
|
||||||
touch $@
|
|
||||||
|
|
140
README.md
140
README.md
|
@ -1,17 +1,117 @@
|
||||||
musl-cross-make
|
musl-cross-make
|
||||||
===============
|
===============
|
||||||
|
|
||||||
This is a quick and simple makefile-based alternative for producing
|
This is a the second generation of musl-cross-make, a fast, simple,
|
||||||
musl-based cross compilers. The current focus is on SH2/J2 Core
|
but advanced makefile-based approach for producing musl-targeting
|
||||||
targets and NOMMU (where PIE or FDPIC is mandatory) since these are
|
cross compilers. Features include:
|
||||||
not adequately supported by other musl cross-compiler toolchain build
|
|
||||||
systems, but all musl-supported targets are intended to work.
|
|
||||||
|
|
||||||
In addition to the build system, musl-cross-make provides a number of
|
- Single-stage GCC build, used to build both musl libc and its own
|
||||||
patches, including:
|
shared target libs depending on libc.
|
||||||
|
|
||||||
- Updated versions of the musl target patches going into upstream GCC
|
- No hard-coded absoluete paths; resulting cross compilers can be
|
||||||
- Static-PIE support and optionally defaulting to PIE
|
copied/moved anywhere.
|
||||||
|
|
||||||
|
- Ability to build multiple cross compilers for different targets
|
||||||
|
using a single set of patched source trees.
|
||||||
|
|
||||||
|
- Nothing is installed until running "make install", and the
|
||||||
|
installation location can be chosen at install time.
|
||||||
|
|
||||||
|
- Automatic download of source packages, including GCC prerequisites
|
||||||
|
(GMP, MPC, MPFR), using https and checking hashes.
|
||||||
|
|
||||||
|
- Automatic patching with canonical musl support patches and patches
|
||||||
|
which provide bug fixes and features musl depends on for some arch
|
||||||
|
targets.
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
|
The build system can be configured by providing a config.mak file in
|
||||||
|
the top-level directory. The only mandatory variable is TARGET, which
|
||||||
|
should contain a gcc target tuple (such as i486-linux-musl), but many
|
||||||
|
more options are available. See the provided config.mak.dist and
|
||||||
|
presets/* for examples.
|
||||||
|
|
||||||
|
To compile, run make. To install to $(OUTPUT), run "make install".
|
||||||
|
|
||||||
|
The default value for $(OUTPUT) is output; after installing here you
|
||||||
|
can move the cross compiler toolchain to another location as desired.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
How it works
|
||||||
|
------------
|
||||||
|
|
||||||
|
The current musl-cross-make is factored into two layers:
|
||||||
|
|
||||||
|
1. The top-level Makefile which is responsible for downloading,
|
||||||
|
verifying, extracting, and patching sources, and for setting up a
|
||||||
|
build directory, and
|
||||||
|
|
||||||
|
2. Litecross, the cross compiler build system, which is itself a
|
||||||
|
Makefile symlinked into the build directory.
|
||||||
|
|
||||||
|
Most of the real magic takes place in litecross. It begins by setting
|
||||||
|
up symlinks to all the source trees provided to it by the caller, then
|
||||||
|
builds a combined "src_toolchain" directory of symlinks that combines
|
||||||
|
the contents of the top-level gcc and binutils source trees and
|
||||||
|
symlinks to gmp, mpc, and mpfr. One configured invocation them
|
||||||
|
configures all the GNU toolchain components together in a manner that
|
||||||
|
does not require any of them to be installed in order for the others
|
||||||
|
to use them.
|
||||||
|
|
||||||
|
Rather than building the whole toolchain tree at once, though,
|
||||||
|
litecross starts by building just the gcc directory and its
|
||||||
|
prerequisites, to get an "xgcc" that can be used to configure musl. It
|
||||||
|
then configures musl, installs musl's headers to a staging "build
|
||||||
|
sysroot", and builds libgcc.a using those headers. At this point it
|
||||||
|
has all the prerequisites to build musl libc.a and libc.so, which the
|
||||||
|
rest of the gcc target-libs depend on; once they are built, the full
|
||||||
|
toolchain "make all" can proceed.
|
||||||
|
|
||||||
|
Litecross does not actually depend on the musl-cross-make top-level
|
||||||
|
build system; it can be used with any pre-extracted, properly patched
|
||||||
|
set of source trees.
|
||||||
|
|
||||||
|
|
||||||
|
Project scope and goals
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
The primary goals of this project are to:
|
||||||
|
|
||||||
|
- Provide canonical musl support patches for GCC and binutils.
|
||||||
|
|
||||||
|
- Serve as a canonical example of how GCC should be built to target
|
||||||
|
musl.
|
||||||
|
|
||||||
|
- Streamline the production of musl-targeting cross compilers so that
|
||||||
|
musl users can easily produce musl-linked applications or bootstrap
|
||||||
|
new systems using musl.
|
||||||
|
|
||||||
|
- Assist musl and toolchain developers in development and testing.
|
||||||
|
|
||||||
|
While the patches applied to GCC and binutils are all intended not to
|
||||||
|
break non-musl configurations, musl-cross-make itself is specific to
|
||||||
|
musl. Changes to add support for exotic target variants outside of
|
||||||
|
what upstream musl supports are probably out-of-scope unless they are
|
||||||
|
non-invasive. Changes to fix issues building musl-cross-make to run on
|
||||||
|
non-Linux systems are well within scope as long as they are clean.
|
||||||
|
|
||||||
|
Most importantly, this is a side project to benefit musl and its
|
||||||
|
users. It's not intended to be something high-maintenance or to divert
|
||||||
|
development effort away from musl itself.
|
||||||
|
|
||||||
|
|
||||||
|
Patches included
|
||||||
|
----------------
|
||||||
|
|
||||||
|
In addition to canonical musl support patches for GCC,
|
||||||
|
musl-cross-make's patch set provides:
|
||||||
|
|
||||||
|
- Static-linked PIE support
|
||||||
|
- Addition of --enable-default-pie
|
||||||
- Fixes for SH-specific bugs and bitrot in GCC
|
- Fixes for SH-specific bugs and bitrot in GCC
|
||||||
- Support for J2 Core CPU target in GCC & binutils
|
- Support for J2 Core CPU target in GCC & binutils
|
||||||
- SH/FDPIC ABI support
|
- SH/FDPIC ABI support
|
||||||
|
@ -22,25 +122,3 @@ build systems, if desired.
|
||||||
|
|
||||||
Some functionality (SH/FDPIC, and support for J2 specific features) is
|
Some functionality (SH/FDPIC, and support for J2 specific features) is
|
||||||
presently only available with gcc 5.2.0 and binutils 2.25.1.
|
presently only available with gcc 5.2.0 and binutils 2.25.1.
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
|
|
||||||
The build system make be configured by providing a config.mak file in
|
|
||||||
the top-level directory. The only mandatory variable is TARGET, which
|
|
||||||
should contain a gcc target tuple (such as sh2eb-linux-musl), but many
|
|
||||||
more options are available. The top-level config.mak.dist file shows
|
|
||||||
examples, and several full configurations are available in presets/*.
|
|
||||||
|
|
||||||
For recent gcc versions that need gmp/mpfr/mpc, suitable versions need
|
|
||||||
to be installed in the default library path, or the appropriate --with
|
|
||||||
configure options need to be added to GCC_CONFIG in config.mak so that
|
|
||||||
the gcc configure process can find them.
|
|
||||||
|
|
||||||
After setting up config.mak, simply run make. Parallel builds are
|
|
||||||
supported.
|
|
||||||
|
|
||||||
The resulting toolchain will be placed ./output by default, or the
|
|
||||||
OUTPUT directory specified in config.mak. It is sysrooted and can be
|
|
||||||
freely moved to a different location.
|
|
||||||
|
|
|
@ -1,14 +1,37 @@
|
||||||
OUTPUT = $(PWD)/output
|
#
|
||||||
TARGET = sh2eb-linux-musl
|
# config.mak.dist - sample musl-cross-make configuration
|
||||||
|
#
|
||||||
|
# Copy to config.mak and edit as desired.
|
||||||
|
#
|
||||||
|
|
||||||
# See the patches directory for supported versions. Versions
|
# There is no default TARGET; you must select one here or on the make
|
||||||
# without patches should not be expected to work until gcc 6.
|
# command line. Some examples:
|
||||||
# Older versions may have known bugs or limited functionality.
|
|
||||||
|
|
||||||
BINUTILS_VER = 2.25.1
|
# TARGET = i486-linux-musl
|
||||||
GCC_VER = 5.2.0
|
# TARGET = x86_64-linux-musl
|
||||||
|
# TARGET = arm-linux-musleabi
|
||||||
|
# TARGET = arm-linux-musleabihf
|
||||||
|
# TARGET = sh2eb-linux-muslfdpic
|
||||||
|
# ...
|
||||||
|
|
||||||
# Recommended options for faster/simpler build
|
# By default, cross compilers are installed to ./output under the top-level
|
||||||
|
# musl-cross-make directory and can later be moved wherever you want them.
|
||||||
|
# To install directly to a specific location, set it here. Multiple targets
|
||||||
|
# can safely be installed in the same location. Some examples:
|
||||||
|
|
||||||
|
# OUTPUT = /opt/cross
|
||||||
|
# OUTPUT = /usr/local
|
||||||
|
|
||||||
|
# By default, latest supported release versions of musl and the toolchain
|
||||||
|
# components are used. You can override those here, but the version selected
|
||||||
|
# must be supported (under hashes/ and patches/) to work. For musl, you
|
||||||
|
# can use "git-refname" (e.g. git-master) instead of a release.
|
||||||
|
|
||||||
|
# BINUTILS_VER = 2.25.1
|
||||||
|
# GCC_VER = 5.2.0
|
||||||
|
# MUSL_VER = git-master
|
||||||
|
|
||||||
|
# Recommended options for faster/simpler build:
|
||||||
|
|
||||||
# COMMON_CONFIG += --disable-nls
|
# COMMON_CONFIG += --disable-nls
|
||||||
# COMMON_CONFIG += MAKEINFO=/bin/false
|
# COMMON_CONFIG += MAKEINFO=/bin/false
|
||||||
|
@ -16,17 +39,19 @@ GCC_VER = 5.2.0
|
||||||
# GCC_CONFIG += --disable-libquadmath --disable-decimal-float
|
# GCC_CONFIG += --disable-libquadmath --disable-decimal-float
|
||||||
# GCC_CONFIG += --disable-multilib
|
# GCC_CONFIG += --disable-multilib
|
||||||
|
|
||||||
# J2/SH2 specific options
|
# The following are options needed to make certain targets work right.
|
||||||
|
# They may be moved to main build logic rather than config.mak at some
|
||||||
|
# point in the future.
|
||||||
|
|
||||||
# GCC_CONFIG += --with-cpu=mj2
|
ifeq ($(TARGET),sh2eb-linux-muslfdpic)
|
||||||
# GCC_CONFIG += --enable-fdpic
|
GCC_CONFIG += --with-cpu=mj2
|
||||||
|
GCC_CONFIG += --enable-fdpic
|
||||||
|
endif
|
||||||
|
|
||||||
# Options for using (plain, non-FDPIC) ELF on NOMMU targets
|
ifeq ($(TARGET),mips64-linux-musl)
|
||||||
|
GCC_CONFIG += --with-abi=64
|
||||||
|
endif
|
||||||
|
|
||||||
# GCC_CONFIG += --enable-default-pie
|
ifeq ($(TARGET),arm-linux-musleabihf)
|
||||||
|
GCC_CONFIG += --with-float=hard
|
||||||
# Last GPLv2 versions
|
endif
|
||||||
|
|
||||||
# GCC_VER = 4.2.1
|
|
||||||
# BINUTILS_VER = 397a64b3
|
|
||||||
# BINUTILS_SITE = http://landley.net/aboriginal/mirror
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1d597ae063e3947a5f61e23ceda8aebf78405fcd binutils-2.25.1.tar.bz2
|
|
@ -0,0 +1 @@
|
||||||
|
f74f1ce2e62c516ba832f99a94289930be7869cf binutils-397a64b3.tar.bz2
|
|
@ -0,0 +1 @@
|
||||||
|
7d66e32bb3cce017e1cc9bef59fb6f8271fb7fec config.sub
|
|
@ -0,0 +1 @@
|
||||||
|
b8a55b13c4e38fae78d5db9a456e2d4ffe003118 gcc-4.2.1.tar.bz2
|
|
@ -0,0 +1 @@
|
||||||
|
f3359a157b3536f289c155363f1736a2c9b414db gcc-4.7.4.tar.bz2
|
|
@ -0,0 +1 @@
|
||||||
|
fe3f5390949d47054b613edc36c557eb1d51c18e gcc-5.2.0.tar.bz2
|
|
@ -0,0 +1 @@
|
||||||
|
db38c7b67f8eea9f2e5b8a48d219165b2fdab11f gmp-6.1.0.tar.bz2
|
|
@ -0,0 +1 @@
|
||||||
|
b8be66396c726fdc36ebb0f692ed8a8cca3bcc66 mpc-1.0.3.tar.gz
|
|
@ -0,0 +1 @@
|
||||||
|
e3b0af77f18505184410d621fe0aae179e229dba mpfr-3.1.4.tar.bz2
|
|
@ -0,0 +1 @@
|
||||||
|
b71208e87e66ac959d0e413dd444279d28a7bff1 musl-1.1.14.tar.gz
|
|
@ -0,0 +1,132 @@
|
||||||
|
|
||||||
|
OUTPUT = $(PWD)/output
|
||||||
|
|
||||||
|
BINUTILS_SRCDIR = BINUTILS_SRCDIR_not_set
|
||||||
|
GCC_SRCDIR = GCC_SRCDIR_not_set
|
||||||
|
MUSL_SRCDIR = MUSL_SRCDIR_not_set
|
||||||
|
|
||||||
|
COMMON_CONFIG =
|
||||||
|
GCC_CONFIG = $(COMMON_CONFIG)
|
||||||
|
TOOLCHAIN_CONFIG = $(GCC_CONFIG)
|
||||||
|
|
||||||
|
XGCC_DIR = ../obj_toolchain/gcc
|
||||||
|
XGCC = $(XGCC_DIR)/xgcc -B $(XGCC_DIR)
|
||||||
|
MUSL_CONFIG = CC="$(XGCC)" LIBCC="../obj_toolchain/$(TARGET)/libgcc/libgcc.a" --prefix=
|
||||||
|
|
||||||
|
-include config.mak
|
||||||
|
|
||||||
|
FULL_TOOLCHAIN_CONFIG = $(TOOLCHAIN_CONFIG) \
|
||||||
|
--disable-werror \
|
||||||
|
--target=$(TARGET) --prefix= \
|
||||||
|
--with-sysroot=/$(TARGET) \
|
||||||
|
--with-build-sysroot='$$(LC_ROOT)/obj_sysroot' \
|
||||||
|
--enable-tls \
|
||||||
|
--disable-libmudflap --disable-libsanitizer
|
||||||
|
|
||||||
|
MUSL_VARS = AR=../obj_toolchain/binutils/ar RANLIB=../obj_toolchain/binutils/ranlib
|
||||||
|
|
||||||
|
ifeq ($(TARGET),)
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo TARGET must be set.
|
||||||
|
@exit 1
|
||||||
|
|
||||||
|
install: all
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
all: musl toolchain
|
||||||
|
|
||||||
|
install: install-musl install-toolchain
|
||||||
|
|
||||||
|
musl: obj_musl/.lc_built
|
||||||
|
|
||||||
|
toolchain: obj_toolchain/.lc_built
|
||||||
|
|
||||||
|
.PHONY: all musl toolchain install-musl install-toolchain clean
|
||||||
|
|
||||||
|
src_binutils: | $(BINUTILS_SRCDIR)
|
||||||
|
ln -sf $(BINUTILS_SRCDIR) $@
|
||||||
|
|
||||||
|
src_gcc: | $(GCC_SRCDIR)
|
||||||
|
ln -sf $(GCC_SRCDIR) $@
|
||||||
|
|
||||||
|
src_musl: | $(MUSL_SRCDIR)
|
||||||
|
ln -sf $(MUSL_SRCDIR) $@
|
||||||
|
|
||||||
|
src_gmp: | $(GMP_SRCDIR)
|
||||||
|
ln -sf "$(GMP_SRCDIR)" $@
|
||||||
|
|
||||||
|
src_mpc: | $(MPC_SRCDIR)
|
||||||
|
ln -sf "$(MPC_SRCDIR)" $@
|
||||||
|
|
||||||
|
src_mpfr: | $(GMP_SRCDIR)
|
||||||
|
ln -sf "$(MPFR_SRCDIR)" $@
|
||||||
|
|
||||||
|
src_toolchain: src_binutils src_gcc src_gmp src_mpc src_mpfr
|
||||||
|
rm -rf $@ $@.tmp
|
||||||
|
mkdir $@.tmp
|
||||||
|
cd $@.tmp && ln -sf ../src_binutils/* .
|
||||||
|
cd $@.tmp && ln -sf ../src_gcc/* .
|
||||||
|
cd $@.tmp && ln -sf ../src_gmp gmp
|
||||||
|
cd $@.tmp && ln -sf ../src_mpc mpc
|
||||||
|
cd $@.tmp && ln -sf ../src_mpfr mpfr
|
||||||
|
mv $@.tmp $@
|
||||||
|
|
||||||
|
obj_%:
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
obj_sysroot/include:
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
obj_sysroot/usr: | obj_sysroot
|
||||||
|
ln -sf . $@
|
||||||
|
|
||||||
|
obj_sysroot/lib64: | obj_sysroot
|
||||||
|
ln -sf lib $@
|
||||||
|
|
||||||
|
obj_toolchain/.lc_configured: | obj_toolchain src_toolchain
|
||||||
|
cd obj_toolchain && ../src_toolchain/configure $(FULL_TOOLCHAIN_CONFIG)
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
obj_toolchain/gcc/.lc_built: | obj_toolchain/.lc_configured obj_sysroot/usr obj_sysroot/lib64 obj_sysroot/include
|
||||||
|
cd obj_toolchain && $(MAKE) LC_ROOT=$(PWD) all-gcc
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
obj_musl/.lc_configured: | obj_toolchain/gcc/.lc_built obj_musl src_musl
|
||||||
|
cd obj_musl && ../src_musl/configure $(MUSL_CONFIG)
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
obj_sysroot/.lc_headers: | obj_musl/.lc_configured obj_sysroot
|
||||||
|
cd obj_musl && $(MAKE) DESTDIR=$(PWD)/obj_sysroot install-headers
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
obj_toolchain/$(TARGET)/libgcc/.lc_configured: | obj_sysroot/.lc_headers
|
||||||
|
cd obj_toolchain && $(MAKE) LC_ROOT=$(PWD) configure-target-libgcc
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
obj_toolchain/$(TARGET)/libgcc/libgcc.a: | obj_toolchain/$(TARGET)/libgcc/.lc_configured
|
||||||
|
cd $(dir $@) && $(MAKE) LC_ROOT=$(PWD) libgcc.a
|
||||||
|
|
||||||
|
obj_musl/.lc_built: | obj_toolchain/$(TARGET)/libgcc/libgcc.a
|
||||||
|
cd obj_musl && $(MAKE) $(MUSL_VARS)
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
obj_sysroot/.lc_libs: | obj_musl/.lc_built
|
||||||
|
cd obj_musl && $(MAKE) $(MUSL_VARS) DESTDIR=$(PWD)/obj_sysroot install
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
obj_toolchain/.lc_built: | obj_toolchain/.lc_configured obj_sysroot/.lc_libs
|
||||||
|
cd obj_toolchain && $(MAKE) LC_ROOT=$(PWD)
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
install-musl: | obj_musl/.lc_built
|
||||||
|
cd obj_musl && $(MAKE) $(MUSL_VARS) DESTDIR=$(DESTDIR)$(OUTPUT)/$(TARGET) install
|
||||||
|
|
||||||
|
install-toolchain: | obj_toolchain/.lc_built
|
||||||
|
cd obj_toolchain && $(MAKE) LC_ROOT=$(PWD) DESTDIR=$(DESTDIR)$(OUTPUT) install
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf src_* obj_*
|
Loading…
Reference in New Issue