# Makefile for ldapcheck: an authenticator for inn
# c code: Keith Lewis
# Makefile & Packaging: Bas Meijer

# how to link against the ldap libraries.
# For OpenLDAP SDKs
LDAPLIB=-lldap -llber
LIBDIR=/usr/lib
INCDIR=/usr/include

# For the Netscape SDK with SSL support
# LDAPLIB=lldapssl30
# LDAPLIB=lldap30
# LIBDIR=/usr/local/lib
# INCDIR=/usr/local/include

LIBS=-L$(LIBDIR) $(LDAPLIB) -lpthread
OPTFLAGS=-g
CFLAGS=$(OPTFLAGS) -I$(INCDIR)
CC=cc

ldapcheck: config.h main.c ldap_pwd_ok.c Makefile
	$(CC) $(CFLAGS) -o ldapcheck main.c ldap_pwd_ok.c $(LIBS)

init: 
	#ldapadd -x -W -v -D "cn=Manager,dc=example,dc=com" -f manager.ldif
	ldapadd -x -W -v -D "cn=Manager,dc=example,dc=com" -f testuser.ldif

test: ldapcheck
	./searchldap.sh testuser
	./ldapcheck -s localhost < testdata

install: ldapcheck test
	# cp readers.conf /etc/news/
	chmod +x ldapcheck
	cp ldapcheck /usr/bin/auth/passwd
	chown news:news /usr/bin/auth/passwd/ldapcheck
