summaryrefslogtreecommitdiff
path: root/debian/rules.d/binary-libubsan.mk
blob: 278ee494d66d163d78d2c4e30e9c8fd0239afdcf (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
$(lib_binaries)  += libubsan
ifeq ($(with_lib64ubsan),yes)
  $(lib_binaries)  += lib64ubsan
endif
ifeq ($(with_lib32ubsan),yes)
  $(lib_binaries)	+= lib32ubsan
endif
ifeq ($(with_libn32ubsan),yes)
  $(lib_binaries)	+= libn32ubsan
endif
ifeq ($(with_libx32ubsan),yes)
  $(lib_binaries)	+= libx32ubsan
endif
ifeq ($(with_libhfubsan),yes)
  $(lib_binaries)	+= libhfubsan
endif
ifeq ($(with_libsfubsan),yes)
  $(lib_binaries)	+= libsfubsan
endif

define __do_ubsan
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_l) $(d_d)
	dh_installdirs -p$(p_l) $(usr_lib$(2))
	$(if $(empty_sanitizer_packages),, \
	DH_COMPAT=2 dh_movefiles -p$(p_l) $(usr_lib$(2))/libubsan.so.* )

	debian/dh_doclink -p$(p_l) $(p_base)
	debian/dh_doclink -p$(p_d) $(p_base)

	if [ -f debian/$(p_l).overrides ]; then \
		mkdir -p debian/$(p_l)/usr/share/lintian/overrides; \
		cp debian/$(p_l).overrides debian/$(p_l)/usr/share/lintian/overrides/$(p_l); \
	fi

	dh_strip -p$(p_l) --dbg-package=$(p_d)
	dh_compress -p$(p_l) -p$(p_d)
	dh_fixperms -p$(p_l) -p$(p_d)
	$(cross_makeshlibs) dh_makeshlibs -p$(p_l)
	$(call cross_mangle_shlibs,$(p_l))
	$(ignshld)DIRNAME=$(subst n,,$(2)) $(cross_shlibdeps) dh_shlibdeps -p$(p_l) \
		$(call shlibdirs_to_search, \
			$(subst ubsan$(UBSAN_SONAME),gcc$(GCC_SONAME),$(p_l)) \
			$(subst ubsan$(UBSAN_SONAME),stdc++$(CXX_SONAME),$(p_l)) \
		,$(2))
	$(call cross_mangle_substvars,$(p_l))
	$(cross_gencontrol) dh_gencontrol -p$(p_l) -p$(p_d)	\
		-- -v$(DEB_VERSION) $(common_substvars)
	$(call cross_mangle_control,$(p_l))
	dh_installdeb -p$(p_l) -p$(p_d)
	dh_md5sums -p$(p_l) -p$(p_d)
	dh_builddeb -p$(p_l) -p$(p_d)

	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)
endef

# ----------------------------------------------------------------------

do_ubsan = $(call __do_ubsan,lib$(1)ubsan$(UBSAN_SONAME),$(1))

$(binary_stamp)-libubsan: $(install_stamp)
	$(call do_ubsan,)

$(binary_stamp)-lib64ubsan: $(install_stamp)
	$(call do_ubsan,64)

$(binary_stamp)-lib32ubsan: $(install_stamp)
	$(call do_ubsan,32)

$(binary_stamp)-libn32ubsan: $(install_stamp)
	$(call do_ubsan,n32)

$(binary_stamp)-libx32ubsan: $(install_stamp)
	$(call do_ubsan,x32)

$(binary_stamp)-libhfubsan: $(install_dependencies)
	$(call do_ubsan,hf)

$(binary_stamp)-libsfubsan: $(install_dependencies)
	$(call do_ubsan,sf)