This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.dkms
92 lines (78 loc) · 3.44 KB
/
Makefile.dkms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#
# Makefile for the output source package
#
ifeq ($(KERNELRELEASE),)
MAKEFLAGS += --no-print-directory
SHELL := /bin/bash
BACKPORT_DIR := $(shell pwd)
KMODDIR ?= updates
ifneq ($(origin KLIB), undefined)
KMODPATH_ARG := "INSTALL_MOD_PATH=$(KLIB)"
else
KLIB := /lib/modules/$(shell uname -r)/
KMODPATH_ARG :=
endif
KLIB_BUILD ?= $(KLIB)/build/
KERNEL_CONFIG := $(KLIB_BUILD)/.config
KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile
CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//')
export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG
# disable built-in rules for this file
.SUFFIXES:
# dkmsrpm-pkg
# Creates Backports dkms package
# command: make dkmsrpm-pkg
# Rpm generated can be copied to client machine and install
# will trigger source build and install on modules
#----------------------------------------------------------------------------
TAR_CONTENT := Makefile* drivers scripts backport-include VERSION
DKMSMKSPEC := $(BACKPORT_DIR)/scripts/backport-mkdkmsspec
BINMKSPEC := $(BACKPORT_DIR)/scripts/backport-mkbinspec
DKMSMKCONF := $(BACKPORT_DIR)/scripts/backport-mkdkmsconf
DKMSPOSTINST := $(BACKPORT_DIR)/scripts/backport-mkdkmspostinst
DKMSPRERM := $(BACKPORT_DIR)/scripts/backport-mkdkmsprerm
DKMSCONTROL := $(BACKPORT_DIR)/scripts/backport-mkdkmscontrol
MODULE_NAME ?= intel-platform-cse-dkms
BIN_MODULE_NAME ?= intel-platform-cse
ARCH := x86_64
SOURCE_VERSION = $(shell cat $(BACKPORT_DIR)/VERSION)
ifneq ($(SOURCE_VERSION), )
VERSION := $(SOURCE_VERSION)
else
$(error "$$SOURCE_VERSION not set")
endif
ifneq ($(BUILD_VERSION), )
RELEASE := $(BUILD_VERSION)
else
$(error "$$BUILD_VERSION not set")
endif
DEB_PACKAGE_NAME := $(MODULE_NAME)-$(VERSION)-$(RELEASE)_amd64
DEB_ROOT_DIR := $(DEB_PACKAGE_NAME)/DEBIAN
DEB_SRC_DIR := $(DEB_PACKAGE_NAME)/usr/src/$(MODULE_NAME)-$(VERSION)-$(RELEASE)
backport-include/generated_osv_version.h:
scripts/generate_osv_version_h.sh > $@
.PHONY: dkmsrpm-pkg dkmsdeb-pkg binrpm-pkg
dkmsrpm-pkg: backport-include/generated_osv_version.h
$(CONFIG_SHELL) $(DKMSMKCONF) $(MODULE_NAME) $(VERSION) $(RELEASE) > $(BACKPORT_DIR)/dkms.conf
$(CONFIG_SHELL) $(DKMSMKSPEC) $(MODULE_NAME) $(VERSION) $(RELEASE) > $(BACKPORT_DIR)/$(MODULE_NAME).spec
tar -cz $(RCS_TAR_IGNORE) -f $(MODULE_NAME)-$(VERSION)-$(RELEASE)-src.tar.gz \
$(TAR_CONTENT) $(MODULE_NAME).spec dkms.conf;
+rpmbuild $(RPMOPTS) --target $(ARCH) -ta $(MODULE_NAME)-$(VERSION)-$(RELEASE)-src.tar.gz \
--define='_smp_mflags %{nil}'
binrpm-pkg: backport-include/generated_osv_version.h
$(CONFIG_SHELL) $(BINMKSPEC) $(BIN_MODULE_NAME) $(VERSION) $(RELEASE) > $(BACKPORT_DIR)/$(BIN_MODULE_NAME).spec
tar -cz $(RCS_TAR_IGNORE) -f $(BIN_MODULE_NAME)-$(VERSION)-$(RELEASE)-src.tar.gz \
$(TAR_CONTENT) $(BIN_MODULE_NAME).spec;
+rpmbuild $(RPMOPTS) --target $(ARCH) -ta $(BIN_MODULE_NAME)-$(VERSION)-$(RELEASE)-src.tar.gz \
--define='_smp_mflags %{nil}'
dkmsdeb-pkg: backport-include/generated_osv_version.h
mkdir -p $(DEB_ROOT_DIR)
$(CONFIG_SHELL) $(DKMSCONTROL) $(MODULE_NAME) $(VERSION) $(RELEASE) > $(DEB_ROOT_DIR)/control
$(CONFIG_SHELL) $(DKMSPOSTINST) $(MODULE_NAME) $(VERSION) $(RELEASE) > $(DEB_ROOT_DIR)/postinst
$(CONFIG_SHELL) $(DKMSPRERM) $(MODULE_NAME) $(VERSION) $(RELEASE) > $(DEB_ROOT_DIR)/prerm
chmod 775 $(DEB_ROOT_DIR)/{postinst,prerm}
mkdir -p $(DEB_SRC_DIR)
$(CONFIG_SHELL) $(DKMSMKCONF) $(MODULE_NAME) $(VERSION) $(RELEASE) > $(DEB_SRC_DIR)/dkms.conf
cp -r $(TAR_CONTENT) $(DEB_SRC_DIR)
+dpkg-deb --root-owner-group --build $(DEB_PACKAGE_NAME)
endif