diff options
author | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2013-05-01 14:19:15 +0200 |
---|---|---|
committer | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2013-05-01 14:19:15 +0200 |
commit | 3c85cd7e7af49e6d674fd3b7c5171425ee227965 (patch) | |
tree | e962a344c021b384dc8e53c714cb211420ae527a | |
parent | 69f49e3831aabfa6a15b675f4682293c746ab7dc (diff) | |
download | embtoolkit-3c85cd7e7af49e6d674fd3b7c5171425ee227965.tar.gz embtoolkit-3c85cd7e7af49e6d674fd3b7c5171425ee227965.tar.bz2 embtoolkit-3c85cd7e7af49e6d674fd3b7c5171425ee227965.tar.xz |
Build system: Initial support of linux kernel image build
Signed-off-by: Abdoulaye Walsimou Gaye <awg@embtoolkit.org>
-rw-r--r-- | Kconfig | 12 | ||||
-rw-r--r-- | kconfig/linux-kernel-build.kconfig | 57 | ||||
-rw-r--r-- | mk/linux.mk | 72 |
3 files changed, 139 insertions, 2 deletions
@@ -1,6 +1,6 @@ ################################################################################ # Abdoulaye Walsimou GAYE <awg@embtoolkit.org> -# Copyright(C) 2009-2012 Abdoulaye Walsimou GAYE. +# Copyright(C) 2009-2013 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 @@ -74,6 +74,16 @@ menu "Embtoolkit build options and host tools" source kconfig/hosttools-buildopts.kconfig endmenu +if EMBTK_OS_LINUX +config EMBTK_BUILD_LINUX_KERNEL + bool "Build linux kernel image" + +if EMBTK_BUILD_LINUX_KERNEL +source kconfig/linux-kernel-build.kconfig +endif + +endif + config EMBTK_HAVE_ROOTFS bool "Build root filesystem" help diff --git a/kconfig/linux-kernel-build.kconfig b/kconfig/linux-kernel-build.kconfig new file mode 100644 index 0000000..24a8749 --- /dev/null +++ b/kconfig/linux-kernel-build.kconfig @@ -0,0 +1,57 @@ +################################################################################ +# EmbToolkit +# Copyright(C) 2013 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 Kconfig +# \brief linux kernel build options +# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org> +# \date May 2013 +################################################################################ + +menu "Linux kernel Image configuration" + +config EMBTK_LINUX_DOTCONFIG + string "Linux kernel config file" + help + Please specify the linux kernel configuration file for + your target/board. + +choice + prompt "Linux source tree to use" + help + Specify which linux source tree to use. + + config EMBTK_LINUX_BUILD_TOOLCHAIN_SRC + bool "The same used to build the toolchain" + help + Select this option to use the same linux source tree used to + build the toolchain. + + config EMBTK_LINUX_BUILD_USE_EXTSRC + bool "The same used to build the toolchain" + help + Select this option to use an external linux source tree. +endchoice + +config EMBTK_LINUX_BUILD_EXTSRC + string "External linux source tree path" + depends on EMBTK_LINUX_BUILD_USE_EXTSRC + help + Please specify your external linux source tree path. + +endmenu diff --git a/mk/linux.mk b/mk/linux.mk index 0b7d6df..5415cbb 100644 --- a/mk/linux.mk +++ b/mk/linux.mk @@ -1,6 +1,6 @@ ################################################################################# # Embtoolkit -# Copyright(C) 2009-2011 Abdoulaye Walsimou GAYE. +# Copyright(C) 2009-2013 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 @@ -63,6 +63,76 @@ define embtk_install_linux_headers endef # +# linux install macros +# +__embtk_linux_dotconfig_f := $(call __embtk_mk_uquote,$(CONFIG_EMBTK_LINUX_DOTCONFIG)) +__embtk_linux_srcdir := $(call __embtk_mk_uquote,$(or $(CONFIG_EMBTK_LINUX_BUILD_EXTSRC),$(LINUX_SRC_DIR))) +__embtk_linux_support_modules := $(shell grep MODULES=y "$(__embtk_linux_dotconfig_f)" 2>/dev/null) + +define __embtk_install_linux_modules + $(MAKE) -C $(__embtk_linux_srcdir) quiet=quiet_ \ + INSTALL_MOD_PATH=$(embtk_rootfs) \ + ARCH=$(LINUX_ARCH) \ + CROSS_COMPILE=$(CROSS_COMPILE_CACHED) modules_install +endef + +define __embtk_install_linux_check_config + if [ "x" = "x$(__embtk_linux_dotconfig_f)" ]; then \ + $(call embtk_perror,"Unable to build linux kernel image: no config file");\ + exit 1; \ + fi + if [ ! -e $(__embtk_linux_dotconfig_f) ]; then \ + $(call embtk_perror,"Unable to build linux kernel image: config file $(__embtk_linux_dotconfig_f) not found");\ + exit 1; \ + fi +endef + +define __embtk_install_linux_check_extsrc + if [ "x" = "x$(__embtk_linux_srcdir)" ]; then \ + $(call embtk_perror,"Unable to build linux kernel image: External source tree not specified");\ + exit 1; \ + fi + if [ ! -d $(__embtk_linux_srcdir) ]; then \ + $(call embtk_perror,"Unable to build linux kernel image: External source tree $(__embtk_linux_srcdir) not found");\ + exit 1; \ + fi +endef + +define __embtk_install_linux + $(call embtk_pinfo,"Generating linux kernel image...") + $(__embtk_install_linux_check_config) + $(if $(CONFIG_EMBTK_LINUX_BUILD_USE_EXTSRC), + $(__embtk_install_linux_check_extsrc)) + $(if $(CONFIG_EMBTK_LINUX_BUILD_TOOLCHAIN_SRC), + $(call embtk_download_pkg,linux) + $(call embtk_decompress_pkg,linux)) + $(MAKE) -C $(__embtk_linux_srcdir) \ + ARCH=$(LINUX_ARCH) \ + CROSS_COMPILE=$(CROSS_COMPILE_CACHED) distclean + rm -rf $(__embtk_linux_srcdir)/.config + cp $(CONFIG_EMBTK_LINUX_DOTCONFIG) $(__embtk_linux_srcdir)/.config + $(MAKE) -C $(__embtk_linux_srcdir) quiet=quiet_ \ + ARCH=$(LINUX_ARCH) \ + CROSS_COMPILE=$(CROSS_COMPILE_CACHED) silentoldconfig + $(MAKE) -C $(__embtk_linux_srcdir) quiet=quiet_ \ + ARCH=$(LINUX_ARCH) \ + CROSS_COMPILE=$(CROSS_COMPILE_CACHED) $(J) + touch $(call __embtk_pkg_dotinstalled_f,linux) + $(call __embtk_pkg_gen_dotkconfig_f,linux) +endef + +define embtk_install_linux + $(if $(call __embtk_pkg_installed-y,linux),true,$(__embtk_install_linux)) + $(if $(__embtk_linux_support_modules), + $(embtk_postinstall_linux)) +endef + +define embtk_postinstall_linux + $(call embtk_pinfo,"Install linux kernel modules...") + $(__embtk_install_linux_modules) +endef + +# # clean target and macros # define embtk_cleanup_linux |