makefilekernel-moduledkms

Building kernel module using dkms


I'm not able to make dkms work on Centos 7. I've been trying changing things in dkms.conf all the day without any progress. Kernel upgrade triggers dkms (which again doesn't work). My minimum non-working example is dkms build. Any suggestions?

dkms.conf:

root@localhost ~# cat /usr/src/cs2-3.2.5/dkms.conf
MAKE="make -C src/ KERNELDIR=/lib/modules/${kernelver}/source"
CLEAN="make -C src/ clean"
BUILT_MODULE_NAME=cs2
BUILT_MODULE_LOCATION=src
DEST_MODULE_LOCATION=/extra
PACKAGE_NAME=cs2
PACKAGE_VERSION=3.2.5
#REMAKE_INITRD=yes
AUTOINSTALL=yes

Registering the module in dkms:

root@localhost ~# dkms add -m cs2 -v 3.2.5

Creating symlink /var/lib/dkms/cs2/3.2.5/source ->
                 /usr/src/cs2-3.2.5

DKMS: add completed.

Building the module using dkms doesn't work:

root@localhost ~# dkms build -m cs2 -v 3.2.5 --verbose

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
make -C src/ clean
make: Entering directory `/var/lib/dkms/cs2/3.2.5/build/src'
rm -f cs2.o cs2.mod.?
rm -f .cs2.ko.cmd .cs2.mod.o.cmd .cs2.o.cmd
rm -rf .tmp_versions Module.symvers modules.order
make: Leaving directory `/var/lib/dkms/cs2/3.2.5/build/src'

{ make -j4 KERNELRELEASE=3.10.0-1127.el7.x86_64 -C src/ KERNELDIR=/lib/modules/3.10.0-1127.el7.x86_64/source; } >> /var/lib/dkms/cs2/3.2.5/build/make.log 2>&1

Error!  Build of cs2.ko failed for: 3.10.0-1127.el7.x86_64 (x86_64)
Consult the make.log in the build directory
/var/lib/dkms/cs2/3.2.5/build/ for more information.

Consulting /var/lib/dkms/cs2/3.2.5/build/make.log isn't much helpful:

EDIT: /var/lib/dkms/cs2/3.2.5/build/make.log looks more like output of make install ....

root@localhost ~# cat /var/lib/dkms/cs2/3.2.5/build/make.log
DKMS make.log for cs2-3.2.5 for kernel 3.10.0-1127.el7.x86_64 (x86_64)
Tue Apr 28 23:29:56 CEST 2020
make: Entering directory `/var/lib/dkms/cs2/3.2.5/build/src'
make -C /lib/modules/3.10.0-1127.el7.x86_64/source SUBDIRS=/var/lib/dkms/cs2/3.2.5/build/src modules_install
make[1]: Entering directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
  DEPMOD  3.10.0-1127.el7.x86_64
make[1]: Leaving directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
make: Leaving directory `/var/lib/dkms/cs2/3.2.5/build/src'

However, calling make manually works just fine:

root@localhost /var/lib/dkms/cs2/3.2.5/build# make -C src/ KERNELDIR=/lib/modules/$(uname -r)/source
make: Entering directory `/var/lib/dkms/cs2/3.2.5/build/src'
make -C /lib/modules/3.10.0-1127.el7.x86_64/source SUBDIRS=/var/lib/dkms/cs2/3.2.5/build/src modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
  CC [M]  /var/lib/dkms/cs2/3.2.5/build/src/cs2.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /var/lib/dkms/cs2/3.2.5/build/src/cs2.mod.o
  LD [M]  /var/lib/dkms/cs2/3.2.5/build/src/cs2.ko
make[1]: Leaving directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
make: Leaving directory `/var/lib/dkms/cs2/3.2.5/build/src'

I believe I have all the needed packages:

root@localhost ~# yum list kernel*
...
Installed Packages
kernel.x86_64                3.10.0-1062.9.1.el7    @updates
kernel.x86_64                3.10.0-1127.el7        @base
kernel-devel.x86_64          3.10.0-1127.el7        @base
kernel-headers.x86_64        3.10.0-1127.el7        @base
kernel-tools.x86_64          3.10.0-1127.el7        @base
kernel-tools-libs.x86_64     3.10.0-1127.el7        @base

Solution

  • There was probably some issue with the Makefile, because dkms build works with this dkms.config:

    PACKAGE_VERSION="3.2.5"
    
    PACKAGE_NAME="cs2"
    MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/src modules"
    CLEAN="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/src clean"
    
    BUILT_MODULE_LOCATION[0]=src/
    BUILT_MODULE_NAME[0]="cs2"
    DEST_MODULE_LOCATION[0]="/extra/"
    
    #REMAKE_INITRD="yes"
    #AUTOINSTALL="yes"