# $Id: Makefile.in,v 1.56 1997/05/20 20:35:04 assar Exp $

SHELL = /bin/sh

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@

topdir	= ../..

CC = @CC@
AR = ar
RANLIB = @RANLIB@
DEFS = @DEFS@ -DBINDIR='"$(bindir)"'
CFLAGS = @CFLAGS@
LD_FLAGS = @LD_FLAGS@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LIBS = @LIBS@
LIB_DBM = @LIB_DBM@
MKINSTALLDIRS = @top_srcdir@/mkinstalldirs

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
libexecdir = @libexecdir@
bindir = @bindir@
transform=@program_transform_name@
EXECSUFFIX=@EXECSUFFIX@

# Beware, these are all setuid root programs
PROG_SUIDBIN	= rsh$(EXECSUFFIX) \
		  rcp$(EXECSUFFIX) \
		  rlogin$(EXECSUFFIX) \
		  su$(EXECSUFFIX)
PROG_BIN	= login$(EXECSUFFIX)
PROG_LIBEXEC	= rshd$(EXECSUFFIX) \
		  rlogind$(EXECSUFFIX)
PROGS = $(PROG_SUIDBIN) $(PROG_BIN) $(PROG_LIBEXEC)

SOURCES = rsh.c kcmd.c krcmd.c rlogin.c rcp.c rcp_util.c rshd.c \
	login.c klogin.c login_access.c su.c rlogind.c iruserok.c \
	login_fbtab.c forkpty.c sysv_default.c sysv_environ.c sysv_shadow.c \
	utmp_login.c utmpx_login.c stty_default.c encrypt.c rcmd_util.c tty.c

rsh_OBJS	= rsh.o kcmd.o krcmd.o encrypt.o rcmd_util.o
rcp_OBJS	= rcp.o rcp_util.o kcmd.o krcmd.o encrypt.o rcmd_util.o
rlogin_OBJS	= rlogin.o kcmd.o krcmd.o encrypt.o rcmd_util.o
login_OBJS 	= login.o klogin.o login_fbtab.o login_access.o \
		  sysv_default.o sysv_environ.o sysv_shadow.o \
		  utmp_login.o utmpx_login.o stty_default.o tty.o
su_OBJS		= su.o
rshd_OBJS	= rshd.o iruserok.o encrypt.o rcmd_util.o
rlogind_OBJS	= rlogind.o iruserok.o forkpty.o encrypt.o rcmd_util.o tty.o


all: $(PROGS) 

Wall:
	make CFLAGS="-g -Wall -Wno-comment -Wmissing-prototypes -Wmissing-declarations -D__USE_FIXED_PROTOTYPES__"

.c.o: 
	$(CC) -c $(CPPFLAGS) $(DEFS) -I../../include -I$(srcdir) $(CFLAGS) $<

install: all
	$(MKINSTALLDIRS) $(libexecdir)
	for x in $(PROG_LIBEXEC); do \
	  $(INSTALL_PROGRAM) $$x $(libexecdir)/`echo $$x| sed '$(transform)'`; \
	done
	$(MKINSTALLDIRS) $(bindir)
	for x in $(PROG_BIN); do \
	  $(INSTALL_PROGRAM) $$x $(bindir)/`echo $$x| sed '$(transform)'`; \
	done
	-for x in $(PROG_SUIDBIN); do \
	  $(INSTALL_PROGRAM) -o root -m 04555 $$x $(bindir)/`echo $$x| sed '$(transform)'`; \
	done

uninstall:
	for x in $(PROG_LIBEXEC); do \
	  rm -f $(libexecdir)/`echo $$x| sed '$(transform)'`; \
	done
	for x in $(PROG_BIN); do \
	  rm -f $(bindir)/`echo $$x| sed '$(transform)'`; \
	done
	for x in $(PROG_SUIDBIN); do \
	  rm -f $(bindir)/`echo $$x| sed '$(transform)'`; \
	done

TAGS: $(SOURCES)
	etags $(SOURCES)

check:

clean:
	rm -f *.a *.o $(PROGS)

mostlyclean: clean

distclean: clean
	rm -f Makefile *.tab.c *~

realclean: distclean
	rm -f TAGS

dist: $(DISTFILES)
	for file in $(DISTFILES); do \
	  ln $$file ../`cat ../.fname`/lib \
	    || cp -p $$file ../`cat ../.fname`/lib; \
	done

KLIB=-L../../lib/krb -lkrb -L../../lib/des -ldes
KLIB_AFS=@KRB_KAFS_LIB@ $(KLIB)
OTPLIB=-L../../lib/otp -lotp
LIBROKEN=-L../../lib/roken -lroken

rcp$(EXECSUFFIX): $(rcp_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(rcp_OBJS) $(KLIB_AFS) $(LIBROKEN) $(LIBS) $(LIBROKEN)

rsh$(EXECSUFFIX): $(rsh_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(rsh_OBJS) $(KLIB) $(LIBROKEN) $(LIBS) $(LIBROKEN)

rshd$(EXECSUFFIX): $(rshd_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(rshd_OBJS) $(KLIB_AFS) $(LIBROKEN) $(LIBS) $(LIBROKEN)

rlogin$(EXECSUFFIX): $(rlogin_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@  $(rlogin_OBJS) $(KLIB) $(LIBROKEN) $(LIBS) $(LIBROKEN)

rlogind$(EXECSUFFIX): $(rlogind_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(rlogind_OBJS) $(KLIB_AFS) $(LIBROKEN) $(LIBS) $(LIBROKEN)

login$(EXECSUFFIX): $(login_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(login_OBJS) $(OTPLIB) $(KLIB_AFS) $(LIBROKEN) $(LIB_DBM) $(LIBS) $(LIBROKEN)

su$(EXECSUFFIX): $(su_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(su_OBJS) $(KLIB_AFS) $(LIBROKEN) $(LIBS) $(LIBROKEN)
