File: rules

package info (click to toggle)
clamav 0.101.4+dfsg-0+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,564 kB
  • sloc: ansic: 158,978; sh: 8,178; cpp: 5,173; makefile: 2,088; yacc: 1,351; lex: 714; python: 120; perl: 17
file content (179 lines) | stat: -rwxr-xr-x 7,861 bytes parent folder | download
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#! /usr/bin/make -f

# Comment this out to turn off verbose mode.
#export DH_VERBOSE=1

# Automake 1.14 warns about not using subdir-objects,
# but using this option breaks the build, see:
#    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16375
#    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
# The following variables can be used to override the automake/aclocal versions.
#export AUTOMAKE = automake
#export ACLOCAL = aclocal

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# This is needed to work around arch-specific quirks in the test suite.
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

# Get the hardening build flags and enable all compiler warnings:
CFLAGS   := $(shell dpkg-buildflags --get CFLAGS) -Wall -D_FILE_OFFSET_BITS=64
CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) -Wall -D_FILE_OFFSET_BITS=64
CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS  := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed

# LLVM is only used on these archs, so no point in enabling it elsewhere
# To add new llvm/jit archs add it here and to the arch list for llvm-dev in
# debian/control.
# PowerPC is disabled until atleast llvm-3.8. As thing stand now MCJIT is
# broken in llvm-3.6. llvm v3.8 looks promissing but needs to be verified.
ifeq (,$(filter $(DEB_HOST_ARCH), i386 amd64 kfreebsd-amd64 kfreebsd-i386))
  export enable_llvm=no
else
    SYSTEM_LLVM = -with-system-llvm=/usr/bin/llvm-config --with-llvm-linking=dynamic
endif

# Set the configure options:
#	* add the build flags
#	* set various paths
#	* disable test for clamav user/group (--disable-clamav)
#	* disable building of the non-free libclamunrar (--disable-unrar)
#	* build clamav-milter (--enable-milter)
#	* enable workaround for broken DNS servers (--enable-dns-fix)
#	* assume the C compiler uses GNU ld (--with-gnu-ld)
#	* use system libraries instead of the embedded copies (--with-system-tommath, --without-included-ltdl, -with-system-llvm=/usr/bin/llvm-config)
CONFIG := CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
	--with-dbdir=/var/lib/clamav --sysconfdir=/etc/clamav \
	--disable-clamav --disable-unrar --enable-milter --enable-dns-fix \
	--with-libjson --with-system-libmspack --with-libcurl=/usr \
	--with-gnu-ld $(SYSTEM_LLVM) \
	--with-systemdsystemunitdir=/lib/systemd/system

DEBUG_OPTS=

# Enable debug code, if nostrip was given.
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
else
	DEBUG_OPTS += --enable-debug
endif

# Don't use systemd on wheezy.
ifeq ($(shell cut -c1 /etc/debian_version),7)
  SYSTEMD =
else
  SYSTEMD = --with systemd
endif

# Use the default debhelper scripts, where possible.
# Enable parallel building and conditionally autoreconf and systemd.
%:
	dh $@ --parallel --with autoreconf $(SYSTEMD)

override_dh_auto_configure:
	$(info DEB_BUILD_OPTIONS = $(DEB_BUILD_OPTIONS))
	$(info CFLAGS = $(CFLAGS))
	$(info CXXFLAGS = $(CXXFLAGS))
	$(info CPPFLAGS = $(CPPFLAGS))
	$(info LDFLAGS = $(LDFLAGS))
	# Check for unknown options in the configuration files.
	egrep '^#[[:alpha:]]' etc/clamd.conf.sample | sed -e 's/^#//' | awk '{print $$1}' | while read opt; do \
	  if ! grep -q "$${opt}" debian/clamav-daemon.postinst.in ; then \
	    echo "Unhandled option(clamd.conf): $${opt}"; \
	    touch debian/exit; \
	  fi;\
	done; \
	egrep '^#[[:alpha:]]' etc/freshclam.conf.sample | sed -e 's/^#//' | awk '{print $$1}' | while read opt; do \
	  if ! grep -q "$${opt}" debian/clamav-freshclam.postinst.in ; then \
	    echo "Unhandled option (freshclam.conf): $${opt}"; \
	    touch debian/exit; \
	  fi;\
	done; \
	egrep '^#[[:alpha:]]' etc/clamav-milter.conf.sample | sed -e 's/^#//' | awk '{print $$1}' | while read opt; do \
	  if ! grep -q "$${opt}" debian/clamav-milter.postinst.in ; then \
	    echo "Unhandled option (clamav-milter.conf): $${opt}"; \
	    touch debian/exit; \
	  fi;\
	done; \
	# Check for library features which may have been upgraded.
	if ! grep -q "CL_FLEVEL 105" libclamav/others.h ; then \
		echo "cl_retflevel needs boosting in symbol file"; \
		touch debian/exit; \
	fi;
	sed "s/ \(.*\)@CLAMAV_PRIVATE .*/ \1@CLAMAV_PRIVATE $(shell dpkg-parsechangelog -S Version | sed 's/+dfsg.*//')/" \
		< debian/libclamav9.symbols > debian/libclamav9.symbols.latest
	if ! cmp debian/libclamav9.symbols debian/libclamav9.symbols.latest; then \
		echo "Need to update CLAMAV_PRIVATE symbols"; \
		touch debian/exit; \
	fi;

	[ ! -f debian/exit ] || (rm debian/exit && exit 1)
	rm debian/libclamav9.symbols.latest

	# Configure using the specified flags.
	dh_auto_configure -- $(CONFIG) $(DEBUG_OPTS)

override_dh_auto_clean:
	# Update .po files for debconf.
	debconf-updatepo
	dh_auto_clean

clamav_build-indep:
	# Add common functions in config and postinst files.
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-base.postinst.in > debian/clamav-base.postinst

clamav_build-arch:
	# Add common functions in config and postinst files.
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-milter.init.in > debian/clamav-milter.init
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-milter.config.in > debian/clamav-milter.config
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-milter.postinst.in > debian/clamav-milter.postinst
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-daemon.config.in > debian/clamav-daemon.config
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-daemon.postinst.in > debian/clamav-daemon.postinst
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-daemon.init.in > debian/clamav-daemon.init
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-freshclam.init.in > debian/clamav-freshclam.init
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-freshclam.config.in > debian/clamav-freshclam.config
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-freshclam.postinst.in > debian/clamav-freshclam.postinst
	perl -pe 's~#COMMON-FUNCTIONS#~qx{cat debian/common_functions}~eg' < debian/clamav-freshclam.prerm.in > debian/clamav-freshclam.prerm

override_dh_auto_build-indep: clamav_build-indep
	# Build architecture-independent files.
	dh_auto_build -i -- V=1

override_dh_auto_build-arch: clamav_build-arch
	# Build architecture-dependent files.
	dh_auto_build -a -- V=1

override_dh_auto_test:
ifneq (,$(filter ia64 sparc, $(DEB_HOST_ARCH)))
	T=900 dh_auto_test -- EF_ALIGNMENT=8 V=1 VERBOSE=1
else
	T=900 dh_auto_test -- V=1 VERBOSE=1
endif

override_dh_strip:
	dh_strip --dbgsym-migration=clamav-dbg

override_dh_install:
	dh_install
	dh_apparmor -pclamav-freshclam --profile-name=usr.bin.freshclam
	dh_apparmor -pclamav-daemon --profile-name=usr.sbin.clamd

override_dh_installinit:
	dh_installinit -pclamav-daemon
	# Don't change the postinst/postrm scripts for clamav-freshclam, as they need non-standard code.
	dh_installinit -pclamav-freshclam --noscripts
	dh_installinit -pclamav-milter

override_dh_installdocs-indep:
	dh_installdocs
	# Make the .rar test files which are no longer created
	cat test/.split/split.clam-v2.raraa test/.split/split.clam-v2.rarab >debian/clamav-testfiles/usr/share/clamav-testfiles/clam-v2.rar
	cat test/.split/split.clam-v3.raraa test/.split/split.clam-v3.rarab >debian/clamav-testfiles/usr/share/clamav-testfiles/clam-v3.rar

# dh_strip_nondeterminism breaks .zip files. See #817943
override_dh_strip_nondeterminism:
	dh_strip_nondeterminism -Xclam.bz2.zip -Xclam.d64.zip -Xclam.impl.zip -Xclam.zip

# Don't compress the example configuration files and the documentation PDFs.
override_dh_compress:
	dh_compress -Xexamples