#-----------------------------------------------------------------------------
# Copyright (c) 1990 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.
#
#       LDAP library makefile
#
#-----------------------------------------------------------------------------

SRCS	= bind.c open.c result.c error.c compare.c search.c parse.c \
	modify.c add.c modrdn.c delete.c abandon.c ufn.c cache.c \
	getfilter.c regex.c sbind.c kbind.c unbind.c friendly.c
OBJS	= bind.o open.o result.o error.o compare.o search.o parse.o \
	modify.o add.o modrdn.o delete.o abandon.o ufn.o cache.o \
	getfilter.o regex.o sbind.o kbind.o unbind.o friendly.o

CFLAGS	= $(ACFLAGS) -I../h $(KRBINCLUDEFLAG)

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

all:	libldap.a ltest

libldap.a:	version.o
	ar ruv $@ $(OBJS) version.o
	if [ ! -z "$(RANLIB)" ]; then \
		$(RANLIB) $@; \
	fi

ltest:	libldap.a test.o ../liblber/liblber.a
	$(CC) $(ALDFLAGS) -o $@ test.o -L. -L../liblber -lldap -llber \
		$(KRBLIBFLAG) $(KRBLIBS)

version.c: $(OBJS)
	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:	$(LIBDIR)/libldap.a $(ETCDIR)/ldapfilter.conf \
		$(ETCDIR)/ldapfriendly

$(LIBDIR)/libldap.a:	libldap.a
	$(INSTALL) $(INSTALLFLAGS) -m 644 libldap.a $(LIBDIR)
	if [ ! -z "$(RANLIB)" ]; then \
		(cd /tmp; $(RANLIB) $@) \
	fi

$(ETCDIR)/ldapfilter.conf:	ldapfilter.conf
	$(INSTALL) $(INSTALLFLAGS) -m 644 ldapfilter.conf $(ETCDIR)

$(ETCDIR)/ldapfriendly:	ldapfriendly
	$(INSTALL) $(INSTALLFLAGS) -m 644 ldapfriendly $(ETCDIR)

lint:;
	lint -I../h $(SRCS)

5lint:;
	/usr/5bin/lint -I../h $(SRCS)

clean:;
	rm -f libldap.a ltest *.o core a.out *.log version.c

depend:;
	../mkdep $(CFLAGS) $(SRCS)

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

bind.o: bind.c ../h/lber.h ../h/ldap.h
open.o: open.c ../h/lber.h ../h/ldap.h
result.o: result.c ../h/lber.h ../h/ldap.h
error.o: error.c ../h/lber.h ../h/ldap.h
compare.o: compare.c ../h/lber.h ../h/ldap.h
search.o: search.c ../h/lber.h ../h/ldap.h
parse.o: parse.c ../h/lber.h ../h/ldap.h
modify.o: modify.c ../h/lber.h ../h/ldap.h
add.o: add.c ../h/lber.h ../h/ldap.h
modrdn.o: modrdn.c ../h/lber.h ../h/ldap.h
delete.o: delete.c ../h/lber.h ../h/ldap.h
abandon.o: abandon.c ../h/lber.h ../h/ldap.h
synchronous.o: synchronous.c ../h/lber.h ../h/ldap.h
kerberos.o: kerberos.c ../h/lber.h ../h/ldap.h
ufn.o: ufn.c ../h/lber.h ../h/ldap.h
cache.o: cache.c ../h/lber.h ../h/ldap.h

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
