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