summaryrefslogtreecommitdiffstats
path: root/packaging/debian/rules
blob: b6aacfac92180d12f9205014a8a978ab60c0141a (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
110
111
#!/usr/bin/make -f
# Originally made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.
# Rewritten to use dh, by Balint Reczey

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

distrelease  := $(shell lsb_release -cs)
ifeq ($(distrelease),n/a)
  distrelease     := sid
endif

include /usr/share/dpkg/pkg-info.mk

# Fetch our Logray version. This is pretty janky, but will have to do for now.
PROJECT_MAJOR_VERSION = $(shell grep '^set(PROJECT_MAJOR_VERSION' CMakeLists.txt | sed -e 's/set.* //' -e 's/)//')
PROJECT_MINOR_VERSION = $(shell grep '^set(PROJECT_MINOR_VERSION' CMakeLists.txt | sed -e 's/set.* //' -e 's/)//')
PROJECT_PATCH_VERSION = $(shell grep '^set(PROJECT_PATCH_VERSION' CMakeLists.txt | sed -e 's/set.* //' -e 's/)//')
LOG_PROJECT_MAJOR_VERSION = $(shell grep '^set(LOG_PROJECT_MAJOR_VERSION' CMakeLists.txt | sed -e 's/set.* //' -e 's/)//')
LOG_PROJECT_MINOR_VERSION = $(shell grep '^set(LOG_PROJECT_MINOR_VERSION' CMakeLists.txt | sed -e 's/set.* //' -e 's/)//')
LOG_PROJECT_PATCH_VERSION = $(shell grep '^set(LOG_PROJECT_PATCH_VERSION' CMakeLists.txt | sed -e 's/set.* //' -e 's/)//')
LOGRAY_VERSION = $(shell echo $(DEB_VERSION) | sed -e "s/$(PROJECT_MAJOR_VERSION)\.$(PROJECT_MINOR_VERSION)\.$(PROJECT_PATCH_VERSION)/$(LOG_PROJECT_MAJOR_VERSION)\.$(LOG_PROJECT_MINOR_VERSION)\.$(LOG_PROJECT_PATCH_VERSION)/")

# This has to be exported to make some magic below work.
export DH_OPTIONS

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

ifeq ($(MAKE),ninja)
	DH_BUILDSYSTEM = cmake+ninja
else
	DH_BUILDSYSTEM = cmake
endif

ifneq ($(filter pkg.wireshark.logray,$(DEB_BUILD_PROFILES)),)
    CONFIGURE_SWITCHES += -DBUILD_logray=ON -DBUILD_falcodump=ON
endif

%:
	dh $@ --with python3 --buildsystem $(DH_BUILDSYSTEM) --with quilt

override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_xxx2deb=ON \
		-DBUILD_corbaidl2wrs=ON \
		$(CONFIGURE_SWITCHES)
	sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \
		debian/logray.postinst.in > debian/logray.postinst

override_dh_auto_build:
	# Ignore warnings from asn2wrs.py about duplicate field names.
	PYTHONWARNINGS='ignore:The same:UserWarning::0' \
	$(MAKE) -C $(CURDIR)/obj-* asn1
	dh_auto_build
	$(MAKE) -C $(CURDIR)/obj-* user_guide_html developer_guide_html
	# fix links in documentation
	sed -i "s|$(CURDIR)/doc|..|" obj-*/doc/ws*g_html_chunked/*.html
ifeq (,$(filter $(DEB_BUILD_OPTIONS),nocheck))
	# Required for the "unittests" suite.
	$(MAKE) -C $(CURDIR)/obj-* test-programs
endif

override_dh_dwz:
	# run dh_dwz only with debhelper (>= 12.6) to work around https://bugs.debian.org/939164
	dpkg -l debhelper | awk '/debhelper/ {print $$3}' | xargs dpkg --compare-versions 12.6 gt || dh_dwz

override_dh_auto_install:
	dh_auto_install
ifeq ($(MAKE),ninja)
	DESTDIR=$(CURDIR)/debian/tmp $(MAKE) -C $(CURDIR)/obj-* install-headers
else
	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp -C $(CURDIR)/obj-* install-headers
endif
	rm -rf $(CURDIR)/debian/tmp/usr/share/wireshark/COPYING

override_dh_install:
	dh_install
	# check all necessary headers are included
	$(CC) -c debian/headers-check.c $(shell pkg-config --cflags glib-2.0) $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS) -Idebian/libwireshark-dev/usr/include -Idebian/libwireshark-dev/usr/include/wireshark -Idebian/libwiretap-dev/usr/include/wireshark -Idebian/libwsutil-dev/usr/include/wireshark -o /dev/null

override_dh_fixperms:
	dh_fixperms
	chmod 644 debian/wireshark-dev/usr/share/pyshared/make-plugin-reg.py \
		debian/wireshark-dev/usr/share/pyshared/wireshark_be.py \
		debian/wireshark-dev/usr/share/pyshared/wireshark_gen.py

override_dh_auto_test:
ifeq (,$(filter $(DEB_BUILD_OPTIONS),nocheck))
	# XXX Add -- --verbose?
	dh_auto_test
else
	@echo '"DEB_BUILD_OPTIONS" has "nocheck". Skipping tests'
endif

override_dh_makeshlibs:
	for package in $$(grep 'Package: lib.*[0-9]$$' debian/control  | cut -d' ' -f2); do \
		lib=$${package%%[0-9]*};\
		major=$${package##*[a-z]}; \
		echo "$$lib $$major $$package (= $(DEB_VERSION))"  > debian/$$package.shlibs; \
	done
	dh_makeshlibs

override_dh_gencontrol:
	dh_gencontrol
	dh_gencontrol -plogray -- -v$(LOGRAY_VERSION)