#-----------------------------------------------------------------------------
# Copyright (c) 1990, 1992 Regents of the University of Michigan.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that this notice is preserved and that due credit is given
# to the University of Michigan at Ann Arbor. 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'' without express or implied warranty.
#
#	ud makefile
#
#	Use -DUOFM for University of Michigan specifics like:
#		if ud should know about noBatchUpdates
#	Use -DDOS if building for a DOS machine
#	Use -DNOTERMCAP if there is no termcap library
#		also need to redefine/undefine the Makefile TERMLIB variable
#-----------------------------------------------------------------------------
SRCS=	main.c find.c mod.c print.c auth.c util.c help.c\
	string_to_key.c group.c
OBJS=	main.o find.o mod.o print.o auth.o util.o help.o\
	string_to_key.o group.o
HDRS=	ud.h
INCLUDES= -I../h $(KRBINCLUDEFLAG)
DEFINES= -DDEBUG
TERMLIB= -ltermcap
CFLAGS= ${INCLUDES} ${DEFINES} ${ACFLAGS}
LDFLAGS= -L../libldap -L../liblber ${TERMLIB} -lldap -llber \
		$(KRBLIBFLAG) $(KRBLIBS)

default:
	(cd ../; make ldap-ud)

all: ud

ud : version.o
	${CC} -g -o $@ version.o ${OBJS} ${LDFLAGS}

version.c: ${OBJS} ../libldap/libldap.a
	rm -f $@
	(u=$${USER-root} v=`cat ../version` d=`pwd` h=`hostname` t=`date`; \
	sed -e "s|%WHEN%|$${t}|" \
	    -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
	    -e "s|%VERSION%|$${v}|" \
	    < Version.c > $@)

install: ${BINDIR}/ud

${BINDIR}/ud : ud
	$(INSTALL) $(INSTALLFLAGS) -m 755 ud ${BINDIR}

depend: FRC
	../mkdep ${CFLAGS} ${SRCS}

clean: FRC
	rm -f ${OBJS} core ud tags version.o version.c

tags: FRC
	ctags ${SRCS} ${HDRS}

lint: FRC
	(cd ../; make lint-ud)

ud-lint: FRC
	/usr/bin/lint -Dlint ${CFLAGS} ${SRCS} version.c | grep -v string_to_key | grep -v "but not defined"

FRC:
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.

main.o: main.c ../h/lber.h ../h/ldap.h ud.h
find.o: find.c ../h/lber.h ../h/ldap.h ud.h
mod.o: mod.c ../h/lber.h ../h/ldap.h ud.h
print.o: print.c ../h/lber.h ../h/ldap.h ud.h
auth.o: auth.c ../h/lber.h ../h/ldap.h ud.h
util.o: util.c ../h/lber.h ../h/ldap.h ud.h
help.o: help.c ../h/lber.h ../h/ldap.h ud.h
string_to_key.o: string_to_key.c
group.o: group.c ../h/lber.h ../h/ldap.h ud.h

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
