Skip to content

Instantly share code, notes, and snippets.

@arkku
Last active December 28, 2025 18:35
Show Gist options
  • Select an option

  • Save arkku/cb7e9b20b913d6c4a38b2a681ae24a92 to your computer and use it in GitHub Desktop.

Select an option

Save arkku/cb7e9b20b913d6c4a38b2a681ae24a92 to your computer and use it in GitHub Desktop.
DKMS makefile for E810 driver intel/ethernet-linux-ice
# Makefile to add the Intel ice driver (E810) as a DKMS module to Debian
#
# Check out the repository https://github.com/intel/ethernet-linux-ice
# into a directory. Put this Makefile into the root of that directory.
# Run `make` as root, which should add the module to DKMS and build it.
# Use `make install` to install, or just `dkms install ice/2.4.5` directly.
# `make clean` to restore the initial state.
#
# When the driver is updated, `git pull` and then just `make` again. It
# should automatically update the version number, as long as the format
# of `src/ice_main.c` remains.
#
# Use and distribute freely at your own risk, absolutely no warranty.
#
# - Kimmo Kulovesi https://github.com/arkku/
MODULE := ice
VERSION := $(shell awk '/^\s*#define DRV_VERSION\s*"[0-9.]+"/ { gsub(/"/, "", $$3); print $$3; exit 0 }' src/$(MODULE)_main.c)
SRC_DIR := /usr/src/$(MODULE)-$(VERSION)
KERNEL_VERSION := $(shell uname -r)
ARCH := $(shell uname -m)
DKMS_DIR := /var/lib/dkms/$(MODULE)/$(VERSION)
DKMS_ADDED := $(DKMS_DIR)/source
DKMS_BUILT := $(DKMS_DIR)/$(KERNEL_VERSION)/$(ARCH)/module/$(MODULE).ko.xz
all: $(DKMS_BUILT)
dkms.conf: src/$(MODULE)_main.c Makefile
@echo 'PACKAGE_NAME="$(MODULE)"' > $@
@echo 'PACKAGE_VERSION="$(VERSION)"' >> $@
@echo 'BUILT_MODULE_NAME[0]="$(MODULE)"' >> $@
@echo 'BUILT_MODULE_LOCATION[0]="src/"' >> $@
@echo "MAKE[0]=\"'make' -j\$$(nproc) -C src/\"" >> $@
@echo 'CLEAN="make -C src/ clean"' >> $@
@echo 'DEST_MODULE_LOCATION[0]="/kernel/drivers/net/ethernet/intel/$(MODULE)/"' >> $@
@echo 'AUTOINSTALL="yes"' >> $@
$(SRC_DIR): dkms.conf $(wildcard src/*)
mkdir -p $@
rsync -a --exclude='.git' --exclude='*.o' --exclude='*.ko' ./ $@/
@touch $@
$(DKMS_ADDED): $(SRC_DIR)
-dkms add -m $(MODULE) -v $(VERSION)
$(DKMS_BUILT): $(DKMS_ADDED)
dkms build -m $(MODULE) -v $(VERSION) -k $(KERNEL_VERSION) --force
build: $(DKMS_BUILT)
add: $(DKMS_ADDED)
install: $(DKMS_BUILT)
dkms install -m $(MODULE) -v $(VERSION)
clean: uninstall
-rm -rf $(SRC_DIR)
uninstall:
-dkms uninstall -m $(MODULE) -v $(VERSION)
-dkms remove -m $(MODULE) -v $(VERSION) --all
.PHONY: all add install clean uninstall build
@arkku
Copy link
Author

arkku commented Dec 28, 2025

Tested with version 2.4.5, the most recent one at the time of writing in intel/ethernet-linux-ice:

…/ethernet-linux-ice# make
mkdir -p /usr/src/ice-2.4.5
rsync -a --exclude='.git' --exclude='*.o' --exclude='*.ko' ./ /usr/src/ice-2.4.5/
dkms add -m ice -v 2.4.5
Creating symlink /var/lib/dkms/ice/2.4.5/source -> /usr/src/ice-2.4.5
dkms build -m ice -v 2.4.5 -k 6.12.57+deb13-amd64 --force
Sign command: /lib/modules/6.12.57+deb13-amd64/build/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub

Building module(s)........ done.
Signing module /var/lib/dkms/ice/2.4.5/build/src/ice.ko

@arkku
Copy link
Author

arkku commented Dec 28, 2025

The Makefile creates a dkms.conf like:

PACKAGE_NAME="ice"
PACKAGE_VERSION="2.4.5"
BUILT_MODULE_NAME[0]="ice"
BUILT_MODULE_LOCATION[0]="src/"
MAKE[0]="'make' -j$(nproc) -C src/"
CLEAN="make -C src/ clean"
DEST_MODULE_LOCATION[0]="/kernel/drivers/net/ethernet/intel/ice/"
AUTOINSTALL="yes"

The version number is extracted from the sources automatically.

@arkku
Copy link
Author

arkku commented Dec 28, 2025

(BTW, currently the Gist looks wrong in the syntax highlighted version, but copypasting from the raw file works.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment