summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 09d5591460ade7ad066ed010a3814c8c3c20d0c6 (plain)
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
93
94
95
96
97
98
99
100
101
102
103
RELEASE_DATE := "6 March 2024"
RELEASE_MAJOR := 3
RELEASE_MINOR := 0
RELEASE_MICRO := 13
RELEASE_NAME := dkms
RELEASE_VERSION := $(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_MICRO)
RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_VERSION)
SHELL=bash

SBIN = /usr/sbin
LIBDIR = /usr/lib/dkms
MODDIR = /lib/modules
KCONF = /etc/kernel
SYSTEMD = /usr/lib/systemd/system

#Define the top-level build directory
BUILDDIR := $(shell pwd)

SED			?= sed
SED_SUBSTITUTIONS	 = \
	-e 's,@RELEASE_STRING@,$(RELEASE_STRING),g' \
	-e 's,@RELEASE_DATE@,$(RELEASE_DATE),g' \
	-e 's,@SBINDIR@,$(SBIN),g' \
	-e 's,@KCONFDIR@,$(KCONF),g' \
	-e 's,@MODDIR@,$(MODDIR),g' \
	-e 's,@LIBDIR@,$(LIBDIR),g'

%: %.in
	$(SED) $(SED_SUBSTITUTIONS) $< > $@

all: \
	dkms \
	dkms.8 \
	dkms_autoinstaller \
	dkms.bash-completion \
	dkms.zsh-completion \
	dkms_common.postinst \
	dkms_framework.conf \
	dkms.service \
	kernel_install.d_dkms \
	kernel_postinst.d_dkms \
	kernel_prerm.d_dkms

clean:
	-rm -rf dist/
	-rm -rf dkms
	-rm -rf dkms.8
	-rm -rf dkms_autoinstaller
	-rm -rf dkms.bash-completion
	-rm -rf dkms.zsh-completion
	-rm -rf dkms_common.postinst
	-rm -rf dkms_framework.conf
	-rm -rf dkms.service
	-rm -rf kernel_install.d_dkms
	-rm -rf kernel_postinst.d_dkms
	-rm -rf kernel_prerm.d_dkms

install: all
	$(if $(strip $(VAR)),$(error Setting VAR is not supported))
	install -d -m 0755 $(DESTDIR)/var/lib/dkms
ifneq (,$(DESTDIR))
	$(if $(filter $(DESTDIR)%,$(SBIN)),$(error Using a DESTDIR as prefix for SBIN is no longer supported))
	$(if $(filter $(DESTDIR)%,$(LIBDIR)),$(error Using a DESTDIR as prefix for LIBDIR is no longer supported))
	$(if $(filter $(DESTDIR)%,$(KCONF)),$(error Using a DESTDIR as prefix for KCONF is no longer supported))
endif
	install -D -m 0755 dkms $(DESTDIR)$(SBIN)/dkms
	install -D -m 0755 dkms_common.postinst $(DESTDIR)$(LIBDIR)/common.postinst
	install -D -m 0755 dkms_autoinstaller $(DESTDIR)$(LIBDIR)/dkms_autoinstaller
	$(if $(strip $(ETC)),$(error Setting ETC is not supported))
	install -D -m 0644 dkms_framework.conf $(DESTDIR)/etc/dkms/framework.conf
	install -d -m 0755 $(DESTDIR)/etc/dkms/framework.conf.d
	$(if $(strip $(BASHDIR)),$(error Setting BASHDIR is not supported))
	install -D -m 0644 dkms.bash-completion $(DESTDIR)/usr/share/bash-completion/completions/dkms
	install -D -m 0644 dkms.zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_dkms
	install -D -m 0644 dkms.8 $(DESTDIR)/usr/share/man/man8/dkms.8
	install -D -m 0755 kernel_install.d_dkms $(DESTDIR)$(KCONF)/install.d/40-dkms.install
	install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/postinst.d/dkms
	install -D -m 0755 kernel_prerm.d_dkms $(DESTDIR)$(KCONF)/prerm.d/dkms

install-redhat: install
ifneq (,$(DESTDIR))
	$(if $(filter $(DESTDIR)%,$(SYSTEMD)),$(error Using a DESTDIR as prefix for SYSTEMD is no longer supported))
endif
	install -D -m 0644 dkms.service $(DESTDIR)$(SYSTEMD)/dkms.service

install-debian: install
	$(if $(strip $(SHAREDIR)),$(error Setting SHAREDIR is not supported))
	install -D -m 0755 dkms_apport.py $(DESTDIR)/usr/share/apport/package-hooks/dkms_packages.py
	install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/header_postinst.d/dkms

install-doc:
	$(if $(strip $(DOC)),$(error Setting DOCDIR is not supported))
	install -d -m 0755 $(DESTDIR)/usr/share/doc/dkms
	install -m 0644 COPYING README.md $(DESTDIR)/usr/share/doc/dkms

.PHONY = tarball

TARBALL=$(BUILDDIR)/dist/$(RELEASE_STRING).tar.gz
tarball: $(TARBALL)

$(TARBALL): all
	mkdir -p $(@D)
	git archive --prefix=$(RELEASE_STRING)/ --add-file=dkms --add-file=dkms.8 -o $@ HEAD