xref: /freebsd/crypto/openssh/Makefile.in (revision 3fc36ee018bb836bd1796067cf4ef8683f166ebc)
1# $Id: Makefile.in,v 1.365 2014/08/30 06:23:07 djm Exp $
2
3# uncomment if you run a non bourne compatable shell. Ie. csh
4#SHELL = @SH@
5
6AUTORECONF=autoreconf
7
8prefix=@prefix@
9exec_prefix=@exec_prefix@
10bindir=@bindir@
11sbindir=@sbindir@
12libexecdir=@libexecdir@
13datadir=@datadir@
14datarootdir=@datarootdir@
15mandir=@mandir@
16mansubdir=@mansubdir@
17sysconfdir=@sysconfdir@
18piddir=@piddir@
19srcdir=@srcdir@
20top_srcdir=@top_srcdir@
21
22DESTDIR=
23VPATH=@srcdir@
24SSH_PROGRAM=@bindir@/ssh
25ASKPASS_PROGRAM=$(libexecdir)/ssh-askpass
26SFTP_SERVER=$(libexecdir)/sftp-server
27SSH_KEYSIGN=$(libexecdir)/ssh-keysign
28SSH_PKCS11_HELPER=$(libexecdir)/ssh-pkcs11-helper
29PRIVSEP_PATH=@PRIVSEP_PATH@
30SSH_PRIVSEP_USER=@SSH_PRIVSEP_USER@
31STRIP_OPT=@STRIP_OPT@
32TEST_SHELL=@TEST_SHELL@
33
34PATHS= -DSSHDIR=\"$(sysconfdir)\" \
35	-D_PATH_SSH_PROGRAM=\"$(SSH_PROGRAM)\" \
36	-D_PATH_SSH_ASKPASS_DEFAULT=\"$(ASKPASS_PROGRAM)\" \
37	-D_PATH_SFTP_SERVER=\"$(SFTP_SERVER)\" \
38	-D_PATH_SSH_KEY_SIGN=\"$(SSH_KEYSIGN)\" \
39	-D_PATH_SSH_PKCS11_HELPER=\"$(SSH_PKCS11_HELPER)\" \
40	-D_PATH_SSH_PIDDIR=\"$(piddir)\" \
41	-D_PATH_PRIVSEP_CHROOT_DIR=\"$(PRIVSEP_PATH)\"
42
43CC=@CC@
44LD=@LD@
45CFLAGS=@CFLAGS@
46CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
47LIBS=@LIBS@
48K5LIBS=@K5LIBS@
49GSSLIBS=@GSSLIBS@
50SSHLIBS=@SSHLIBS@
51SSHDLIBS=@SSHDLIBS@
52LIBEDIT=@LIBEDIT@
53AR=@AR@
54AWK=@AWK@
55RANLIB=@RANLIB@
56INSTALL=@INSTALL@
57PERL=@PERL@
58SED=@SED@
59ENT=@ENT@
60XAUTH_PATH=@XAUTH_PATH@
61LDFLAGS=-L. -Lopenbsd-compat/ @LDFLAGS@
62EXEEXT=@EXEEXT@
63MANFMT=@MANFMT@
64
65TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keyscan${EXEEXT} ssh-keysign${EXEEXT} ssh-pkcs11-helper$(EXEEXT) ssh-agent$(EXEEXT) scp$(EXEEXT) sftp-server$(EXEEXT) sftp$(EXEEXT)
66
67LIBOPENSSH_OBJS=\
68	ssh_api.o \
69	ssherr.o \
70	sshbuf.o \
71	sshkey.o \
72	sshbuf-getput-basic.o \
73	sshbuf-misc.o \
74	sshbuf-getput-crypto.o \
75	krl.o \
76	bitmap.o
77
78LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
79	authfd.o authfile.o bufaux.o bufbn.o bufec.o buffer.o \
80	canohost.o channels.o cipher.o cipher-aes.o cipher-aesctr.o \
81	cipher-bf1.o cipher-ctr.o cipher-3des1.o cleanup.o \
82	compat.o crc32.o deattack.o fatal.o hostfile.o \
83	log.o match.o md-sha256.o moduli.o nchan.o packet.o opacket.o \
84	readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \
85	atomicio.o key.o dispatch.o mac.o uidswap.o uuencode.o misc.o \
86	monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
87	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
88	ssh-pkcs11.o smult_curve25519_ref.o \
89	poly1305.o chacha.o cipher-chachapoly.o \
90	ssh-ed25519.o digest-openssl.o digest-libc.o hmac.o \
91	sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o \
92	kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \
93	kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \
94	kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \
95	platform-pledge.o
96
97SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
98	sshconnect.o sshconnect1.o sshconnect2.o mux.o
99
100SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
101	audit.o audit-bsm.o audit-linux.o platform.o \
102	sshpty.o sshlogin.o servconf.o serverloop.o \
103	auth.o auth1.o auth2.o auth-options.o session.o \
104	auth-chall.o auth2-chall.o groupaccess.o \
105	auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
106	auth2-none.o auth2-passwd.o auth2-pubkey.o \
107	monitor_mm.o monitor.o monitor_wrap.o auth-krb5.o \
108	auth2-gss.o gss-serv.o gss-serv-krb5.o \
109	loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
110	sftp-server.o sftp-common.o \
111	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
112	sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-pledge.o \
113	sandbox-solaris.o
114
115MANPAGES	= moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
116MANPAGES_IN	= moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5
117MANTYPE		= @MANTYPE@
118
119CONFIGFILES=sshd_config.out ssh_config.out moduli.out
120CONFIGFILES_IN=sshd_config ssh_config moduli
121
122PATHSUBS	= \
123	-e 's|/etc/ssh/ssh_config|$(sysconfdir)/ssh_config|g' \
124	-e 's|/etc/ssh/ssh_known_hosts|$(sysconfdir)/ssh_known_hosts|g' \
125	-e 's|/etc/ssh/sshd_config|$(sysconfdir)/sshd_config|g' \
126	-e 's|/usr/libexec|$(libexecdir)|g' \
127	-e 's|/etc/shosts.equiv|$(sysconfdir)/shosts.equiv|g' \
128	-e 's|/etc/ssh/ssh_host_key|$(sysconfdir)/ssh_host_key|g' \
129	-e 's|/etc/ssh/ssh_host_ecdsa_key|$(sysconfdir)/ssh_host_ecdsa_key|g' \
130	-e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \
131	-e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \
132	-e 's|/etc/ssh/ssh_host_ed25519_key|$(sysconfdir)/ssh_host_ed25519_key|g' \
133	-e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \
134	-e 's|/etc/moduli|$(sysconfdir)/moduli|g' \
135	-e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \
136	-e 's|/etc/ssh/sshrc|$(sysconfdir)/sshrc|g' \
137	-e 's|/usr/X11R6/bin/xauth|$(XAUTH_PATH)|g' \
138	-e 's|/var/empty|$(PRIVSEP_PATH)|g' \
139	-e 's|/usr/bin:/bin:/usr/sbin:/sbin|@user_path@|g'
140
141FIXPATHSCMD	= $(SED) $(PATHSUBS)
142FIXALGORITHMSCMD= $(SHELL) $(srcdir)/fixalgorithms $(SED) \
143		     @UNSUPPORTED_ALGORITHMS@
144
145all: $(CONFIGFILES) $(MANPAGES) $(TARGETS)
146
147$(LIBSSH_OBJS): Makefile.in config.h
148$(SSHOBJS): Makefile.in config.h
149$(SSHDOBJS): Makefile.in config.h
150
151.c.o:
152	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
153
154LIBCOMPAT=openbsd-compat/libopenbsd-compat.a
155$(LIBCOMPAT): always
156	(cd openbsd-compat && $(MAKE))
157always:
158
159libssh.a: $(LIBSSH_OBJS)
160	$(AR) rv $@ $(LIBSSH_OBJS)
161	$(RANLIB) $@
162
163ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
164	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
165
166sshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
167	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
168
169scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
170	$(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
171
172ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
173	$(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
174
175ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
176	$(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
177
178ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
179	$(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
180
181ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o readconf.o
182	$(LD) -o $@ ssh-keysign.o readconf.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
183
184ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
185	$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
186
187ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o
188	$(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
189
190sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
191	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
192
193sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-common.o sftp-glob.o progressmeter.o
194	$(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
195
196# test driver for the loginrec code - not built by default
197logintest: logintest.o $(LIBCOMPAT) libssh.a loginrec.o
198	$(LD) -o $@ logintest.o $(LDFLAGS) loginrec.o -lopenbsd-compat -lssh $(LIBS)
199
200$(MANPAGES): $(MANPAGES_IN)
201	if test "$(MANTYPE)" = "cat"; then \
202		manpage=$(srcdir)/`echo $@ | sed 's/\.[1-9]\.out$$/\.0/'`; \
203	else \
204		manpage=$(srcdir)/`echo $@ | sed 's/\.out$$//'`; \
205	fi; \
206	if test "$(MANTYPE)" = "man"; then \
207		$(FIXPATHSCMD) $${manpage} | $(FIXALGORITHMSCMD) | \
208		    $(AWK) -f $(srcdir)/mdoc2man.awk > $@; \
209	else \
210		$(FIXPATHSCMD) $${manpage} | $(FIXALGORITHMSCMD) > $@; \
211	fi
212
213$(CONFIGFILES): $(CONFIGFILES_IN)
214	conffile=`echo $@ | sed 's/.out$$//'`; \
215	$(FIXPATHSCMD) $(srcdir)/$${conffile} > $@
216
217# fake rule to stop make trying to compile moduli.o into a binary "moduli.o"
218moduli:
219	echo
220
221# special case target for umac128
222umac128.o:	umac.c
223	$(CC) $(CFLAGS) $(CPPFLAGS) -o umac128.o -c $(srcdir)/umac.c \
224	    -DUMAC_OUTPUT_LEN=16 -Dumac_new=umac128_new \
225	    -Dumac_update=umac128_update -Dumac_final=umac128_final \
226	    -Dumac_delete=umac128_delete
227
228clean:	regressclean
229	rm -f *.o *.a $(TARGETS) logintest config.cache config.log
230	rm -f *.out core survey
231	rm -f regress/unittests/test_helper/*.a
232	rm -f regress/unittests/test_helper/*.o
233	rm -f regress/unittests/sshbuf/*.o
234	rm -f regress/unittests/sshbuf/test_sshbuf
235	rm -f regress/unittests/sshkey/*.o
236	rm -f regress/unittests/sshkey/test_sshkey
237	rm -f regress/unittests/bitmap/*.o
238	rm -f regress/unittests/bitmap/test_bitmap
239	rm -f regress/unittests/hostkeys/*.o
240	rm -f regress/unittests/hostkeys/test_hostkeys
241	rm -f regress/unittests/kex/*.o
242	rm -f regress/unittests/kex/test_kex
243	(cd openbsd-compat && $(MAKE) clean)
244
245distclean:	regressclean
246	rm -f *.o *.a $(TARGETS) logintest config.cache config.log
247	rm -f *.out core opensshd.init openssh.xml
248	rm -f Makefile buildpkg.sh config.h config.status
249	rm -f survey.sh openbsd-compat/regress/Makefile *~
250	rm -rf autom4te.cache
251	rm -f regress/unittests/test_helper/*.a
252	rm -f regress/unittests/test_helper/*.o
253	rm -f regress/unittests/sshbuf/*.o
254	rm -f regress/unittests/sshbuf/test_sshbuf
255	rm -f regress/unittests/sshkey/*.o
256	rm -f regress/unittests/sshkey/test_sshkey
257	rm -f regress/unittests/bitmap/*.o
258	rm -f regress/unittests/bitmap/test_bitmap
259	rm -f regress/unittests/hostkeys/*.o
260	rm -f regress/unittests/hostkeys/test_hostkeys
261	rm -f regress/unittests/kex/*.o
262	rm -f regress/unittests/kex/test_kex
263	(cd openbsd-compat && $(MAKE) distclean)
264	if test -d pkg ; then \
265		rm -fr pkg ; \
266	fi
267
268veryclean: distclean
269	rm -f configure config.h.in *.0
270
271cleandir: veryclean
272
273mrproper: veryclean
274
275realclean: veryclean
276
277catman-do:
278	@for f in $(MANPAGES_IN) ; do \
279		base=`echo $$f | sed 's/\..*$$//'` ; \
280		echo "$$f -> $$base.0" ; \
281		$(MANFMT) $$f | cat -v | sed -e 's/.\^H//g' \
282			>$$base.0 ; \
283	done
284
285distprep: catman-do
286	$(AUTORECONF)
287	-rm -rf autom4te.cache
288
289install: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files install-sysconf host-key check-config
290install-nokeys: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files install-sysconf
291install-nosysconf: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files
292
293check-config:
294	-$(DESTDIR)$(sbindir)/sshd -t -f $(DESTDIR)$(sysconfdir)/sshd_config
295
296install-files:
297	$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
298	$(srcdir)/mkinstalldirs $(DESTDIR)$(sbindir)
299	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
300	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)1
301	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)5
302	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)8
303	$(srcdir)/mkinstalldirs $(DESTDIR)$(libexecdir)
304	(umask 022 ; $(srcdir)/mkinstalldirs $(DESTDIR)$(PRIVSEP_PATH))
305	$(INSTALL) -m 0755 $(STRIP_OPT) ssh$(EXEEXT) $(DESTDIR)$(bindir)/ssh$(EXEEXT)
306	$(INSTALL) -m 0755 $(STRIP_OPT) scp$(EXEEXT) $(DESTDIR)$(bindir)/scp$(EXEEXT)
307	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-add$(EXEEXT) $(DESTDIR)$(bindir)/ssh-add$(EXEEXT)
308	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-agent$(EXEEXT) $(DESTDIR)$(bindir)/ssh-agent$(EXEEXT)
309	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-keygen$(EXEEXT) $(DESTDIR)$(bindir)/ssh-keygen$(EXEEXT)
310	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-keyscan$(EXEEXT) $(DESTDIR)$(bindir)/ssh-keyscan$(EXEEXT)
311	$(INSTALL) -m 0755 $(STRIP_OPT) sshd$(EXEEXT) $(DESTDIR)$(sbindir)/sshd$(EXEEXT)
312	$(INSTALL) -m 4711 $(STRIP_OPT) ssh-keysign$(EXEEXT) $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)
313	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-pkcs11-helper$(EXEEXT) $(DESTDIR)$(SSH_PKCS11_HELPER)$(EXEEXT)
314	$(INSTALL) -m 0755 $(STRIP_OPT) sftp$(EXEEXT) $(DESTDIR)$(bindir)/sftp$(EXEEXT)
315	$(INSTALL) -m 0755 $(STRIP_OPT) sftp-server$(EXEEXT) $(DESTDIR)$(SFTP_SERVER)$(EXEEXT)
316	$(INSTALL) -m 644 ssh.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1
317	$(INSTALL) -m 644 scp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/scp.1
318	$(INSTALL) -m 644 ssh-add.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-add.1
319	$(INSTALL) -m 644 ssh-agent.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
320	$(INSTALL) -m 644 ssh-keygen.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
321	$(INSTALL) -m 644 ssh-keyscan.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
322	$(INSTALL) -m 644 moduli.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/moduli.5
323	$(INSTALL) -m 644 sshd_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/sshd_config.5
324	$(INSTALL) -m 644 ssh_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/ssh_config.5
325	$(INSTALL) -m 644 sshd.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
326	$(INSTALL) -m 644 sftp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
327	$(INSTALL) -m 644 sftp-server.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
328	$(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
329	$(INSTALL) -m 644 ssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
330
331install-sysconf:
332	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
333		$(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir); \
334	fi
335	@if [ ! -f $(DESTDIR)$(sysconfdir)/ssh_config ]; then \
336		$(INSTALL) -m 644 ssh_config.out $(DESTDIR)$(sysconfdir)/ssh_config; \
337	else \
338		echo "$(DESTDIR)$(sysconfdir)/ssh_config already exists, install will not overwrite"; \
339	fi
340	@if [ ! -f $(DESTDIR)$(sysconfdir)/sshd_config ]; then \
341		$(INSTALL) -m 644 sshd_config.out $(DESTDIR)$(sysconfdir)/sshd_config; \
342	else \
343		echo "$(DESTDIR)$(sysconfdir)/sshd_config already exists, install will not overwrite"; \
344	fi
345	@if [ ! -f $(DESTDIR)$(sysconfdir)/moduli ]; then \
346		if [ -f $(DESTDIR)$(sysconfdir)/primes ]; then \
347			echo "moving $(DESTDIR)$(sysconfdir)/primes to $(DESTDIR)$(sysconfdir)/moduli"; \
348			mv "$(DESTDIR)$(sysconfdir)/primes" "$(DESTDIR)$(sysconfdir)/moduli"; \
349		else \
350			$(INSTALL) -m 644 moduli.out $(DESTDIR)$(sysconfdir)/moduli; \
351		fi ; \
352	else \
353		echo "$(DESTDIR)$(sysconfdir)/moduli already exists, install will not overwrite"; \
354	fi
355
356host-key: ssh-keygen$(EXEEXT)
357	@if [ -z "$(DESTDIR)" ] ; then \
358		./ssh-keygen -A; \
359	fi
360
361host-key-force: ssh-keygen$(EXEEXT) ssh$(EXEEXT)
362	if ./ssh -Q protocol-version | grep '^1$$' >/dev/null; then \
363		./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N ""; \
364	fi
365	./ssh-keygen -t dsa -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key -N ""
366	./ssh-keygen -t rsa -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key -N ""
367	./ssh-keygen -t ed25519 -f $(DESTDIR)$(sysconfdir)/ssh_host_ed25519_key -N ""
368	if ./ssh -Q key | grep ecdsa >/dev/null ; then \
369		./ssh-keygen -t ecdsa -f $(DESTDIR)$(sysconfdir)/ssh_host_ecdsa_key -N ""; \
370	fi
371
372uninstallall:	uninstall
373	-rm -f $(DESTDIR)$(sysconfdir)/ssh_config
374	-rm -f $(DESTDIR)$(sysconfdir)/sshd_config
375	-rmdir $(DESTDIR)$(sysconfdir)
376	-rmdir $(DESTDIR)$(bindir)
377	-rmdir $(DESTDIR)$(sbindir)
378	-rmdir $(DESTDIR)$(mandir)/$(mansubdir)1
379	-rmdir $(DESTDIR)$(mandir)/$(mansubdir)8
380	-rmdir $(DESTDIR)$(mandir)
381	-rmdir $(DESTDIR)$(libexecdir)
382
383uninstall:
384	-rm -f $(DESTDIR)$(bindir)/ssh$(EXEEXT)
385	-rm -f $(DESTDIR)$(bindir)/scp$(EXEEXT)
386	-rm -f $(DESTDIR)$(bindir)/ssh-add$(EXEEXT)
387	-rm -f $(DESTDIR)$(bindir)/ssh-agent$(EXEEXT)
388	-rm -f $(DESTDIR)$(bindir)/ssh-keygen$(EXEEXT)
389	-rm -f $(DESTDIR)$(bindir)/ssh-keyscan$(EXEEXT)
390	-rm -f $(DESTDIR)$(bindir)/sftp$(EXEEXT)
391	-rm -f $(DESTDIR)$(sbindir)/sshd$(EXEEXT)
392	-rm -r $(DESTDIR)$(SFTP_SERVER)$(EXEEXT)
393	-rm -f $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)
394	-rm -f $(DESTDIR)$(SSH_PKCS11_HELPER)$(EXEEXT)
395	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1
396	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/scp.1
397	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-add.1
398	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
399	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
400	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
401	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
402	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
403	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
404	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
405	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
406
407regress-prep:
408	[ -d `pwd`/regress ] || mkdir -p `pwd`/regress
409	[ -d `pwd`/regress/unittests ] || mkdir -p `pwd`/regress/unittests
410	[ -d `pwd`/regress/unittests/test_helper ] || \
411		mkdir -p `pwd`/regress/unittests/test_helper
412	[ -d `pwd`/regress/unittests/sshbuf ] || \
413		mkdir -p `pwd`/regress/unittests/sshbuf
414	[ -d `pwd`/regress/unittests/sshkey ] || \
415		mkdir -p `pwd`/regress/unittests/sshkey
416	[ -d `pwd`/regress/unittests/bitmap ] || \
417		mkdir -p `pwd`/regress/unittests/bitmap
418	[ -d `pwd`/regress/unittests/hostkeys ] || \
419		mkdir -p `pwd`/regress/unittests/hostkeys
420	[ -d `pwd`/regress/unittests/kex ] || \
421		mkdir -p `pwd`/regress/unittests/kex
422	[ -f `pwd`/regress/Makefile ] || \
423	    ln -s `cd $(srcdir) && pwd`/regress/Makefile `pwd`/regress/Makefile
424
425regress/modpipe$(EXEEXT): $(srcdir)/regress/modpipe.c
426	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
427	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
428
429regress/setuid-allowed$(EXEEXT): $(srcdir)/regress/setuid-allowed.c
430	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
431	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
432
433regress/netcat$(EXEEXT): $(srcdir)/regress/netcat.c
434	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
435	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
436
437regress/check-perm$(EXEEXT): $(srcdir)/regress/check-perm.c
438	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
439	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
440
441UNITTESTS_TEST_HELPER_OBJS=\
442	regress/unittests/test_helper/test_helper.o \
443	regress/unittests/test_helper/fuzz.o
444
445regress/unittests/test_helper/libtest_helper.a: ${UNITTESTS_TEST_HELPER_OBJS}
446	$(AR) rv $@ $(UNITTESTS_TEST_HELPER_OBJS)
447	$(RANLIB) $@
448
449UNITTESTS_TEST_SSHBUF_OBJS=\
450	regress/unittests/sshbuf/tests.o \
451	regress/unittests/sshbuf/test_sshbuf.o \
452	regress/unittests/sshbuf/test_sshbuf_getput_basic.o \
453	regress/unittests/sshbuf/test_sshbuf_getput_crypto.o \
454	regress/unittests/sshbuf/test_sshbuf_misc.o \
455	regress/unittests/sshbuf/test_sshbuf_fuzz.o \
456	regress/unittests/sshbuf/test_sshbuf_getput_fuzz.o \
457	regress/unittests/sshbuf/test_sshbuf_fixed.o
458
459regress/unittests/sshbuf/test_sshbuf$(EXEEXT): ${UNITTESTS_TEST_SSHBUF_OBJS} \
460    regress/unittests/test_helper/libtest_helper.a libssh.a
461	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHBUF_OBJS) \
462	    regress/unittests/test_helper/libtest_helper.a \
463	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
464
465UNITTESTS_TEST_SSHKEY_OBJS=\
466	regress/unittests/sshkey/test_fuzz.o \
467	regress/unittests/sshkey/tests.o \
468	regress/unittests/sshkey/common.o \
469	regress/unittests/sshkey/test_file.o \
470	regress/unittests/sshkey/test_sshkey.o
471
472regress/unittests/sshkey/test_sshkey$(EXEEXT): ${UNITTESTS_TEST_SSHKEY_OBJS} \
473    regress/unittests/test_helper/libtest_helper.a libssh.a
474	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHKEY_OBJS) \
475	    regress/unittests/test_helper/libtest_helper.a \
476	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
477
478UNITTESTS_TEST_BITMAP_OBJS=\
479	regress/unittests/bitmap/tests.o
480
481regress/unittests/bitmap/test_bitmap$(EXEEXT): ${UNITTESTS_TEST_BITMAP_OBJS} \
482    regress/unittests/test_helper/libtest_helper.a libssh.a
483	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_BITMAP_OBJS) \
484	    regress/unittests/test_helper/libtest_helper.a \
485	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
486
487UNITTESTS_TEST_KEX_OBJS=\
488	regress/unittests/kex/tests.o \
489	regress/unittests/kex/test_kex.o
490
491regress/unittests/kex/test_kex$(EXEEXT): ${UNITTESTS_TEST_KEX_OBJS} \
492    regress/unittests/test_helper/libtest_helper.a libssh.a
493	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_KEX_OBJS) \
494	    regress/unittests/test_helper/libtest_helper.a \
495	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
496
497UNITTESTS_TEST_HOSTKEYS_OBJS=\
498	regress/unittests/hostkeys/tests.o \
499	regress/unittests/hostkeys/test_iterate.o
500
501regress/unittests/hostkeys/test_hostkeys$(EXEEXT): \
502    ${UNITTESTS_TEST_HOSTKEYS_OBJS} \
503    regress/unittests/test_helper/libtest_helper.a libssh.a
504	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_HOSTKEYS_OBJS) \
505	    regress/unittests/test_helper/libtest_helper.a \
506	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
507
508REGRESS_BINARIES=\
509	regress/modpipe$(EXEEXT) \
510	regress/setuid-allowed$(EXEEXT) \
511	regress/netcat$(EXEEXT) \
512	regress/check-perm$(EXEEXT) \
513	regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \
514	regress/unittests/sshkey/test_sshkey$(EXEEXT) \
515	regress/unittests/bitmap/test_bitmap$(EXEEXT) \
516	regress/unittests/hostkeys/test_hostkeys$(EXEEXT) \
517	regress/unittests/kex/test_kex$(EXEEXT)
518
519tests interop-tests t-exec: regress-prep $(TARGETS) $(REGRESS_BINARIES)
520	BUILDDIR=`pwd`; \
521	TEST_SSH_SCP="$${BUILDDIR}/scp"; \
522	TEST_SSH_SSH="$${BUILDDIR}/ssh"; \
523	TEST_SSH_SSHD="$${BUILDDIR}/sshd"; \
524	TEST_SSH_SSHAGENT="$${BUILDDIR}/ssh-agent"; \
525	TEST_SSH_SSHADD="$${BUILDDIR}/ssh-add"; \
526	TEST_SSH_SSHKEYGEN="$${BUILDDIR}/ssh-keygen"; \
527	TEST_SSH_SSHPKCS11HELPER="$${BUILDDIR}/ssh-pkcs11-helper"; \
528	TEST_SSH_SSHKEYSCAN="$${BUILDDIR}/ssh-keyscan"; \
529	TEST_SSH_SFTP="$${BUILDDIR}/sftp"; \
530	TEST_SSH_SFTPSERVER="$${BUILDDIR}/sftp-server"; \
531	TEST_SSH_PLINK="plink"; \
532	TEST_SSH_PUTTYGEN="puttygen"; \
533	TEST_SSH_CONCH="conch"; \
534	TEST_SSH_IPV6="@TEST_SSH_IPV6@" ; \
535	TEST_SSH_ECC="@TEST_SSH_ECC@" ; \
536	cd $(srcdir)/regress || exit $$?; \
537	$(MAKE) \
538		.OBJDIR="$${BUILDDIR}/regress" \
539		.CURDIR="`pwd`" \
540		BUILDDIR="$${BUILDDIR}" \
541		OBJ="$${BUILDDIR}/regress/" \
542		PATH="$${BUILDDIR}:$${PATH}" \
543		TEST_ENV=MALLOC_OPTIONS="@TEST_MALLOC_OPTIONS@" \
544		TEST_SSH_SCP="$${TEST_SSH_SCP}" \
545		TEST_SSH_SSH="$${TEST_SSH_SSH}" \
546		TEST_SSH_SSHD="$${TEST_SSH_SSHD}" \
547		TEST_SSH_SSHAGENT="$${TEST_SSH_SSHAGENT}" \
548		TEST_SSH_SSHADD="$${TEST_SSH_SSHADD}" \
549		TEST_SSH_SSHKEYGEN="$${TEST_SSH_SSHKEYGEN}" \
550		TEST_SSH_SSHPKCS11HELPER="$${TEST_SSH_SSHPKCS11HELPER}" \
551		TEST_SSH_SSHKEYSCAN="$${TEST_SSH_SSHKEYSCAN}" \
552		TEST_SSH_SFTP="$${TEST_SSH_SFTP}" \
553		TEST_SSH_SFTPSERVER="$${TEST_SSH_SFTPSERVER}" \
554		TEST_SSH_PLINK="$${TEST_SSH_PLINK}" \
555		TEST_SSH_PUTTYGEN="$${TEST_SSH_PUTTYGEN}" \
556		TEST_SSH_CONCH="$${TEST_SSH_CONCH}" \
557		TEST_SSH_IPV6="$${TEST_SSH_IPV6}" \
558		TEST_SSH_ECC="$${TEST_SSH_ECC}" \
559		TEST_SHELL="${TEST_SHELL}" \
560		EXEEXT="$(EXEEXT)" \
561		$@ && echo all tests passed
562
563compat-tests: $(LIBCOMPAT)
564	(cd openbsd-compat/regress && $(MAKE))
565
566regressclean:
567	if [ -f regress/Makefile ] && [ -r regress/Makefile ]; then \
568		(cd regress && $(MAKE) clean) \
569	fi
570
571survey: survey.sh ssh
572	@$(SHELL) ./survey.sh > survey
573	@echo 'The survey results have been placed in the file "survey" in the'
574	@echo 'current directory.  Please review the file then send with'
575	@echo '"make send-survey".'
576
577send-survey:	survey
578	mail portable-survey@mindrot.org <survey
579
580package: $(CONFIGFILES) $(MANPAGES) $(TARGETS)
581	if [ "@MAKE_PACKAGE_SUPPORTED@" = yes ]; then \
582		sh buildpkg.sh; \
583	fi
584