overhaul build process with litecross, next-gen top-level makefile

This commit is contained in:
Rich Felker 2016-05-01 05:36:28 +00:00
parent b453751480
commit ee1ebda23e
15 changed files with 391 additions and 159 deletions

6
.gitignore vendored
View File

@ -3,4 +3,8 @@
/output/
/binutils-*/
/gcc-*/
/musl/
/musl-*/
/gmp-*/
/mpc-*/
/mpfr-*/
/build-*/

199
Makefile
View File

@ -2,154 +2,137 @@
OUTPUT = $(PWD)/output
SOURCES = sources
CONFIG_SUB_REV = 3d5db9ebe860
BINUTILS_VER = 2.25.1
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
BINUTILS_SITE = $(GNU_SITE)/binutils
GMP_SITE = $(GNU_SITE)/gmp
MPC_SITE = $(GNU_SITE)/mpc
MPFR_SITE = $(GNU_SITE)/mpfr
COMMON_CONFIG = --disable-werror \
--target=$(TARGET) --prefix=$(OUTPUT) \
--with-sysroot=$(OUTPUT)/$(TARGET)
MUSL_SITE = https://www.musl-libc.org/releases
MUSL_REPO = git://git.musl-libc.org/musl
BINUTILS_CONFIG = $(COMMON_CONFIG)
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=
BUILD_DIR = build-$(TARGET)
-include config.mak
ifeq ($(TARGET),)
$(error TARGET must be set via config.mak or command line)
endif
SRC_DIRS = gcc-$(GCC_VER) binutils-$(BINUTILS_VER) musl-$(MUSL_VER) \
$(if $(GMP_VER),gmp-$(GMP_VER)) \
$(if $(MPC_VER),mpc-$(MPC_VER)) \
$(if $(MPFR_VER),mpfr-$(MPFR_VER))
all: install_binutils install_musl install_gcc
all:
clean:
rm -rf gcc-$(GCC_VER) binutils-$(BINUTILS_VER) musl
rm -rf gcc-* binutils-* musl-* gmp-* mpc-* mpfr-* build-*
distclean: clean
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
extract_gcc: gcc-$(GCC_VER)/.mcm_extracted
clone_musl: musl/.mcm_cloned
# Rules for downloading and verifying sources. Treat an external SOURCES path as
# immutable and do not try to download anything into it.
configure_binutils: binutils-$(BINUTILS_VER)/.mcm_configured
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
ifeq ($(SOURCES),sources)
$(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):
mkdir -p $@
$(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)
wget -c -O $@.part $(BINUTILS_SITE)/$(notdir $@)
mv $@.part $@
$(SOURCES)/%: hashes/%.sha1 | $(SOURCES)
mkdir -p $@.tmp
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)
wget -c -O $@.part $(GCC_SITE)/$(basename $(basename $(notdir $@)))/$(notdir $@)
mv $@.part $@
endif
# 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
tar jxvf $<
cat patches/binutils-$(BINUTILS_VER)/* | ( cd binutils-$(BINUTILS_VER) && patch -p1 )
cp $(SOURCES)/config.sub binutils-$(BINUTILS_VER)
touch $@
musl-git-%:
rm -rf $@.tmp
git clone -b $(patsubst musl-git-%,%,$@) $(MUSL_REPO) $@.tmp
cd $@.tmp && git fsck
mv $@.tmp $@
binutils-$(BINUTILS_VER)/.mcm_configured: binutils-$(BINUTILS_VER)/.mcm_extracted
test -e binutils-$(BINUTILS_VER)/config.status || ( cd binutils-$(BINUTILS_VER) && ./configure $(BINUTILS_CONFIG) )
touch $@
%: $(SOURCES)/%.tar.gz | $(SOURCES)/config.sub
rm -rf $@.tmp
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
cd binutils-$(BINUTILS_VER) && $(MAKE)
touch $@
binutils-$(BINUTILS_VER)/.mcm_installed: binutils-$(BINUTILS_VER)/.mcm_built
cd binutils-$(BINUTILS_VER) && $(MAKE) install
touch $@
%: $(SOURCES)/%.tar.bz2 | $(SOURCES)/config.sub
rm -rf $@.tmp
mkdir $@.tmp
( cd $@.tmp && tar jxvf - ) < $<
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
# Rules for building.
ifeq ($(TARGET),)
gcc-$(GCC_VER)/.mcm_extracted: $(SOURCES)/gcc-$(GCC_VER).tar.bz2 $(SOURCES)/config.sub
tar jxvf $<
cat patches/gcc-$(GCC_VER)/* | ( cd gcc-$(GCC_VER) && patch -p1 )
cp $(SOURCES)/config.sub gcc-$(GCC_VER)
touch $@
all:
@echo TARGET must be set via config.mak or command line.
@exit 1
gcc-$(GCC_VER)/build0/.mcm_configured: gcc-$(GCC_VER)/.mcm_extracted | binutils-$(BINUTILS_VER)/.mcm_installed
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 $@
else
gcc-$(GCC_VER)/build0/.mcm_built: gcc-$(GCC_VER)/build0/.mcm_configured
cd gcc-$(GCC_VER)/build0 && $(MAKE)
touch $@
$(BUILD_DIR):
mkdir -p $@
gcc-$(GCC_VER)/build/.mcm_configured: gcc-$(GCC_VER)/.mcm_extracted | binutils-$(BINUTILS_VER)/.mcm_installed musl/.mcm_installed
mkdir -p gcc-$(GCC_VER)/build
test -e gcc-$(GCC_VER)/build/config.status || ( cd gcc-$(GCC_VER)/build && ../configure $(GCC_CONFIG) )
touch $@
$(BUILD_DIR)/Makefile: | $(BUILD_DIR)
ln -sf ../litecross/Makefile $@
gcc-$(GCC_VER)/build/.mcm_built: gcc-$(GCC_VER)/build/.mcm_configured
cd gcc-$(GCC_VER)/build && $(MAKE)
touch $@
$(BUILD_DIR)/config.mak: | $(BUILD_DIR)
printf >$@ -- '%s\n' \
"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
cd gcc-$(GCC_VER)/build && $(MAKE) install
touch $@
all: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
cd $(BUILD_DIR) && $(MAKE) $@
install: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
cd $(BUILD_DIR) && $(MAKE) OUTPUT=$(OUTPUT) $@
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 $@
endif

140
README.md
View File

@ -1,17 +1,117 @@
musl-cross-make
===============
This is a quick and simple makefile-based alternative for producing
musl-based cross compilers. The current focus is on SH2/J2 Core
targets and NOMMU (where PIE or FDPIC is mandatory) since these are
not adequately supported by other musl cross-compiler toolchain build
systems, but all musl-supported targets are intended to work.
This is a the second generation of musl-cross-make, a fast, simple,
but advanced makefile-based approach for producing musl-targeting
cross compilers. Features include:
In addition to the build system, musl-cross-make provides a number of
patches, including:
- Single-stage GCC build, used to build both musl libc and its own
shared target libs depending on libc.
- Updated versions of the musl target patches going into upstream GCC
- Static-PIE support and optionally defaulting to PIE
- No hard-coded absoluete paths; resulting cross compilers can be
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
- Support for J2 Core CPU target in GCC & binutils
- SH/FDPIC ABI support
@ -22,25 +122,3 @@ build systems, if desired.
Some functionality (SH/FDPIC, and support for J2 specific features) is
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.

View File

@ -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
# without patches should not be expected to work until gcc 6.
# Older versions may have known bugs or limited functionality.
# There is no default TARGET; you must select one here or on the make
# command line. Some examples:
BINUTILS_VER = 2.25.1
GCC_VER = 5.2.0
# TARGET = i486-linux-musl
# 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 += MAKEINFO=/bin/false
@ -16,17 +39,19 @@ GCC_VER = 5.2.0
# GCC_CONFIG += --disable-libquadmath --disable-decimal-float
# 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
# GCC_CONFIG += --enable-fdpic
ifeq ($(TARGET),sh2eb-linux-muslfdpic)
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
# Last GPLv2 versions
# GCC_VER = 4.2.1
# BINUTILS_VER = 397a64b3
# BINUTILS_SITE = http://landley.net/aboriginal/mirror
ifeq ($(TARGET),arm-linux-musleabihf)
GCC_CONFIG += --with-float=hard
endif

View File

@ -0,0 +1 @@
1d597ae063e3947a5f61e23ceda8aebf78405fcd binutils-2.25.1.tar.bz2

View File

@ -0,0 +1 @@
f74f1ce2e62c516ba832f99a94289930be7869cf binutils-397a64b3.tar.bz2

View File

@ -0,0 +1 @@
7d66e32bb3cce017e1cc9bef59fb6f8271fb7fec config.sub

View File

@ -0,0 +1 @@
b8a55b13c4e38fae78d5db9a456e2d4ffe003118 gcc-4.2.1.tar.bz2

View File

@ -0,0 +1 @@
f3359a157b3536f289c155363f1736a2c9b414db gcc-4.7.4.tar.bz2

View File

@ -0,0 +1 @@
fe3f5390949d47054b613edc36c557eb1d51c18e gcc-5.2.0.tar.bz2

View File

@ -0,0 +1 @@
db38c7b67f8eea9f2e5b8a48d219165b2fdab11f gmp-6.1.0.tar.bz2

View File

@ -0,0 +1 @@
b8be66396c726fdc36ebb0f692ed8a8cca3bcc66 mpc-1.0.3.tar.gz

View File

@ -0,0 +1 @@
e3b0af77f18505184410d621fe0aae179e229dba mpfr-3.1.4.tar.bz2

View File

@ -0,0 +1 @@
b71208e87e66ac959d0e413dd444279d28a7bff1 musl-1.1.14.tar.gz

132
litecross/Makefile Normal file
View File

@ -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_*