summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2014-10-19 21:06:25 +0200
committerAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2014-10-19 21:06:25 +0200
commit15e53a0f5a4b793833d9779b18af3edf65957fd1 (patch)
tree6c7c13a181c5d86eba61ac2b1ab5bd74f5907f54 /core
parent6e585adec4594ca504f913c1f036635bc00bf898 (diff)
downloadembtoolkit-15e53a0f5a4b793833d9779b18af3edf65957fd1.tar.gz
embtoolkit-15e53a0f5a4b793833d9779b18af3edf65957fd1.tar.bz2
embtoolkit-15e53a0f5a4b793833d9779b18af3edf65957fd1.tar.xz
TOolchain: split linux Makefile and move it to toolchain dir
Signed-off-by: Abdoulaye Walsimou Gaye <awg@embtoolkit.org>
Diffstat (limited to 'core')
-rw-r--r--core/toolchain/core.mk8
-rw-r--r--core/toolchain/linux/common.mk48
-rw-r--r--core/toolchain/linux/headers.mk52
-rw-r--r--core/toolchain/linux/linux.mk (renamed from core/mk/linux.mk)111
4 files changed, 133 insertions, 86 deletions
diff --git a/core/toolchain/core.mk b/core/toolchain/core.mk
index a52bf88..1008936 100644
--- a/core/toolchain/core.mk
+++ b/core/toolchain/core.mk
@@ -128,9 +128,13 @@ include core/toolchain/libcxxrt/libcxxrt.mk
include core/toolchain/llvm/libc++/libcxx.mk
#
-# linux kernel headers
+# linux kernel
#
-include core/mk/linux.mk
+include core/toolchain/linux/common.mk
+include core/toolchain/linux/headers.mk
+ifeq ($(CONFIG_EMBTK_BUILD_LINUX_KERNEL),y)
+include core/toolchain/linux/linux.mk
+endif
#
# C library
diff --git a/core/toolchain/linux/common.mk b/core/toolchain/linux/common.mk
new file mode 100644
index 0000000..1f8c98c
--- /dev/null
+++ b/core/toolchain/linux/common.mk
@@ -0,0 +1,48 @@
+################################################################################
+# 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 linux.mk
+# \brief common variables and macros for linux kernel
+# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
+# \date May 2009
+################################################################################
+
+pembtk_linux_site = $(or $(pembtk_linux_site_mirror),$(pembtk_linux_site_full))
+pembtk_linux_site_mirror = $(call embtk_uquote,$(CONFIG_EMBTK_LINUX_HAVE_MIRROR))
+pembtk_linux_site_full = $(pembtk_linux_site_base)/$(LINUX_MAJORV)$(pembtk_linux_longterm_v)
+pembtk_linux_site_base = http://ftp.kernel.org/pub/linux/kernel
+pembtk_linux_longterm_v = $(if $(LINUX_LONGTERMV),/longterm/$(LINUX_LONGTERMV))
+
+LINUX_NAME := linux
+LINUX_MAJORV := $(call embtk_pkg_version,linux_major)
+LINUX_LONGTERMV := $(call embtk_pkg_version,linux_longterm)
+LINUX_VERSION := $(call embtk_pkg_version,linux)
+LINUX_SITE := $(pembtk_linux_site)
+LINUX_PACKAGE := linux-$(LINUX_VERSION).tar.xz
+LINUX_SRC_DIR := $(embtk_toolsb)/linux-$(LINUX_VERSION)
+LINUX_BUILD_DIR := $(embtk_toolsb)/linux-$(LINUX_VERSION)
+LINUX_KEEP_SRC_DIR := $(CONFIG_EMBTK_BUILD_LINUX_KERNEL)
+
+#
+# common make options
+#
+LINUX_MAKE_OPTS := quiet=quiet_
+LINUX_MAKE_OPTS += ARCH=$(LINUX_ARCH)
+LINUX_MAKE_OPTS += CROSS_COMPILE=$(CROSS_COMPILE_CACHED)
+LINUX_MAKE_OPTS += HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)"
diff --git a/core/toolchain/linux/headers.mk b/core/toolchain/linux/headers.mk
new file mode 100644
index 0000000..866d039
--- /dev/null
+++ b/core/toolchain/linux/headers.mk
@@ -0,0 +1,52 @@
+################################################################################
+# 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 headers.mk
+# \brief linux headers installation
+# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
+# \date May 2009
+################################################################################
+
+LINUX_HEADERS_NAME := linux
+LINUX_HEADERS_VERSION := $(LINUX_VERSION)
+LINUX_HEADERS_SITE := $(LINUX_SITE)
+LINUX_HEADERS_PACKAGE := $(LINUX_PACKAGE)
+LINUX_HEADERS_SRC_DIR := $(LINUX_SRC_DIR)
+LINUX_HEADERS_BUILD_DIR := $(LINUX_BUILD_DIR)
+LINUX_HEADERS_KEEP_SRC_DIR := $(LINUX_KEEP_SRC_DIR)
+LINUX_HEADERS_KCONFIGS_NAME := LINUX
+
+#
+# linux headers install
+#
+ifeq ($(embtk_buildhost_os),macos)
+define embtk_beforeinstall_linux_headers
+ cp $(EMBTK_ROOT)/scripts/unifdef.c \
+ $(LINUX_HEADERS_SRC_DIR)/scripts/unifdef.c
+endef
+endif
+
+define embtk_install_linux_headers
+ $(MAKE) -C $(LINUX_HEADERS_BUILD_DIR) $(LINUX_MAKE_OPTS) \
+ INSTALL_HDR_PATH=$(embtk_sysroot)/usr headers_install
+endef
+
+define embtk_cleanup_linux_headers
+ [ -d $(LINUX_BUILD_DIR) ] && $(call __embtk_unsetinstalled_pkg,linux_headers) ||:
+endef
diff --git a/core/mk/linux.mk b/core/toolchain/linux/linux.mk
index f7811f1..06cd5c8 100644
--- a/core/mk/linux.mk
+++ b/core/toolchain/linux/linux.mk
@@ -18,85 +18,18 @@
################################################################################
#
# \file linux.mk
-# \brief linux.mk of Embtoolkit
+# \brief linux image and module build/install
# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
# \date May 2009
################################################################################
-__LINUX_SITE_BASE = http://ftp.kernel.org/pub/linux/kernel
-__LINUX_SITE_LONGTERM = $(strip $(if $(LINUX_LONGTERMV), \
- /longterm/$(LINUX_LONGTERMV)))
-__LINUX_SITE = $(strip $(if $(CONFIG_EMBTK_LINUX_HAVE_MIRROR), \
- $(patsubst '"',,$(strip $(CONFIG_EMBTK_LINUX_HAVE_MIRROR_SITE))), \
- $(__LINUX_SITE_BASE)/$(LINUX_MAJORV)$(__LINUX_SITE_LONGTERM)))
-
-#
-# linux kernel part
-#
-LINUX_NAME := linux
-LINUX_MAJORV := $(call embtk_get_pkgversion,linux_major)
-LINUX_LONGTERMV := $(call embtk_get_pkgversion,linux_longterm)
-LINUX_VERSION := $(call embtk_get_pkgversion,linux)
-LINUX_SITE := $(call __LINUX_SITE)
-LINUX_PACKAGE := linux-$(LINUX_VERSION).tar.xz
-LINUX_SRC_DIR := $(embtk_toolsb)/linux-$(LINUX_VERSION)
-LINUX_BUILD_DIR := $(embtk_toolsb)/linux-$(LINUX_VERSION)
-LINUX_KEEP_SRC_DIR := $(CONFIG_EMBTK_BUILD_LINUX_KERNEL)
-
-#
-# linux headers part
-#
-LINUX_HEADERS_NAME := linux
-LINUX_HEADERS_VERSION := $(LINUX_VERSION)
-LINUX_HEADERS_SITE := $(LINUX_SITE)
-LINUX_HEADERS_PACKAGE := $(LINUX_PACKAGE)
-LINUX_HEADERS_SRC_DIR := $(LINUX_SRC_DIR)
-LINUX_HEADERS_BUILD_DIR := $(LINUX_BUILD_DIR)
-LINUX_HEADERS_KCONFIGS_NAME := LINUX
-LINUX_HEADERS_KEEP_SRC_DIR := $(CONFIG_EMBTK_BUILD_LINUX_KERNEL)
-
-#
-# linux modules part
-#
-LINUX_MODULES_NAME := linux
-LINUX_MODULES_VERSION := $(LINUX_VERSION)
-LINUX_MODULES_SITE := $(LINUX_SITE)
-LINUX_MODULES_PACKAGE := $(LINUX_PACKAGE)
-LINUX_MODULES_SRC_DIR := $(LINUX_SRC_DIR)
-LINUX_MODULES_BUILD_DIR := $(LINUX_BUILD_DIR)
-LINUX_MODULES_KCONFIGS_NAME := LINUX
-LINUX_MODULES_KEEP_SRC_DIR := $(CONFIG_EMBTK_BUILD_LINUX_KERNEL)
-
-#
-# common options
-#
-LINUX_MAKE_OPTS := quiet=quiet_
-LINUX_MAKE_OPTS += ARCH=$(LINUX_ARCH)
-LINUX_MAKE_OPTS += CROSS_COMPILE=$(CROSS_COMPILE_CACHED)
-LINUX_MAKE_OPTS += HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)"
-
-#
-# linux headers install
-#
-ifeq ($(embtk_buildhost_os),macos)
-define embtk_beforeinstall_linux_headers
- cp $(EMBTK_ROOT)/scripts/unifdef.c \
- $(LINUX_HEADERS_SRC_DIR)/scripts/unifdef.c
-endef
-endif
-
-define embtk_install_linux_headers
- $(MAKE) -C $(LINUX_BUILD_DIR) $(LINUX_MAKE_OPTS) \
- INSTALL_HDR_PATH=$(embtk_sysroot)/usr headers_install
-endef
-
#
# linux install macros
#
-pembtk_linux_dotconfig_f := $(call __embtk_mk_uquote,$(CONFIG_EMBTK_LINUX_DOTCONFIG))
+pembtk_linux_dotconfig_f := $(call embtk_uquote,$(CONFIG_EMBTK_LINUX_DOTCONFIG))
pembtk_linux_extsrc-y := $(CONFIG_EMBTK_LINUX_BUILD_USE_EXTSRC)
-pembtk_linux_srcdir := $(call __embtk_mk_uquote,$(or $(CONFIG_EMBTK_LINUX_BUILD_EXTSRC),$(LINUX_SRC_DIR)))
+pembtk_linux_srcdir := $(call embtk_uquote,$(or $(CONFIG_EMBTK_LINUX_BUILD_EXTSRC),$(LINUX_SRC_DIR)))
pembtk_linux_modules-y := $(shell grep MODULES=y "$(pembtk_linux_dotconfig_f)" 2>/dev/null)
define pembtk_linux_check_dotconfig
@@ -121,6 +54,13 @@ define pembtk_linux_check_extsrc
fi
endef
+ifeq ($(embtk_buildhost_os),macos)
+define embtk_beforeinstall_linux
+ cp $(EMBTK_ROOT)/scripts/unifdef.c \
+ $(LINUX_SRC_DIR)/scripts/unifdef.c
+endef
+endif
+
pembtk_linux_generated := $(embtk_generated)/linux-images-$(GNU_TARGET)-$(EMBTK_MCU_FLAG)
pembtk_linux_generated/boot := $(pembtk_linux_generated)/boot
pembtk_linux_generated/boot/dts := $(pembtk_linux_generated/boot)/dts
@@ -144,15 +84,29 @@ define embtk_install_linux
for b in $(pembtk_linux_bootfiles); do \
if [ -e $$b ]; then cp $$b $(pembtk_linux_generated/boot); fi; \
done
- for b in $$(ls $(pembtk_linux_bootdir)/dts/*.dtb 2>/dev/null); \
+ for b in $$(ls $(pembtk_linux_bootdir)/dts/*.dtb 2>/dev/null); \
do \
cp $$b $(pembtk_linux_generated/boot/dts); \
done
endef
+define embtk_cleanup_linux
+ [ -d $(LINUX_BUILD_DIR) ] && $(call __embtk_unsetinstalled_pkg,linux) ||:
+ rm -rf $(pembtk_linux_generated)
+endef
+
#
-# linux modules install
+# linux modules part
#
+LINUX_MODULES_NAME := linux
+LINUX_MODULES_VERSION := $(LINUX_VERSION)
+LINUX_MODULES_SITE := $(LINUX_SITE)
+LINUX_MODULES_PACKAGE := $(LINUX_PACKAGE)
+LINUX_MODULES_SRC_DIR := $(LINUX_SRC_DIR)
+LINUX_MODULES_BUILD_DIR := $(LINUX_BUILD_DIR)
+LINUX_MODULES_KCONFIGS_NAME := LINUX
+LINUX_MODULES_KEEP_SRC_DIR := $(LINUX_KEEP_SRC_DIR)
+
define embtk_install_linux_modules
$(if $(pembtk_linux_modules-y),$(pembtk_install_linux_modules))
endef
@@ -162,23 +116,12 @@ define pembtk_install_linux_modules
$(MAKE) -C $(pembtk_linux_srcdir) $(LINUX_MAKE_OPTS) \
INSTALL_MOD_PATH=$(embtk_rootfs) modules_install
endef
+
define embtk_postinstall_linux_modules
rm -rf $(embtk_rootfs)/lib/modules/*/build
rm -rf $(embtk_rootfs)/lib/modules/*/source
endef
-#
-# clean target and macros
-#
-define embtk_cleanup_linux
- [ -d $(LINUX_BUILD_DIR) ] && $(call __embtk_unsetinstalled_pkg,linux) ||:
- rm -rf $(pembtk_linux_generated)
-endef
-
-define embtk_cleanup_linux_headers
- [ -d $(LINUX_BUILD_DIR) ] && $(call __embtk_unsetinstalled_pkg,linux_headers) ||:
-endef
-
define embtk_cleanup_linux_modules
[ -d $(LINUX_BUILD_DIR) ] && $(call __embtk_unsetinstalled_pkg,linux_modules) ||:
endef