summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2014-09-16 17:05:11 +0200
committerAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2014-09-16 17:55:22 +0200
commit4486889aee04ebc524bd8f1b8e258d52d7116331 (patch)
treea8f3e51c06441777ecc78a458ba4e8f82ec8af77
parenta0c5a351297a85ccc32f7f1353a86b91e3f561f2 (diff)
downloadembtoolkit-4486889aee04ebc524bd8f1b8e258d52d7116331.tar.gz
embtoolkit-4486889aee04ebc524bd8f1b8e258d52d7116331.tar.bz2
embtoolkit-4486889aee04ebc524bd8f1b8e258d52d7116331.tar.xz
Toolchain: split makefile into {common,core,addons}.mk for better readability
Signed-off-by: Abdoulaye Walsimou Gaye <awg@embtoolkit.org>
-rw-r--r--core/toolchain/addons.mk87
-rw-r--r--core/toolchain/common.mk102
-rw-r--r--core/toolchain/core.mk122
-rw-r--r--core/toolchain/toolchain.mk237
4 files changed, 327 insertions, 221 deletions
diff --git a/core/toolchain/addons.mk b/core/toolchain/addons.mk
new file mode 100644
index 0000000..3ef7b8a
--- /dev/null
+++ b/core/toolchain/addons.mk
@@ -0,0 +1,87 @@
+################################################################################
+# Embtoolkit
+# Copyright(C) 2009-2014 Abdoulaye Walsimou GAYE.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+################################################################################
+#
+# \file addons.mk
+# \brief Toolchain addons part
+# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
+# \date September 2014
+################################################################################
+
+TOOLCHAIN_ADDONS_NAME := toolchain_addons
+TOOLCHAIN_ADDONS_SRC_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain_addons
+TOOLCHAIN_ADDONS_BUILD_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain_addons
+
+# Include .kconfig symbols if any
+-include $(call __embtk_pkg_dotkconfig_f,toolchain_addons)
+
+#
+# Addon: strace
+#
+TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HAVE_STRACE) += strace_install
+
+#
+# Addon: gdb
+#
+TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HAVE_GDB) += gdb_install
+TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HAVE_GDBSERVER) += gdbserver_install
+TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HOST_HAVE_GDB) += gdb_host_install
+
+TOOLCHAIN_ADDONS_DEPS := $(TOOLCHAIN_ADDONS-y)
+
+
+#
+# Toolchain addons build recipe
+#
+__embtk_toolchain_addons-y = $(patsubst %_install,%,$(TOOLCHAIN_ADDONS-y))
+__embtk_toolchain_addons-n = $(patsubst %_install,%,$(TOOLCHAIN_ADDONS-))
+__embtk_toolsaddons_build_msg = $(call embtk_pinfo,"Building new $(GNU_TARGET)/$(EMBTK_MCU_FLAG) toolchain ADDONS - please wait...")
+
+define __embtk_toolchain_addons_build
+ $(__embtk_toolsaddons_build_msg)
+ $(call __embtk_unsetinstalled_pkg,toolchain_addons)
+ $(call __embtk_unsetdecompressed_pkg,toolchain_addons)
+ $(__embtk_toolchain_mkinitdirs)
+ $(if $(findstring core,$(1)),,
+ $(foreach rootfspkg,$(__embtk_rootfs_pkgs-y),
+ $(call embtk_cleanup_pkg,$(rootfspkg)))
+ $(foreach rootfsnpkg,$(__embtk_rootfs_pkgs-n),
+ $(call embtk_cleanup_pkg,$(rootfsnpkg)))
+ $(___embtk_toolchain_decompress))
+ $(if $(findstring core,$(1)),
+ $(foreach addon,$(__embtk_toolchain_addons-y),
+ $(call embtk_cleanup_pkg,$(addon))))
+ $(if $(TOOLCHAIN_ADDONS-),
+ $(foreach addon,$(__embtk_toolchain_addons-n),
+ $(call embtk_cleanup_pkg,$(addon))))
+ $(if $(TOOLCHAIN_ADDONS-y),
+ $(foreach pdep,$(__embtk_toolchain_predeps-y),
+ $(call embtk_install_xpkg,$(pdep)))
+ $(foreach addon,$(__embtk_toolchain_addons-y),
+ $(call embtk_install_xpkg,$(addon))))
+ $(call __embtk_setinstalled_pkg,toolchain_addons)
+ $(if $(TOOLCHAIN_ADDONS-y),
+ $(call __embtk_pkg_gen_dotkconfig_f,toolchain_addons),
+ $(call __embtk_pkg_setkconfigured,toolchain_addons))
+endef
+
+#
+# Addons Makefile
+#
+include core/mk/strace.mk
+include packages/development/gdb/gdb.mk
diff --git a/core/toolchain/common.mk b/core/toolchain/common.mk
new file mode 100644
index 0000000..8fa54b4
--- /dev/null
+++ b/core/toolchain/common.mk
@@ -0,0 +1,102 @@
+################################################################################
+# Embtoolkit
+# Copyright(C) 2009-2014 Abdoulaye Walsimou GAYE.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+################################################################################
+#
+# \file common.mk
+# \brief Toolchain common variables and macros
+# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
+# \date September 2014
+################################################################################
+
+#
+# Toolchain base directory definition
+#
+__xtools_compiler-$(CONFIG_EMBTK_LLVM_ONLY_TOOLCHAIN) := clangllvm-$(call embtk_pkg_version,llvm_host)
+__xtools_compiler-$(CONFIG_EMBTK_LLVM_DEFAULT_TOOLCHAIN) := clangllvm-$(call embtk_pkg_version,llvm_host)
+__xtools_compiler-$(CONFIG_EMBTK_GCC_ONLY_TOOLCHAIN) := gcc-$(call embtk_pkg_version,gcc)
+__xtools_compiler-$(CONFIG_EMBTK_GCC_DEFAULT_TOOLCHAIN) := gcc-$(call embtk_pkg_version,gcc)
+__xtools_bins := $(__xtools_compiler-y)-$(embtk_clib)-$(embtk_clib_version)
+
+TOOLCHAIN_DIR := $(embtk_generated)/toolchains/toolchain-$(__xtools_archos)-$(__xtools_bins)-$(__xtools_env)
+
+#
+# Toolchain pre-dependencies
+#
+TOOLCHAIN_PREDEPS-y := ccache_host_install
+TOOLCHAIN_PREDEPS-y += m4_host_install
+TOOLCHAIN_PREDEPS-y += libtool_host_install
+TOOLCHAIN_PREDEPS-y += autoconf_host_install
+TOOLCHAIN_PREDEPS-y += automake_host_install
+TOOLCHAIN_PREDEPS-y += pkgconf_host_install
+ifeq ($(embtk_buildhost_os_type),bsd)
+TOOLCHAIN_PREDEPS-y += gsed_host_install gmake_host_install
+endif
+TOOLCHAIN_PREDEPS-$(CONFIG_EMBTK_TOOLCHAIN_PREDEP_GPERF_HOST) += gperf_host_install
+
+#
+# Toolchain macros evaluating if core and addons need to be built
+#
+__embtk_toolchain_runrecipe-y = $(strip $(___embtk_toolchain_runrecipe-y))
+define ___embtk_toolchain_runrecipe-y
+ $(eval __xtool_changed-y := $(call __embtk_pkg_runrecipe-y,toolchain))
+ $(eval __xtool_exists-y := $(if $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)),,y))
+ $(eval __xtool_runrecipe-y := $(or $(__xtool_changed-y),$(__xtool_exists-y)))$(__xtool_runrecipe-y)
+endef
+
+__embtk_toolchain_addons_runrecipe-y = $(strip $(___embtk_toolchain_addons_runrecipe-y))
+define ___embtk_toolchain_addons_runrecipe-y
+ $(eval __xtool_addons_changed-y := $(call __embtk_pkg_runrecipe-y,toolchain_addons))
+ $(eval __xtool_exists-y := $(if $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)),,y))
+ $(eval __xtool_runrecipe-y := $(or $(__xtool_addons_changed-y),$(__xtool_exists-y)))$(__xtool_runrecipe-y)
+endef
+
+#
+# Toolchain needed directories creation
+#
+define __embtk_toolchain_mkinitdirs
+ mkdir -p $(embtk_generated)
+ mkdir -p $(TOOLCHAIN_DIR)
+ mkdir -p $(TOOLCHAIN_ADDONS_BUILD_DIR)
+ $(__embtk_mk_initsysrootdirs)
+ $(__embtk_mk_inittoolsdirs)
+ $(__embtk_mk_inithosttoolsdirs)
+ $(__embtk_mk_initpkgdirs)
+endef
+
+#
+# Toolchain compress/uncompress macros
+#
+define __embtk_toolchain_compress
+ cd $(embtk_generated); \
+ tar -cjf $(TOOLCHAIN_PACKAGE) \
+ $(notdir $(embtk_sysroot)) $(notdir $(embtk_tools)) && \
+ mv $(TOOLCHAIN_PACKAGE) $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)
+endef
+
+define __embtk_toolchain_decompress
+ $(if $(call __embtk_pkg_notdecompressed-y,toolchain),
+ $(call embtk_pinfo,"Decompressing cached $(GNU_TARGET)/$(EMBTK_MCU_FLAG) toolchain - please wait...")
+ $(___embtk_toolchain_decompress)
+ $(call __embtk_setdecompressed_pkg,toolchain))
+endef
+define ___embtk_toolchain_decompress
+ rm -rf $(embtk_sysroot) $(embtk_tools)
+ cd $(embtk_generated) && tar xjf $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)
+ $(__embtk_toolchain_mkinitdirs)
+ $(MAKE) $(TOOLCHAIN_PREDEPS-y)
+endef
diff --git a/core/toolchain/core.mk b/core/toolchain/core.mk
new file mode 100644
index 0000000..f1bbc8e
--- /dev/null
+++ b/core/toolchain/core.mk
@@ -0,0 +1,122 @@
+################################################################################
+# Embtoolkit
+# Copyright(C) 2009-2014 Abdoulaye Walsimou GAYE.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+################################################################################
+#
+# \file core.mk
+# \brief Toolchain core part
+# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
+# \date September 2014
+################################################################################
+
+TOOLCHAIN_NAME := toolchain
+TOOLCHAIN_VERSION := $(HOST_ARCH)-target-$(__xtools_archos)-$(__xtools_bins)-$(__xtools_env)
+TOOLCHAIN_PACKAGE := toolchain-$(TOOLCHAIN_VERSION).tar.bz2
+TOOLCHAIN_SRC_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain
+TOOLCHAIN_BUILD_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain
+
+# Include .kconfig symbols if any
+-include $(call __embtk_pkg_dotkconfig_f,toolchain)
+
+__embtk_xtool_gcc3-$(CONFIG_EMBTK_GCC_ONLY_TOOLCHAIN) := gcc3_install
+__embtk_xtool_gcc3-$(CONFIG_EMBTK_GCC_DEFAULT_TOOLCHAIN) := gcc3_install
+
+# FIXME: When libc++ will be used with clang/llvm toolchain, remove this
+__embtk_xtool_gcc3-$(CONFIG_EMBTK_GCC_LANGUAGE_CPP) := gcc3_install
+
+__embtk_xtool_gcc3-$(CONFIG_EMBTK_GCC_LANGUAGE_OBJECTIVEC) := gcc3_install
+__embtk_xtool_gcc3-$(CONFIG_EMBTK_GCC_LANGUAGE_OBJECTIVECPP) := gcc3_install
+
+#
+# FIXME:
+# 1- Handle clang/llvm/uClibc based toolchain where linuxthread.old is used or
+# no threading is used at all.
+# 2- Handle clang/llvm/musl MIPS based toolchain
+#
+
+ifeq ($(CONFIG_EMBTK_HAVE_COMPILER-RT)$(CONFIG_KEMBTK_UCLIBC_LINUXTHREADS_OLD),yy)
+else ifeq ($(CONFIG_EMBTK_HAVE_COMPILER-RT)$(CONFIG_KEMBTK_UCLIBC_LINUXTHREADS_OLD),yy)
+else ifeq ($(CONFIG_EMBTK_HAVE_COMPILER-RT)$(CONFIG_EMBTK_CLIB_MUSL)$(CONFIG_EMBTK_ARCH_MIPS),yyy)
+else
+__embtk_xtool_compiler-rt-$(CONFIG_EMBTK_HAVE_COMPILER-RT) := compiler-rt_install
+endif
+
+TOOLCHAIN_DEPS-y := linux_headers_install binutils_install
+TOOLCHAIN_DEPS-$(CONFIG_EMBTK_HOST_HAVE_LLVM) += llvm_host_install
+TOOLCHAIN_DEPS-y += gcc1_install
+TOOLCHAIN_DEPS-$(CONFIG_EMBTK_CLIB_UCLIBC) += $(embtk_clib)_headers_install gcc2_install
+TOOLCHAIN_DEPS-y += $(embtk_clib)_install
+TOOLCHAIN_DEPS-y += $(__embtk_xtool_gcc3-y)
+TOOLCHAIN_DEPS-y += $(__embtk_xtool_compiler-rt-y)
+TOOLCHAIN_DEPS := $(TOOLCHAIN_DEPS-y)
+
+#
+# Toolchain core build recipe
+#
+__embtk_toolchain_deps-y = $(patsubst %_install,%,$(TOOLCHAIN_DEPS))
+__embtk_toolchain_predeps-y = $(patsubst %_install,%,$(TOOLCHAIN_PREDEPS-y))
+__embtk_toolchain_built_msg = $(call embtk_pinfo,"New $(GNU_TARGET)/$(EMBTK_MCU_FLAG) toolchain successfully built!")
+__embtk_toolchain_building_msg = $(call embtk_pinfo,"Building new $(GNU_TARGET)/$(EMBTK_MCU_FLAG) CORE toolchain - please wait...")
+
+define __embtk_toolchain_core_build
+ $(__embtk_toolchain_building_msg)
+ $(call __embtk_unsetinstalled_pkg,toolchain)
+ $(call __embtk_unsetdecompressed_pkg,toolchain)
+ $(foreach dep,$(__embtk_toolchain_deps-y),
+ $(call embtk_cleanup_pkg,$(dep)))
+ $(foreach pkg,$(__embtk_rootfs_pkgs-y),
+ $(call embtk_cleanup_pkg,$(pkg)))
+ $(foreach pkgn,$(__embtk_rootfs_pkgs-n),
+ $(call embtk_cleanup_pkg,$(pkgn)))
+ rm -rf $(embtk_sysroot) $(embtk_tools)
+ $(__embtk_toolchain_mkinitdirs)
+ $(foreach pdep,$(__embtk_toolchain_predeps-y),
+ $(call embtk_install_xpkg,$(pdep)))
+ $(foreach dep,$(__embtk_toolchain_deps-y),
+ $(call embtk_install_xpkg,$(dep)))
+ $(call __embtk_setinstalled_pkg,toolchain)
+ $(call __embtk_pkg_gen_dotkconfig_f,toolchain)
+endef
+
+#
+# binutils
+#
+include core/toolchain/binutils/binutils.mk
+
+#
+# GCC
+#
+include core/toolchain/gcc/gcc.mk
+
+#
+# llvm/clang compiler infrastructure
+#
+include core/toolchain/llvm/clang/clang.mk
+include core/toolchain/llvm/llvm/llvm.mk
+include core/toolchain/llvm/compiler-rt/compiler-rt.mk
+include core/toolchain/libcxxrt/libcxxrt.mk
+include core/toolchain/llvm/libc++/libcxx.mk
+
+#
+# linux kernel headers
+#
+include core/mk/linux.mk
+
+#
+# C library
+#
+-include core/mk/$(embtk_clib).mk
diff --git a/core/toolchain/toolchain.mk b/core/toolchain/toolchain.mk
index 9fdf391..e85293b 100644
--- a/core/toolchain/toolchain.mk
+++ b/core/toolchain/toolchain.mk
@@ -28,226 +28,26 @@ embtk_pkgincdir := toolchain
# Toolchain variables and macros
#
include core/toolchain/vars.mk
+include core/toolchain/common.mk
+
include packages/htools/ccache/vars.mk
include packages/htools/m4/vars.mk
include packages/htools/libtool/vars.mk
include packages/htools/autoconf/vars.mk
include packages/htools/automake/vars.mk
-__embtk_toolchain_runrecipe-y = $(strip $(___embtk_toolchain_runrecipe-y))
-define ___embtk_toolchain_runrecipe-y
- $(eval __xtool_changed-y := $(call __embtk_pkg_runrecipe-y,toolchain))
- $(eval __xtool_exists-y := $(if $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)),,y))
- $(eval __xtool_runrecipe-y := $(or $(__xtool_changed-y),$(__xtool_exists-y)))$(__xtool_runrecipe-y)
-endef
-
-__embtk_toolchain_addons_runrecipe-y = $(strip $(___embtk_toolchain_addons_runrecipe-y))
-define ___embtk_toolchain_addons_runrecipe-y
- $(eval __xtool_addons_changed-y := $(call __embtk_pkg_runrecipe-y,toolchain_addons))
- $(eval __xtool_exists-y := $(if $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)),,y))
- $(eval __xtool_runrecipe-y := $(or $(__xtool_addons_changed-y),$(__xtool_exists-y)))$(__xtool_runrecipe-y)
-endef
-
-#
-# binutils
-#
-include core/toolchain/binutils/binutils.mk
-
-#
-# GCC
-#
-include core/toolchain/gcc/gcc.mk
-
-#
-# llvm/clang compiler infrastructure
-#
-include core/toolchain/llvm/clang/clang.mk
-include core/toolchain/llvm/llvm/llvm.mk
-include core/toolchain/llvm/compiler-rt/compiler-rt.mk
-include core/toolchain/libcxxrt/libcxxrt.mk
-include core/toolchain/llvm/libc++/libcxx.mk
-
-#
-# linux kernel headers
-#
-include core/mk/linux.mk
-
-#
-# toolchain addon: strace
-#
-include core/mk/strace.mk
-TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HAVE_STRACE) += strace_install
-
-#
-# toolchain addon: gdb
-#
-include packages/development/gdb/gdb.mk
-TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HAVE_GDB) += gdb_install
-TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HAVE_GDBSERVER) += gdbserver_install
-TOOLCHAIN_ADDONS-$(CONFIG_EMBTK_HOST_HAVE_GDB) += gdb_host_install
-
-#
-# Autotools
-#
-AUTOTOOLS_INSTALL := m4_host_install libtool_host_install
-AUTOTOOLS_INSTALL += autoconf_host_install automake_host_install
-
-# BSD make
-include core/mk/bmake.mk
-
-#
-# Toolchain internal virtual packages
-#
-__xtools_compiler-$(CONFIG_EMBTK_LLVM_ONLY_TOOLCHAIN) := clangllvm-$(LLVM_HOST_VERSION)
-__xtools_compiler-$(CONFIG_EMBTK_LLVM_DEFAULT_TOOLCHAIN) := clangllvm-$(LLVM_HOST_VERSION)
-__xtools_compiler-$(CONFIG_EMBTK_GCC_ONLY_TOOLCHAIN) := gcc-$(GCC_VERSION)
-__xtools_compiler-$(CONFIG_EMBTK_GCC_DEFAULT_TOOLCHAIN) := gcc-$(GCC_VERSION)
-__xtools_bins := $(__xtools_compiler-y)-$(embtk_clib)-$(embtk_clib_version)
-
-# Toolchain virtual package
-TOOLCHAIN_NAME := toolchain
-TOOLCHAIN_VERSION := $(HOST_ARCH)-target-$(__xtools_archos)-$(__xtools_bins)-$(__xtools_env)
-TOOLCHAIN_PACKAGE := toolchain-$(TOOLCHAIN_VERSION).tar.bz2
-TOOLCHAIN_DIR := $(embtk_generated)/toolchains/toolchain-$(__xtools_archos)-$(__xtools_bins)-$(__xtools_env)
-TOOLCHAIN_SRC_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain
-TOOLCHAIN_BUILD_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain
-
-TOOLCHAIN_PREDEPS-y := ccache_host_install $(AUTOTOOLS_INSTALL) pkgconf_host_install
-ifeq ($(embtk_buildhost_os_type),bsd)
-TOOLCHAIN_PREDEPS-y += gsed_host_install gmake_host_install
-endif
-TOOLCHAIN_PREDEPS-$(CONFIG_EMBTK_TOOLCHAIN_PREDEP_GPERF_HOST) += gperf_host_install
-
-__embtk_toolchain_gcc3-$(CONFIG_EMBTK_GCC_ONLY_TOOLCHAIN) := gcc3_install
-__embtk_toolchain_gcc3-$(CONFIG_EMBTK_GCC_DEFAULT_TOOLCHAIN) := gcc3_install
-
-# FIXME: When libc++ will be used with clang/llvm toolchain, remove this
-__embtk_toolchain_gcc3-$(CONFIG_EMBTK_GCC_LANGUAGE_CPP) := gcc3_install
-
-__embtk_toolchain_gcc3-$(CONFIG_EMBTK_GCC_LANGUAGE_OBJECTIVEC) := gcc3_install
-__embtk_toolchain_gcc3-$(CONFIG_EMBTK_GCC_LANGUAGE_OBJECTIVECPP) := gcc3_install
-
-#
-# FIXME:
-# 1- Handle clang/llvm/uClibc based toolchain where linuxthread.old is used or
-# no threading is used at all.
-# 2- Handle clang/llvm/musl MIPS based toolchain
-#
-
-ifeq ($(CONFIG_EMBTK_HAVE_COMPILER-RT)$(CONFIG_KEMBTK_UCLIBC_LINUXTHREADS_OLD),yy)
-else ifeq ($(CONFIG_EMBTK_HAVE_COMPILER-RT)$(CONFIG_KEMBTK_UCLIBC_LINUXTHREADS_OLD),yy)
-else ifeq ($(CONFIG_EMBTK_HAVE_COMPILER-RT)$(CONFIG_EMBTK_CLIB_MUSL)$(CONFIG_EMBTK_ARCH_MIPS),yyy)
-else
-__llvm_compiler-rt-$(CONFIG_EMBTK_HAVE_COMPILER-RT) := compiler-rt_install
-endif
-
-TOOLCHAIN_DEPS-y := linux_headers_install binutils_install
-TOOLCHAIN_DEPS-$(CONFIG_EMBTK_HOST_HAVE_LLVM) += llvm_host_install
-TOOLCHAIN_DEPS-y += gcc1_install
-TOOLCHAIN_DEPS-$(CONFIG_EMBTK_CLIB_UCLIBC) += $(embtk_clib)_headers_install gcc2_install
-TOOLCHAIN_DEPS-y += $(embtk_clib)_install
-TOOLCHAIN_DEPS-y += $(__embtk_toolchain_gcc3-y) $(__llvm_compiler-rt-y)
-TOOLCHAIN_DEPS := $(TOOLCHAIN_DEPS-y)
-
-# toolchain addons virtual package
-TOOLCHAIN_ADDONS_NAME := toolchain_addons
-TOOLCHAIN_ADDONS_DEPS := $(TOOLCHAIN_ADDONS-y)
-TOOLCHAIN_ADDONS_SRC_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain_addons
-TOOLCHAIN_ADDONS_BUILD_DIR := $(TOOLCHAIN_DIR)/.embtk-toolchain_addons
-
--include core/mk/$(embtk_clib).mk
-
-define __embtk_toolchain_mkinitdirs
- mkdir -p $(embtk_generated)
- mkdir -p $(TOOLCHAIN_DIR)
- mkdir -p $(TOOLCHAIN_ADDONS_BUILD_DIR)
- $(__embtk_mk_initsysrootdirs)
- $(__embtk_mk_inittoolsdirs)
- $(__embtk_mk_inithosttoolsdirs)
- $(__embtk_mk_initpkgdirs)
-endef
-
-define __embtk_toolchain_compress
- cd $(embtk_generated); \
- tar -cjf $(TOOLCHAIN_PACKAGE) \
- $(notdir $(embtk_sysroot)) $(notdir $(embtk_tools)) && \
- mv $(TOOLCHAIN_PACKAGE) $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)
-endef
-
-define ___embtk_toolchain_decompress
- rm -rf $(embtk_sysroot) $(embtk_tools)
- cd $(embtk_generated) && tar xjf $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)
- $(__embtk_toolchain_mkinitdirs)
- $(MAKE) $(TOOLCHAIN_PREDEPS-y)
-endef
-
-define __embtk_toolchain_decompress
- $(if $(call __embtk_pkg_notdecompressed-y,toolchain),
- $(call embtk_pinfo,"Decompressing cached $(GNU_TARGET)/$(EMBTK_MCU_FLAG) toolchain - please wait...")
- $(___embtk_toolchain_decompress)
- $(call __embtk_setdecompressed_pkg,toolchain))
-endef
-
-__embtk_toolchain_deps-y = $(patsubst %_install,%,$(TOOLCHAIN_DEPS))
-__embtk_toolchain_predeps-y = $(patsubst %_install,%,$(TOOLCHAIN_PREDEPS-y))
-__embtk_toolchain_addons-y = $(patsubst %_install,%,$(TOOLCHAIN_ADDONS-y))
-__embtk_toolchain_addons-n = $(patsubst %_install,%,$(TOOLCHAIN_ADDONS-))
-__embtk_toolchain_built_msg = $(call embtk_pinfo,"New $(GNU_TARGET)/$(EMBTK_MCU_FLAG) toolchain successfully built!")
-__embtk_toolchain_building_msg = $(call embtk_pinfo,"Building new $(GNU_TARGET)/$(EMBTK_MCU_FLAG) CORE toolchain - please wait...")
-__embtk_toolsaddons_build_msg = $(call embtk_pinfo,"Building new $(GNU_TARGET)/$(EMBTK_MCU_FLAG) toolchain ADDONS - please wait...")
-
-define __embtk_toolchain_build_core
- $(__embtk_toolchain_building_msg)
- $(call __embtk_unsetinstalled_pkg,toolchain)
- $(call __embtk_unsetdecompressed_pkg,toolchain)
- $(foreach dep,$(__embtk_toolchain_deps-y),
- $(call embtk_cleanup_pkg,$(dep)))
- $(foreach pkg,$(__embtk_rootfs_pkgs-y),
- $(call embtk_cleanup_pkg,$(pkg)))
- $(foreach pkgn,$(__embtk_rootfs_pkgs-n),
- $(call embtk_cleanup_pkg,$(pkgn)))
- rm -rf $(embtk_sysroot) $(embtk_tools)
- $(__embtk_toolchain_mkinitdirs)
- $(foreach pdep,$(__embtk_toolchain_predeps-y),
- $(call embtk_install_xpkg,$(pdep)))
- $(foreach dep,$(__embtk_toolchain_deps-y),
- $(call embtk_install_xpkg,$(dep)))
- $(call __embtk_setinstalled_pkg,toolchain)
- $(call __embtk_pkg_gen_dotkconfig_f,toolchain)
-endef
-
-define __embtk_toolchain_build_addons
- $(__embtk_toolsaddons_build_msg)
- $(call __embtk_unsetinstalled_pkg,toolchain_addons)
- $(call __embtk_unsetdecompressed_pkg,toolchain_addons)
- $(__embtk_toolchain_mkinitdirs)
- $(if $(findstring core,$(1)),,
- $(foreach rootfspkg,$(__embtk_rootfs_pkgs-y),
- $(call embtk_cleanup_pkg,$(rootfspkg)))
- $(foreach rootfsnpkg,$(__embtk_rootfs_pkgs-n),
- $(call embtk_cleanup_pkg,$(rootfsnpkg)))
- $(___embtk_toolchain_decompress))
- $(if $(findstring core,$(1)),
- $(foreach addon,$(__embtk_toolchain_addons-y),
- $(call embtk_cleanup_pkg,$(addon))))
- $(if $(TOOLCHAIN_ADDONS-),
- $(foreach addon,$(__embtk_toolchain_addons-n),
- $(call embtk_cleanup_pkg,$(addon))))
- $(if $(TOOLCHAIN_ADDONS-y),
- $(foreach pdep,$(__embtk_toolchain_predeps-y),
- $(call embtk_install_xpkg,$(pdep)))
- $(foreach addon,$(__embtk_toolchain_addons-y),
- $(call embtk_install_xpkg,$(addon))))
- $(call __embtk_setinstalled_pkg,toolchain_addons)
- $(if $(TOOLCHAIN_ADDONS-y),
- $(call __embtk_pkg_gen_dotkconfig_f,toolchain_addons),
- $(call __embtk_pkg_setkconfigured,toolchain_addons))
-endef
+include core/toolchain/core.mk
+include core/toolchain/addons.mk
define __embtk_toolchain_build
- $(if $(findstring core,$(1)),$(__embtk_toolchain_build_core))
- $(if $(findstring addons,$(1)),$(__embtk_toolchain_build_addons))
- $(if $(findstring core,$(1))$(findstring addons,$(1)),
+ $(eval __xtool_build := $(if $(__embtk_toolchain_runrecipe-y),core))
+ $(eval __xtool_addons_build := $(if $(__embtk_toolchain_addons_runrecipe-y),addons))
+ $(eval __xtool_build_args := $(strip $(__xtool_build) $(__xtool_addons_build)))
+ $(if $(__xtool_build),
+ $(call __embtk_toolchain_core_build,$(__xtool_build_args)))
+ $(if $(__xtool_addons_build),
+ $(call __embtk_toolchain_addons_build,$(__xtool_build_args)))
+ $(if $(__xtool_build_args),
$(call embtk_pinfo,"Packaging new $(GNU_TARGET)/$(EMBTK_MCU_FLAG) toolchain - please wait...")
$(__embtk_toolchain_compress)
$(call __embtk_setdecompressed_pkg,toolchain)
@@ -256,24 +56,22 @@ define __embtk_toolchain_build
$(__embtk_toolchain_decompress))
endef
-__embtk_toolchain_buildargs = $(if $(strip $(__embtk_toolchain_runrecipe-y)),core-addons)
-__embtk_toolchain_buildargs += $(if $(strip $(__embtk_toolchain_addons_runrecipe-y)),addons)
-
toolchain_install:
- $(Q)$(call __embtk_toolchain_build,$(__embtk_toolchain_buildargs))
+ $(Q)$(__embtk_toolchain_build)
define __embtk_toolchain_clean
$(call __embtk_unsetdecompressed_pkg,toolchain)
+ $(call __embtk_unsetdecompressed_pkg,toolchain_addons)
endef
toolchain_clean:
$(Q)$(__embtk_toolchain_clean)
pembtk_toolchain_mkinitdirs:
- $(call __embtk_toolchain_mkinitdirs)
+ $(__embtk_toolchain_mkinitdirs)
pembtk_toolchain_predeps_install:
- $(call __embtk_toolchain_mkinitdirs)
+ $(__embtk_toolchain_mkinitdirs)
$(MAKE) $(TOOLCHAIN_PREDEPS-y)
# Download target for offline build
@@ -281,6 +79,3 @@ TOOLCHAIN_ALL_DEPS := $(TOOLCHAIN_PREDEPS-y) $(TOOLCHAIN_DEPS)
TOOLCHAIN_ALL_DEPS += $(TOOLCHAIN_ADDONS_DEPS)
packages_fetch:: $(patsubst %_install,download_%,$(TOOLCHAIN_ALL_DEPS))
-
--include $(call __embtk_pkg_dotkconfig_f,toolchain)
--include $(call __embtk_pkg_dotkconfig_f,toolchain_addons)