CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) $(DEFINES)
LOCALINCLUDE=-I$(SRCTOP)/include/kerberosIV
SETENVSRC=@SETENVSRC@
SETENVOBJ=@SETENVOBJ@

LOGINLIBS = @LOGINLIBS@
LIBOBJS=@LIBOBJS@

LOCAL_LIBRARIES=-lpty
DEPLOCAL_LIBRARIES=$(TOPLIBD)/../util/pty/libpty.a

SRCS= krcp.c krlogin.c krsh.c kcmd.c forward.c  $(SETENVSRC) \
	login.c krshd.c krlogind.c
OBJS= krcp.o krlogin.o krsh.o kcmd.o forward.o  $(SETENVOBJ) \
	login.o krshd.o krlogind.o $(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 krshd krlogind login.krb5

clean:: 
	$(RM) rsh rcp rlogin krshd krlogind login.krb5

rsh: krsh.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS)
	$(LD) $(LDFLAGS) $(LDARGS) -o rsh krsh.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LIBS)

install::
	$(INSTALL_PROGRAM) rsh $(DESTDIR)$(CLIENT_BINDIR)/rsh
	$(INSTALL_DATA) $(srcdir)/rsh.M ${DESTDIR}$(CLIENT_MANDIR)/rsh.1

rcp: krcp.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS)
	$(LD) $(LDFLAGS) $(LDARGS) -o rcp krcp.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LIBS)

install::
	$(INSTALL_PROGRAM) rcp $(DESTDIR)$(CLIENT_BINDIR)/rcp
	$(INSTALL_DATA) $(srcdir)/rcp.M ${DESTDIR}$(CLIENT_MANDIR)/rcp.1

rlogin: krlogin.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS)
	$(LD) $(LDFLAGS) $(LDARGS) -o rlogin krlogin.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LIBS)

install::
	$(INSTALL_PROGRAM) rlogin $(DESTDIR)$(CLIENT_BINDIR)/rlogin
	$(INSTALL_DATA) $(srcdir)/rlogin.M ${DESTDIR}$(CLIENT_MANDIR)/rlogin.1

krshd: krshd.o kcmd.o  forward.o $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS)
	$(LD) $(LDFLAGS) $(LDARGS) -o krshd krshd.o kcmd.o  forward.o $(SETENVOBJ) $(LIBOBJS) $(LIBS)

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

krlogind: krlogind.o  kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS)
	$(LD) $(LDFLAGS) $(LDARGS) -o krlogind krlogind.o  kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LIBS)

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

#
# We load the libraries twice here since des425 has a dependency on 
# krb5_read_passwrd in krb5.a.  Sigh, circular references.
#
login.krb5: login.o  $(SETENVOBJ) $(LIBOBJS) $(DEPLIBS)
	$(LD) $(LDFLAGS) $(LDARGS) -o login.krb5 login.o $(SETENVOBJ) $(LIBOBJS) $(LIBS) $(LOGINLIBS)

install::
	$(INSTALL_PROGRAM) login.krb5 $(DESTDIR)$(SERVER_BINDIR)/login.krb5

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

