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