Build linux kernel
Take a copy of the linux kernel source repository via
git
softwaregit clone --depth=1 https://github.com/torvalds/linux
or download a zip file from this link - https://github.com/torvalds/linux/archive/refs/heads/master.zip
make menuconfig
Here are the images of the some menuconfig options chosen.

menuconfig

Options

kernel .config support

Module unloading

Kernel Function Tracer
Run
make help
to get the hints and options for building.After that do,
make bzImage
./workspace/linux (master) $ make bzImage
SYSHDR arch/x86/include/generated/uapi/asm/unistd_32.h
...
GZIP arch/x86/boot/compressed/vmlinux.bin.gz
HOSTCC arch/x86/boot/compressed/mkpiggy
MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
CC arch/x86/boot/compressed/cpuflags.o
CC arch/x86/boot/compressed/early_serial_console.o
CC arch/x86/boot/compressed/kaslr.o
CC arch/x86/boot/compressed/ident_map_64.o
CC arch/x86/boot/compressed/idt_64.o
AS arch/x86/boot/compressed/idt_handlers_64.o
AS arch/x86/boot/compressed/mem_encrypt.o
CC arch/x86/boot/compressed/pgtable_64.o
CC arch/x86/boot/compressed/acpi.o
AS arch/x86/boot/compressed/efi_thunk_64.o
LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
AS arch/x86/boot/header.o
CC arch/x86/boot/main.o
CC arch/x86/boot/memory.o
CC arch/x86/boot/pm.o
AS arch/x86/boot/pmjump.o
CC arch/x86/boot/printf.o
CC arch/x86/boot/regs.o
CC arch/x86/boot/string.o
CC arch/x86/boot/tty.o
CC arch/x86/boot/video.o
CC arch/x86/boot/video-mode.o
CC arch/x86/boot/version.o
CC arch/x86/boot/video-vga.o
CC arch/x86/boot/video-vesa.o
CC arch/x86/boot/video-bios.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
OBJCOPY arch/x86/boot/vmlinux.bin
HOSTCC arch/x86/boot/tools/build
BUILD arch/x86/boot/bzImage
Kernel: arch/x86/boot/bzImage is ready (#1)
/workspace/linux (master) $
Note Kernel: arch/x86/boot/bzImage is ready (#1).
fatal error: libelf.h: No such file or directory
/workspace/linux (master) $ make
SYSHDR arch/x86/include/generated/uapi/asm/unistd_32.h
...
DESCEND objtool
<stdin>:1:10: fatal error: libelf.h: No such file or directory
compilation terminated.
HOSTCC /workspace/linux/tools/objtool/fixdep.o
...
AR /workspace/linux/tools/objtool/libsubcmd.a
CC /workspace/linux/tools/objtool/arch/x86/special.o
In file included from /workspace/linux/tools/objtool/include/objtool/objtool.h:13,
from /workspace/linux/tools/objtool/include/objtool/arch.h:11,
from /workspace/linux/tools/objtool/include/objtool/check.h:11,
from /workspace/linux/tools/objtool/include/objtool/special.h:10,
from arch/x86/special.c:4:
/workspace/linux/tools/objtool/include/objtool/elf.h:10:10: fatal error: gelf.h: No such file or directory
10 | #include <gelf.h>
| ^~~~~~~~
compilation terminated.
make[4]: *** [/workspace/linux/tools/build/Makefile.build:97: /workspace/linux/tools/objtool/arch/x86/special.o] Error 1
make[3]: *** [/workspace/linux/tools/build/Makefile.build:139: arch/x86] Error 2
make[2]: *** [Makefile:56: /workspace/linux/tools/objtool/objtool-in.o] Error 2
make[1]: *** [Makefile:69: objtool] Error 2
make: *** [Makefile:1337: tools/objtool] Error 2
Install
libelf-dev
packageLast modified 1yr ago