#
# Copyright (c) 1988 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation, advertising
# materials, and other materials related to such redistribution and
# use acknowledge that the software was developed by the University
# of California, Berkeley.  The name of the University may not be
# used to endorse or promote products derived from this software
# without specific prior written permission.  THIS SOFTWARE IS PROVIDED
# ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
# FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)Makefile	5.3 (Berkeley) 9/20/88
#
srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config


LIBC=	/lib/libc.a
SRCS=	rlogind.c ../rsh/rcmd.c ../rsh/herror.c ../inetd/ta-rauth.c
OBJS=	rlogind.o ../rsh/rcmd.o ../rsh/herror.o ../inetd/ta-rauth.o
MAN=
AFSLIBS = ${TOP_LIBDIR}/libkauth.a ${TOP_LIBDIR}/libprot.a \
	  ${TOP_LIBDIR}/libubik.a ${TOP_LIBDIR}/libauth.a \
	  ${TOP_LIBDIR}/librxkad.a ${TOP_LIBDIR}/libsys.a \
	  ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a \
	  ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librxkad.a \
	  ${TOP_LIBDIR}/libdes.a ${TOP_LIBDIR}/libcmd.a \
	  ${TOP_LIBDIR}/libcom_err.a ${TOP_LIBDIR}/util.a \
	  ${TOP_LIBDIR}/libaudit.a
RES = 
LIBS = ../login/libutil.a ${RES} ${AFSLIBS}
ALIBS= ${AFSLIBS} 
CFLAGS=-I. -I${srcdir} ${OPTMZ} -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} ${XCFLAGS}

include ../config/Makefile.version

all: rlogind rexecd

system: install

rlogind: ${OBJS} ${LIBS} ../login/libutil.a
	case ${SYS_NAME} in \
	rs_aix*) \
		${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} ${XLIBS} -ls ;; \
	hp_ux110) \
		${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} ${XLIBS} -lsec ;; \
	*) ${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} ${XLIBS} ;;\
	esac 

rlogind.o: rlogind.c AFS_component_version_number.c

rexecd.o: rexecd.c AFS_component_version_number.c

rexecd: rexecd.o ${ALIBS}
	case ${SYS_NAME} in \
	rs_aix*) \
		${CC} -o $@ ${CFLAGS} rexecd.o ${ALIBS} ${XLIBS} -ls ;; \
	*) ${CC} -o $@ ${CFLAGS} rexecd.o ${ALIBS} ${XLIBS} ;;\
	esac 


../login/libutil.a : ../login/util_login.c ../login/util_logout.c ../login/util_logwtmp.c
	( cd ../login ; $(MAKE) libutil.a )

../rsh/rcmd.o : ../rsh/rcmd.c
	(cp AFS_component_version_number.c ../rsh/AFS_component_version_number.c ;  cd ../rsh ; $(MAKE) rsh.o )

../rsh/herror.o : ../rsh/herror.c
	( cd ../rsh ; $(MAKE) herror.o )

clean:
	$(RM) -f ${OBJS} core rlogind AFS_component_version_number.c

cleandir: clean
	$(RM) -f ${MAN} tags .depend

depend: ${SRCS}
	mkdep -p ${CFLAGS} ${SRCS}

install: ${DESTDIR}${sbindir}/rlogind ${DESTDIR}${sbindir}/rexecd

${DEST}/etc/rlogind: rlogind
	${INSTALL} $? $@

${DESTDIR}${sbindir}/rlogind: rlogind
	${INSTALL} $? $@

${DEST}/etc/rexecd: rexecd
	${INSTALL} $? $@

${DESTDIR}${sbindir}/rexecd: rexecd
	${INSTALL} $? $@


dest:   ${DEST}/etc/rlogind ${DEST}/etc/rexecd

