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