1、内核中的makefile
内核中的每个模块下都存在makefile,用于编译内核模块,以sample/watchdog为例
-rw-r--r-- 1 root root 127 Mar 27 13:41 Makefile
-rw-r--r-- 1 root root 382 Mar 27 13:41 watchdog-simple.c
[root@VM_0_11_centos watchdog]# pwd
/home/kernel_source/linux/samples/watchdog
[root@VM_0_11_centos watchdog]#
# SPDX-License-Identifier: GPL-2.0
CC := $(CROSS_COMPILE)gcc
PROGS := watchdog-simple
all: $(PROGS)
clean:
rm -fr $(PROGS)
[root@VM_0_11_centos watchdog]# ll
total 20
-rw-r--r-- 1 root root 127 Mar 27 13:41 Makefile
-rwxr-xr-x 1 root root 8624 Mar 29 01:56 watchdog-simple
-rw-r--r-- 1 root root 382 Mar 27 13:41 watchdog-simple.c
[root@VM_0_11_centos watchdog]#
2、clean
[root@VM_0_11_centos watchdog]# ll
total 20
-rw-r--r-- 1 root root 127 Mar 27 13:41 Makefile
-rwxr-xr-x 1 root root 8624 Mar 29 01:56 watchdog-simple
-rw-r--r-- 1 root root 382 Mar 27 13:41 watchdog-simple.c
[root@VM_0_11_centos watchdog]# make clean
rm -fr watchdog-simple
[root@VM_0_11_centos watchdog]# ll
total 8
-rw-r--r-- 1 root root 127 Mar 27 13:41 Makefile
-rw-r--r-- 1 root root 382 Mar 27 13:41 watchdog-simple.c
[root@VM_0_11_centos watchdog]#
3、Kconfig
Kconfig的作用:Kconfig用来配置内核,它就是各种配置界面的源文件,内核的配置工具读取各个Kconfig文件,生成配置界面供开发人员配置内核,最后生成配置文件.config
# SPDX-License-Identifier: GPL-2.0-only
#
# Network configuration
#
menuconfig NET
bool "Networking support"
select NLATTR
select GENERIC_NET_UTILS
select BPF
---help---
Unless you really know what you are doing, you should say Y here.
The reason is that some programs need kernel networking support even
when running on a stand-alone machine that isn't connected to any
other computer.
If you are upgrading from an older kernel, you
should consider updating your networking tools too because changes
in the kernel and the tools often go hand in hand. The tools are
contained in the package net-tools, the location and version number
of which are given in <file:Documentation/Changes>.
For a general introduction to Linux networking, it is highly
recommended to read the NET-HOWTO, available from
<http://www.tldp.org/docs.html#howto>.
if NET
config WANT_COMPAT_NETLINK_MESSAGES
bool
help
This option can be selected by other options that need compat
netlink messages.
config COMPAT_NETLINK_MESSAGES
def_bool y
depends on COMPAT
depends on WEXT_CORE || WANT_COMPAT_NETLINK_MESSAGES
help
This option makes it possible to send different netlink messages
to tasks depending on whether the task is a compat task or not. To
achieve this, you need to set skb_shinfo(skb)->frag_list to the
compat skb before sending the skb, the netlink code will sort out
which message to actually pass to the task.
Newly written code should NEVER need this option but do
compat-independent messages instead!