#-----------------------------------------------------------------------------
# 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.
#
#       LDAP library makefile
#
#-----------------------------------------------------------------------------

LDAPSRC	= ../..

SRCS	= bind.c open.c result.c error.c compare.c search.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 cldap.c \
	free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
	getdn.c getentry.c getattr.c getvalues.c addentry.c \
	request.c getdxbyname.c os-ip.c url.c charset.c
OBJS	= bind.o open.o result.o error.o compare.o search.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 cldap.o \
	free.o disptmpl.o srchpref.o dsparse.o tmplout.o sort.o \
	getdn.o getentry.o getattr.o getvalues.o addentry.o \
	request.o getdxbyname.o os-ip.o url.o charset.o

HDIR	= ../../include

INCLUDES= -I$(HDIR) $(KRBINCLUDEFLAG)
DEFINES	= $(DEFS) -DFILTERFILE="\"$(RUNTIMEETCDIR)/ldapfilter.conf\"" \
	-DTEMPLATEFILE="\"$(RUNTIMEETCDIR)/ldaptemplates.conf\""

CFLAGS	= $(INCLUDES) $(DEFINES) $(ACFLAGS)
LIBS	= -L. -L../liblber -lldap -llber $(KRBLIBFLAG) $(KRBLIBS) $(ALIBS)

all:	libldap.a ltest ttest

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

ltest:	libldap.a test.o ../liblber/liblber.a
	$(CC) $(ALDFLAGS) -o $@ test.o $(LIBS)

ttest:	libldap.a tmpltest.o ../liblber/liblber.a
	$(CC) $(ALDFLAGS) -o $@ tmpltest.o $(LIBS)

version.c:	$(OBJS)
	$(RM) $@
	(u=$${USER-root} v=`$(CAT) ../../build/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:	libldap.a ldapfilter.conf ldapfriendly ldaptemplates.conf ldapsearchprefs.conf FORCE
	-$(MKDIR) -p $(LIBDIR)
	$(INSTALL) $(INSTALLFLAGS) -m 644 libldap.a $(LIBDIR)
	@if [ ! -z "$(RANLIB)" ]; then \
		(cd /tmp; $(RANLIB) $(LIBDIR)/libldap.a) \
	fi
	-$(MKDIR) -p $(ETCDIR)
	-$(MV) $(ETCDIR)/ldapfriendly $(ETCDIR)/ldapfriendly-
	$(INSTALL) $(INSTALLFLAGS) -m 644 ldapfriendly $(ETCDIR)
	-$(MV) $(ETCDIR)/ldapfilter.conf $(ETCDIR)/ldapfilter.conf-
	$(INSTALL) $(INSTALLFLAGS) -m 644 ldapfilter.conf $(ETCDIR)
	-$(MV) $(ETCDIR)/ldaptemplates.conf $(ETCDIR)/ldaptemplates.conf-
	$(INSTALL) $(INSTALLFLAGS) -m 644 ldaptemplates.conf $(ETCDIR)
	-$(MV) $(ETCDIR)/ldapsearchprefs.conf $(ETCDIR)/ldapsearchprefs.conf-
	$(INSTALL) $(INSTALLFLAGS) -m 644 ldapsearchprefs.conf $(ETCDIR)

lint:	FORCE
	$(LINT) $(INCLUDES) $(DEFINES) $(SRCS)

5lint:	FORCE
	$(5LINT) $(INCLUDES) $(DEFINES) $(SRCS)

clean:	FORCE
	$(RM) libldap.a ../libldap.a ltest ttest *.o core a.out *.log version.c

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

links:
	@$(LN) .src/*.[ch] .src/ldapfriendly .src/ldapfilter.conf \
		.src/ldaptemplates.conf .src/ldapsearchprefs.conf .

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

bind.o: bind.c ../../include/lber.h ../../include/ldap.h
open.o: open.c ../../include/lber.h ../../include/ldap.h ldap-int.h
result.o: result.c ../../include/portable.h ../../include/lber.h
result.o: ../../include/ldap.h ldap-int.h
error.o: error.c ../../include/lber.h ../../include/ldap.h
compare.o: compare.c ../../include/lber.h ../../include/ldap.h ldap-int.h
search.o: search.c ../../include/lber.h ../../include/ldap.h ldap-int.h
modify.o: modify.c ../../include/lber.h ../../include/ldap.h ldap-int.h
add.o: add.c ../../include/lber.h ../../include/ldap.h ldap-int.h
modrdn.o: modrdn.c ../../include/lber.h ../../include/ldap.h ldap-int.h
delete.o: delete.c ../../include/lber.h ../../include/ldap.h ldap-int.h
abandon.o: abandon.c ../../include/lber.h ../../include/ldap.h ldap-int.h
ufn.o: ufn.c ../../include/lber.h ../../include/ldap.h
cache.o: cache.c ../../include/lber.h ../../include/ldap.h ldap-int.h
getfilter.o: getfilter.c ../../include/lber.h ../../include/ldap.h
getfilter.o: ../../include/regex.h
regex.o: regex.c ../../include/portable.h
sbind.o: sbind.c ../../include/lber.h ../../include/ldap.h ldap-int.h
kbind.o: kbind.c ../../include/lber.h ../../include/ldap.h ldap-int.h
unbind.o: unbind.c ../../include/lber.h ../../include/ldap.h ldap-int.h
friendly.o: friendly.c ../../include/lber.h ../../include/ldap.h
cldap.o: cldap.c ../../include/lber.h ../../include/ldap.h ldap-int.h
free.o: free.c ../../include/lber.h ../../include/ldap.h
disptmpl.o: disptmpl.c ../../include/lber.h ../../include/ldap.h
disptmpl.o: ../../include/disptmpl.h
srchpref.o: srchpref.c ../../include/lber.h ../../include/ldap.h
srchpref.o: ../../include/srchpref.h
dsparse.o: dsparse.c ../../include/lber.h ../../include/ldap.h
tmplout.o: tmplout.c ../../include/lber.h ../../include/ldap.h
tmplout.o: ../../include/disptmpl.h
sort.o: sort.c ../../include/lber.h ../../include/ldap.h
getdn.o: getdn.c ../../include/lber.h ../../include/ldap.h
getentry.o: getentry.c ../../include/lber.h ../../include/ldap.h
getattr.o: getattr.c ../../include/lber.h ../../include/ldap.h ldap-int.h
getvalues.o: getvalues.c ../../include/lber.h ../../include/ldap.h
addentry.o: addentry.c ../../include/lber.h ../../include/ldap.h
request.o: request.c ../../include/portable.h ../../include/lber.h
request.o: ../../include/ldap.h ldap-int.h
getdxbyname.o: getdxbyname.c
os-ip.o: os-ip.c ../../include/portable.h ../../include/lber.h
os-ip.o: ../../include/ldap.h
url.o: url.c ../../include/lber.h ../../include/ldap.h ldap-int.h
charset.o: charset.c

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
