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