Questions tagged [kbuild]

kbuild is the build system used by the Linux kernel.

kbuild is a build framework based on GNU make and a standard set of cross platform tools. It was originally developed for the Linux Kernel, but is now used in other projects such as crosstool-ng, buildroot, ltib, etc.

kbuild is extremely powerful and tries to hide most of its complexity in templates so that the actual makefiles are relatively easy to understand and write. There are two distinct parts of kbuild; A set of tools and languages for describing configuration variables and Gnu make template code to drive the actual build process.

There are stock documentation for different topics,

The Gnu make harness for the Linux kernel is in the main Makefile and Kbuild.include. The tools for configuring variable (and processing the Kconfig language) are in a kconfig directory. Obviously other projects such as buildroot, and crosstool-ng use modified versions.

The two aspects are found in files within the kernel source. They are a Kconfig file defining variables that can be defined by the tools. The second portion is a Makefile, which uses the Kconfig output (usually .config) to guide the build process through normal Gnu make rules, templates and macros.

144 questions
0
votes
1 answer

Include dir in makefile

I am compiling one C file in Ubuntu but I am getting an error in including a header file. My Makefile is as follows: obj-m := ov7725.o CC = /opt/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc EXTRA_CFLAGS +=-march=armv5 CFLAGS += -I…
Mayank
  • 1
  • 2
0
votes
0 answers

Is it possible to dump Kbuild?

I would like to know if it is possible -- and how -- to dump all Kbuild targets in the Linux Kernel. I want to get all targets to run given a .config. Thank you
Ngahy Be
  • 545
  • 1
  • 4
  • 10
0
votes
0 answers

Building Linux Driver Failed in 5.4, patch fixed, now 5.10 no longer builds with patch adjusted "No rule to make target"

I have a Linux driver I've been building since 3.x days, 4.x days, when hitting 5.4 it broke the build but I found a patch that fixed it. Now moving to 5.10 (jumped over the others), it's no longer working even with the patch applied (Hunk #1…
user3161924
  • 1,849
  • 18
  • 33
0
votes
0 answers

Resolve dependency in Kconfig

Is it possible to resolve the dependencies of an option using Kconfig utility? For instance, I have my .config and I would like to add an option CONFIG_FOO and its dependency automatically without using menuconfig. Note that using make oldconfig…
Ngahy Be
  • 545
  • 1
  • 4
  • 10
0
votes
1 answer

How to check if a Kconfig string is empty using Zephyr?

Given this Kconfig: config MY_STR string "A string" The directive #if defined(CONFIG_MY_STR) will eval to true for the default empty string. How to check if CONFIG_MY_STR is an empty string at compile time? Is it a better practice to use a…
DurandA
  • 1,095
  • 1
  • 17
  • 35
0
votes
0 answers

How to view device driver source files

Hello i want to learn how to write device drivers so i figured i should check out some of the driver source files for i2c,spi,usb, etc. I did some searching to see if anyone else had a similar issue and i used the info found in this stack overflow…
0
votes
1 answer

Kbuild - build multiple .o files from same .c file

I have two drivers that share some of the same source files. Most of the shared code is identical but there are a few pieces that I need to ifdef for a specific driver. I would like these files to reside in the same directory so I don't have…
0
votes
1 answer

Kconfig and select to get predefined and editable configurations?

I want to provide a Kconfig / menuconfig configuration for an implementation. I'm using the toolchain from Espressif ESP-IDF 3.3, but it seems not to be related with the toolchain. I want to have a minimum resulting sdkconfig file without any…
AnErd
  • 415
  • 3
  • 12
0
votes
1 answer

Linux Kernel Makefile.build strange behavior when building external modules

I need some KBuild implementation details advice related to building of external modules. Linux Kernel 5.0.0-32 Here is my LKM Makefile: obj-m += pfsw.o pfsw-objs := src/init.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD)…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
0
votes
1 answer

I2C driver changes to recognize multiple buses

We have defined the analog videoIn adv7180 metadata hardware definition in the i2c2 node in one iMX device tree file. The ultimate aim is to recognize adv7180 driver from the i2c2 bus. During the boot process of the processor using the linux image…
abunickabhi
  • 558
  • 2
  • 9
  • 31
0
votes
0 answers

insmod error in helloworld kernel module: invalid module format

i'm crosscompiling a helloworld kernel module my files are: hello-1.c #include #include int init_module(void) { printk(KERN_INFO "Hello world 1.\n"); return 0; } void cleanup_module(void) { …
Ali
  • 1
0
votes
1 answer

How to cross-compile external kernel modules whe the kernel build is out-of-tree?

On an x86_64 host I have cross-compiled a Linux kernel for an ARM target out-of tree. So I have two directories: ~/kernel_git_repo/ - contains kernel source only ~/kernel_buld_dir/ - contains the .config file and built kernel objects In a third…
Jonathan Ben-Avraham
  • 4,615
  • 2
  • 34
  • 37
0
votes
0 answers

Linux Kernel #ifdef directive available set by kbuild?

Is there a Linux Kernel #ifdef directive for conditional compilation available, which is set by the kernel build system (kbuild)? Usecase: I have a source code file with register map entries for a SoC and with functions used by a Kernel driver. This…
0
votes
2 answers

Difference between LDFLAGS and ldflags-y

The kbuild document says that: ldflags-y... [applies] only to the kbuild makefile in which they are assigned....[is used] for all ld invocations happening during a recursive build. while LDFLAGS... [is used] for all invocations of the linker. I…
Ta Thanh Dinh
  • 638
  • 1
  • 5
  • 12
0
votes
1 answer

Expand macros of a single file when compiling linux kernel

I'm interested in expanding the macros of a single Linux kernel file (arch/x86/kernel/nmi.c). I know that normally one can use gcc -E to expand the macros. However since the file is part of the Linux kernel, many options need to be passed to gcc.…