thisconfigdir=.
myfulldir=appl/bsd
mydir=.
BUILDTOP=$(REL)$(U)$(S)$(U)
LOCALINCLUDES=@KRB4_INCLUDES@
PROG_LIBPATH=-L$(TOPLIBD)
PROG_RPATH=$(KRB5_LIBDIR)

SETENVSRC=@SETENVSRC@
SETENVOBJ=@SETENVOBJ@

LOGINLIBS =@LOGINLIBS@
LIBOBJS=@LIBOBJS@
V4RCP=@V4RCP@
V4RCPO=@V4RCPO@

SRCS= krcp.c krlogin.c krsh.c kcmd.c forward.c  $(SETENVSRC) \
	login.c krshd.c krlogind.c v4rcp.c
OBJS= krcp.o krlogin.o krsh.o kcmd.o forward.o  $(SETENVOBJ) \
	login.o krshd.o krlogind.o $(V4RCPO) $(LIBOBJS)

UCB_RLOGIN = @UCB_RLOGIN@
UCB_RSH = @UCB_RSH@
UCB_RCP = @UCB_RCP@

RSH=	-DKRB5_PATH_RLOGIN=\"$(CLIENT_BINDIR)/rlogin\"
BSD=	-DUCB_RLOGIN=\"$(UCB_RLOGIN)\" \
	-DUCB_RSH=\"$(UCB_RSH)\" -DUCB_RCP=\"$(UCB_RCP)\"

DEFINES = $(RSH) $(BSD) $(RPROGS) \
	-DLOGIN_PROGRAM=\"$(SERVER_BINDIR)/login.krb5\" -DKPROGDIR=\"$(CLIENT_BINDIR)\"

all:: rsh rcp rlogin kshd klogind login.krb5 $(V4RCP)

clean:: 
	$(RM) rsh rcp rlogin kshd klogind login.krb5 v4rcp

rsh: krsh.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
	$(CC_LINK) -o rsh krsh.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(UTIL_LIB) $(KRB4COMPAT_LIBS)

rcp: krcp.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(UTIL_DEPLIB) $(KRB4COMATP_DEPLIBS)
	$(CC_LINK) -o rcp krcp.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(UTIL_LIB) $(KRB4COMPAT_LIBS)

v4rcp: v4rcp.o $(SETENVOBJ) $(LIBOBJS) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
	$(CC_LINK) -o v4rcp v4rcp.o $(SETENVOBJ) $(LIBOBJS) $(UTIL_LIB) $(KRB4COMPAT_LIBS)

rlogin: krlogin.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_DEPLIB) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
	$(CC_LINK) -o rlogin krlogin.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_LIB) $(UTIL_LIB) $(KRB4COMPAT_LIBS)

install::
	for f in rsh rcp rlogin; do \
	 ($(INSTALL_PROGRAM) $$f \
		$(DESTDIR)$(CLIENT_BINDIR)/`echo $$f|sed '$(transform)'` && \
	  $(INSTALL_DATA) $(srcdir)/$$f.M \
		${DESTDIR}$(CLIENT_MANDIR)/`echo $$f|sed '$(transform)'`.1 \
	  ) || exit 1; \
	done
	f=$(V4RCP); \
	if test -n "$$f" ; then	$(INSTALL_SETUID) $$f \
		$(DESTDIR)$(CLIENT_BINDIR)/`echo $$f|sed '$(transform)'`; \
	$(INSTALL_DATA) $(srcdir)/$$f.M \
		${DESTDIR}$(CLIENT_MANDIR)/`echo $$f|sed '$(transform)'`.1; \
	fi

kshd: krshd.o kcmd.o  forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_DEPLIB) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
	$(CC_LINK) -o kshd krshd.o kcmd.o  forward.o $(SETENVOBJ) $(LIBOBJS) $(LOGINLIBS) $(PTY_LIB) $(UTIL_LIB) $(KRB4COMPAT_LIBS)

klogind: krlogind.o  kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_DEPLIB) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
	$(CC_LINK) -o klogind krlogind.o  kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_LIB) $(UTIL_LIB) $(KRB4COMPAT_LIBS)

install::
	for f in kshd klogind; do \
	 ($(INSTALL_PROGRAM) $$f \
		$(DESTDIR)$(SERVER_BINDIR)/`echo $$f|sed '$(transform)'` && \
	  $(INSTALL_DATA) $(srcdir)/$$f.M \
		${DESTDIR}$(SERVER_MANDIR)/`echo $$f|sed '$(transform)'`.8 \
	 ) || exit 1 ; \
	done

# No program name transformation is done with login.krb5 since it is directly
# referenced by klogind.
#
login.krb5: login.o  $(SETENVOBJ) $(LIBOBJS) $(PTY_DEPLIB) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
	$(CC_LINK) -o login.krb5 login.o $(SETENVOBJ) $(LIBOBJS) $(LOGINLIBS) $(PTY_LIB) $(UTIL_LIB) $(KRB4COMPAT_LIBS)

install::
	$(INSTALL_PROGRAM) login.krb5 $(DESTDIR)$(SERVER_BINDIR)/login.krb5
	$(INSTALL_DATA) $(srcdir)/login.M \
		${DESTDIR}$(SERVER_MANDIR)/login.krb5.8

getdtablesize.o: $(srcdir)/getdtablesize.c

kcmd.o krcp.o krlogin.o krlogind.o krsh.o krshd.o : defines.h
