How to write Makefile of kernel module by Centos

now you need to write a Linux kernel program. I don"t know how to write the Makefile file. The
code directory structure is as follows

-
-src/
    -conf/
        -log.conf          // log.c
    -demo.c                // log.h,
    -log.c                 // log.h,
-header/
    -log.h

question
how to write Makefile file to generate xx.ko kernel module file

status
Makefile written by oneself looks like this, as shown in the following file

ifneq ($(KERNELRELEASE),)
    XXXXXXXXXXXXXX

else      
    KDIR := /lib/modules/$(shell uname -r)/build
    PWD:= $(shell pwd)

all:   
    make -C $(KDIR) M=$(PWD) modules

clean:
    rm -f *.ko *.o *.mod.o *.mod.c *.symvers

endif  

what I want to ask is how to write the code in the XXXXXXXXXXXXXX area so that it compiles successfully

Mar.10,2021
Menu