#
# 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.1 (Berkeley) 10/18/88
#

srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config

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}/libdes.a ${TOP_LIBDIR}/librx.a \
	   ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libcmd.a \
	   ${TOP_LIBDIR}/libcom_err.a ${TOP_LIBDIR}/util.a

KAFSLIBS = ${TOP_LIBDIR}/libkauth.krb.a ${TOP_LIBDIR}/libprot.a \
	   ${TOP_LIBDIR}/libubik.a ${TOP_LIBDIR}/libauth.krb.a \
	   ${TOP_LIBDIR}/librxkad.a ${TOP_LIBDIR}/libsys.a \
	   ${TOP_LIBDIR}/libdes.a ${TOP_LIBDIR}/librx.a \
	   ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libcmd.a \
	   ${TOP_LIBDIR}/libcom_err.a ${TOP_LIBDIR}/util.a

SRCS=	login.c 
OBJS=   login.o setenv.o getenv.o libutil.a
KOBJS=  login.krb.o setenv.o getenv.o libutil.a
UTILOBJS = util_login.o util_logout.o util_logwtmp.o

all: login login.krb

login:	${OBJS} ${AFSLIBS}
	case ${SYS_NAME} in \
	sun4x_5? | sunx86_5? ) ${CC} -g -o $@ ${CFLAGS} ${OBJS} -lc ${LIBS} ${XLIBS} -lcmd;;\
	*) ${CC} -g -o $@ ${CFLAGS} ${OBJS} ${LIBS} ${XLIBS} ;;\
	esac 

login.krb: ${KOBJS} ${KAFSLIBS}
	case ${SYS_NAME} in \
	sun4x_5? | sunx86_5? ) ${CC} -g -o $@ ${CFLAGS} ${KOBJS} -lc ${KLIBS} ${XLIBS} -lcmd;;\
	*) ${CC} -g -o $@ ${CFLAGS} ${KOBJS} ${KLIBS} ${XLIBS} ;;\
	esac 

libutil.a : ${UTILOBJS}
	$(RM) -f $@
	$(AR) crv $@ ${UTILOBJS}
	$(RANLIB) $@

login.o: login.c AFS_component_version_number.c
	${CC} ${CFLAGS} -c ${srcdir}/login.c

login.krb.o: login.c
	${CC} ${CFLAGS} -DAFS_KERBEROS_ENV -c ${srcdir}/login.c
	mv login.o login.krb.o

#
# Installation targets
#
install: \
	${DESTDIR}${bindir}/login \
	${DESTDIR}${bindir}/login.krb

${DESTDIR}${bindir}/login: login
	${INSTALL} $? $@

${DESTDIR}${bindir}/login.krb: login.krb
	${INSTALL} $? $@


dest: \
	${DEST}/bin/login \
	${DEST}/bin/login.krb

${DEST}/bin/login: login
	${INSTALL} $? $@

${DEST}/bin/login.krb: login.krb
	${INSTALL} $? $@

#
# Misc. targets
#
clean:
	$(RM) -f *.o ${OBJS} core login AFS_component_version_number.c

include ../config/Makefile.version

