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
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
XGCC_DIR = ../obj_gcc/gcc
|
2016-05-01 07:36:28 +02:00
|
|
|
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
|
|
|
|
|
2016-12-29 20:40:40 +01:00
|
|
|
ifneq ($(findstring powerpc64,$(TARGET)),)
|
|
|
|
GCC_CONFIG_FOR_TARGET += --with-abi=elfv2
|
|
|
|
endif
|
|
|
|
|
2016-05-19 05:15:32 +02:00
|
|
|
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
|
|
|
|
|
2018-02-28 16:36:47 +01:00
|
|
|
ifneq ($(findstring s390x,$(TARGET)),)
|
|
|
|
GCC_CONFIG_FOR_TARGET += --with-long-double-128
|
|
|
|
endif
|
|
|
|
|
2016-05-19 05:15:32 +02:00
|
|
|
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
|
|
|
|
|
2018-02-28 03:56:48 +01:00
|
|
|
ifneq ($(LIBTOOL),)
|
2018-10-30 04:01:00 +01:00
|
|
|
LIBTOOL_ARG = LIBTOOL=$(LIBTOOL)
|
2018-02-28 03:56:48 +01:00
|
|
|
endif
|
2016-05-19 05:15:32 +02:00
|
|
|
|
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-12-14 18:42:16 +01:00
|
|
|
MAKE += MAKEINFO=false
|
2016-05-02 20:19:19 +02:00
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
FULL_BINUTILS_CONFIG = \
|
|
|
|
$(COMMON_CONFIG) $(BINUTILS_CONFIG) $(TOOLCHAIN_CONFIG) \
|
|
|
|
--disable-werror \
|
|
|
|
--target=$(TARGET) --prefix= \
|
|
|
|
--libdir=/lib --disable-multilib \
|
|
|
|
--with-sysroot=$(SYSROOT)
|
|
|
|
|
|
|
|
FULL_GCC_CONFIG = --enable-languages=c,c++ \
|
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
|
|
|
--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-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 \
|
2017-03-06 03:59:47 +01:00
|
|
|
--enable-deterministic-archives \
|
2016-05-06 20:37:09 +02:00
|
|
|
--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)
|
|
|
|
|
2017-06-11 01:47:23 +02:00
|
|
|
ifneq ($(NATIVE),)
|
|
|
|
HOST:=$(TARGET)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(HOST),)
|
2016-05-06 05:00:35 +02:00
|
|
|
SYSROOT = /$(TARGET)
|
2018-02-26 22:02:16 +01:00
|
|
|
FULL_GCC_CONFIG += --with-build-sysroot=$(CURDIR)/obj_sysroot \
|
|
|
|
AR_FOR_TARGET=$(PWD)/obj_binutils/binutils/ar \
|
|
|
|
AS_FOR_TARGET=$(PWD)/obj_binutils/gas/as-new \
|
|
|
|
LD_FOR_TARGET=$(PWD)/obj_binutils/ld/ld-new \
|
|
|
|
NM_FOR_TARGET=$(PWD)/obj_binutils/binutils/nm-new \
|
|
|
|
OBJCOPY_FOR_TARGET=$(PWD)/obj_binutils/binutils/objcopy \
|
|
|
|
OBJDUMP_FOR_TARGET=$(PWD)/obj_binutils/binutils/objdump \
|
|
|
|
RANLIB_FOR_TARGET=$(PWD)/obj_binutils/binutils/ranlib \
|
|
|
|
READELF_FOR_TARGET=$(PWD)/obj_binutils/binutils/readelf \
|
|
|
|
STRIP_FOR_TARGET=$(PWD)/obj_binutils/binutils/strip-new \
|
|
|
|
# end
|
|
|
|
FULL_MUSL_CONFIG += CC="$(XGCC)" LIBCC="../obj_gcc/$(TARGET)/libgcc/libgcc.a"
|
|
|
|
MUSL_VARS = AR=../obj_binutils/binutils/ar RANLIB=../obj_binutils/binutils/ranlib
|
|
|
|
obj_musl/.lc_configured: | obj_gcc/gcc/.lc_built
|
|
|
|
obj_musl/.lc_built: | obj_gcc/$(TARGET)/libgcc/libgcc.a
|
|
|
|
obj_gcc/gcc/.lc_built: | obj_sysroot/usr obj_sysroot/lib32 obj_sysroot/lib64 obj_sysroot/include
|
|
|
|
obj_gcc/.lc_built: | obj_sysroot/.lc_libs obj_sysroot/.lc_headers
|
|
|
|
obj_gcc/.lc_configured: obj_binutils/.lc_built
|
2016-05-06 05:00:35 +02:00
|
|
|
else
|
|
|
|
SYSROOT = /
|
2018-02-26 22:02:16 +01:00
|
|
|
FULL_BINUTILS_CONFIG += --host=$(HOST)
|
|
|
|
FULL_GCC_CONFIG += --host=$(HOST)
|
2016-05-06 05:00:35 +02:00
|
|
|
MUSL_VARS =
|
|
|
|
endif
|
2016-05-01 07:36:28 +02:00
|
|
|
|
|
|
|
ifeq ($(TARGET),)
|
|
|
|
|
|
|
|
all:
|
|
|
|
@echo TARGET must be set.
|
|
|
|
@exit 1
|
|
|
|
|
|
|
|
install: all
|
|
|
|
|
|
|
|
else
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
all: musl gcc binutils
|
2016-05-01 07:36:28 +02:00
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
install: install-musl install-gcc install-binutils
|
2016-05-01 07:36:28 +02:00
|
|
|
|
|
|
|
musl: obj_musl/.lc_built
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
toolchain: gcc binutils
|
|
|
|
|
|
|
|
install-toolchain: install-gcc install-binutils
|
|
|
|
|
|
|
|
gcc: obj_gcc/.lc_built
|
|
|
|
|
|
|
|
binutils: obj_binutils/.lc_built
|
2016-05-01 07:36:28 +02:00
|
|
|
|
|
|
|
.PHONY: all musl toolchain install-musl install-toolchain clean
|
|
|
|
|
|
|
|
src_binutils: | $(BINUTILS_SRCDIR)
|
|
|
|
ln -sf $(BINUTILS_SRCDIR) $@
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
src_gcc_base: | $(GCC_SRCDIR)
|
2016-05-01 07:36:28 +02:00
|
|
|
ln -sf $(GCC_SRCDIR) $@
|
|
|
|
|
|
|
|
src_musl: | $(MUSL_SRCDIR)
|
|
|
|
ln -sf $(MUSL_SRCDIR) $@
|
|
|
|
|
2016-05-02 19:45:22 +02:00
|
|
|
ifneq ($(GMP_SRCDIR),)
|
2018-02-26 22:02:16 +01:00
|
|
|
src_gcc: 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),)
|
2018-02-26 22:02:16 +01:00
|
|
|
src_gcc: 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),)
|
2018-02-26 22:02:16 +01:00
|
|
|
src_gcc: 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),)
|
2018-02-26 22:02:16 +01:00
|
|
|
src_gcc: src_isl
|
2016-05-22 13:27:05 +02:00
|
|
|
src_isl: | $(ISL_SRCDIR)
|
|
|
|
ln -sf "$(ISL_SRCDIR)" $@
|
|
|
|
endif
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
src_gcc: src_gcc_base
|
2016-05-01 07:36:28 +02:00
|
|
|
rm -rf $@ $@.tmp
|
|
|
|
mkdir $@.tmp
|
2018-02-26 22:02:16 +01:00
|
|
|
cd $@.tmp && ln -sf ../src_gcc_base/* .
|
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 . $@
|
|
|
|
|
2017-06-11 03:24:12 +02:00
|
|
|
obj_sysroot/lib32: | obj_sysroot
|
|
|
|
ln -sf lib $@
|
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
obj_sysroot/lib64: | obj_sysroot
|
|
|
|
ln -sf lib $@
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
obj_binutils/.lc_configured: | obj_binutils src_binutils
|
|
|
|
cd obj_binutils && ../src_binutils/configure $(FULL_BINUTILS_CONFIG)
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
obj_binutils/.lc_built: | obj_binutils/.lc_configured
|
2018-10-30 04:01:00 +01:00
|
|
|
cd obj_binutils && $(MAKE) MAKE="$(MAKE) $(LIBTOOL_ARG)" all
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
obj_gcc/.lc_configured: | obj_gcc src_gcc
|
|
|
|
cd obj_gcc && ../src_gcc/configure $(FULL_GCC_CONFIG)
|
|
|
|
touch $@
|
|
|
|
|
2018-10-31 03:35:07 +01:00
|
|
|
obj_gcc/gcc/.lc_built: | obj_gcc/.lc_configured
|
2018-02-28 03:56:48 +01:00
|
|
|
cd obj_gcc && $(MAKE) MAKE="$(MAKE) $(LIBTOOL_ARG)" all-gcc
|
2016-05-01 07:36:28 +02:00
|
|
|
touch $@
|
|
|
|
|
2016-12-03 10:58:12 +01:00
|
|
|
obj_musl/.lc_configured: | 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 $@
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
obj_gcc/$(TARGET)/libgcc/libgcc.a: | obj_sysroot/.lc_headers
|
2018-02-28 03:56:48 +01:00
|
|
|
cd obj_gcc && $(MAKE) MAKE="$(MAKE) enable_shared=no $(LIBTOOL_ARG)" all-target-libgcc
|
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 $@
|
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
obj_gcc/.lc_built: | obj_gcc/.lc_configured obj_gcc/gcc/.lc_built
|
2018-02-28 03:56:48 +01:00
|
|
|
cd obj_gcc && $(MAKE) MAKE="$(MAKE) $(LIBTOOL_ARG)"
|
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
|
|
|
|
2018-02-26 22:02:16 +01:00
|
|
|
install-binutils: | obj_binutils/.lc_built
|
2018-10-30 04:01:00 +01:00
|
|
|
cd obj_binutils && $(MAKE) MAKE="$(MAKE) $(LIBTOOL_ARG)" DESTDIR=$(DESTDIR)$(OUTPUT) install
|
2018-02-26 22:02:16 +01:00
|
|
|
|
|
|
|
install-gcc: | obj_gcc/.lc_built
|
2018-02-28 03:56:48 +01:00
|
|
|
cd obj_gcc && $(MAKE) MAKE="$(MAKE) $(LIBTOOL_ARG)" 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/*)))
|
2017-08-20 22:30:33 +02:00
|
|
|
LINUX_ARCH = $(lastword $(foreach a,$(LINUX_ARCH_LIST),$(if $(filter $(a)%,$(TARGET_ARCH_MANGLED)),$(a))))
|
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-12-03 08:56:06 +01:00
|
|
|
find obj_kernel_headers/staged/include '(' -name .install -o -name ..install.cmd ')' -exec rm {} +
|
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_*
|