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