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