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