rules revision c5a342bd
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
42clean:
43	dh_testdir
44	rm -rf debian/build debian/tmp
45	dh_clean
46
47build-config:
48	dh_testdir
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
62build-indep: build-config
63	dh_testdir
64	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) doc-api-html doc-guides-html
65
66build-arch: build-config
67	dh_testdir
68	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) build
69	# Unfortunately the decision about having static or shared libraries is
70	# made for the whole build, which then produces only .a or .so files
71	# (but not both).
72	# And the target layout for target selection has no field for the
73	# type of library.
74	# Right now I hack this by doing a second build which only differs in
75	# the selection of shared libs.
76	# Shared libs should be default, so the previous static build is only
77	# used to get static libraries.
78	cp -a $(DPDK_STATIC_DIR) $(DPDK_SHARED_DIR)
79	sed -ri 's,(RTE_BUILD_SHARED_LIB=).*,\1y,' \
80		$(DPDK_SHARED_DIR)/.config
81	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) build
82
83build: build-arch build-indep
84
85binary-indep: PACKAGE_NAME=dpdk-doc
86binary-indep: DOCDIR=usr/share/doc/dpdk
87binary-indep: export DH_OPTIONS=--indep
88binary-indep:
89	dh_testroot
90	dh_prep
91	dh_testdir
92	dh_installdirs
93	dh_install
94	dh_installdocs
95	dh_installchangelogs
96	dh_lintian
97	# Package: dpdk-doc
98	# All files based on the install-doc rule (includes examples)
99	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) prefix=/usr \
100		DESTDIR=debian/dpdk-doc install-doc
101	dh_link
102	dh_compress
103	dh_fixperms
104	dh_installdeb
105	dh_gencontrol
106	dh_md5sums
107	dh_builddeb
108
109binary-arch: LIBDIR=usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
110binary-arch: export DH_OPTIONS=--arch
111binary-arch:
112	dh_testroot
113	dh_prep
114	dh_testdir
115	dh_installdirs
116	dh_install
117	dh_installdocs
118	dh_installchangelogs
119	dh_lintian
120	dh_systemd_enable
121	dh_installinit --no-start --no-restart-on-upgrade
122	dh_systemd_start --no-start --no-restart-on-upgrade
123	# Package: dpdk (runtime)
124	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_STATIC_DIR) prefix=/usr \
125		DESTDIR=debian/dpdk install-runtime
126	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) prefix=/usr \
127		DESTDIR=debian/dpdk install-runtime
128	cp debian/dpdk.interfaces debian/dpdk/etc/dpdk/interfaces
129	rm debian/dpdk/usr/sbin/dpdk_nic_bind
130	mkdir -p debian/dpdk/sbin
131	ln -s /usr/share/dpdk/tools/dpdk_nic_bind.py \
132		debian/dpdk/sbin/dpdk_nic_bind
133	# Package: dpdk-dev (build environment)
134	$(MAKE) V=$(DH_VERBOSE) O=$(DPDK_SHARED_DIR) prefix=/usr \
135		DESTDIR=debian/dpdk-dev install-sdk
136	cp $(DPDK_SHARED_DIR)/.config debian/dpdk-dev/usr/share/dpdk/config
137	sed -e 's/SDK_TARGET/$(RTE_TARGET)/' debian/dpdk-sdk-env.sh.in > \
138		debian/dpdk-dev/usr/share/dpdk/dpdk-sdk-env.sh
139	# Package: libdpdk-dev (bare headers, static devel libs and linker
140	# script)
141	mkdir -p debian/libdpdk-dev/$(LIBDIR)
142	# linker script
143	mv debian/dpdk/usr/lib/libdpdk.so debian/libdpdk-dev/$(LIBDIR)/
144	# includes
145	mkdir -p debian/libdpdk-dev/usr/include
146	mv debian/dpdk-dev/usr/include/dpdk debian/libdpdk-dev/usr/include/
147	# all static libs are in the dev package
148	mv debian/dpdk/usr/lib/lib*.a debian/libdpdk-dev/$(LIBDIR)/
149	# symlinks to last .so's are in the non versioned libdpdk-dev as well
150	# this allows multiple libdpdk-<NAME><VER> at different VER concurrently
151	# libdpdk-dev depends on all sublibs so symlinks are never broken
152	mv debian/dpdk/usr/lib/*.so debian/libdpdk-dev/$(LIBDIR)/
153	# Package(s): libdpdk-<NAME><VER> (bare runtime libs)
154	for lib in $$(ls -1 debian/dpdk/usr/lib/*.so.*); do \
155	  BN=$$(basename $${lib}); \
156	  VER=$$(echo $${BN} | sed -e 's/^.*\.so\.//'); \
157	  LN=$$(echo $${BN} | sed -e 's/\.so\.[0-9]*$$//' | tr '_' '-'); \
158	  if echo $${LN} | grep -q ".*[0-9]$$"; then \
159	    PKG=$${LN}-$${VER}; \
160	  else \
161	    PKG=$${LN}$${VER}; \
162	  fi; \
163	  echo "moving $${lib} for library $${PKG}"; \
164	  mkdir -p debian/$${PKG}/$(LIBDIR); \
165	  mv $${lib} debian/$${PKG}/$(LIBDIR); \
166	done
167	# Package: dpdk-igb-uio-dkms
168	mkdir -p debian/dpdk-igb-uio-dkms/usr/src/dpdk-igb-uio-$(VERSION)
169	cp lib/librte_eal/linuxapp/igb_uio/* \
170		debian/dpdk-igb-uio-dkms/usr/src/dpdk-igb-uio-$(VERSION)
171	# Package: dpdk-rte-kni-dkms
172	mkdir -p debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION)
173	cp -a lib/librte_eal/linuxapp/kni/* \
174		debian/dpdk-rte-kni-dkms/usr/src/dpdk-rte-kni-$(VERSION)
175	dh_dkms -V $(VERSION)
176	dh_python2
177	dh_perl
178	dh_link
179	dh_compress
180	dh_fixperms
181	dh_strip
182	dh_makeshlibs
183	dh_shlibdeps
184	dh_installdeb
185	dh_gencontrol
186	dh_md5sums
187	dh_builddeb
188
189binary: binary-arch binary-indep
190