33# output every command that modifies files on the build system.
44# export DH_VERBOSE = 1
55
6+ .ONESHELL :
7+ SHELL = /bin/bash
8+ .SHELLFLAGS += -ex
9+
10+ # see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
11+ DPKG_EXPORT_BUILDFLAGS = 1
12+ include /usr/share/dpkg/default.mk
13+
614ifneq (${SWSS_COMMON_INC},)
715 SWSS_COMMON_CONFIG = "--with-swss-common-inc=${SWSS_COMMON_INC}"
816endif
@@ -13,7 +21,7 @@ ifneq (${SWSS_COMMON_LIB},)
1321endif
1422
1523# see FEATURE AREAS in dpkg-buildflags(1)
16- export DEB_BUILD_MAINT_OPTIONS = hardening=+all
24+ # export DEB_BUILD_MAINT_OPTIONS = hardening=+all
1725
1826# see ENVIRONMENT in dpkg-buildflags(1)
1927# package maintainers to append CFLAGS
@@ -23,53 +31,78 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
2331
2432DOPACKAGES = $(shell dh_listpackages)
2533
26- configure_opts = --disable-static
27- ifeq ($(ENABLE_ASAN ) , y)
28- configure_opts += --enable-asan
29- endif
30-
3134# For Debian jessie, stretch, and buster, and Ubuntu bionic and focal, build
3235# Python 2 bindings. This is controlled by the build profile being used.
33- ifeq (,$(filter nopython2 ,$(DEB_BUILD_PROFILES ) ) )
36+ ifneq (,$(filter python-pysairedis ,$(DOPACKAGES ) ) )
3437configure_opts += --enable-python2
3538else
3639configure_opts += --disable-python2
3740endif
3841
39- ifneq ($(filter syncd,$(DEB_BUILD_PROFILES ) ) ,)
40- ifneq ($(filter rpc,$(DEB_BUILD_PROFILES ) ) ,)
41- configure_opts += --enable-rpcserver
42- endif
43- ifneq ($(filter vs,$(DEB_BUILD_PROFILES ) ) ,)
44- configure_opts += --with-sai=vs
45- endif
46- else
47- configure_opts += --disable-syncd
48- endif
42+ clean :
43+ dh $@ --with autotools-dev
44+
45+ build :
46+ echo build stage is skipped. Please use binary to generate debian packages
4947
50- % :
51- dh $@
48+ binary : binary-syncd-rpc binary-syncd
49+
50+ binary-sairedis :
51+ echo ' --enable-syncd=no' > /tmp/syncd-build
52+ ENABLESYNCD=no dh clean --with autotools-dev
53+ dh build -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
54+ dh binary -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
55+
56+ binary-syncd :
57+ echo > /tmp/syncd-build
58+ dh clean --with autotools-dev
59+ dh build -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
60+ dh binary -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
61+
62+ binary-syncd-rpc : | binary-syncd
63+ echo ' --enable-rpcserver=yes' > /tmp/syncd-build
64+ dh clean --with autotools-dev
65+ dh build -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
66+ dh binary -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
67+
68+ binary-syncd-vs :
69+ echo ' --with-sai=vs' > /tmp/syncd-build
70+ dh clean --with autotools-dev
71+ dh build -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev
72+ dh binary -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev
5273
5374# dh_make generated override targets
5475# This is example for Cmake (See https://bugs.debian.org/641051 )
5576# override_dh_auto_configure:
5677# dh_auto_configure -- \
5778# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
5879
80+ configure_opts =
81+ ifeq ($(ENABLE_ASAN ) , y)
82+ configure_opts += --enable-asan
83+ endif
84+
5985override_dh_auto_configure :
60- dh_auto_configure -- ${SWSS_COMMON_CONFIG} $(configure_opts )
86+ ./autogen.sh
87+ dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS ) $(shell cat /tmp/syncd-build) ${SWSS_COMMON_CONFIG} $(configure_opts )
6188
6289override_dh_install :
6390 dh_install
6491 # Note: escape $ with an extra $ symbol
65- ifneq ($(filter rpc,$(DEB_BUILD_PROFILES ) ) ,)
66- if [ -f debian/syncd-rpc/usr/bin/syncd_init_common.sh ] ; then
92+ if egrep -q ' (^| )--enable-rpcserver=yes( |$$)' /tmp/syncd-build && [ -f debian/syncd-rpc/usr/bin/syncd_init_common.sh ] ; then
6793 sed -i ' s|ENABLE_SAITHRIFT=0|ENABLE_SAITHRIFT=1 # Add a comment to fix https://github.com/Azure/sonic-buildimage/issues/2694 |' debian/syncd-rpc/usr/bin/syncd_init_common.sh
6894 fi
69- endif
7095
7196override_dh_installinit :
7297 dh_installinit --init-script=syncd
7398
7499override_dh_shlibdeps :
75- $(LD_LIBRARY_PATH_CONFIG ) dh_shlibdeps -- --ignore-missing-info -xlibsai
100+ $(LD_LIBRARY_PATH_CONFIG ) dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
101+
102+ override_dh_strip :
103+ dh_strip -psyncd-rpc --dbg-package=syncd-rpc-dbg
104+ dh_strip -psyncd --dbg-package=syncd-dbg
105+ dh_strip -psyncd-vs --dbg-package=syncd-vs-dbg
106+ dh_strip -plibsairedis --dbg-package=libsairedis-dbg
107+ dh_strip -plibsaivs --dbg-package=libsaivs-dbg
108+ dh_strip -plibsaimetadata --dbg-package=libsaimetadata-dbg
0 commit comments