#-----------------------------------------------------------------------------
# Copyright (c) 1994 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
#-----------------------------------------------------------------------------
LDAPSRC	= ../..
HDIR	= $(LDAPSRC)/include
LDIR	= $(LDAPSRC)/libraries
VERSIONFILE = $(LDAPSRC)/build/version

SRCS=	main.c find.c mod.c print.c auth.c util.c help.c\
	string_to_key.c group.c edit.c globals.c
OBJS=	main.o find.o mod.o print.o auth.o util.o help.o\
	string_to_key.o group.o globals.o edit.o
HDRS=	ud.h

INCLUDES= -I$(HDIR) $(KRBINCLUDEFLAG)
DEFINES= $(DEFS) -DDEBUG -DCONFIG_FILE=\"$(RUNTIMEETCDIR)/ud.conf\" \
		-DLDAP_FRIENDLY_MAP_FILE=\"$(RUNTIMEETCDIR)/ldapfriendly\"
TERMLIB= -ltermcap

CFLAGS= ${INCLUDES} ${DEFINES} ${ACFLAGS}
LIBS= ${TERMLIB} -lldap -llber $(KRBLIBFLAG) $(KRBLIBS) $(ALIBS)

PURIFY=
#PURIFY=purify

all: ud

ud : version.o
	$(PURIFY) ${CC} $(ALDFLAGS) -o $@ version.o ${OBJS} -L${LDIR} ${LIBS}

version.c: ${OBJS} $(LDIR)/libldap/libldap.a
	$(RM) $@
	(u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \
	    t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \
	    -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
	    -e "s|%VERSION%|$${v}|" \
	    < Version.c > $@)

install: ud FORCE
	-$(MKDIR) -p $(BINDIR)
	-mv -f ${BINDIR}/ud ${BINDIR}/ud-
	$(INSTALL) $(INSTALLFLAGS) -m 775 ud ${BINDIR}

depend: FORCE
	$(MKDEP) $(INCLUDES) $(DEFINES) $(SRCS)

clean: FORCE
	$(RM) $(OBJS) core ud tags version.o version.c
	$(RM) *_pure_*.o ud.pure_hardlink ud.pure_linkinfo

tags: FORCE
	$(CTAGS) $(SRCS) ${HDRS}

lint: FORCE
	$(LINT) -Dlint $(INCLUDES) $(DEFINES) $(SRCS) version.c | \
		egrep -v "string_to_key|but not defined"

5lint:	FORCE
	$(5LINT) -Dlint $(INCLUDES) $(DEFINES) $(SRCS) version.c

links:
	@$(LN) .src/README .src/etc.ud.conf .src/*.[ch] .

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

main.o: main.c ../../include/lber.h ../../include/ldap.h
main.o: ../../include/ldapconfig.h ../../include/portable.h ud.h
find.o: find.c ../../include/lber.h ../../include/ldap.h ud.h
mod.o: mod.c ../../include/lber.h ../../include/ldap.h ud.h
print.o: print.c ../../include/lber.h ../../include/ldap.h ud.h
auth.o: auth.c ../../include/lber.h ../../include/ldap.h
auth.o: ../../include/ldapconfig.h ud.h
util.o: util.c ../../include/lber.h ../../include/ldap.h
util.o: ../../include/ldapconfig.h ../../include/portable.h ud.h
help.o: help.c ../../include/lber.h ../../include/ldap.h ud.h
string_to_key.o: string_to_key.c
group.o: group.c ../../include/lber.h ../../include/ldap.h
group.o: ../../include/ldapconfig.h ud.h
edit.o: edit.c ../../include/lber.h ../../include/ldap.h
edit.o: ../../include/ldapconfig.h ud.h
globals.o: globals.c ud.h

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
