diff --git a/rules/functions b/rules/functions index d5aba46fd5d2..4c1131ba6ddb 100644 --- a/rules/functions +++ b/rules/functions @@ -153,3 +153,12 @@ $(foreach deb,$(1), \ fi; \ done; } ) endef + +############################################################################### +## src/*/Makefile functions +############################################################################### +define add_dbgsym_debs +ifneq ($(findstring nostrip, $(1)), nostrip) +DERIVED_TARGETS = $(2) $(3) +endif +endef diff --git a/src/hiredis/Makefile b/src/hiredis/Makefile index 746056e51de5..21fb74e9153d 100644 --- a/src/hiredis/Makefile +++ b/src/hiredis/Makefile @@ -2,8 +2,13 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = libhiredis0.14_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = libhiredis0.14-dbgsym_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb libhiredis-dev_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb +DEBUG_TARGETS = libhiredis0.14-dbgsym_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb +DERIVED_TARGETS = libhiredis-dev_$(HIREDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf hiredis-$(HIREDIS_VERSION) diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index bd957a08a6f5..965f3c12d31d 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -2,8 +2,13 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = $(ISC_DHCP_RELAY) -DERIVED_TARGETS = $(ISC_DHCP_RELAY_DBG) +DEBUG_TARGETS = $(ISC_DHCP_RELAY_DBG) +DERIVED_TARGETS = + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Remove any stale files diff --git a/src/libteam/Makefile b/src/libteam/Makefile index 9fd5f582ed4d..15d97cabe088 100644 --- a/src/libteam/Makefile +++ b/src/libteam/Makefile @@ -2,13 +2,17 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = libteam5_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = libteam-dev_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ - libteamdctl0_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ - libteam-utils_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ - libteam5-dbgsym_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ +DEBUG_TARGETS = libteam5-dbgsym_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ libteamdctl0-dbgsym_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ libteam-utils-dbgsym_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb +DERIVED_TARGETS = libteam-dev_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ + libteamdctl0_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb \ + libteam-utils_$(LIBTEAM_VERSION)_$(CONFIGURED_ARCH).deb + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtain libteam diff --git a/src/libyang/Makefile b/src/libyang/Makefile index 32cabdf13bdf..10400ca552d1 100644 --- a/src/libyang/Makefile +++ b/src/libyang/Makefile @@ -2,8 +2,13 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = $(LIBYANG) -DERIVED_TARGETS = $(LIBYANG_DEV) $(LIBYANG_DBG) $(LIBYANG_PY2) $(LIBYANG_PY3) $(LIBYANG_CPP) +DEBUG_TARGETS = $(LIBYANG_DBG) +DERIVED_TARGETS = $(LIBYANG_DEV) $(LIBYANG_PY2) $(LIBYANG_PY3) $(LIBYANG_CPP) + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtaining the libyang diff --git a/src/lldpd/Makefile b/src/lldpd/Makefile index fa997e3486c8..ed28006e6844 100644 --- a/src/lldpd/Makefile +++ b/src/lldpd/Makefile @@ -2,8 +2,11 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = $(LLDPD) -DERIVED_TARGETS = $(LIBLLDPCTL) $(LLDPD_DBG) +DEBUG_TARGETS = $(LLDPD_DBG) +DERIVED_TARGETS = $(LIBLLDPCTL) LLDP_URL = https://sonicstorage.blob.core.windows.net/debian/pool/main/l/lldpd @@ -15,6 +18,8 @@ DSC_FILE_URL = $(LLDP_URL)/$(DSC_FILE) ORIG_FILE_URL = $(LLDP_URL)/$(ORIG_FILE) DEBIAN_FILE_URL = $(LLDP_URL)/$(DEBIAN_FILE) +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) + $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Remove any stale files rm -rf lldpd-$(LLDPD_VERSION) diff --git a/src/lm-sensors/Makefile b/src/lm-sensors/Makefile index af080a8dba55..28d170bd8a72 100644 --- a/src/lm-sensors/Makefile +++ b/src/lm-sensors/Makefile @@ -2,14 +2,17 @@ SHELL = /bin/bash .ONESHELL: .SHELLFLAGS += -e +include /sonic/rules/functions MAIN_TARGET = $(LM_SENSORS) +DEBUG_TARGETS = $(LM_SENSORS_DBG) \ + $(LIBSENSORS_DBG) \ + $(SENSORD_DBG) DERIVED_TARGETS = fancontrol_$(LM_SENSORS_VERSION_FULL)_all.deb \ $(LIBSENSORS) \ - sensord_$(LM_SENSORS_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ - $(LM_SENSORS_DBG) \ - $(LIBSENSORS_DBG) \ - $(SENSORD_DBG) + sensord_$(LM_SENSORS_VERSION_FULL)_$(CONFIGURED_ARCH).deb + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf lm-sensors-$(LM_SENSORS_VERSION) diff --git a/src/monit/Makefile b/src/monit/Makefile index 4ad9edd79143..51d883aabafa 100644 --- a/src/monit/Makefile +++ b/src/monit/Makefile @@ -2,8 +2,13 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = monit_$(MONIT_VERSION)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = monit-dbgsym_$(MONIT_VERSION)_$(CONFIGURED_ARCH).deb +DEBUG_TARGETS = monit-dbgsym_$(MONIT_VERSION)_$(CONFIGURED_ARCH).deb +DERIVED_TARGETS = + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Remove any stale files diff --git a/src/openssh/Makefile b/src/openssh/Makefile index 66c6f019619f..04e0a31b2cc9 100644 --- a/src/openssh/Makefile +++ b/src/openssh/Makefile @@ -2,8 +2,13 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = openssh-server_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = openssh-server-dbgsym_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb +DEBUG_TARGETS = openssh-server-dbgsym_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb +DERIVED_TARGETS = + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtain openssh: https://salsa.debian.org/ssh-team/openssh/-/tree/debian/1%257.9p1-10+deb10u2 diff --git a/src/redis/Makefile b/src/redis/Makefile index e2d9e5828f5b..ec33e1f837b4 100644 --- a/src/redis/Makefile +++ b/src/redis/Makefile @@ -2,13 +2,17 @@ SHELL = /bin/bash .ONESHELL: .SHELLFLAGS += -e +include /sonic/rules/functions + REDIS_VERSION = 5.0.3 REDIS_VERSION_FULL = $(REDIS_VERSION)-3~bpo9+2 MAIN_TARGET = redis-server_$(REDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb +DEBUG_TARGETS = redis-tools-dbgsym_$(REDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb DERIVED_TARGETS = redis-tools_$(REDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ - redis-sentinel_$(REDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ - redis-tools-dbgsym_$(REDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb + redis-sentinel_$(REDIS_VERSION_FULL)_$(CONFIGURED_ARCH).deb + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf redis_build diff --git a/src/sflow/hsflowd/Makefile b/src/sflow/hsflowd/Makefile index f0b15c78bd3c..a9975eef033c 100644 --- a/src/sflow/hsflowd/Makefile +++ b/src/sflow/hsflowd/Makefile @@ -2,8 +2,13 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = $(HSFLOWD) -DERIVED_TARGET = $(HSFLOWD_DBG) +DEBUG_TARGETS = $(HSFLOWD_DBG) +DERIVED_TARGET = + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -fr ./host-sflow diff --git a/src/snmpd/Makefile b/src/snmpd/Makefile index 5e5c2a88098a..29b04340cb1f 100644 --- a/src/snmpd/Makefile +++ b/src/snmpd/Makefile @@ -2,12 +2,14 @@ SHELL = /bin/bash .ONESHELL: .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = libsnmp-base_$(SNMPD_VERSION_FULL)_all.deb +DEBUG_TARGETS = snmp-dbgsym_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ + snmpd-dbgsym_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb DERIVED_TARGETS = snmptrapd_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ snmp_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ snmpd_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ - snmp-dbgsym_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ - snmpd-dbgsym_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ libsnmp30_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ libsnmp30-dbg_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ libsnmp-dev_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ @@ -15,6 +17,8 @@ DERIVED_TARGETS = snmptrapd_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ python-netsnmp_$(SNMPD_VERSION_FULL)_$(CONFIGURED_ARCH).deb \ tkmib_$(SNMPD_VERSION_FULL)_all.deb +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) + $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf net-snmp-$(SNMPD_VERSION) diff --git a/src/sonic-frr/Makefile b/src/sonic-frr/Makefile index e479f5e2ca1e..086717b3490a 100644 --- a/src/sonic-frr/Makefile +++ b/src/sonic-frr/Makefile @@ -2,11 +2,16 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = $(FRR) -DERIVED_TARGET = $(FRR_PYTHONTOOLS) $(FRR_DBG) $(FRR_SNMP) $(FRR_SNMP_DBG) +DEBUG_TARGETS = $(FRR_DBG) $(FRR_SNMP_DBG) +DERIVED_TARGET = $(FRR_PYTHONTOOLS) $(FRR_SNMP) SUFFIX = $(shell date +%Y%m%d\.%H%M%S) STG_BRANCH = stg_temp.$(SUFFIX) +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) + $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package pushd ./frr diff --git a/src/swig/Makefile b/src/swig/Makefile index f9deda6a831d..1b86e6275eeb 100644 --- a/src/swig/Makefile +++ b/src/swig/Makefile @@ -2,8 +2,13 @@ SHELL = /bin/bash .SHELLFLAGS += -e +include /sonic/rules/functions + MAIN_TARGET = $(SWIG_BASE) -DERIVED_TARGETS = $(SWIG) $(SWIG_DBG) +DEBUG_TARGETS = $(SWIG_DBG) +DERIVED_TARGETS = $(SWIG) + +$(eval $(call add_dbgsym_debs, $(DEB_BUILD_OPTIONS), $(DEBUG_TARGETS), $(DERIVED_TARGETS))) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -fr ./swig-$(SWIG_VERSION) *.deb diff --git a/src/systemd-sonic-generator/Makefile b/src/systemd-sonic-generator/Makefile index 973c0d64eaed..c13da03cfbf4 100644 --- a/src/systemd-sonic-generator/Makefile +++ b/src/systemd-sonic-generator/Makefile @@ -3,11 +3,15 @@ CFLAGS=-std=gnu99 BINARY = systemd-sonic-generator MAIN_TARGET = $(BINARY)_1.0.0_$(CONFIGURED_ARCH).deb +DEBUG_TARGETS = $(BINARY)-dbgsym_1.0.0_$(CONFIGURED_ARCH).deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-buildpackage -us -uc -b mv ../$(MAIN_TARGET) $(DEST)/ - rm ../$(BINARY)-* ../$(BINARY)_* + rm ../$(BINARY)_* +ifneq ($(findstring nostrip,$(DEB_BUILD_OPTIONS)),nostrip) + rm ../$(DEBUG_TARGETS) +endif $(BINARY): systemd-sonic-generator.c rm -f ./systemd-sonic-generator