Makefile.in revision 323134
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 utf8.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 platform-tracing.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 \
101	audit.o audit-bsm.o audit-linux.o platform.o \
102	sshpty.o sshlogin.o servconf.o serverloop.o \
103	auth.o auth2.o auth-options.o session.o \
104	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.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 -Dumac_ctx=umac128_ctx
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	rm -f regress/unittests/match/*.o
244	rm -f regress/unittests/match/test_match
245	rm -f regress/unittests/utf8/*.o
246	rm -f regress/unittests/utf8/test_utf8
247	rm -f regress/misc/kexfuzz/*.o
248	rm -f regress/misc/kexfuzz/kexfuzz
249	(cd openbsd-compat && $(MAKE) clean)
250
251distclean:	regressclean
252	rm -f *.o *.a $(TARGETS) logintest config.cache config.log
253	rm -f *.out core opensshd.init openssh.xml
254	rm -f Makefile buildpkg.sh config.h config.status
255	rm -f survey.sh openbsd-compat/regress/Makefile *~ 
256	rm -rf autom4te.cache
257	rm -f regress/unittests/test_helper/*.a
258	rm -f regress/unittests/test_helper/*.o
259	rm -f regress/unittests/sshbuf/*.o
260	rm -f regress/unittests/sshbuf/test_sshbuf
261	rm -f regress/unittests/sshkey/*.o
262	rm -f regress/unittests/sshkey/test_sshkey
263	rm -f regress/unittests/bitmap/*.o
264	rm -f regress/unittests/bitmap/test_bitmap
265	rm -f regress/unittests/hostkeys/*.o
266	rm -f regress/unittests/hostkeys/test_hostkeys
267	rm -f regress/unittests/kex/*.o
268	rm -f regress/unittests/kex/test_kex
269	rm -f regress/unittests/match/*.o
270	rm -f regress/unittests/match/test_match
271	rm -f regress/unittests/utf8/*.o
272	rm -f regress/unittests/utf8/test_utf8
273	rm -f regress/unittests/misc/kexfuzz
274	(cd openbsd-compat && $(MAKE) distclean)
275	if test -d pkg ; then \
276		rm -fr pkg ; \
277	fi
278
279veryclean: distclean
280	rm -f configure config.h.in *.0
281
282cleandir: veryclean
283
284mrproper: veryclean
285
286realclean: veryclean
287
288catman-do:
289	@for f in $(MANPAGES_IN) ; do \
290		base=`echo $$f | sed 's/\..*$$//'` ; \
291		echo "$$f -> $$base.0" ; \
292		$(MANFMT) $$f | cat -v | sed -e 's/.\^H//g' \
293			>$$base.0 ; \
294	done
295
296distprep: catman-do
297	$(AUTORECONF)
298	-rm -rf autom4te.cache
299
300install: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files install-sysconf host-key check-config
301install-nokeys: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files install-sysconf
302install-nosysconf: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files
303
304check-config:
305	-$(DESTDIR)$(sbindir)/sshd -t -f $(DESTDIR)$(sysconfdir)/sshd_config
306
307install-files:
308	$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
309	$(srcdir)/mkinstalldirs $(DESTDIR)$(sbindir)
310	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
311	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)1
312	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)5
313	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)8
314	$(srcdir)/mkinstalldirs $(DESTDIR)$(libexecdir)
315	(umask 022 ; $(srcdir)/mkinstalldirs $(DESTDIR)$(PRIVSEP_PATH))
316	$(INSTALL) -m 0755 $(STRIP_OPT) ssh$(EXEEXT) $(DESTDIR)$(bindir)/ssh$(EXEEXT)
317	$(INSTALL) -m 0755 $(STRIP_OPT) scp$(EXEEXT) $(DESTDIR)$(bindir)/scp$(EXEEXT)
318	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-add$(EXEEXT) $(DESTDIR)$(bindir)/ssh-add$(EXEEXT)
319	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-agent$(EXEEXT) $(DESTDIR)$(bindir)/ssh-agent$(EXEEXT)
320	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-keygen$(EXEEXT) $(DESTDIR)$(bindir)/ssh-keygen$(EXEEXT)
321	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-keyscan$(EXEEXT) $(DESTDIR)$(bindir)/ssh-keyscan$(EXEEXT)
322	$(INSTALL) -m 0755 $(STRIP_OPT) sshd$(EXEEXT) $(DESTDIR)$(sbindir)/sshd$(EXEEXT)
323	$(INSTALL) -m 4711 $(STRIP_OPT) ssh-keysign$(EXEEXT) $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)
324	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-pkcs11-helper$(EXEEXT) $(DESTDIR)$(SSH_PKCS11_HELPER)$(EXEEXT)
325	$(INSTALL) -m 0755 $(STRIP_OPT) sftp$(EXEEXT) $(DESTDIR)$(bindir)/sftp$(EXEEXT)
326	$(INSTALL) -m 0755 $(STRIP_OPT) sftp-server$(EXEEXT) $(DESTDIR)$(SFTP_SERVER)$(EXEEXT)
327	$(INSTALL) -m 644 ssh.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1
328	$(INSTALL) -m 644 scp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/scp.1
329	$(INSTALL) -m 644 ssh-add.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-add.1
330	$(INSTALL) -m 644 ssh-agent.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
331	$(INSTALL) -m 644 ssh-keygen.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
332	$(INSTALL) -m 644 ssh-keyscan.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
333	$(INSTALL) -m 644 moduli.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/moduli.5
334	$(INSTALL) -m 644 sshd_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/sshd_config.5
335	$(INSTALL) -m 644 ssh_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/ssh_config.5
336	$(INSTALL) -m 644 sshd.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
337	$(INSTALL) -m 644 sftp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
338	$(INSTALL) -m 644 sftp-server.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
339	$(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
340	$(INSTALL) -m 644 ssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
341
342install-sysconf:
343	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
344		$(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir); \
345	fi
346	@if [ ! -f $(DESTDIR)$(sysconfdir)/ssh_config ]; then \
347		$(INSTALL) -m 644 ssh_config.out $(DESTDIR)$(sysconfdir)/ssh_config; \
348	else \
349		echo "$(DESTDIR)$(sysconfdir)/ssh_config already exists, install will not overwrite"; \
350	fi
351	@if [ ! -f $(DESTDIR)$(sysconfdir)/sshd_config ]; then \
352		$(INSTALL) -m 644 sshd_config.out $(DESTDIR)$(sysconfdir)/sshd_config; \
353	else \
354		echo "$(DESTDIR)$(sysconfdir)/sshd_config already exists, install will not overwrite"; \
355	fi
356	@if [ ! -f $(DESTDIR)$(sysconfdir)/moduli ]; then \
357		if [ -f $(DESTDIR)$(sysconfdir)/primes ]; then \
358			echo "moving $(DESTDIR)$(sysconfdir)/primes to $(DESTDIR)$(sysconfdir)/moduli"; \
359			mv "$(DESTDIR)$(sysconfdir)/primes" "$(DESTDIR)$(sysconfdir)/moduli"; \
360		else \
361			$(INSTALL) -m 644 moduli.out $(DESTDIR)$(sysconfdir)/moduli; \
362		fi ; \
363	else \
364		echo "$(DESTDIR)$(sysconfdir)/moduli already exists, install will not overwrite"; \
365	fi
366
367host-key: ssh-keygen$(EXEEXT)
368	@if [ -z "$(DESTDIR)" ] ; then \
369		./ssh-keygen -A; \
370	fi
371
372host-key-force: ssh-keygen$(EXEEXT) ssh$(EXEEXT)
373	if ./ssh -Q protocol-version | grep '^1$$' >/dev/null; then \
374		./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N ""; \
375	fi
376	./ssh-keygen -t dsa -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key -N ""
377	./ssh-keygen -t rsa -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key -N ""
378	./ssh-keygen -t ed25519 -f $(DESTDIR)$(sysconfdir)/ssh_host_ed25519_key -N ""
379	if ./ssh -Q key | grep ecdsa >/dev/null ; then \
380		./ssh-keygen -t ecdsa -f $(DESTDIR)$(sysconfdir)/ssh_host_ecdsa_key -N ""; \
381	fi
382
383uninstallall:	uninstall
384	-rm -f $(DESTDIR)$(sysconfdir)/ssh_config
385	-rm -f $(DESTDIR)$(sysconfdir)/sshd_config
386	-rmdir $(DESTDIR)$(sysconfdir)
387	-rmdir $(DESTDIR)$(bindir)
388	-rmdir $(DESTDIR)$(sbindir)
389	-rmdir $(DESTDIR)$(mandir)/$(mansubdir)1
390	-rmdir $(DESTDIR)$(mandir)/$(mansubdir)8
391	-rmdir $(DESTDIR)$(mandir)
392	-rmdir $(DESTDIR)$(libexecdir)
393
394uninstall:
395	-rm -f $(DESTDIR)$(bindir)/ssh$(EXEEXT)
396	-rm -f $(DESTDIR)$(bindir)/scp$(EXEEXT)
397	-rm -f $(DESTDIR)$(bindir)/ssh-add$(EXEEXT)
398	-rm -f $(DESTDIR)$(bindir)/ssh-agent$(EXEEXT)
399	-rm -f $(DESTDIR)$(bindir)/ssh-keygen$(EXEEXT)
400	-rm -f $(DESTDIR)$(bindir)/ssh-keyscan$(EXEEXT)
401	-rm -f $(DESTDIR)$(bindir)/sftp$(EXEEXT)
402	-rm -f $(DESTDIR)$(sbindir)/sshd$(EXEEXT)
403	-rm -r $(DESTDIR)$(SFTP_SERVER)$(EXEEXT)
404	-rm -f $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)
405	-rm -f $(DESTDIR)$(SSH_PKCS11_HELPER)$(EXEEXT)
406	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1
407	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/scp.1
408	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-add.1
409	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
410	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
411	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
412	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
413	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
414	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
415	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
416	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
417
418regress-prep:
419	[ -d `pwd`/regress ] || mkdir -p `pwd`/regress
420	[ -d `pwd`/regress/unittests ] || mkdir -p `pwd`/regress/unittests
421	[ -d `pwd`/regress/unittests/test_helper ] || \
422		mkdir -p `pwd`/regress/unittests/test_helper
423	[ -d `pwd`/regress/unittests/sshbuf ] || \
424		mkdir -p `pwd`/regress/unittests/sshbuf
425	[ -d `pwd`/regress/unittests/sshkey ] || \
426		mkdir -p `pwd`/regress/unittests/sshkey
427	[ -d `pwd`/regress/unittests/bitmap ] || \
428		mkdir -p `pwd`/regress/unittests/bitmap
429	[ -d `pwd`/regress/unittests/hostkeys ] || \
430		mkdir -p `pwd`/regress/unittests/hostkeys
431	[ -d `pwd`/regress/unittests/kex ] || \
432		mkdir -p `pwd`/regress/unittests/kex
433	[ -d `pwd`/regress/unittests/match ] || \
434		mkdir -p `pwd`/regress/unittests/match
435	[ -d `pwd`/regress/unittests/utf8 ] || \
436		mkdir -p `pwd`/regress/unittests/utf8
437	[ -d `pwd`/regress/misc/kexfuzz ] || \
438		mkdir -p `pwd`/regress/misc/kexfuzz
439	[ -f `pwd`/regress/Makefile ] || \
440	    ln -s `cd $(srcdir) && pwd`/regress/Makefile `pwd`/regress/Makefile
441
442REGRESSLIBS=libssh.a $(LIBCOMPAT)
443
444regress/modpipe$(EXEEXT): $(srcdir)/regress/modpipe.c $(REGRESSLIBS)
445	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/modpipe.c \
446	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
447
448regress/setuid-allowed$(EXEEXT): $(srcdir)/regress/setuid-allowed.c $(REGRESSLIBS)
449	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/setuid-allowed.c \
450	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
451
452regress/netcat$(EXEEXT): $(srcdir)/regress/netcat.c $(REGRESSLIBS)
453	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/netcat.c \
454	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
455
456regress/check-perm$(EXEEXT): $(srcdir)/regress/check-perm.c $(REGRESSLIBS)
457	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/check-perm.c \
458	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
459
460UNITTESTS_TEST_HELPER_OBJS=\
461	regress/unittests/test_helper/test_helper.o \
462	regress/unittests/test_helper/fuzz.o
463
464regress/unittests/test_helper/libtest_helper.a: ${UNITTESTS_TEST_HELPER_OBJS}
465	$(AR) rv $@ $(UNITTESTS_TEST_HELPER_OBJS)
466	$(RANLIB) $@
467
468UNITTESTS_TEST_SSHBUF_OBJS=\
469	regress/unittests/sshbuf/tests.o \
470	regress/unittests/sshbuf/test_sshbuf.o \
471	regress/unittests/sshbuf/test_sshbuf_getput_basic.o \
472	regress/unittests/sshbuf/test_sshbuf_getput_crypto.o \
473	regress/unittests/sshbuf/test_sshbuf_misc.o \
474	regress/unittests/sshbuf/test_sshbuf_fuzz.o \
475	regress/unittests/sshbuf/test_sshbuf_getput_fuzz.o \
476	regress/unittests/sshbuf/test_sshbuf_fixed.o
477
478regress/unittests/sshbuf/test_sshbuf$(EXEEXT): ${UNITTESTS_TEST_SSHBUF_OBJS} \
479    regress/unittests/test_helper/libtest_helper.a libssh.a
480	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHBUF_OBJS) \
481	    regress/unittests/test_helper/libtest_helper.a \
482	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
483
484UNITTESTS_TEST_SSHKEY_OBJS=\
485	regress/unittests/sshkey/test_fuzz.o \
486	regress/unittests/sshkey/tests.o \
487	regress/unittests/sshkey/common.o \
488	regress/unittests/sshkey/test_file.o \
489	regress/unittests/sshkey/test_sshkey.o
490
491regress/unittests/sshkey/test_sshkey$(EXEEXT): ${UNITTESTS_TEST_SSHKEY_OBJS} \
492    regress/unittests/test_helper/libtest_helper.a libssh.a
493	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHKEY_OBJS) \
494	    regress/unittests/test_helper/libtest_helper.a \
495	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
496
497UNITTESTS_TEST_BITMAP_OBJS=\
498	regress/unittests/bitmap/tests.o
499
500regress/unittests/bitmap/test_bitmap$(EXEEXT): ${UNITTESTS_TEST_BITMAP_OBJS} \
501    regress/unittests/test_helper/libtest_helper.a libssh.a
502	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_BITMAP_OBJS) \
503	    regress/unittests/test_helper/libtest_helper.a \
504	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
505
506UNITTESTS_TEST_KEX_OBJS=\
507	regress/unittests/kex/tests.o \
508	regress/unittests/kex/test_kex.o
509
510regress/unittests/kex/test_kex$(EXEEXT): ${UNITTESTS_TEST_KEX_OBJS} \
511    regress/unittests/test_helper/libtest_helper.a libssh.a
512	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_KEX_OBJS) \
513	    regress/unittests/test_helper/libtest_helper.a \
514	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
515
516UNITTESTS_TEST_HOSTKEYS_OBJS=\
517	regress/unittests/hostkeys/tests.o \
518	regress/unittests/hostkeys/test_iterate.o
519
520regress/unittests/hostkeys/test_hostkeys$(EXEEXT): \
521    ${UNITTESTS_TEST_HOSTKEYS_OBJS} \
522    regress/unittests/test_helper/libtest_helper.a libssh.a
523	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_HOSTKEYS_OBJS) \
524	    regress/unittests/test_helper/libtest_helper.a \
525	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
526
527UNITTESTS_TEST_MATCH_OBJS=\
528	regress/unittests/match/tests.o
529
530regress/unittests/match/test_match$(EXEEXT): \
531    ${UNITTESTS_TEST_MATCH_OBJS} \
532    regress/unittests/test_helper/libtest_helper.a libssh.a
533	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_MATCH_OBJS) \
534	    regress/unittests/test_helper/libtest_helper.a \
535	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
536
537UNITTESTS_TEST_UTF8_OBJS=\
538	regress/unittests/utf8/tests.o
539
540regress/unittests/utf8/test_utf8$(EXEEXT): \
541    ${UNITTESTS_TEST_UTF8_OBJS} \
542    regress/unittests/test_helper/libtest_helper.a libssh.a
543	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_UTF8_OBJS) \
544	    regress/unittests/test_helper/libtest_helper.a \
545	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
546
547MISC_KEX_FUZZ_OBJS=\
548	regress/misc/kexfuzz/kexfuzz.o
549
550regress/misc/kexfuzz/kexfuzz$(EXEEXT): ${MISC_KEX_FUZZ_OBJS} libssh.a
551	$(LD) -o $@ $(LDFLAGS) $(MISC_KEX_FUZZ_OBJS) \
552	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
553
554regress-binaries: regress/modpipe$(EXEEXT) \
555	regress/setuid-allowed$(EXEEXT) \
556	regress/netcat$(EXEEXT) \
557	regress/check-perm$(EXEEXT) \
558	regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \
559	regress/unittests/sshkey/test_sshkey$(EXEEXT) \
560	regress/unittests/bitmap/test_bitmap$(EXEEXT) \
561	regress/unittests/hostkeys/test_hostkeys$(EXEEXT) \
562	regress/unittests/kex/test_kex$(EXEEXT) \
563	regress/unittests/match/test_match$(EXEEXT) \
564	regress/unittests/utf8/test_utf8$(EXEEXT) \
565	regress/misc/kexfuzz/kexfuzz$(EXEEXT)
566
567tests interop-tests t-exec: regress-prep regress-binaries $(TARGETS)
568	BUILDDIR=`pwd`; \
569	TEST_SSH_SCP="$${BUILDDIR}/scp"; \
570	TEST_SSH_SSH="$${BUILDDIR}/ssh"; \
571	TEST_SSH_SSHD="$${BUILDDIR}/sshd"; \
572	TEST_SSH_SSHAGENT="$${BUILDDIR}/ssh-agent"; \
573	TEST_SSH_SSHADD="$${BUILDDIR}/ssh-add"; \
574	TEST_SSH_SSHKEYGEN="$${BUILDDIR}/ssh-keygen"; \
575	TEST_SSH_SSHPKCS11HELPER="$${BUILDDIR}/ssh-pkcs11-helper"; \
576	TEST_SSH_SSHKEYSCAN="$${BUILDDIR}/ssh-keyscan"; \
577	TEST_SSH_SFTP="$${BUILDDIR}/sftp"; \
578	TEST_SSH_SFTPSERVER="$${BUILDDIR}/sftp-server"; \
579	TEST_SSH_PLINK="plink"; \
580	TEST_SSH_PUTTYGEN="puttygen"; \
581	TEST_SSH_CONCH="conch"; \
582	TEST_SSH_IPV6="@TEST_SSH_IPV6@" ; \
583	TEST_SSH_UTF8="@TEST_SSH_UTF8@" ; \
584	TEST_SSH_ECC="@TEST_SSH_ECC@" ; \
585	cd $(srcdir)/regress || exit $$?; \
586	$(MAKE) \
587		.OBJDIR="$${BUILDDIR}/regress" \
588		.CURDIR="`pwd`" \
589		BUILDDIR="$${BUILDDIR}" \
590		OBJ="$${BUILDDIR}/regress/" \
591		PATH="$${BUILDDIR}:$${PATH}" \
592		TEST_ENV=MALLOC_OPTIONS="@TEST_MALLOC_OPTIONS@" \
593		TEST_MALLOC_OPTIONS="@TEST_MALLOC_OPTIONS@" \
594		TEST_SSH_SCP="$${TEST_SSH_SCP}" \
595		TEST_SSH_SSH="$${TEST_SSH_SSH}" \
596		TEST_SSH_SSHD="$${TEST_SSH_SSHD}" \
597		TEST_SSH_SSHAGENT="$${TEST_SSH_SSHAGENT}" \
598		TEST_SSH_SSHADD="$${TEST_SSH_SSHADD}" \
599		TEST_SSH_SSHKEYGEN="$${TEST_SSH_SSHKEYGEN}" \
600		TEST_SSH_SSHPKCS11HELPER="$${TEST_SSH_SSHPKCS11HELPER}" \
601		TEST_SSH_SSHKEYSCAN="$${TEST_SSH_SSHKEYSCAN}" \
602		TEST_SSH_SFTP="$${TEST_SSH_SFTP}" \
603		TEST_SSH_SFTPSERVER="$${TEST_SSH_SFTPSERVER}" \
604		TEST_SSH_PLINK="$${TEST_SSH_PLINK}" \
605		TEST_SSH_PUTTYGEN="$${TEST_SSH_PUTTYGEN}" \
606		TEST_SSH_CONCH="$${TEST_SSH_CONCH}" \
607		TEST_SSH_IPV6="$${TEST_SSH_IPV6}" \
608		TEST_SSH_UTF8="$${TEST_SSH_UTF8}" \
609		TEST_SSH_ECC="$${TEST_SSH_ECC}" \
610		TEST_SHELL="${TEST_SHELL}" \
611		EXEEXT="$(EXEEXT)" \
612		$@ && echo all tests passed
613
614compat-tests: $(LIBCOMPAT)
615	(cd openbsd-compat/regress && $(MAKE))
616
617regressclean:
618	if [ -f regress/Makefile ] && [ -r regress/Makefile ]; then \
619		(cd regress && $(MAKE) clean) \
620	fi
621
622survey: survey.sh ssh
623	@$(SHELL) ./survey.sh > survey
624	@echo 'The survey results have been placed in the file "survey" in the'
625	@echo 'current directory.  Please review the file then send with'
626	@echo '"make send-survey".'
627
628send-survey:	survey
629	mail portable-survey@mindrot.org <survey
630
631package: $(CONFIGFILES) $(MANPAGES) $(TARGETS)
632	if [ "@MAKE_PACKAGE_SUPPORTED@" = yes ]; then \
633		sh buildpkg.sh; \
634	fi
635