summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 4bc13c283a6b60b52415541ad3556294e5ed6352 (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
104
105
106
107
108
109
#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -DNDEBUG

export DPKG_GENSYMBOLS_CHECK_LEVEL := 4
export KNOT_SOFTHSM2_DSO = /usr/lib/softhsm/libsofthsm2.so
export KNOT_VERSION_FORMAT = release
export KNOT_FULL_ARCHS = amd64 arm64 armhf i386 mips64el ppc64el riscv64 s390x ppc64

include /usr/share/dpkg/default.mk

# Enable extra modules and features only for well supported architectures
ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),$(KNOT_FULL_ARCHS)))
  FASTPARSER := --enable-fastparser
  RECVMMSG   := --enable-recvmmsg=yes
  QUIC       := --enable-quic=auto
  RRL        := --with-module-rrl=yes
  GEOIP      := --with-module-geoip=shared
  DNSTAP     := --enable-dnstap --with-module-dnstap=shared
  RUN_TEST   :=
else
  FASTPARSER := --disable-fastparser
  RECVMMSG   := --enable-recvmmsg=no
  QUIC       := --enable-quic=no
  RRL        := --with-module-rrl=no
  GEOIP      := --with-modle-geoip=no
  DNSTAP     := --disable-dnstap --with-module-dnstap=no
  RUN_TEST   := -timeout --kill-after=5s 5m
endif

# Disable fastparser if requested
ifeq (maint,$(filter $(DEB_BUILD_OPTIONS),maint))
  FASTPARSER := --disable-fastparser
endif

# MAJOR.MINOR version part
BASE_VERSION := $(shell echo $(DEB_VERSION) | sed 's/^\([^.]\+\.[^.]\+\).*/\1/')

# pyproject is supported by knot but fails on second `pybuild --build`
# invocation due to bug in dh-python's plugin_pyproject.py wheel unpack
export PYBUILD_SYSTEM = distutils

%:
	dh $@ \
	 --exclude=.la --exclude=example.com.zone \
	 --with python3

override_dh_auto_configure:
	@echo 'architecture:' $(DEB_HOST_ARCH)
	dh_auto_configure -- \
	  --sysconfdir=/etc \
	  --localstatedir=/var/lib \
	  --libexecdir=/usr/lib/knot \
	  --with-rundir=/run/knot \
	  --with-moduledir=/usr/lib/$(DEB_HOST_MULTIARCH)/knot/modules-$(BASE_VERSION) \
	  --with-storage=/var/lib/knot \
	  --enable-systemd=auto \
	  --disable-silent-rules \
	  $(RRL) \
	  $(GEOIP) \
	  $(DNSTAP) \
	  $(RECVMMSG) \
	  $(FASTPARSER) \
	  $(QUIC)

override_dh_auto_configure-indep:
	pybuild --dir python/libknot --configure
	pybuild --dir python/knot_exporter --configure

override_dh_auto_build-indep:
	dh_auto_build -- html
	pybuild --dir python/libknot --build
	pybuild --dir python/knot_exporter --build

override_dh_auto_install-arch:
	dh_auto_install -- install
	# rename knot.sample.conf to knot.conf
	mv $(CURDIR)/debian/tmp/etc/knot/knot.sample.conf $(CURDIR)/debian/tmp/etc/knot/knot.conf
	# Some workarounds where XDP is unavailable
	@if [ -f "$(CURDIR)/debian/tmp/usr/sbin/kxdpgun" ]; then \
	  echo "XDP enabled"; \
	else \
	  echo "XDP disabled"; \
	  touch $(CURDIR)/debian/tmp/usr/share/man/man8/kxdpgun.8; \
	  printf '#!/bin/sh\n\necho "kxdpgun not available"\n' > $(CURDIR)/debian/tmp/usr/sbin/kxdpgun; \
	fi

override_dh_auto_install-indep:
	dh_auto_install -- install-html
	# rename knot.sample.conf to knot.conf
	mv $(CURDIR)/debian/tmp/etc/knot/knot.sample.conf $(CURDIR)/debian/tmp/etc/knot/knot.conf
	pybuild --dir python/libknot --install
	pybuild --dir python/knot_exporter --install
	rm -rf $(CURDIR)/debian/tmp/usr/lib/python*/dist-packages/libknot/__pycache__
	rm -rf $(CURDIR)/debian/tmp/usr/lib/python*/dist-packages/knot_exporter/__pycache__

override_dh_auto_test-indep:
override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(RUN_TEST) dh_auto_test
	$(MAKE) -C samples knot.sample.conf
endif

override_dh_missing:
	dh_missing --fail-missing

override_dh_installchangelogs:
	dh_installchangelogs NEWS