From 15e53a0f5a4b793833d9779b18af3edf65957fd1 Mon Sep 17 00:00:00 2001 From: Abdoulaye Walsimou Gaye Date: Sun, 19 Oct 2014 21:06:25 +0200 Subject: TOolchain: split linux Makefile and move it to toolchain dir Signed-off-by: Abdoulaye Walsimou Gaye --- core/mk/linux.mk | 184 ---------------------------------------- core/toolchain/core.mk | 8 +- core/toolchain/linux/common.mk | 48 +++++++++++ core/toolchain/linux/headers.mk | 52 ++++++++++++ core/toolchain/linux/linux.mk | 127 +++++++++++++++++++++++++++ 5 files changed, 233 insertions(+), 186 deletions(-) delete mode 100644 core/mk/linux.mk create mode 100644 core/toolchain/linux/common.mk create mode 100644 core/toolchain/linux/headers.mk create mode 100644 core/toolchain/linux/linux.mk diff --git a/core/mk/linux.mk b/core/mk/linux.mk deleted file mode 100644 index f7811f1..0000000 --- a/core/mk/linux.mk +++ /dev/null @@ -1,184 +0,0 @@ -################################################################################# -# 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 . -# -################################################################################ -# -# \file linux.mk -# \brief linux.mk of Embtoolkit -# \author Abdoulaye Walsimou GAYE -# \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_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_modules-y := $(shell grep MODULES=y "$(pembtk_linux_dotconfig_f)" 2>/dev/null) - -define pembtk_linux_check_dotconfig - if [ "x" = "x$(pembtk_linux_dotconfig_f)" ]; then \ - $(call embtk_perror,"No kernel config file specified"); \ - exit 1; \ - fi - if [ ! -e $(pembtk_linux_dotconfig_f) ]; then \ - $(call embtk_perror,"Kernel config file $(pembtk_linux_dotconfig_f) not found");\ - exit 1; \ - fi -endef - -define pembtk_linux_check_extsrc - if [ "x" = "x$(pembtk_linux_srcdir)" ]; then \ - $(call embtk_perror,"kernel source tree not specified"); \ - exit 1; \ - fi - if [ ! -d $(pembtk_linux_srcdir) ]; then \ - $(call embtk_perror,"kernel source tree $(pembtk_linux_srcdir) not found");\ - exit 1; \ - fi -endef - -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 -pembtk_linux_bootdir := $(pembtk_linux_srcdir)/arch/$(LINUX_ARCH)/boot -pembtk_linux_bootfiles := Image zImage xipImage bootpImage uImage -pembtk_linux_bootfiles += vmlinux.ecoff vmlinux.bin vmlinux.srec -pembtk_linux_bootfiles += uImage.gz - -define embtk_install_linux - $(pembtk_linux_check_dotconfig) - $(if $(pembtk_linux_extsrc-y),$(pembtk_linux_check_extsrc)) - cp $(CONFIG_EMBTK_LINUX_DOTCONFIG) $(pembtk_linux_srcdir)/.config - $(MAKE) -C $(pembtk_linux_srcdir) $(LINUX_MAKE_OPTS) silentoldconfig - $(MAKE) -C $(pembtk_linux_srcdir) $(LINUX_MAKE_OPTS) $(J) - [ -e $(pembtk_linux_generated/boot) ] || \ - install -d $(pembtk_linux_generated/boot) - [ -e $(pembtk_linux_generated/boot/dts) ] || \ - install -d $(pembtk_linux_generated/boot/dts) - cp $(pembtk_linux_srcdir)/vmlinux $(pembtk_linux_generated) - cd $(pembtk_linux_bootdir); \ - 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); \ - do \ - cp $$b $(pembtk_linux_generated/boot/dts); \ - done -endef - -# -# linux modules install -# -define embtk_install_linux_modules - $(if $(pembtk_linux_modules-y),$(pembtk_install_linux_modules)) -endef -define pembtk_install_linux_modules - $(call embtk_pinfo,"Install linux kernel modules...") - $(embtk_install_linux) - $(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 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 . +# +################################################################################ +# +# \file linux.mk +# \brief common variables and macros for linux kernel +# \author Abdoulaye Walsimou GAYE +# \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 . +# +################################################################################ +# +# \file headers.mk +# \brief linux headers installation +# \author Abdoulaye Walsimou GAYE +# \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/toolchain/linux/linux.mk b/core/toolchain/linux/linux.mk new file mode 100644 index 0000000..06cd5c8 --- /dev/null +++ b/core/toolchain/linux/linux.mk @@ -0,0 +1,127 @@ +################################################################################# +# 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 . +# +################################################################################ +# +# \file linux.mk +# \brief linux image and module build/install +# \author Abdoulaye Walsimou GAYE +# \date May 2009 +################################################################################ + +# +# linux install macros +# + +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_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 + if [ "x" = "x$(pembtk_linux_dotconfig_f)" ]; then \ + $(call embtk_perror,"No kernel config file specified"); \ + exit 1; \ + fi + if [ ! -e $(pembtk_linux_dotconfig_f) ]; then \ + $(call embtk_perror,"Kernel config file $(pembtk_linux_dotconfig_f) not found");\ + exit 1; \ + fi +endef + +define pembtk_linux_check_extsrc + if [ "x" = "x$(pembtk_linux_srcdir)" ]; then \ + $(call embtk_perror,"kernel source tree not specified"); \ + exit 1; \ + fi + if [ ! -d $(pembtk_linux_srcdir) ]; then \ + $(call embtk_perror,"kernel source tree $(pembtk_linux_srcdir) not found");\ + exit 1; \ + 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 +pembtk_linux_bootdir := $(pembtk_linux_srcdir)/arch/$(LINUX_ARCH)/boot +pembtk_linux_bootfiles := Image zImage xipImage bootpImage uImage +pembtk_linux_bootfiles += vmlinux.ecoff vmlinux.bin vmlinux.srec +pembtk_linux_bootfiles += uImage.gz + +define embtk_install_linux + $(pembtk_linux_check_dotconfig) + $(if $(pembtk_linux_extsrc-y),$(pembtk_linux_check_extsrc)) + cp $(CONFIG_EMBTK_LINUX_DOTCONFIG) $(pembtk_linux_srcdir)/.config + $(MAKE) -C $(pembtk_linux_srcdir) $(LINUX_MAKE_OPTS) silentoldconfig + $(MAKE) -C $(pembtk_linux_srcdir) $(LINUX_MAKE_OPTS) $(J) + [ -e $(pembtk_linux_generated/boot) ] || \ + install -d $(pembtk_linux_generated/boot) + [ -e $(pembtk_linux_generated/boot/dts) ] || \ + install -d $(pembtk_linux_generated/boot/dts) + cp $(pembtk_linux_srcdir)/vmlinux $(pembtk_linux_generated) + cd $(pembtk_linux_bootdir); \ + 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); \ + 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 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 +define pembtk_install_linux_modules + $(call embtk_pinfo,"Install linux kernel modules...") + $(embtk_install_linux) + $(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 + +define embtk_cleanup_linux_modules + [ -d $(LINUX_BUILD_DIR) ] && $(call __embtk_unsetinstalled_pkg,linux_modules) ||: +endef -- cgit v1.2.3