summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules246
1 files changed, 246 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..225655612
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,246 @@
1#!/usr/bin/make -f
2
3# Uncomment this to turn on verbose mode.
4# export DH_VERBOSE=1
5
6# This has to be exported to make some magic below work.
7export DH_OPTIONS
8
9ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
10 RUN_TESTS := yes
11else
12 RUN_TESTS :=
13endif
14
15ifeq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
16 PARALLEL :=
17else
18 PARALLEL := \
19 -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
20endif
21
22DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
23DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
24DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
25
26ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
27 CC := gcc
28 PKG_CONFIG = pkg-config
29else
30 CC := $(DEB_HOST_GNU_TYPE)-gcc
31 PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config
32 RUN_TESTS :=
33endif
34
35DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
36
37# Take account of old dpkg-architecture output.
38ifeq ($(DEB_HOST_ARCH_OS),)
39 DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM))
40 ifeq ($(DEB_HOST_ARCH_OS),gnu)
41 DEB_HOST_ARCH_OS := hurd
42 endif
43endif
44
45# Change the version string to reflect distribution
46DISTRIBUTION := $(shell dpkg-vendor --query vendor)
47SSH_EXTRAVERSION := $(DISTRIBUTION)-$(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p' | sed -e 's/[^-]*-//')
48
49DISTRIBUTOR := $(shell if dpkg-vendor --derives-from Ubuntu 2>/dev/null; then echo Ubuntu; else echo Debian; fi)
50ifeq ($(DISTRIBUTOR),Ubuntu)
51DEFAULT_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
52else
53DEFAULT_PATH := /usr/local/bin:/usr/bin:/bin:/usr/games
54endif
55SUPERUSER_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
56
57ifeq ($(DISTRIBUTOR),Ubuntu)
58server_recommends := ssh-import-id
59else
60server_recommends :=
61endif
62
63# Common path configuration.
64confflags += --sysconfdir=/etc/ssh
65confflags += --libexecdir=\$${prefix}/lib/openssh
66
67# Common build options.
68confflags += --disable-strip
69confflags += --with-mantype=doc
70confflags += --with-4in6
71confflags += --with-privsep-path=/run/sshd
72confflags += --with-pid-dir=/run
73
74# The Hurd needs libcrypt for res_query et al.
75ifeq ($(DEB_HOST_ARCH_OS),hurd)
76confflags += --with-libs=-lcrypt
77endif
78
79# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60155
80ifeq ($(DEB_HOST_ARCH),hppa)
81confflags += --without-hardening
82endif
83
84# Everything above here is common to the deb and udeb builds.
85confflags_udeb := $(confflags)
86
87# Options specific to the deb build.
88confflags += --with-tcp-wrappers
89confflags += --with-pam
90confflags += --with-libedit
91confflags += --with-kerberos5=/usr
92confflags += --with-ssl-engine
93ifeq ($(DEB_HOST_ARCH_OS),linux)
94confflags += --with-selinux
95confflags += --with-audit=linux
96confflags += --with-systemd
97endif
98
99# The deb build wants xauth; the udeb build doesn't.
100confflags += --with-xauth=/usr/bin/xauth
101confflags_udeb += --without-xauth
102
103# Default paths. The udeb build has /usr/games removed.
104confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH)
105confflags_udeb += --with-default-path=/usr/local/bin:/usr/bin:/bin --with-superuser-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
106
107# Compiler flags.
108export DEB_BUILD_MAINT_OPTIONS := hardening=+all
109include /usr/share/dpkg/buildflags.mk
110cflags := $(CPPFLAGS) $(CFLAGS)
111cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
112cflags_udeb := -Os
113cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
114confflags += --with-cflags='$(cflags)'
115confflags_udeb += --with-cflags='$(cflags_udeb)'
116
117# Linker flags.
118confflags += --with-ldflags='$(strip -Wl,--as-needed $(LDFLAGS))'
119confflags_udeb += --with-ldflags='-Wl,--as-needed'
120
121%:
122 dh $@ --with=autoreconf,systemd
123
124autoreconf:
125 autoreconf -f -i
126 cp -f /usr/share/misc/config.guess /usr/share/misc/config.sub ./
127
128override_dh_autoreconf-arch:
129 dh_autoreconf debian/rules -- autoreconf
130
131override_dh_autoreconf-indep:
132
133override_dh_auto_configure-arch:
134 dh_auto_configure -Bdebian/build-deb -- $(confflags)
135ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
136 dh_auto_configure -Bdebian/build-udeb -- $(confflags_udeb)
137 # Avoid libnsl linkage. Ugh.
138 perl -pi -e 's/ +-lnsl//' debian/build-udeb/config.status
139 cd debian/build-udeb && ./config.status
140endif
141
142override_dh_auto_configure-indep:
143
144override_dh_auto_build-arch:
145 $(MAKE) -C debian/build-deb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass'
146ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
147 $(MAKE) -C debian/build-udeb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass' ssh scp sftp sshd ssh-keygen
148endif
149
150ifeq ($(filter pkg.openssh.nognome,$(DEB_BUILD_PROFILES)),)
151 $(MAKE) -C contrib gnome-ssh-askpass3 CC='$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wl,--as-needed $(LDFLAGS)' PKG_CONFIG=$(PKG_CONFIG)
152endif
153
154override_dh_auto_build-indep:
155
156override_dh_auto_test-arch:
157ifeq ($(RUN_TESTS),yes)
158 $(MAKE) -C debian/build-deb regress-prep
159 $(MAKE) -C debian/build-deb $(PARALLEL) regress-binaries
160 $(MAKE) -C debian/build-deb/regress \
161 .OBJDIR="$(CURDIR)/debian/build-deb/regress" \
162 .CURDIR="$(CURDIR)/regress" \
163 unit
164 $(MAKE) -C debian/build-deb compat-tests
165 $(MAKE) -C debian/keygen-test
166endif
167
168override_dh_auto_test-indep:
169
170override_dh_auto_clean:
171 rm -rf debian/build-deb debian/build-udeb
172ifeq ($(RUN_TESTS),yes)
173 $(MAKE) -C debian/keygen-test clean
174endif
175 $(MAKE) -C contrib clean
176
177override_dh_auto_install-arch:
178 $(MAKE) -C debian/build-deb DESTDIR=`pwd`/debian/tmp install-nokeys
179
180override_dh_auto_install-indep:
181
182override_dh_install-arch:
183 rm -f debian/tmp/etc/ssh/sshd_config
184
185 dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing
186ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
187 dh_install -popenssh-client-udeb -popenssh-server-udeb \
188 --sourcedir=debian/build-udeb
189endif
190
191 # Remove version control tags to avoid unnecessary conffile
192 # resolution steps for administrators.
193 sed -i '/\$$OpenBSD:/d' \
194 debian/openssh-client/etc/ssh/moduli \
195 debian/openssh-client/etc/ssh/ssh_config
196
197# We'd like to use dh_install --fail-missing here, but that doesn't work
198# well in combination with dh-exec: it complains that files generated by
199# dh-exec for architecture-dependent packages aren't installed.
200override_dh_install-indep:
201 rm -f debian/tmp/etc/ssh/sshd_config
202 dh_install
203
204override_dh_installdocs:
205 dh_installdocs -Nopenssh-server -Nopenssh-sftp-server
206 dh_installdocs -popenssh-server -popenssh-sftp-server \
207 --link-doc=openssh-client
208 # Avoid breaking dh_installexamples later.
209 mkdir -p debian/openssh-server/usr/share/doc/openssh-client
210
211override_dh_systemd_enable:
212 dh_systemd_enable -popenssh-server --name ssh ssh.service
213 dh_systemd_enable -popenssh-server --name ssh --no-enable ssh.socket
214
215override_dh_installinit:
216 dh_installinit -R --name ssh
217
218debian/openssh-server.sshd.pam: debian/openssh-server.sshd.pam.in
219ifeq ($(DEB_HOST_ARCH_OS),linux)
220 sed 's/^@IF_KEYINIT@//' $< > $@
221else
222 sed '/^@IF_KEYINIT@/d' $< > $@
223endif
224
225override_dh_installpam: debian/openssh-server.sshd.pam
226 dh_installpam --name sshd
227
228override_dh_fixperms-arch:
229 dh_fixperms
230 chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign
231
232# Tighten libssl dependencies to match the check in entropy.c.
233override_dh_shlibdeps:
234 dh_shlibdeps
235 debian/adjust-openssl-dependencies
236
237override_dh_gencontrol:
238 dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)'
239
240override_dh_builddeb:
241 dh_builddeb -- -Zxz
242
243debian/faq.html:
244 wget -O - http://www.openssh.com/faq.html | \
245 sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.com/\2,g' \
246 > debian/faq.html