#-----------------------------------------------------------------------------
# Copyright (c) 1995 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.
#
#       Stand-alone LDAP Update RePlication Daemon makefile
#
#-----------------------------------------------------------------------------
LDAPSRC	= ../..
HDIR	= $(LDAPSRC)/include
LDIR	= $(LDAPSRC)/libraries
VERSIONFILE = $(LDAPSRC)/build/version

SRCS	=	admin.c args.c ch_malloc.c config.c detach.c \
		fm.c globals.c ldap_op.c lock.c main.c re.c \
		reject.c replica.c replog.c ri.c rq.c sanity.c st.c \
		tsleep.c

OBJS	=	admin.o args.o ch_malloc.o config.o detach.o \
		fm.o globals.o ldap_op.o lock.o main.o re.o \
		reject.o replica.o replog.o ri.o rq.o sanity.o st.o \
		tsleep.o

INCLUDES= -I. -I$(HDIR) $(KRBINCLUDEFLAG)
DEFINES = $(DEFS) $(SERVERDEFS)
CFLAGS	= $(INCLUDES) $(THREADSINCLUDE) $(DEFINES) $(ACFLAGS) $(THREADS)
LDFLAGS	= -L$(LDIR) $(KRBLIBFLAG)
LIBS	= -lldap -llber -lm -llthread -lldif $(THREADSLIB) $(KRBLIBS) \
	  $(ALIBS)

all: 	FORCE
	@if [ -z "$(MAKESLAPD)" ]; then \
		echo "uncomment the MAKESLAPD line in Make-common to make slurpd"; \
		exit 0; \
	else \
		make slurpd; \
	fi

slurpd:	version.o
	$(CC) $(ALDFLAGS) -o $@ $(OBJS) version.o $(LDFLAGS) $(LIBS)

slurpd.pure:	version.o
	purify $(CC) $(ALDFLAGS) -o $@ $(OBJS) version.o $(LDFLAGS) $(LIBS)

version.c: $(OBJS) $(LDIR)/liblber/liblber.a $(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: $(ETCDIR) $(ETCDIR)/slurpd

$(ETCDIR)/slurpd:	slurpd
	$(INSTALL) $(INSTALLFLAGS) -m 755 slurpd $(ETCDIR)

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

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

clean:	FORCE
	@echo "making clean in `$(PWD)`"
	$(RM) slurpd *.o core a.out version.c

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

links:
	@echo "making links in `$(PWD)`"
	@$(LN) .src/*.[ch] .

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

admin.o: admin.c slurp.h ../../include/lber.h ../../include/ldap.h
admin.o: ../../include/lthread.h ../../include/portable.h
admin.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
args.o: args.c ../../include/lber.h ../../include/ldap.h slurp.h
args.o: ../../include/lber.h ../../include/ldap.h ../../include/lthread.h
args.o: ../../include/portable.h ../../include/ldapconfig.h
args.o: ../../include/ldif.h globals.h slurp.h
ch_malloc.o: ch_malloc.c ../slapd/slap.h ../../include/avl.h
ch_malloc.o: ../../include/lber.h ../../include/ldap.h ../../include/lthread.h
ch_malloc.o: ../../include/ldif.h
config.o: config.c ../../include/lber.h ../../include/ldap.h slurp.h
config.o: ../../include/lber.h ../../include/ldap.h ../../include/lthread.h
config.o: ../../include/portable.h ../../include/ldapconfig.h
config.o: ../../include/ldif.h globals.h slurp.h
detach.o: detach.c ../../include/portable.h
fm.o: fm.c slurp.h ../../include/lber.h ../../include/ldap.h
fm.o: ../../include/lthread.h ../../include/portable.h
fm.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
globals.o: globals.c slurp.h ../../include/lber.h ../../include/ldap.h
globals.o: ../../include/lthread.h ../../include/portable.h
globals.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
ldap_op.o: ldap_op.c ../../include/lber.h ../../include/ldap.h
ldap_op.o: ../../include/portable.h slurp.h ../../include/lber.h
ldap_op.o: ../../include/ldap.h ../../include/lthread.h
ldap_op.o: ../../include/portable.h ../../include/ldapconfig.h
ldap_op.o: ../../include/ldif.h
lock.o: lock.c ../../include/portable.h ../slapd/slap.h ../../include/avl.h
lock.o: ../../include/lber.h ../../include/ldap.h ../../include/lthread.h
lock.o: ../../include/ldif.h
main.o: main.c slurp.h ../../include/lber.h ../../include/ldap.h
main.o: ../../include/lthread.h ../../include/portable.h
main.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
re.o: re.c ../slapd/slap.h ../../include/avl.h ../../include/lber.h
re.o: ../../include/ldap.h ../../include/lthread.h ../../include/ldif.h slurp.h
re.o: ../../include/lber.h ../../include/ldap.h ../../include/lthread.h
re.o: ../../include/portable.h ../../include/ldapconfig.h ../../include/ldif.h
re.o: globals.h slurp.h
reject.o: reject.c slurp.h ../../include/lber.h ../../include/ldap.h
reject.o: ../../include/lthread.h ../../include/portable.h
reject.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
replica.o: replica.c slurp.h ../../include/lber.h ../../include/ldap.h
replica.o: ../../include/lthread.h ../../include/portable.h
replica.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
replog.o: replog.c ../../include/portable.h slurp.h ../../include/lber.h
replog.o: ../../include/ldap.h ../../include/lthread.h ../../include/portable.h
replog.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
ri.o: ri.c slurp.h ../../include/lber.h ../../include/ldap.h
ri.o: ../../include/lthread.h ../../include/portable.h
ri.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
rq.o: rq.c slurp.h ../../include/lber.h ../../include/ldap.h
rq.o: ../../include/lthread.h ../../include/portable.h
rq.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
sanity.o: sanity.c slurp.h ../../include/lber.h ../../include/ldap.h
sanity.o: ../../include/lthread.h ../../include/portable.h
sanity.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
sanity.o: ../../include/portable.h
st.o: st.c slurp.h ../../include/lber.h ../../include/ldap.h
st.o: ../../include/lthread.h ../../include/portable.h
st.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h
tsleep.o: tsleep.c slurp.h ../../include/lber.h ../../include/ldap.h
tsleep.o: ../../include/lthread.h ../../include/portable.h
tsleep.o: ../../include/ldapconfig.h ../../include/ldif.h globals.h slurp.h

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
