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