summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 286dcf1dfce331166f532141d74c7d02a2c9fdd2 (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
#!/usr/bin/make -f

# verbose mode
export DH_VERBOSE=1

SURICATA_DESTDIR = $(CURDIR)/debian/tmp
export DEB_BUILD_MAINT_OPTIONS = hardening=+pie,+bindnow
export CARGO_HOME = $(CURDIR)/debian/cargohome

include /usr/share/dpkg/architecture.mk

# workaround for linking issue on some archs
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--allow-multiple-definition
EXTRA_ATOMIC_ARCHS = armel mipsel powerpc
ifneq (,$(findstring $(DEB_HOST_ARCH),$(EXTRA_ATOMIC_ARCHS)))
	DEB_LDFLAGS_MAINT_APPEND +=  -Wl,--no-as-needed -Wl,-latomic -Wl,--as-needed
	export DEB_LDFLAGS_MAINT_APPEND
endif

LUAJIT_ARCHS = i386 amd64 powerpc mips mipsel armel armhf
HYPERSCAN_ARCHS = i386 amd64 hurd-i386 kfreebsd-amd64 x32
RUST_ARCHS = i386 amd64
EBPF_ARCHS = amd64 arm64 armel armhf i386 ppc64el s390x ppc64 sparc64 x32
DPDK_ARCHS = amd64x arm64x riscv64x ppc64elx

LIBHTP_PKG_VERSION=$(shell apt-cache policy libhtp2 | grep Installed | cut -f2- -d: | cut -c2-)

ifneq (,$(findstring $(DEB_HOST_ARCH),$(LUAJIT_ARCHS)))
	ENABLE_LUAJIT="--enable-luajit"
endif

ifneq (,$(findstring $(DEB_HOST_ARCH),$(HYPERSCAN_ARCHS)))
	ENABLE_HYPERSCAN="--enable-libhs"
endif

ifneq (,$(findstring $(DEB_HOST_ARCH),$(RUST_ARCHS)))
	ENABLE_HYPERSCAN="--enable-rust"
endif

ifneq (,$(findstring $(DEB_HOST_ARCH)x,$(DPDK_ARCHS)))
	ENABLE_DPDK="--enable-dpdk"
endif

CI ?= $(shell $(CURDIR)/debian/building-in-ci.sh)
ifeq ($(CI),true)
        ENABLE_UNITTESTS="--enable-unittests"
endif

ifneq (,$(findstring $(DEB_HOST_ARCH),$(EBPF_ARCHS)))
	ENABLE_EBPF=--enable-ebpf --enable-ebpf-build \
		--with-ebpf-includes=/usr/include/$(DEB_HOST_MULTIARCH)
endif

CONFIGURE_ARGS = --enable-af-packet --enable-nfqueue --enable-nflog \
	--enable-gccprotect --disable-gccmarch-native \
	--with-libnss-includes=/usr/include/nss --with-libnss-libraries=/usr/lib/$(DEB_HOST_MULTIARCH) \
	--with-libnspr-includes=/usr/include/nspr --with-libnspr-libraries=/usr/lib/$(DEB_HOST_MULTIARCH) \
	--with-libevent-includes=/usr/include --with-libevent-libraries=/usr/lib/$(DEB_HOST_MULTIARCH) \
	--disable-coccinelle \
	--enable-geoip --enable-hiredis \
	--enable-non-bundled-htp \
	--disable-suricata-update \
	$(ENABLE_LUAJIT) \
	$(ENABLE_HYPERSCAN) \
	$(ENABLE_UNITTESTS) \
	$(ENABLE_EBPF) \
	$(ENABLE_DPDK)

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_ARGS)

override_dh_auto_build:
	uname -a
	mkdir -p $(CARGO_HOME)
	dh_auto_build

override_dh_auto_clean:
	rm -rf $(CARGO_HOME)
	rm -f debian/suricata.substvars

override_dh_auto_install:
	dh_auto_install --destdir=$(SURICATA_DESTDIR)
	rm -rf $(SURICATA_DESTDIR)/usr/lib/python*;\
	(cd python && make prefix=$(SURICATA_DESTDIR)/usr)
	# clean upstream install documentation
	rm -rf $(SURICATA_DESTDIR)/usr/share/doc/suricata/*
	$(foreach file, $(wildcard ebpf/*bpf), \
		install -D -t $(SURICATA_DESTDIR)/usr/lib/suricata/ebpf $(file) ;\
	)

override_dh_auto_test:
	# do nothing

override_dh_missing:
	dh_missing --list-missing

override_dh_gencontrol:
	echo "libhtp:Version=$(LIBHTP_PKG_VERSION)" >> debian/suricata.substvars
	dh_gencontrol

%:
	dh $@ --with python3