2016-05-01 07:36:28 +02:00
|
|
|
|
2016-12-02 08:14:01 +01:00
|
|
|
OUTPUT = $(CURDIR)/output
|
2016-05-01 07:36:28 +02:00
|
|
|
|
|
|
|
BINUTILS_SRCDIR = BINUTILS_SRCDIR_not_set
|
|
|
|
GCC_SRCDIR = GCC_SRCDIR_not_set
|
|
|
|
MUSL_SRCDIR = MUSL_SRCDIR_not_set
|
|
|
|
|
2016-07-08 04:19:14 +02:00
|
|
|
GCC_CONFIG_FOR_TARGET =
|
|
|
|
COMMON_CONFIG =
|
|
|
|
GCC_CONFIG =
|
|
|
|
TOOLCHAIN_CONFIG =
|
2016-05-01 07:36:28 +02:00
|
|
|
|
|
|
|
XGCC_DIR = ../obj_toolchain/gcc
|
|
|
|
XGCC = $(XGCC_DIR)/xgcc -B $(XGCC_DIR)
|
|
|
|
|
2016-06-22 20:32:56 +02:00
|
|
|
-include config.mak
|
|
|
|
|
2016-05-19 05:15:32 +02:00
|
|
|
ifneq ($(findstring fdpic,$(TARGET)),)
|
2016-07-08 04:19:14 +02:00
|
|
|
GCC_CONFIG_FOR_TARGET += --enable-fdpic
|
2016-05-19 05:15:32 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(filter x86_64%x32,$(TARGET)),)
|
2016-07-08 04:19:14 +02:00
|
|
|
GCC_CONFIG_FOR_TARGET += --with-abi=x32
|
2016-05-19 05:15:32 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(findstring mips64,$(TARGET))$(findstring mipsisa64,$(TARGET)),)
|
|
|
|
ifneq ($(findstring n32,$(TARGET)),)
|
2016-07-08 04:19:14 +02:00
|
|
|
GCC_CONFIG_FOR_TARGET += --with-abi=n32
|
2016-05-19 05:15:32 +02:00
|
|
|
else
|
2016-07-08 04:19:14 +02:00
|
|
|
GCC_CONFIG_FOR_TARGET += --with-abi=64
|
2016-05-19 05:15:32 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(filter %sf,$(TARGET)),)
|
2016-07-08 04:19:14 +02:00
|
|
|
GCC_CONFIG_FOR_TARGET += --with-float=soft
|
2016-05-19 05:15:32 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(filter %hf,$(TARGET)),)
|
2016-07-08 04:19:14 +02:00
|
|
|
GCC_CONFIG_FOR_TARGET += --with-float=hard
|
2016-05-19 05:15:32 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2016-05-06 07:29:07 +02:00
|
|
|
MAKE += MULTILIB_OSDIRNAMES=
|
2016-05-03 06:28:26 +02:00
|
|
|
MAKE += INFO_DEPS= infodir=
|
2016-05-02 20:43:15 +02:00
|
|
|
MAKE += ac_cv_prog_lex_root=lex.yy.c
|
2016-05-02 20:19:19 +02:00
|
|
|
|
2016-07-08 04:19:14 +02:00
|
|
|
FULL_TOOLCHAIN_CONFIG = --enable-languages=c,c++ \
|
|
|
|
$(GCC_CONFIG_FOR_TARGET) \
|
|
|
|
$(COMMON_CONFIG) $(GCC_CONFIG) $(TOOLCHAIN_CONFIG) \
|
2016-05-01 07:36:28 +02:00
|
|
|
--disable-werror \
|
|
|
|
--target=$(TARGET) --prefix= \
|
2016-05-06 07:29:07 +02:00
|
|
|
--libdir=/lib --disable-multilib \
|
2016-05-06 05:00:35 +02:00
|
|
|
--with-sysroot=$(SYSROOT) \
|
2016-12-02 08:14:01 +01:00
|
|
|
--with-build-sysroot=$(CURDIR)/obj_sysroot \
|
2016-05-01 07:36:28 +02:00
|
|
|
--enable-tls \
|
2016-05-06 20:37:09 +02:00
|
|
|
--disable-libmudflap --disable-libsanitizer \
|
|
|
|
--disable-gnu-indirect-function \
|
|
|
|
--disable-libmpx \
|
|
|
|
--enable-libstdcxx-time
|
2016-05-01 07:36:28 +02:00
|
|
|
|
2016-05-06 05:00:35 +02:00
|
|
|
FULL_MUSL_CONFIG = $(MUSL_CONFIG) \
|
|
|
|
--prefix= --host=$(TARGET)
|
|
|
|
|
|
|
|
ifeq ($(NATIVE),)
|
|
|
|
SYSROOT = /$(TARGET)
|
|
|
|
FULL_MUSL_CONFIG += CC="$(XGCC)" LIBCC="../obj_toolchain/$(TARGET)/libgcc/libgcc.a"
|
2016-05-01 07:36:28 +02:00
|
|
|
MUSL_VARS = AR=../obj_toolchain/binutils/ar RANLIB=../obj_toolchain/binutils/ranlib
|
2016-05-06 05:00:35 +02:00
|
|
|
obj_musl/.lc_built: | obj_toolchain/$(TARGET)/libgcc/libgcc.a
|
2016-07-07 02:41:13 +02:00
|
|
|
obj_toolchain/.lc_built: | obj_sysroot/.lc_libs obj_sysroot/.lc_headers
|
2016-05-06 05:00:35 +02:00
|
|
|
else
|
|
|
|
SYSROOT = /
|
|
|
|
FULL_TOOLCHAIN_CONFIG += --host=$(TARGET)
|
|
|
|
MUSL_VARS =
|
|
|
|
endif
|
2016-05-01 07:36:28 +02:00
|
|
|
|
|
|
|
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) $@
|
|
|
|
|
2016-05-02 19:45:22 +02:00
|
|
|
ifneq ($(GMP_SRCDIR),)
|
|
|
|
src_toolchain: src_gmp
|
2016-05-01 07:36:28 +02:00
|
|
|
src_gmp: | $(GMP_SRCDIR)
|
|
|
|
ln -sf "$(GMP_SRCDIR)" $@
|
2016-05-02 19:45:22 +02:00
|
|
|
endif
|
2016-05-01 07:36:28 +02:00
|
|
|
|
2016-05-02 19:45:22 +02:00
|
|
|
ifneq ($(MPC_SRCDIR),)
|
|
|
|
src_toolchain: src_mpc
|
2016-05-01 07:36:28 +02:00
|
|
|
src_mpc: | $(MPC_SRCDIR)
|
|
|
|
ln -sf "$(MPC_SRCDIR)" $@
|
2016-05-02 19:45:22 +02:00
|
|
|
endif
|
2016-05-01 07:36:28 +02:00
|
|
|
|
2016-05-02 19:45:22 +02:00
|
|
|
ifneq ($(MPFR_SRCDIR),)
|
|
|
|
src_toolchain: src_mpfr
|
2016-05-02 07:36:54 +02:00
|
|
|
src_mpfr: | $(MPFR_SRCDIR)
|
2016-05-01 07:36:28 +02:00
|
|
|
ln -sf "$(MPFR_SRCDIR)" $@
|
2016-05-02 19:45:22 +02:00
|
|
|
endif
|
2016-05-01 07:36:28 +02:00
|
|
|
|
2016-05-22 13:27:05 +02:00
|
|
|
ifneq ($(ISL_SRCDIR),)
|
|
|
|
src_toolchain: src_isl
|
|
|
|
src_isl: | $(ISL_SRCDIR)
|
|
|
|
ln -sf "$(ISL_SRCDIR)" $@
|
|
|
|
endif
|
|
|
|
|
2016-05-02 19:45:22 +02:00
|
|
|
src_toolchain: src_binutils src_gcc
|
2016-05-01 07:36:28 +02:00
|
|
|
rm -rf $@ $@.tmp
|
|
|
|
mkdir $@.tmp
|
|
|
|
cd $@.tmp && ln -sf ../src_binutils/* .
|
|
|
|
cd $@.tmp && ln -sf ../src_gcc/* .
|
2016-05-02 19:45:22 +02:00
|
|
|
$(if $(GMP_SRCDIR),cd $@.tmp && ln -sf ../src_gmp gmp)
|
|
|
|
$(if $(MPC_SRCDIR),cd $@.tmp && ln -sf ../src_mpc mpc)
|
|
|
|
$(if $(MPFR_SRCDIR),cd $@.tmp && ln -sf ../src_mpfr mpfr)
|
2016-05-22 13:27:05 +02:00
|
|
|
$(if $(ISL_SRCDIR),cd $@.tmp && ln -sf ../src_isl isl)
|
2016-05-01 07:36:28 +02:00
|
|
|
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
|
2016-07-19 21:43:08 +02:00
|
|
|
cd obj_toolchain && $(MAKE) MAKE="$(MAKE)" all-gcc
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
obj_musl/.lc_configured: | obj_toolchain/gcc/.lc_built obj_musl src_musl
|
2016-05-06 05:00:35 +02:00
|
|
|
cd obj_musl && ../src_musl/configure $(FULL_MUSL_CONFIG)
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
obj_sysroot/.lc_headers: | obj_musl/.lc_configured obj_sysroot
|
2016-12-02 08:14:01 +01:00
|
|
|
cd obj_musl && $(MAKE) DESTDIR=$(CURDIR)/obj_sysroot install-headers
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
obj_toolchain/$(TARGET)/libgcc/.lc_configured: | obj_sysroot/.lc_headers
|
2016-07-19 21:43:08 +02:00
|
|
|
cd obj_toolchain && $(MAKE) MAKE="$(MAKE)" configure-target-libgcc
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
obj_toolchain/$(TARGET)/libgcc/libgcc.a: | obj_toolchain/$(TARGET)/libgcc/.lc_configured
|
2016-07-19 21:43:08 +02:00
|
|
|
cd $(dir $@) && $(MAKE) MAKE="$(MAKE)" libgcc.a
|
2016-05-01 07:36:28 +02:00
|
|
|
|
2016-05-06 05:00:35 +02:00
|
|
|
obj_musl/.lc_built: | obj_musl/.lc_configured
|
2016-05-01 07:36:28 +02:00
|
|
|
cd obj_musl && $(MAKE) $(MUSL_VARS)
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
obj_sysroot/.lc_libs: | obj_musl/.lc_built
|
2016-12-02 08:14:01 +01:00
|
|
|
cd obj_musl && $(MAKE) $(MUSL_VARS) DESTDIR=$(CURDIR)/obj_sysroot install
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
2016-07-07 18:56:18 +02:00
|
|
|
obj_toolchain/.lc_built: | obj_toolchain/.lc_configured obj_toolchain/gcc/.lc_built
|
2016-07-19 21:43:08 +02:00
|
|
|
cd obj_toolchain && $(MAKE) MAKE="$(MAKE)"
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
install-musl: | obj_musl/.lc_built
|
2016-05-06 05:00:35 +02:00
|
|
|
cd obj_musl && $(MAKE) $(MUSL_VARS) DESTDIR=$(DESTDIR)$(OUTPUT)$(SYSROOT) install
|
2016-05-01 07:36:28 +02:00
|
|
|
|
|
|
|
install-toolchain: | obj_toolchain/.lc_built
|
2016-07-19 21:43:08 +02:00
|
|
|
cd obj_toolchain && $(MAKE) MAKE="$(MAKE)" DESTDIR=$(DESTDIR)$(OUTPUT) install
|
2016-05-14 05:09:41 +02:00
|
|
|
ln -sf $(TARGET)-gcc $(DESTDIR)$(OUTPUT)/bin/$(TARGET)-cc
|
2016-05-01 07:36:28 +02:00
|
|
|
|
2016-05-14 06:14:52 +02:00
|
|
|
ifneq ($(LINUX_SRCDIR),)
|
2016-05-14 07:23:25 +02:00
|
|
|
TARGET_ARCH = $(firstword $(subst -, ,$(TARGET)))
|
|
|
|
TARGET_ARCH_MANGLED = $(patsubst i%86,x86,$(patsubst aarch64%,arm64%,$(TARGET_ARCH)))
|
|
|
|
LINUX_ARCH_LIST = $(sort $(notdir $(wildcard $(LINUX_SRCDIR)/arch/*)))
|
|
|
|
LINUX_ARCH = $(firstword $(foreach a,$(LINUX_ARCH_LIST),$(findstring $(a),$(TARGET_ARCH_MANGLED))))
|
2016-05-14 06:14:52 +02:00
|
|
|
ifneq ($(LINUX_ARCH),)
|
|
|
|
all: kernel-headers
|
|
|
|
install: install-kernel-headers
|
2016-05-14 09:34:36 +02:00
|
|
|
kernel-headers: | obj_kernel_headers/.lc_built
|
2016-05-14 06:14:52 +02:00
|
|
|
src_kernel_headers: | $(LINUX_SRCDIR)
|
2016-05-14 09:34:36 +02:00
|
|
|
ln -sf "$(LINUX_SRCDIR)" $@
|
|
|
|
obj_kernel_headers/.lc_built: | src_kernel_headers
|
2016-12-02 08:14:01 +01:00
|
|
|
mkdir -p $(CURDIR)/obj_kernel_headers/staged
|
|
|
|
cd src_kernel_headers && $(MAKE) ARCH=$(LINUX_ARCH) O=$(CURDIR)/obj_kernel_headers INSTALL_HDR_PATH=$(CURDIR)/obj_kernel_headers/staged headers_install
|
2016-05-14 09:34:36 +02:00
|
|
|
touch $@
|
|
|
|
install-kernel-headers: | obj_kernel_headers/.lc_built
|
2016-05-14 06:14:52 +02:00
|
|
|
mkdir -p $(DESTDIR)$(OUTPUT)$(SYSROOT)/include
|
2016-05-14 09:34:36 +02:00
|
|
|
cp -R obj_kernel_headers/staged/include/* $(DESTDIR)$(OUTPUT)$(SYSROOT)/include
|
2016-05-14 06:14:52 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf src_* obj_*
|