The “Oldconfig” Target In The Linux Kernel Makefile


Abstract

The Linux kernel is the core component of the Linux operating system, and it is responsible for managing system resources and providing various services to user space applications. Building the Linux kernel from source is a common task for developers and system administrators, and the Makefile is the primary tool used for this purpose. One of the targets provided by the Makefile is the "oldconfig" target, which is used to update the kernel configuration file based on the current system configuration. In this tutorial, we will explain the "oldconfig" target and how to use it.

Note − Linux commands are case-sensitive.

Kernel Makefile

The Makefile is a file that specifies how to build the kernel from its source code. It contains a set of rules that define the various steps involved in the build process, including compiling source files, linking object files, and generating the final kernel image. The Makefile also includes a set of targets that can be invoked by the user to perform specific tasks, such as building the kernel or cleaning up intermediate files.

The Kernel Build System, often known as the config system, is an indispensable tool. Even drivers and other low-level software developers rarely use this approach, therefore not everyone will use it. The fact that you are reading this indicates that you are interested in learning more about the kernel build system.

There are five essential parts of the Kernel Makefile −

  • Makefile: In the source root, this is the main make file.

  • arch/$(ARCH) Makefile: This is the top-level Makefile and it serves as a supplement. Makefile.

  • .config: The kernel configuration file is located here.

  • Scripts/Makefile.*: For all kbuild Makefiles, these set rules are defined.

  • Makefiles for Kbuild: Kbuild Makefiles number around 500, and they are not the easiest to read.

What is the "oldconfig" target?

The "oldconfig" target is a Makefile target provided by the Linux kernel build system. It is used to update the kernel configuration file based on the current system configuration. The kernel configuration file contains various configuration options that determine the behavior of the kernel. These options include hardware support, filesystem support, network support, and other kernel features.

When building the kernel from source, it is necessary to configure the kernel to match the system on which it will run. The "oldconfig" target is used to update an existing kernel configuration file to match the current system configuration. This can be useful when upgrading the kernel or building a new kernel on a system that has already been configured.

How to use the "oldconfig" target?

To use the "oldconfig" target, you must first have a kernel configuration file. If you do not have a configuration file, you can create one by running the "make defconfig" command. This will create a default configuration file based on the architecture of the system on which you are building the kernel. To do this, run the following command,

$ make defconfig

Once you have a configuration file, you can use the "oldconfig" target to update it. To do this, run the following command in the root directory of the kernel source −

$ make oldconfig

When you run "make oldconfig", the command reads the current configuration file (usually located at /usr/src/linux/.config) and prompts you for any new configuration options that have been added since the last kernel version. You can choose to accept the default values or modify the options as needed, i.e., configuration process that will update the existing configuration file to match the current system configuration. During the configuration process, you may be prompted to select new options or confirm existing options. You can use the default options by pressing Enter or select a different option by entering the corresponding number.

Once the configuration process is complete, the updated configuration file will be saved as ".config" in the root directory of the kernel source.

Conclusion

The "oldconfig" target in the Linux kernel Makefile is a useful tool for updating an existing kernel configuration file to match the current system configuration. It can be used to update the configuration file when upgrading the kernel or building a new kernel on a system that has already been configured. By using the "oldconfig" target, you can save time and ensure that the kernel is configured correctly for the system on which it will run.

Updated on: 23-Mar-2023

382 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements