aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlns <matzeton@googlemail.com>2018-08-24 13:16:16 +0200
committerlns <matzeton@googlemail.com>2018-08-24 13:16:16 +0200
commit0cbc10658d0f8e1e00909c94fa66fbcd83701b86 (patch)
tree542b9d92a57c3a2a6dba9095f537e6a8dac9f6b6
linux kernel build
Signed-off-by: lns <matzeton@googlemail.com>
-rw-r--r--Makefile54
1 files changed, 54 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a6a711a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,54 @@
+BUILDJOBS ?= 5
+THIS_DIR=$(realpath .)
+
+DL_DIR=$(THIS_DIR)/dl
+BUILD_DIR=$(THIS_DIR)/build
+
+ROOT_DIR=$(THIS_DIR)/root
+STAGING_DIR=$(THIS_DIR)/staging
+
+LINUX_DL_PREFIX=https://cdn.kernel.org/pub/linux/kernel/v4.x
+LINUX_DL_BASENAME=linux
+LINUX_DL_VERSION=4.18
+LINUX_DL_SUFFIX=tar.xz
+LINUX_DL_URL=$(LINUX_DL_PREFIX)/$(LINUX_DL_BASENAME)-$(LINUX_DL_VERSION).$(LINUX_DL_SUFFIX)
+LINUX_DL_FILE=$(DL_DIR)/$(LINUX_DL_BASENAME)-$(LINUX_DL_VERSION).$(LINUX_DL_SUFFIX)
+LINUX_BUILD_DIR=$(BUILD_DIR)/linux-$(LINUX_DL_VERSION)
+
+all: pre dl extract build
+
+pre:
+ mkdir -p $(DL_DIR)
+ mkdir -p $(BUILD_DIR)
+ mkdir -p $(LINUX_BUILD_DIR)
+
+$(LINUX_DL_FILE):
+ wget '$(LINUX_DL_URL)' -O '$@' || (rm -f '$(LINUX_DL_FILE)' && false)
+
+dl: pre $(LINUX_DL_FILE)
+
+$(LINUX_BUILD_DIR)/Makefile:
+ tar --strip-components=1 -C '$(LINUX_BUILD_DIR)' -xvf '$(LINUX_DL_FILE)' || (rm -rf '$(LINUX_BUILD_DIR)' && false)
+
+extract: dl $(LINUX_BUILD_DIR)/Makefile
+
+$(LINUX_BUILD_DIR)/vmlinux:
+ make -C '$(LINUX_BUILD_DIR)' allnoconfig
+ echo 'CONFIG_64BIT=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_BLK_DEV_INITRD=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_EXPERT=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_BINFMT_ELF=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_BINFMT_SCRIPT=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_DEVTMPFS=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_DEVTMPFS_MOUNT=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_TTY=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_VT=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_VT_CONSOLE=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_SERIAL_8250=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_SERIAL_8250_CONSOLE=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_PROC_FS=y' >>'$(LINUX_BUILD_DIR)/.config'
+ echo 'CONFIG_SYSFS=y' >>'$(LINUX_BUILD_DIR)/.config'
+ make -C '$(LINUX_BUILD_DIR)' menuconfig
+ make -C '$(LINUX_BUILD_DIR)' -j$(BUILDJOBS)
+
+build: extract $(LINUX_BUILD_DIR)/vmlinux