diff options
Diffstat (limited to 'debian/rules')
-rwxr-xr-x | debian/rules | 349 |
1 files changed, 349 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules new file mode 100755 index 000000000..ff83b852b --- /dev/null +++ b/debian/rules | |||
@@ -0,0 +1,349 @@ | |||
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. | ||
7 | export DH_OPTIONS | ||
8 | |||
9 | ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) | ||
10 | OPTFLAGS := -O2 | ||
11 | else | ||
12 | OPTFLAGS := -O0 | ||
13 | endif | ||
14 | |||
15 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) | ||
16 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) | ||
17 | |||
18 | ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) | ||
19 | confflags += --build=$(DEB_HOST_GNU_TYPE) | ||
20 | else | ||
21 | confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) | ||
22 | endif | ||
23 | |||
24 | DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null) | ||
25 | DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null) | ||
26 | |||
27 | # Take account of old dpkg-architecture output. | ||
28 | ifeq ($(DEB_HOST_ARCH_OS),) | ||
29 | DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)) | ||
30 | ifeq ($(DEB_HOST_ARCH_OS),gnu) | ||
31 | DEB_HOST_ARCH_OS := hurd | ||
32 | endif | ||
33 | endif | ||
34 | ifeq ($(DEB_HOST_ARCH_CPU),) | ||
35 | DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU) | ||
36 | ifeq ($(DEB_HOST_ARCH_CPU),x86_64) | ||
37 | DEB_HOST_ARCH_CPU := amd64 | ||
38 | endif | ||
39 | endif | ||
40 | |||
41 | ifneq (,$(findstring :$(DEB_HOST_ARCH_OS):,:linux:knetbsd:)) | ||
42 | ifneq (,$(findstring :$(DEB_HOST_ARCH_CPU):,:mips:mipsel:)) | ||
43 | # Apparently this is not implied by -fPIE, at least on the mipsen. | ||
44 | PIC_CFLAGS := -fPIC | ||
45 | PIC_LDFLAGS := -fPIC | ||
46 | endif | ||
47 | ifeq (,$(findstring :$(DEB_HOST_ARCH_CPU):,:hppa:m68k:mips:mipsel:)) | ||
48 | # Use position-independent executables to take advantage of address space | ||
49 | # layout randomisation. TODO: This should be done in configure. | ||
50 | PIE_CFLAGS := -fPIE | ||
51 | PIE_LDFLAGS := -fPIE -pie | ||
52 | endif | ||
53 | endif | ||
54 | |||
55 | # Change the version string to include the Debian version | ||
56 | SSH_EXTRAVERSION := Debian-$(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p' | sed -e 's/[^-]*-//') | ||
57 | |||
58 | DISTRIBUTOR := $(shell lsb_release -is 2>/dev/null || echo Debian) | ||
59 | ifeq ($(DISTRIBUTOR),Ubuntu) | ||
60 | DEFAULT_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games | ||
61 | else | ||
62 | DEFAULT_PATH := /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games | ||
63 | endif | ||
64 | SUPERUSER_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11 | ||
65 | |||
66 | # Common path configuration. | ||
67 | confflags += --prefix=/usr --sysconfdir=/etc/ssh --libexecdir=/usr/lib/openssh --mandir=/usr/share/man | ||
68 | |||
69 | # Common build options. | ||
70 | confflags += --disable-strip | ||
71 | confflags += --with-mantype=doc | ||
72 | confflags += --with-4in6 | ||
73 | confflags += --with-privsep-path=/var/run/sshd | ||
74 | confflags += --without-rand-helper | ||
75 | |||
76 | # The Hurd needs libcrypt for res_query et al. | ||
77 | ifeq ($(DEB_HOST_ARCH_OS),hurd) | ||
78 | confflags += --with-libs=-lcrypt | ||
79 | endif | ||
80 | |||
81 | # Everything above here is common to the deb and udeb builds. | ||
82 | confflags_udeb := $(confflags) | ||
83 | |||
84 | # Options specific to the deb build. | ||
85 | confflags += --with-tcp-wrappers | ||
86 | confflags += --with-pam | ||
87 | confflags += --with-libedit | ||
88 | confflags += --with-kerberos5=/usr | ||
89 | confflags += --with-ssl-engine | ||
90 | ifeq ($(DEB_HOST_ARCH_OS),linux) | ||
91 | confflags += --with-selinux | ||
92 | endif | ||
93 | |||
94 | # The deb build wants xauth; the udeb build doesn't. | ||
95 | confflags += --with-xauth=/usr/bin/X11/xauth | ||
96 | confflags_udeb += --without-xauth | ||
97 | |||
98 | # Default paths. The udeb build has /usr/bin/X11 and /usr/games removed. | ||
99 | confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH) | ||
100 | confflags_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 | ||
101 | |||
102 | # Compiler flags. | ||
103 | cflags := $(OPTFLAGS) $(PIC_CFLAGS) $(PIE_CFLAGS) | ||
104 | cflags += -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT | ||
105 | cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\" | ||
106 | cflags_udeb := -Os | ||
107 | cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\" | ||
108 | confflags += --with-cflags='$(cflags)' | ||
109 | confflags_udeb += --with-cflags='$(cflags_udeb)' | ||
110 | |||
111 | # Linker flags. | ||
112 | ifneq ($(PIC_LDFLAGS)$(PIE_LDFLAGS),) | ||
113 | confflags += --with-ldflags='$(strip $(PIC_LDFLAGS) $(PIE_LDFLAGS))' | ||
114 | endif | ||
115 | |||
116 | build: build-deb build-udeb | ||
117 | |||
118 | build-deb: build-deb-stamp | ||
119 | build-deb-stamp: | ||
120 | dh_testdir | ||
121 | mkdir -p build-deb | ||
122 | cd build-deb && ../configure $(confflags) | ||
123 | |||
124 | ifeq ($(DEB_HOST_ARCH_OS),linux) | ||
125 | # Some 2.2 kernels have trouble with setres[ug]id() (bug #239999). | ||
126 | perl -pi -e 's/.*#undef (BROKEN_SETRES[UG]ID).*/#define $$1 1/' build-deb/config.h | ||
127 | endif | ||
128 | # Debian's /var/log/btmp has inappropriate permissions. | ||
129 | perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-deb/config.h | ||
130 | |||
131 | $(MAKE) -C build-deb -j 2 ASKPASS_PROGRAM='/usr/bin/ssh-askpass' | ||
132 | $(MAKE) -C contrib gnome-ssh-askpass2 CC='gcc $(OPTFLAGS) -g -Wall' | ||
133 | $(MAKE) -C debian/tests | ||
134 | |||
135 | touch build-deb-stamp | ||
136 | |||
137 | build-udeb: build-udeb-stamp | ||
138 | build-udeb-stamp: | ||
139 | dh_testdir | ||
140 | mkdir -p build-udeb | ||
141 | cd build-udeb && ../configure $(confflags_udeb) | ||
142 | # Debian's /var/log/btmp has inappropriate permissions. | ||
143 | perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-udeb/config.h | ||
144 | # Avoid libnsl linkage. Ugh. | ||
145 | perl -pi -e 's/ +-lnsl//' build-udeb/config.status | ||
146 | cd build-udeb && ./config.status | ||
147 | $(MAKE) -C build-udeb -j 2 ASKPASS_PROGRAM='/usr/bin/ssh-askpass' ssh scp sftp sshd ssh-keygen | ||
148 | touch build-udeb-stamp | ||
149 | |||
150 | clean: | ||
151 | dh_testdir | ||
152 | rm -rf build-deb build-udeb | ||
153 | $(MAKE) -C debian/tests clean | ||
154 | $(MAKE) -C contrib clean | ||
155 | (cat debian/copyright.head; iconv -f ISO-8859-1 -t UTF-8 LICENCE) \ | ||
156 | > debian/copyright | ||
157 | dh_clean | ||
158 | |||
159 | install: DH_OPTIONS=-a | ||
160 | install: build | ||
161 | dh_testdir | ||
162 | dh_testroot | ||
163 | dh_prep | ||
164 | dh_installdirs | ||
165 | |||
166 | $(MAKE) -C build-deb DESTDIR=`pwd`/debian/openssh-client install-nokeys | ||
167 | |||
168 | rm -f debian/openssh-client/etc/ssh/sshd_config | ||
169 | #Temporary hack: remove /usr/share/Ssh.bin, since we have no smartcard support anyway. | ||
170 | rm -f debian/openssh-client/usr/share/Ssh.bin | ||
171 | |||
172 | # Split off the server. | ||
173 | mv debian/openssh-client/usr/sbin/sshd debian/openssh-server/usr/sbin/ | ||
174 | mv debian/openssh-client/usr/lib/openssh/sftp-server debian/openssh-server/usr/lib/openssh/ | ||
175 | mv debian/openssh-client/usr/share/man/man5/authorized_keys.5 debian/openssh-server/usr/share/man/man5/ | ||
176 | mv debian/openssh-client/usr/share/man/man5/sshd_config.5 debian/openssh-server/usr/share/man/man5/ | ||
177 | mv debian/openssh-client/usr/share/man/man8/sshd.8 debian/openssh-server/usr/share/man/man8/ | ||
178 | mv debian/openssh-client/usr/share/man/man8/sftp-server.8 debian/openssh-server/usr/share/man/man8/ | ||
179 | rmdir debian/openssh-client/usr/sbin debian/openssh-client/var/run/sshd | ||
180 | |||
181 | install -m 755 contrib/ssh-copy-id debian/openssh-client/usr/bin/ssh-copy-id | ||
182 | install -m 644 -c contrib/ssh-copy-id.1 debian/openssh-client/usr/share/man/man1/ssh-copy-id.1 | ||
183 | |||
184 | install -s -o root -g root -m 755 contrib/gnome-ssh-askpass2 debian/ssh-askpass-gnome/usr/lib/openssh/gnome-ssh-askpass | ||
185 | install -m 644 debian/gnome-ssh-askpass.1 debian/ssh-askpass-gnome/usr/share/man/man1/gnome-ssh-askpass.1 | ||
186 | uudecode -o debian/ssh-askpass-gnome/usr/share/pixmaps/ssh-askpass-gnome.png debian/ssh-askpass-gnome.png.uue | ||
187 | |||
188 | install -m 755 debian/ssh-argv0 debian/openssh-client/usr/bin/ssh-argv0 | ||
189 | install -m 644 debian/ssh-argv0.1 debian/openssh-client/usr/share/man/man1/ssh-argv0.1 | ||
190 | |||
191 | install -o root -g root debian/openssh-server.init debian/openssh-server/etc/init.d/ssh | ||
192 | install -o root -g root -m 644 debian/openssh-server.default debian/openssh-server/etc/default/ssh | ||
193 | install -o root -g root debian/openssh-server.if-up debian/openssh-server/etc/network/if-up.d/openssh-server | ||
194 | install -o root -g root -m 644 debian/openssh-server.ufw.profile debian/openssh-server/etc/ufw/applications.d/openssh-server | ||
195 | |||
196 | install -m 755 build-udeb/ssh debian/openssh-client-udeb/usr/bin/ssh | ||
197 | install -m 755 build-udeb/scp debian/openssh-client-udeb/usr/bin/scp | ||
198 | install -m 755 build-udeb/sftp debian/openssh-client-udeb/usr/bin/sftp | ||
199 | install -m 755 build-udeb/sshd debian/openssh-server-udeb/usr/sbin/sshd | ||
200 | install -m 755 build-udeb/ssh-keygen debian/openssh-server-udeb/usr/bin/ssh-keygen | ||
201 | |||
202 | # Remove version control tags to avoid unnecessary conffile | ||
203 | # resolution steps for administrators. | ||
204 | sed -i '/\$$OpenBSD:/d' \ | ||
205 | debian/openssh-client/etc/ssh/moduli \ | ||
206 | debian/openssh-client/etc/ssh/ssh_config | ||
207 | |||
208 | # Build architecture-independent files here. | ||
209 | binary-indep: binary-ssh binary-ssh-krb5 | ||
210 | |||
211 | # Build architecture-dependent files here. | ||
212 | binary-arch: binary-openssh-client binary-openssh-server | ||
213 | binary-arch: binary-ssh-askpass-gnome | ||
214 | binary-arch: binary-openssh-client-udeb binary-openssh-server-udeb | ||
215 | |||
216 | binary-openssh-client: DH_OPTIONS=-popenssh-client | ||
217 | binary-openssh-client: build install | ||
218 | dh_testdir | ||
219 | dh_testroot | ||
220 | dh_installdebconf | ||
221 | dh_installdocs | ||
222 | dh_installchangelogs | ||
223 | install -m644 debian/openssh-client.lintian debian/openssh-client/usr/share/lintian/overrides/openssh-client | ||
224 | dh_strip | ||
225 | dh_compress | ||
226 | dh_fixperms | ||
227 | chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign | ||
228 | dh_installdeb | ||
229 | test ! -e debian/ssh/etc/ssh/ssh_prng_cmds \ | ||
230 | || echo "/etc/ssh/ssh_prng_cmds" >> debian/openssh-client/DEBIAN/conffiles | ||
231 | perl -i debian/substitute-conffile.pl \ | ||
232 | ETC_SSH_MODULI debian/openssh-client/etc/ssh/moduli \ | ||
233 | ETC_SSH_SSH_CONFIG debian/openssh-client/etc/ssh/ssh_config \ | ||
234 | debian/openssh-client/DEBIAN/preinst | ||
235 | dh_shlibdeps | ||
236 | dh_gencontrol | ||
237 | dh_md5sums | ||
238 | dh_builddeb | ||
239 | |||
240 | binary-openssh-server: DH_OPTIONS=-popenssh-server | ||
241 | binary-openssh-server: build install | ||
242 | dh_testdir | ||
243 | dh_testroot | ||
244 | dh_installdebconf | ||
245 | dh_installdocs | ||
246 | mv debian/openssh-server/usr/share/doc/openssh-server debian/openssh-server/usr/share/doc/openssh-client | ||
247 | rm -f debian/openssh-server/usr/share/doc/openssh-client/copyright | ||
248 | install -m644 debian/openssh-server.lintian debian/openssh-server/usr/share/lintian/overrides/openssh-server | ||
249 | dh_installpam --name sshd | ||
250 | dh_link | ||
251 | dh_strip | ||
252 | dh_compress | ||
253 | dh_fixperms | ||
254 | dh_installdeb | ||
255 | perl -i debian/substitute-conffile.pl \ | ||
256 | ETC_DEFAULT_SSH debian/openssh-server/etc/default/ssh \ | ||
257 | ETC_INIT_D_SSH debian/openssh-server/etc/init.d/ssh \ | ||
258 | ETC_PAM_D_SSH debian/openssh-server/etc/pam.d/ssh \ | ||
259 | debian/openssh-server/DEBIAN/preinst | ||
260 | dh_shlibdeps | ||
261 | dh_gencontrol | ||
262 | dh_md5sums | ||
263 | dh_builddeb | ||
264 | |||
265 | binary-ssh: DH_OPTIONS=-pssh | ||
266 | binary-ssh: build install | ||
267 | dh_testdir | ||
268 | dh_testroot | ||
269 | dh_installdirs | ||
270 | dh_installdocs | ||
271 | mv debian/ssh/usr/share/doc/ssh debian/ssh/usr/share/doc/openssh-client | ||
272 | rm -f debian/ssh/usr/share/doc/openssh-client/copyright | ||
273 | install -m644 debian/ssh.lintian debian/ssh/usr/share/lintian/overrides/ssh | ||
274 | dh_link | ||
275 | dh_compress | ||
276 | dh_fixperms | ||
277 | dh_installdeb | ||
278 | dh_gencontrol | ||
279 | dh_md5sums | ||
280 | dh_builddeb | ||
281 | |||
282 | binary-ssh-krb5: DH_OPTIONS=-pssh-krb5 | ||
283 | binary-ssh-krb5: build install | ||
284 | dh_testdir | ||
285 | dh_testroot | ||
286 | dh_installdocs | ||
287 | dh_installchangelogs | ||
288 | dh_link | ||
289 | dh_compress | ||
290 | dh_fixperms | ||
291 | dh_installdeb | ||
292 | dh_gencontrol | ||
293 | dh_md5sums | ||
294 | dh_builddeb | ||
295 | |||
296 | binary-ssh-askpass-gnome: DH_OPTIONS=-pssh-askpass-gnome | ||
297 | binary-ssh-askpass-gnome: build install | ||
298 | dh_testdir | ||
299 | dh_testroot | ||
300 | dh_installdocs | ||
301 | dh_installexamples | ||
302 | dh_installchangelogs | ||
303 | dh_strip | ||
304 | dh_compress | ||
305 | dh_fixperms | ||
306 | dh_installdeb | ||
307 | dh_shlibdeps | ||
308 | dh_gencontrol | ||
309 | dh_md5sums | ||
310 | dh_builddeb | ||
311 | |||
312 | binary-openssh-client-udeb: DH_OPTIONS=-popenssh-client-udeb | ||
313 | binary-openssh-client-udeb: build install | ||
314 | dh_testdir | ||
315 | dh_testroot | ||
316 | dh_strip | ||
317 | dh_compress | ||
318 | dh_fixperms | ||
319 | dh_installdeb | ||
320 | dh_shlibdeps | ||
321 | dh_gencontrol | ||
322 | dh_md5sums | ||
323 | dh_builddeb | ||
324 | |||
325 | binary-openssh-server-udeb: DH_OPTIONS=-popenssh-server-udeb | ||
326 | binary-openssh-server-udeb: build install | ||
327 | dh_testdir | ||
328 | dh_testroot | ||
329 | dh_strip | ||
330 | dh_compress | ||
331 | dh_fixperms | ||
332 | dh_installdeb | ||
333 | dh_shlibdeps | ||
334 | dh_gencontrol | ||
335 | dh_md5sums | ||
336 | dh_builddeb | ||
337 | |||
338 | binary: binary-indep binary-arch | ||
339 | |||
340 | debian/faq.html: | ||
341 | wget -O - http://www.openssh.org/faq.html | \ | ||
342 | sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.org/\2,g' \ | ||
343 | > debian/faq.html | ||
344 | |||
345 | .PHONY: build clean binary-indep binary-arch binary install | ||
346 | .PHONY: build-deb build-udeb | ||
347 | .PHONY: binary-openssh-client binary-openssh-server binary-ssh | ||
348 | .PHONY: binary-ssh-krb5 binary-ssh-askpass-gnome | ||
349 | .PHONY: binary-openssh-client-udeb binary-openssh-server-udeb | ||