rules revision ca40d310
1#!/usr/bin/make -f
2# See debhelper(7) (uncomment to enable)
3# output every command that modifies files on the build system.
4export DH_VERBOSE=1
5export DH_OPTIONS=-v
6
7VERSION := $(shell dpkg-parsechangelog | sed -nr '/^Version:/s/Version: (.*:)?(.*)-(.*)/\2/p')
8
9# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
10include /usr/share/dpkg/default.mk
11
12DEB_HOST_GNU_CPU := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
13
14# see FEATURE AREAS in dpkg-buildflags(1)
15export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
16
17# see ENVIRONMENT in dpkg-buildflags(1)
18# package maintainers to append CFLAGS
19export DEB_CFLAGS_MAINT_APPEND  = -fPIC
20# package maintainers to append LDFLAGS
21#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
22
23include /usr/share/dpkg/buildflags.mk
24export EXTRA_CFLAGS=$(CFLAGS)
25# need to be stripped as DPDK build system adds them and it would be -Wl,-Wl,opt
26export EXTRA_LDFLAGS=$(shell echo $(LDFLAGS) | sed 's/-Wl,//g')
27
28# People rebuilding this package can overwrite DPDK_CONFIG, RTE_MACHINE and
29# RTE_TARGET via environment variables if they like
30ifneq (,$(filter $(DEB_HOST_ARCH), arm64))
31DPDK_CONFIG := "arm64-armv8a-linuxapp-gcc"
32RTE_MACHINE := "armv8a"
33RTE_TARGET := "arm64-armv8a-linuxapp-gcc"
34else
35DPDK_CONFIG := "$(DEB_HOST_GNU_CPU)-native-linuxapp-gcc"
36RTE_MACHINE := "default"
37RTE_TARGET := "$(DEB_HOST_GNU_CPU)-default-linuxapp-gcc"
38endif
39DPDK_STATIC_DIR = "debian/build/static-root"
40DPDK_SHARED_DIR = "debian/build/shared-root"
41
42%:
43	dh $@ --with python2,dkms
44
45override_dh_auto_clean:
46	rm -rf debian/build debian/tmp
47
48override_dh_auto_configure:
49	# report dpkg-buildflags status to build log
50	dpkg-buildflags --status
51	echo EXTRA_CFLAGS $$EXTRA_CFLAGS
52	echo EXTRA_LDFLAGS: $$EXTRA_LDFLAGS
53	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) T=$(DPDK_CONFIG) config
54	sed -ri -e 's,(RTE_MACHINE=).*,\1$(RTE_MACHINE),' \
55		-e 's,(RTE_NEXT_ABI=).*,\1n,' \
56		-e 's,(CONFIG_RTE_EAL_IGB_UIO=).*,\1n,' \
57		-e 's,(CONFIG_RTE_KNI_KMOD=).*,\1n,' \
58		-e 's,(LIBRTE_PMD_PCAP=).*,\1y,' \
59		-e 's,(LIBRTE_PMD_XENVIRT=).*,\1y,' \
60		$(DPDK_STATIC_DIR)/.config
61	dh_auto_configure
62
63override_dh_auto_build-indep:
64	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) doc-api-html doc-guides-html
65
66override_dh_auto_install-indep:
67	# Package: dpdk-doc
68	# All files based on the install-doc rule (includes examples)
69	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) prefix=/usr \
70		DESTDIR=debian/dpdk-doc install-doc
71
72override_dh_auto_build-arch:
73	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) build
74	# Unfortunately the decision about having static or shared libraries is
75	# made for the whole build, which then produces only .a or .so files
76	# (but not both).
77	# And the target layout for target selection has no field for the
78	# type of library.
79	# Right now I hack this by doing a second build which only differs in
80	# the selection of shared libs.
81	# Shared libs should be default, so the previous static build is only
82	# used to get static libraries.
83	cp -a $(DPDK_STATIC_DIR) $(DPDK_SHARED_DIR)
84	sed -ri 's,(RTE_BUILD_SHARED_LIB=).*,\1y,' \
85		$(DPDK_SHARED_DIR)/.config
86	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) build
87
88override_dh_auto_install-arch: LIBDIR=usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
89override_dh_auto_install-arch:
90	# Package: dpdk (runtime)
91	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) prefix=/usr \
92		DESTDIR=debian/dpdk install-runtime
93	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) prefix=/usr \
94		DESTDIR=debian/dpdk install-runtime
95	mkdir -p debian/dpdk/etc/dpdk
96	cp debian/dpdk.interfaces debian/dpdk/etc/dpdk/interfaces
97	rm debian/dpdk/usr/sbin/dpdk-devbind
98	mkdir -p debian/dpdk/sbin
99	ln -s /usr/share/dpdk/tools/dpdk-devbind.py \
100		debian/dpdk/sbin/dpdk-devbind
101	# Package: dpdk-dev (build environment)
102	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) prefix=/usr \
103		DESTDIR=debian/dpdk-dev install-sdk
104	cp $(DPDK_SHARED_DIR)/.config debian/dpdk-dev/usr/share/dpdk/config
105	sed -e 's/SDK_TARGET/$(RTE_TARGET)/' debian/dpdk-sdk-env.sh.in > \
106		debian/dpdk-dev/usr/share/dpdk/dpdk-sdk-env.sh
107	# Package: libdpdk-dev (bare headers, static devel libs and linker
108	# script)
109	mkdir -p debian/libdpdk-dev/$(LIBDIR)
110	# linker script
111	mv debian/dpdk/usr/lib/libdpdk.so debian/libdpdk-dev/$(LIBDIR)/
112	# includes
113	mkdir -p debian/libdpdk-dev/usr/include
114	mv debian/dpdk-dev/usr/include/dpdk debian/libdpdk-dev/usr/include/
115	# all static libs are in the dev package
116	mv debian/dpdk/usr/lib/lib*.a debian/libdpdk-dev/$(LIBDIR)/
117	# symlinks to last .so's are in the non versioned libdpdk-dev as well
118	# this allows multiple libdpdk-<NAME><VER> at different VER concurrently
119	# libdpdk-dev depends on all sublibs so symlinks are never broken
120	mv debian/dpdk/usr/lib/*.so debian/libdpdk-dev/$(LIBDIR)/
121	# Package(s): libdpdk-<NAME><VER> (bare runtime libs)
122	for lib in $$(ls -1 debian/dpdk/usr/lib/*.so.*); do \
123	  BN=$$(basename $${lib}); \
124	  VER=$$(echo $${BN} | sed -e 's/^.*\.so\.//'); \
125	  LN=$$(echo $${BN} | sed -e 's/\.so\.[0-9]*$$//' | tr '_' '-'); \
126	  if echo $${LN} | grep -q ".*[0-9]$$"; then \
127	    PKG=$${LN}-$${VER}; \
128	  else \
129	    PKG=$${LN}$${VER}; \
130	  fi; \
131	  echo "moving $${lib} for library $${PKG}"; \
132	  mkdir -p debian/$${PKG}/$(LIBDIR); \
133	  mv $${lib} debian/$${PKG}/$(LIBDIR); \
134	done
135	# pkg-config
136	mkdir -p debian/libdpdk-dev/$(LIBDIR)/pkgconfig
137	LIBS=$$(sed -e 's/GROUP ( \(.*\) )/\1/' -e 's/lib/-l/g' -e 's/\.so//g' \
138		$(CURDIR)/debian/libdpdk-dev/$(LIBDIR)/libdpdk.so); \
139	sed -e "s/@DPDK_LIBS@/$${LIBS}/" -e "s/@VERSION@/$(VERSION)/" \
140		debian/libdpdk.pc.in > debian/libdpdk-dev/$(LIBDIR)/pkgconfig/libdpdk.pc
141	# Package: dpdk-igb-uio-dkms
142	mkdir -p debian/dpdk-igb-uio-dkms/usr/src/dpdk-igb-uio-$(VERSION)
143	cp lib/librte_eal/linuxapp/igb_uio/* \
144		debian/dpdk-igb-uio-dkms/usr/src/dpdk-igb-uio-$(VERSION)
145	# Package: dpdk-rte-kni-dkms
146	mkdir -p debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION)
147	cp -a lib/librte_eal/linuxapp/kni/* \
148		debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION)
149
150override_dh_dkms:
151	dh_dkms -V $(VERSION)
152
153override_dh_installinit:
154	dh_installinit --no-start --no-restart-on-upgrade
155
156override_dh_systemd_start:
157	dh_systemd_start --no-start --no-restart-on-upgrade
158
159override_dh_auto_test:
160
161