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