1255670Sdes# $Id: Makefile.in,v 1.340 2013/06/11 01:26:10 dtucker Exp $
298937Sdes
398937Sdes# uncomment if you run a non bourne compatable shell. Ie. csh
498937Sdes#SHELL = @SH@
598937Sdes
698937SdesAUTORECONF=autoreconf
798937Sdes
898937Sdesprefix=@prefix@
998937Sdesexec_prefix=@exec_prefix@
1098937Sdesbindir=@bindir@
1198937Sdessbindir=@sbindir@
1298937Sdeslibexecdir=@libexecdir@
1398937Sdesdatadir=@datadir@
14164146Sdesdatarootdir=@datarootdir@
1598937Sdesmandir=@mandir@
1698937Sdesmansubdir=@mansubdir@
1798937Sdessysconfdir=@sysconfdir@
1898937Sdespiddir=@piddir@
1998937Sdessrcdir=@srcdir@
2098937Sdestop_srcdir=@top_srcdir@
2198937Sdes
2298937SdesDESTDIR=
2398937SdesVPATH=@srcdir@
2498937SdesSSH_PROGRAM=@bindir@/ssh
2598937SdesASKPASS_PROGRAM=$(libexecdir)/ssh-askpass
2698937SdesSFTP_SERVER=$(libexecdir)/sftp-server
2798937SdesSSH_KEYSIGN=$(libexecdir)/ssh-keysign
28204861SdesSSH_PKCS11_HELPER=$(libexecdir)/ssh-pkcs11-helper
2998937SdesPRIVSEP_PATH=@PRIVSEP_PATH@
3099060SdesSSH_PRIVSEP_USER=@SSH_PRIVSEP_USER@
31113908SdesSTRIP_OPT=@STRIP_OPT@
3298937Sdes
3398937SdesPATHS= -DSSHDIR=\"$(sysconfdir)\" \
3498937Sdes	-D_PATH_SSH_PROGRAM=\"$(SSH_PROGRAM)\" \
3598937Sdes	-D_PATH_SSH_ASKPASS_DEFAULT=\"$(ASKPASS_PROGRAM)\" \
3698937Sdes	-D_PATH_SFTP_SERVER=\"$(SFTP_SERVER)\" \
3798937Sdes	-D_PATH_SSH_KEY_SIGN=\"$(SSH_KEYSIGN)\" \
38204861Sdes	-D_PATH_SSH_PKCS11_HELPER=\"$(SSH_PKCS11_HELPER)\" \
3998937Sdes	-D_PATH_SSH_PIDDIR=\"$(piddir)\" \
40248613Sdes	-D_PATH_PRIVSEP_CHROOT_DIR=\"$(PRIVSEP_PATH)\"
4198937Sdes
4298937SdesCC=@CC@
4398937SdesLD=@LD@
4498937SdesCFLAGS=@CFLAGS@
4598937SdesCPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
4698937SdesLIBS=@LIBS@
47248613SdesK5LIBS=@K5LIBS@
48248613SdesGSSLIBS=@GSSLIBS@
49218769SdesSSHLIBS=@SSHLIBS@
50162852SdesSSHDLIBS=@SSHDLIBS@
51146998SdesLIBEDIT=@LIBEDIT@
5298937SdesAR=@AR@
53124208SdesAWK=@AWK@
5498937SdesRANLIB=@RANLIB@
5598937SdesINSTALL=@INSTALL@
5698937SdesPERL=@PERL@
57113908SdesSED=@SED@
5898937SdesENT=@ENT@
5998937SdesXAUTH_PATH=@XAUTH_PATH@
6098937SdesLDFLAGS=-L. -Lopenbsd-compat/ @LDFLAGS@
6198937SdesEXEEXT=@EXEEXT@
62218767SdesMANFMT=@MANFMT@
6398937Sdes
64225825SdesTARGETS=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)
6598937Sdes
66248613SdesLIBSSH_OBJS=authfd.o authfile.o bufaux.o bufbn.o buffer.o \
67248613Sdes	canohost.o channels.o cipher.o cipher-aes.o \
68126274Sdes	cipher-bf1.o cipher-ctr.o cipher-3des1.o cleanup.o \
69126274Sdes	compat.o compress.o crc32.o deattack.o fatal.o hostfile.o \
70162852Sdes	log.o match.o md-sha256.o moduli.o nchan.o packet.o \
71180750Sdes	readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \
72137015Sdes	atomicio.o key.o dispatch.o kex.o mac.o uidswap.o uuencode.o misc.o \
73218767Sdes	monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
74218767Sdes	kexdh.o kexgex.o kexdhc.o kexgexc.o bufec.o kexecdh.o kexecdhc.o \
75248613Sdes	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
76248613Sdes	jpake.o schnorr.o ssh-pkcs11.o krl.o
7798937Sdes
78113908SdesSSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
79197670Sdes	sshconnect.o sshconnect1.o sshconnect2.o mux.o \
80204861Sdes	roaming_common.o roaming_client.o
8198937Sdes
82113908SdesSSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
83218767Sdes	audit.o audit-bsm.o audit-linux.o platform.o \
84137015Sdes	sshpty.o sshlogin.o servconf.o serverloop.o \
85113908Sdes	auth.o auth1.o auth2.o auth-options.o session.o \
86113908Sdes	auth-chall.o auth2-chall.o groupaccess.o \
87113908Sdes	auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
88189006Sdes	auth2-none.o auth2-passwd.o auth2-pubkey.o auth2-jpake.o \
89218767Sdes	monitor_mm.o monitor.o monitor_wrap.o kexdhs.o kexgexs.o kexecdhs.o \
90124208Sdes	auth-krb5.o \
91124208Sdes	auth2-gss.o gss-serv.o gss-serv-krb5.o \
92146998Sdes	loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
93218767Sdes	sftp-server.o sftp-common.o \
94225825Sdes	roaming_common.o roaming_serv.o \
95239844Sdes	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
96239844Sdes	sandbox-seccomp-filter.o
9798937Sdes
98225825SdesMANPAGES	= 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 sshd_config.5.out ssh_config.5.out
99225825SdesMANPAGES_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 sshd_config.5 ssh_config.5
10098937SdesMANTYPE		= @MANTYPE@
10198937Sdes
10298937SdesCONFIGFILES=sshd_config.out ssh_config.out moduli.out
10398937SdesCONFIGFILES_IN=sshd_config ssh_config moduli
10498937Sdes
10598937SdesPATHSUBS	= \
106113908Sdes	-e 's|/etc/ssh/ssh_config|$(sysconfdir)/ssh_config|g' \
107113908Sdes	-e 's|/etc/ssh/ssh_known_hosts|$(sysconfdir)/ssh_known_hosts|g' \
108113908Sdes	-e 's|/etc/ssh/sshd_config|$(sysconfdir)/sshd_config|g' \
109113908Sdes	-e 's|/usr/libexec|$(libexecdir)|g' \
110113908Sdes	-e 's|/etc/shosts.equiv|$(sysconfdir)/shosts.equiv|g' \
111113908Sdes	-e 's|/etc/ssh/ssh_host_key|$(sysconfdir)/ssh_host_key|g' \
112218767Sdes	-e 's|/etc/ssh/ssh_host_ecdsa_key|$(sysconfdir)/ssh_host_ecdsa_key|g' \
113113908Sdes	-e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \
114113908Sdes	-e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \
115113908Sdes	-e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \
116180750Sdes	-e 's|/etc/moduli|$(sysconfdir)/moduli|g' \
117113908Sdes	-e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \
118162852Sdes	-e 's|/etc/ssh/sshrc|$(sysconfdir)/sshrc|g' \
119113908Sdes	-e 's|/usr/X11R6/bin/xauth|$(XAUTH_PATH)|g' \
120113908Sdes	-e 's|/var/empty|$(PRIVSEP_PATH)|g' \
121113908Sdes	-e 's|/usr/bin:/bin:/usr/sbin:/sbin|@user_path@|g'
12298937Sdes
123113908SdesFIXPATHSCMD	= $(SED) $(PATHSUBS)
124255670SdesFIXALGORITHMSCMD= $(SHELL) $(srcdir)/fixalgorithms $(SED) \
125255670Sdes		     @UNSUPPORTED_ALGORITHMS@
12698937Sdes
127225825Sdesall: $(CONFIGFILES) $(MANPAGES) $(TARGETS)
12898937Sdes
129124208Sdes$(LIBSSH_OBJS): Makefile.in config.h
130124208Sdes$(SSHOBJS): Makefile.in config.h
131124208Sdes$(SSHDOBJS): Makefile.in config.h
13298937Sdes
13398937Sdes.c.o:
13498937Sdes	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
13598937Sdes
13698937SdesLIBCOMPAT=openbsd-compat/libopenbsd-compat.a
13798937Sdes$(LIBCOMPAT): always
13898937Sdes	(cd openbsd-compat && $(MAKE))
13998937Sdesalways:
14098937Sdes
14198937Sdeslibssh.a: $(LIBSSH_OBJS)
14298937Sdes	$(AR) rv $@ $(LIBSSH_OBJS)
14398937Sdes	$(RANLIB) $@
14498937Sdes
14598937Sdesssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
146248613Sdes	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
14798937Sdes
14898937Sdessshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
149248613Sdes	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
15098937Sdes
151113908Sdesscp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
152157016Sdes	$(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
15398937Sdes
15498937Sdesssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
155126274Sdes	$(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
15698937Sdes
157204861Sdesssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
158204861Sdes	$(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
15998937Sdes
16098937Sdesssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
161126274Sdes	$(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
16298937Sdes
163204861Sdesssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o readconf.o
164197670Sdes	$(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
16598937Sdes
166204861Sdesssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
167214979Sdes	$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
168204861Sdes
169197670Sdesssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
170197670Sdes	$(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
17198937Sdes
172180746Sdessftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
173180746Sdes	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
17498937Sdes
175126274Sdessftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-common.o sftp-glob.o progressmeter.o
176146998Sdes	$(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
17798937Sdes
17898937Sdes# test driver for the loginrec code - not built by default
17998937Sdeslogintest: logintest.o $(LIBCOMPAT) libssh.a loginrec.o
18098937Sdes	$(LD) -o $@ logintest.o $(LDFLAGS) loginrec.o -lopenbsd-compat -lssh $(LIBS)
18198937Sdes
18298937Sdes$(MANPAGES): $(MANPAGES_IN)
18398937Sdes	if test "$(MANTYPE)" = "cat"; then \
18498937Sdes		manpage=$(srcdir)/`echo $@ | sed 's/\.[1-9]\.out$$/\.0/'`; \
18598937Sdes	else \
18698937Sdes		manpage=$(srcdir)/`echo $@ | sed 's/\.out$$//'`; \
18798937Sdes	fi; \
18898937Sdes	if test "$(MANTYPE)" = "man"; then \
189255670Sdes		$(FIXPATHSCMD) $${manpage} | $(FIXALGORITHMSCMD) | \
190255670Sdes		    $(AWK) -f $(srcdir)/mdoc2man.awk > $@; \
19198937Sdes	else \
192255670Sdes		$(FIXPATHSCMD) $${manpage} | $(FIXALGORITHMSCMD) > $@; \
19398937Sdes	fi
19498937Sdes
19598937Sdes$(CONFIGFILES): $(CONFIGFILES_IN)
19698937Sdes	conffile=`echo $@ | sed 's/.out$$//'`; \
19798937Sdes	$(FIXPATHSCMD) $(srcdir)/$${conffile} > $@
19898937Sdes
199149749Sdes# fake rule to stop make trying to compile moduli.o into a binary "moduli.o"
200124208Sdesmoduli:
201124208Sdes	echo
202124208Sdes
203248613Sdes# special case target for umac128
204248613Sdesumac128.o:	umac.c
205248613Sdes	$(CC) $(CFLAGS) $(CPPFLAGS) -o umac128.o -c $(srcdir)/umac.c \
206248613Sdes	    -DUMAC_OUTPUT_LEN=16 -Dumac_new=umac128_new \
207248613Sdes	    -Dumac_update=umac128_update -Dumac_final=umac128_final \
208248613Sdes	    -Dumac_delete=umac128_delete
209248613Sdes
210124208Sdesclean:	regressclean
211126274Sdes	rm -f *.o *.a $(TARGETS) logintest config.cache config.log
212146998Sdes	rm -f *.out core survey
21398937Sdes	(cd openbsd-compat && $(MAKE) clean)
21498937Sdes
215124208Sdesdistclean:	regressclean
216126274Sdes	rm -f *.o *.a $(TARGETS) logintest config.cache config.log
217162852Sdes	rm -f *.out core opensshd.init openssh.xml
218225825Sdes	rm -f Makefile buildpkg.sh config.h config.status
219162852Sdes	rm -f survey.sh openbsd-compat/regress/Makefile *~ 
22098937Sdes	rm -rf autom4te.cache
22198937Sdes	(cd openbsd-compat && $(MAKE) distclean)
222137015Sdes	if test -d pkg ; then \
223137015Sdes		rm -fr pkg ; \
224137015Sdes	fi
22598937Sdes
226124208Sdesveryclean: distclean
22798937Sdes	rm -f configure config.h.in *.0
22898937Sdes
229225825Sdescleandir: veryclean
230225825Sdes
231124208Sdesmrproper: veryclean
23298937Sdes
233124208Sdesrealclean: veryclean
234124208Sdes
23598937Sdescatman-do:
23698937Sdes	@for f in $(MANPAGES_IN) ; do \
23798937Sdes		base=`echo $$f | sed 's/\..*$$//'` ; \
23898937Sdes		echo "$$f -> $$base.0" ; \
239218767Sdes		$(MANFMT) $$f | cat -v | sed -e 's/.\^H//g' \
24098937Sdes			>$$base.0 ; \
24198937Sdes	done
24298937Sdes
24398937Sdesdistprep: catman-do
24498937Sdes	$(AUTORECONF)
245126274Sdes	-rm -rf autom4te.cache
24698937Sdes
247225825Sdesinstall: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files install-sysconf host-key check-config
248225825Sdesinstall-nokeys: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files install-sysconf
249225825Sdesinstall-nosysconf: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files
25098937Sdes
251106121Sdescheck-config:
252106121Sdes	-$(DESTDIR)$(sbindir)/sshd -t -f $(DESTDIR)$(sysconfdir)/sshd_config
25399060Sdes
254204861Sdesinstall-files:
25598937Sdes	$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
25698937Sdes	$(srcdir)/mkinstalldirs $(DESTDIR)$(sbindir)
25798937Sdes	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
25898937Sdes	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)1
25998937Sdes	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)5
26098937Sdes	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)8
26198937Sdes	$(srcdir)/mkinstalldirs $(DESTDIR)$(libexecdir)
262106121Sdes	(umask 022 ; $(srcdir)/mkinstalldirs $(DESTDIR)$(PRIVSEP_PATH))
263207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) ssh$(EXEEXT) $(DESTDIR)$(bindir)/ssh$(EXEEXT)
264207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) scp$(EXEEXT) $(DESTDIR)$(bindir)/scp$(EXEEXT)
265207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-add$(EXEEXT) $(DESTDIR)$(bindir)/ssh-add$(EXEEXT)
266207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-agent$(EXEEXT) $(DESTDIR)$(bindir)/ssh-agent$(EXEEXT)
267207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-keygen$(EXEEXT) $(DESTDIR)$(bindir)/ssh-keygen$(EXEEXT)
268207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-keyscan$(EXEEXT) $(DESTDIR)$(bindir)/ssh-keyscan$(EXEEXT)
269207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) sshd$(EXEEXT) $(DESTDIR)$(sbindir)/sshd$(EXEEXT)
270207311Sdes	$(INSTALL) -m 4711 $(STRIP_OPT) ssh-keysign$(EXEEXT) $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)
271207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) ssh-pkcs11-helper$(EXEEXT) $(DESTDIR)$(SSH_PKCS11_HELPER)$(EXEEXT)
272207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) sftp$(EXEEXT) $(DESTDIR)$(bindir)/sftp$(EXEEXT)
273207311Sdes	$(INSTALL) -m 0755 $(STRIP_OPT) sftp-server$(EXEEXT) $(DESTDIR)$(SFTP_SERVER)$(EXEEXT)
27498937Sdes	$(INSTALL) -m 644 ssh.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1
27598937Sdes	$(INSTALL) -m 644 scp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/scp.1
27698937Sdes	$(INSTALL) -m 644 ssh-add.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-add.1
27798937Sdes	$(INSTALL) -m 644 ssh-agent.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
27898937Sdes	$(INSTALL) -m 644 ssh-keygen.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
27998937Sdes	$(INSTALL) -m 644 ssh-keyscan.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
280180750Sdes	$(INSTALL) -m 644 moduli.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/moduli.5
28198937Sdes	$(INSTALL) -m 644 sshd_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/sshd_config.5
28298937Sdes	$(INSTALL) -m 644 ssh_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/ssh_config.5
28398937Sdes	$(INSTALL) -m 644 sshd.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
284113908Sdes	$(INSTALL) -m 644 sftp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
285113908Sdes	$(INSTALL) -m 644 sftp-server.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
28698937Sdes	$(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
287204861Sdes	$(INSTALL) -m 644 ssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
28898937Sdes	-rm -f $(DESTDIR)$(bindir)/slogin
289106121Sdes	ln -s ./ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin
29098937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
291106121Sdes	ln -s ./ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
292146998Sdes
293146998Sdesinstall-sysconf:
29498937Sdes	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
29598937Sdes		$(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir); \
29698937Sdes	fi
297106121Sdes	@if [ ! -f $(DESTDIR)$(sysconfdir)/ssh_config ]; then \
29898937Sdes		$(INSTALL) -m 644 ssh_config.out $(DESTDIR)$(sysconfdir)/ssh_config; \
29998937Sdes	else \
30098937Sdes		echo "$(DESTDIR)$(sysconfdir)/ssh_config already exists, install will not overwrite"; \
30198937Sdes	fi
302106121Sdes	@if [ ! -f $(DESTDIR)$(sysconfdir)/sshd_config ]; then \
30398937Sdes		$(INSTALL) -m 644 sshd_config.out $(DESTDIR)$(sysconfdir)/sshd_config; \
30498937Sdes	else \
30598937Sdes		echo "$(DESTDIR)$(sysconfdir)/sshd_config already exists, install will not overwrite"; \
30698937Sdes	fi
307106121Sdes	@if [ ! -f $(DESTDIR)$(sysconfdir)/moduli ]; then \
30898937Sdes		if [ -f $(DESTDIR)$(sysconfdir)/primes ]; then \
30998937Sdes			echo "moving $(DESTDIR)$(sysconfdir)/primes to $(DESTDIR)$(sysconfdir)/moduli"; \
31098937Sdes			mv "$(DESTDIR)$(sysconfdir)/primes" "$(DESTDIR)$(sysconfdir)/moduli"; \
31198937Sdes		else \
31298937Sdes			$(INSTALL) -m 644 moduli.out $(DESTDIR)$(sysconfdir)/moduli; \
31398937Sdes		fi ; \
31498937Sdes	else \
31598937Sdes		echo "$(DESTDIR)$(sysconfdir)/moduli already exists, install will not overwrite"; \
31698937Sdes	fi
31798937Sdes
31898937Sdeshost-key: ssh-keygen$(EXEEXT)
319106121Sdes	@if [ -z "$(DESTDIR)" ] ; then \
320218767Sdes		if [ -f "$(sysconfdir)/ssh_host_key" ] ; then \
321218767Sdes			echo "$(sysconfdir)/ssh_host_key already exists, skipping." ; \
32298937Sdes		else \
323218767Sdes			./ssh-keygen -t rsa1 -f $(sysconfdir)/ssh_host_key -N "" ; \
32498937Sdes		fi ; \
325218767Sdes		if [ -f $(sysconfdir)/ssh_host_dsa_key ] ; then \
326218767Sdes			echo "$(sysconfdir)/ssh_host_dsa_key already exists, skipping." ; \
32798937Sdes		else \
328218767Sdes			./ssh-keygen -t dsa -f $(sysconfdir)/ssh_host_dsa_key -N "" ; \
32998937Sdes		fi ; \
330218767Sdes		if [ -f $(sysconfdir)/ssh_host_rsa_key ] ; then \
331218767Sdes			echo "$(sysconfdir)/ssh_host_rsa_key already exists, skipping." ; \
33298937Sdes		else \
333218767Sdes			./ssh-keygen -t rsa -f $(sysconfdir)/ssh_host_rsa_key -N "" ; \
33498937Sdes		fi ; \
335218767Sdes		if [ -z "@COMMENT_OUT_ECC@" ] ; then \
336218767Sdes		    if [ -f $(sysconfdir)/ssh_host_ecdsa_key ] ; then \
337218767Sdes			echo "$(sysconfdir)/ssh_host_ecdsa_key already exists, skipping." ; \
338218767Sdes		    else \
339218767Sdes			./ssh-keygen -t ecdsa -f $(sysconfdir)/ssh_host_ecdsa_key -N "" ; \
340218767Sdes		    fi ; \
341218767Sdes		fi ; \
34298937Sdes	fi ;
34398937Sdes
34498937Sdeshost-key-force: ssh-keygen$(EXEEXT)
34598937Sdes	./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N ""
34698937Sdes	./ssh-keygen -t dsa -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key -N ""
34798937Sdes	./ssh-keygen -t rsa -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key -N ""
348218767Sdes	test -z "@COMMENT_OUT_ECC@" && ./ssh-keygen -t ecdsa -f $(DESTDIR)$(sysconfdir)/ssh_host_ecdsa_key -N ""
34998937Sdes
35098937Sdesuninstallall:	uninstall
35198937Sdes	-rm -f $(DESTDIR)$(sysconfdir)/ssh_config
35298937Sdes	-rm -f $(DESTDIR)$(sysconfdir)/sshd_config
35398937Sdes	-rmdir $(DESTDIR)$(sysconfdir)
35498937Sdes	-rmdir $(DESTDIR)$(bindir)
35598937Sdes	-rmdir $(DESTDIR)$(sbindir)
35698937Sdes	-rmdir $(DESTDIR)$(mandir)/$(mansubdir)1
35798937Sdes	-rmdir $(DESTDIR)$(mandir)/$(mansubdir)8
35898937Sdes	-rmdir $(DESTDIR)$(mandir)
35998937Sdes	-rmdir $(DESTDIR)$(libexecdir)
36098937Sdes
361126274Sdesuninstall:
36298937Sdes	-rm -f $(DESTDIR)$(bindir)/slogin
36398937Sdes	-rm -f $(DESTDIR)$(bindir)/ssh$(EXEEXT)
36498937Sdes	-rm -f $(DESTDIR)$(bindir)/scp$(EXEEXT)
36598937Sdes	-rm -f $(DESTDIR)$(bindir)/ssh-add$(EXEEXT)
36698937Sdes	-rm -f $(DESTDIR)$(bindir)/ssh-agent$(EXEEXT)
36798937Sdes	-rm -f $(DESTDIR)$(bindir)/ssh-keygen$(EXEEXT)
36898937Sdes	-rm -f $(DESTDIR)$(bindir)/ssh-keyscan$(EXEEXT)
36998937Sdes	-rm -f $(DESTDIR)$(bindir)/sftp$(EXEEXT)
37098937Sdes	-rm -f $(DESTDIR)$(sbindir)/sshd$(EXEEXT)
37198937Sdes	-rm -r $(DESTDIR)$(SFTP_SERVER)$(EXEEXT)
37298937Sdes	-rm -f $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)
373204861Sdes	-rm -f $(DESTDIR)$(SSH_PKCS11_HELPER)$(EXEEXT)
37498937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh.1
37598937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/scp.1
37698937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-add.1
37798937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
37898937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
37998937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
38098937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
38198937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
38298937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
38398937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
384204861Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
38598937Sdes	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
386124208Sdes
387248613Sdesregress/modpipe$(EXEEXT): $(srcdir)/regress/modpipe.c
388255670Sdes	[ -d `pwd`/regress ]  ||  mkdir -p `pwd`/regress
389255670Sdes	[ -f `pwd`/regress/Makefile ]  || \
390255670Sdes	    ln -s `cd $(srcdir) && pwd`/regress/Makefile `pwd`/regress/Makefile
391255670Sdes	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
392255670Sdes	$(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
393248613Sdes
394248613Sdestests interop-tests:	$(TARGETS) regress/modpipe$(EXEEXT)
395124208Sdes	BUILDDIR=`pwd`; \
396137015Sdes	TEST_SHELL="@TEST_SHELL@"; \
397124208Sdes	TEST_SSH_SSH="$${BUILDDIR}/ssh"; \
398124208Sdes	TEST_SSH_SSHD="$${BUILDDIR}/sshd"; \
399124208Sdes	TEST_SSH_SSHAGENT="$${BUILDDIR}/ssh-agent"; \
400124208Sdes	TEST_SSH_SSHADD="$${BUILDDIR}/ssh-add"; \
401124208Sdes	TEST_SSH_SSHKEYGEN="$${BUILDDIR}/ssh-keygen"; \
402204861Sdes	TEST_SSH_SSHPKCS11HELPER="$${BUILDDIR}/ssh-pkcs11-helper"; \
403124208Sdes	TEST_SSH_SSHKEYSCAN="$${BUILDDIR}/ssh-keyscan"; \
404124208Sdes	TEST_SSH_SFTP="$${BUILDDIR}/sftp"; \
405124208Sdes	TEST_SSH_SFTPSERVER="$${BUILDDIR}/sftp-server"; \
406180746Sdes	TEST_SSH_PLINK="plink"; \
407180746Sdes	TEST_SSH_PUTTYGEN="puttygen"; \
408180750Sdes	TEST_SSH_CONCH="conch"; \
409180750Sdes	TEST_SSH_IPV6="@TEST_SSH_IPV6@" ; \
410218767Sdes	TEST_SSH_ECC="@TEST_SSH_ECC@" ; \
411218767Sdes	TEST_SSH_SHA256="@TEST_SSH_SHA256@" ; \
412124208Sdes	cd $(srcdir)/regress || exit $$?; \
413124208Sdes	$(MAKE) \
414124208Sdes		.OBJDIR="$${BUILDDIR}/regress" \
415124208Sdes		.CURDIR="`pwd`" \
416124208Sdes		BUILDDIR="$${BUILDDIR}" \
417124208Sdes		OBJ="$${BUILDDIR}/regress/" \
418124208Sdes		PATH="$${BUILDDIR}:$${PATH}" \
419126274Sdes		TEST_SHELL="$${TEST_SHELL}" \
420124208Sdes		TEST_SSH_SSH="$${TEST_SSH_SSH}" \
421124208Sdes		TEST_SSH_SSHD="$${TEST_SSH_SSHD}" \
422124208Sdes		TEST_SSH_SSHAGENT="$${TEST_SSH_SSHAGENT}" \
423124208Sdes		TEST_SSH_SSHADD="$${TEST_SSH_SSHADD}" \
424124208Sdes		TEST_SSH_SSHKEYGEN="$${TEST_SSH_SSHKEYGEN}" \
425204861Sdes		TEST_SSH_SSHPKCS11HELPER="$${TEST_SSH_SSHPKCS11HELPER}" \
426124208Sdes		TEST_SSH_SSHKEYSCAN="$${TEST_SSH_SSHKEYSCAN}" \
427124208Sdes		TEST_SSH_SFTP="$${TEST_SSH_SFTP}" \
428124208Sdes		TEST_SSH_SFTPSERVER="$${TEST_SSH_SFTPSERVER}" \
429180746Sdes		TEST_SSH_PLINK="$${TEST_SSH_PLINK}" \
430180746Sdes		TEST_SSH_PUTTYGEN="$${TEST_SSH_PUTTYGEN}" \
431180750Sdes		TEST_SSH_CONCH="$${TEST_SSH_CONCH}" \
432218767Sdes		TEST_SSH_IPV6="$${TEST_SSH_IPV6}" \
433218767Sdes		TEST_SSH_ECC="$${TEST_SSH_ECC}" \
434218767Sdes		TEST_SSH_SHA256="$${TEST_SSH_SHA256}" \
435124208Sdes		EXEEXT="$(EXEEXT)" \
436180750Sdes		$@ && echo all tests passed
437124208Sdes
438162852Sdescompat-tests: $(LIBCOMPAT)
439162852Sdes	(cd openbsd-compat/regress && $(MAKE))
440162852Sdes
441124208Sdesregressclean:
442146998Sdes	if [ -f regress/Makefile ] && [ -r regress/Makefile ]; then \
443124208Sdes		(cd regress && $(MAKE) clean) \
444124208Sdes	fi
445137015Sdes
446146998Sdessurvey: survey.sh ssh
447146998Sdes	@$(SHELL) ./survey.sh > survey
448146998Sdes	@echo 'The survey results have been placed in the file "survey" in the'
449146998Sdes	@echo 'current directory.  Please review the file then send with'
450146998Sdes	@echo '"make send-survey".'
451146998Sdes
452146998Sdessend-survey:	survey
453146998Sdes	mail portable-survey@mindrot.org <survey
454146998Sdes
455225825Sdespackage: $(CONFIGFILES) $(MANPAGES) $(TARGETS)
456137015Sdes	if [ "@MAKE_PACKAGE_SUPPORTED@" = yes ]; then \
457137015Sdes		sh buildpkg.sh; \
458137015Sdes	fi
459137015Sdes
460