Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > cdedc712ab3cd61c674716aaa506265d > files > 31

openldap-2.4.38-1.3.mga4.src.rpm

From 6d0668bf60eef5f1b9a29e7af8d4a09f614bd6e0 Mon Sep 17 00:00:00 2001
From: Buchan Milne <bgmilne@staff.telkomsa.net>
Date: Fri, 3 Jun 2011 10:18:39 +0200
Subject: [PATCH] Fix contrib Makefiles to use libtool and be consistent
 (ITS#6883)

This makes existing Makefiles provided with contrib modules more
consistent, using libtool for compiling and linking. A trivial
test target has also been added, which tests that the module can
be loaded. Existing Makefiles were consulted, but were mainly copied
from the first working/tested Makefile. As such, any pre-existing
copyright notices have been replaced.

Makefiles are also provided for all the contrib modules that did not
have Makefiles.
---
 contrib/slapd-modules/acl/Makefile         |   48 +++++++++++++++
 contrib/slapd-modules/addpartial/Makefile  |   50 ++++++++++++++---
 contrib/slapd-modules/allop/Makefile       |   47 +++++++++++++++
 contrib/slapd-modules/allowed/Makefile     |   56 +++++++++---------
 contrib/slapd-modules/autogroup/Makefile   |   36 +++++++++---
 contrib/slapd-modules/cloak/Makefile       |   43 ++++++++++++--
 contrib/slapd-modules/denyop/Makefile      |   48 +++++++++++++++
 contrib/slapd-modules/dsaschema/Makefile   |   47 +++++++++++++++
 contrib/slapd-modules/dupent/Makefile      |   58 +++++++++----------
 contrib/slapd-modules/kinit/Makefile       |   47 +++++++++++++++
 contrib/slapd-modules/lastbind/Makefile    |   32 +++++++---
 contrib/slapd-modules/lastmod/Makefile     |   48 +++++++++++++++
 contrib/slapd-modules/noopsrch/Makefile    |   58 +++++++++----------
 contrib/slapd-modules/nops/Makefile        |   47 ++++++++++++----
 contrib/slapd-modules/nssov/Makefile       |   13 ++++-
 contrib/slapd-modules/passwd/Makefile      |   86 +++++++++++++++-------------
 contrib/slapd-modules/passwd/sha2/Makefile |   48 +++++++++++++---
 contrib/slapd-modules/trace/Makefile       |   48 +++++++++++++++
 18 files changed, 679 insertions(+), 181 deletions(-)
 create mode 100644 contrib/slapd-modules/acl/Makefile
 create mode 100644 contrib/slapd-modules/allop/Makefile
 create mode 100644 contrib/slapd-modules/denyop/Makefile
 create mode 100644 contrib/slapd-modules/dsaschema/Makefile
 create mode 100644 contrib/slapd-modules/kinit/Makefile
 create mode 100644 contrib/slapd-modules/lastmod/Makefile
 create mode 100644 contrib/slapd-modules/trace/Makefile

diff --git a/contrib/slapd-modules/acl/Makefile b/contrib/slapd-modules/acl/Makefile
new file mode 100644
index 0000000..9f48c0d
--- /dev/null
+++ b/contrib/slapd-modules/acl/Makefile
@@ -0,0 +1,48 @@
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+CPPFLAGS+=-DSLAPD_OVER_ACL=SLAPD_MOD_DYNAMIC
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: posixgroup.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
+
+clean:
+	rm -rf *.lo *.la *.o .libs/
+
+install: posixgroup.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: posixgroup.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/addpartial/Makefile b/contrib/slapd-modules/addpartial/Makefile
index 3b68815..2f1fd31 100644
--- a/contrib/slapd-modules/addpartial/Makefile
+++ b/contrib/slapd-modules/addpartial/Makefile
@@ -1,13 +1,47 @@
 # $OpenLDAP$
-OPENLDAP_SRC=../../..
-OPENLDAP_BLD=../../..
-CPPFLAGS+=-I${OPENLDAP_SRC}/include -I${OPENLDAP_SRC}/servers/slapd -I${OPENLDAP_BLD}/include
-CC=gcc
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
 
-all: addpartial-overlay.so
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+LIBTOOL=../../../libtool
 
-addpartial-overlay.so: addpartial-overlay.c
-	$(CC) -shared $(CPPFLAGS) $(LDFLAGS) -Wall -o $@ $?
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: addpartial.la
+
+%.lo:	addpartial-overlay.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $< -o addpartial.lo
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm addpartial-overlay.so
+	rm -rf *.lo *.la *.o .libs/
+
+install: addpartial.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: addpartial.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/allop/Makefile b/contrib/slapd-modules/allop/Makefile
new file mode 100644
index 0000000..a995e61
--- /dev/null
+++ b/contrib/slapd-modules/allop/Makefile
@@ -0,0 +1,47 @@
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: allop.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
+
+clean:
+	rm -rf *.lo *.la *.o .libs/
+
+install: allop.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: allop.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/allowed/Makefile b/contrib/slapd-modules/allowed/Makefile
index 148460d..54f9746 100644
--- a/contrib/slapd-modules/allowed/Makefile
+++ b/contrib/slapd-modules/allowed/Makefile
@@ -1,8 +1,6 @@
 # $OpenLDAP$
-# This work is part of OpenLDAP Software <http://www.openldap.org/>.
-#
-# Copyright 1998-2012 The OpenLDAP Foundation.
-# Copyright 2004 Howard Chu, Symas Corp. All Rights Reserved.
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted only as authorized by the OpenLDAP
@@ -12,35 +10,39 @@
 # top-level directory of the distribution or, alternatively, at
 # <http://www.OpenLDAP.org/license.html>.
 
-PREFIX=/opt/openldap-HEAD
-
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+CPPFLAGS+=-DSLAPD_OVER_ALLOWED=SLAPD_MOD_DYNAMIC
 LIBTOOL=../../../libtool
-OPT=-g -O2
-CC=gcc
-
-DEFS=-DSLAPD_OVER_ALLOWED=SLAPD_MOD_DYNAMIC
-
-LDAP_INC=-I../../../include -I../../../servers/slapd
-INCS=$(LDAP_INC)
-
-LDAP_LIB=-lldap_r -llber -L../../../lib
-LDAP_LIB=
-LIBS=$(LDAP_LIB)
 
-all:	allowed.la
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
 
+all: allowed.la
 
-allowed.lo:	allowed.c
-	$(LIBTOOL) --mode=compile $(CC) $(OPT) $(DEFS) $(INCS) -c $?
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
 
-allowed.la:	allowed.lo
-	$(LIBTOOL) --mode=link $(CC) $(OPT) -version-info 0:0:0 \
-	-rpath $(PREFIX)/lib -module -o $@ $? $(LIBS)
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm -f allowed.o allowed.lo allowed.la
+	rm -rf *.lo *.la *.o .libs/
 
 install: allowed.la
-	mkdir -p $(PREFIX)/libexec/openldap
-	$(LIBTOOL) --mode=install cp allowed.la $(PREFIX)/libexec/openldap
-	$(LIBTOOL) --finish $(PREFIX)/libexec/openldap
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: allowed.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/autogroup/Makefile b/contrib/slapd-modules/autogroup/Makefile
index 70146ac..4438cbf 100644
--- a/contrib/slapd-modules/autogroup/Makefile
+++ b/contrib/slapd-modules/autogroup/Makefile
@@ -1,6 +1,17 @@
-LIBTOOL=../../../libtool
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
 
-CPPFLAGS+=-I../../../include -I../../../servers/slapd
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+LIBTOOL=../../../libtool
 
 ldap_subdir = openldap
 prefix=/usr/local
@@ -8,20 +19,29 @@ exec_prefix = $(prefix)
 libdir = $(exec_prefix)/lib
 libexecdir = $(exec_prefix)/libexec
 moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
 
 all: autogroup.la
 
-autogroup.lo:	autogroup.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
 
-autogroup.la:	autogroup.lo
+%.la:   %.lo
 	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-	-rpath $(libdir) -module -o $@ $? 
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm -f autogroup.lo autogroup.la
+	rm -rf *.lo *.la *.o .libs/
 
 install: autogroup.la
 	mkdir -p $(DESTDIR)$(moduledir)
-	$(LIBTOOL) --mode=install cp autogroup.la $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
 	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: autogroup.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/cloak/Makefile b/contrib/slapd-modules/cloak/Makefile
index 4562fcb..d92ff8b 100644
--- a/contrib/slapd-modules/cloak/Makefile
+++ b/contrib/slapd-modules/cloak/Makefile
@@ -1,17 +1,48 @@
 # $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
 CPPFLAGS+=-I../../../include -I../../../servers/slapd 
 CPPFLAGS+=-DSLAPD_OVER_CLOAK=SLAPD_MOD_DYNAMIC
-LIBS=-lldap_r -llber -lcrypto
 LIBTOOL=../../../libtool
 
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
 all: cloak.la
 
-cloak.lo:    cloak.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -c $?
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
 
-cloak.la:    cloak.lo
+%.la:   %.lo
 	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-		   -rpath $(PREFIX)/lib -module -o $@ $? $(LIBS)
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm cloak.lo cloak.la
+	rm -rf *.lo *.la *.o .libs/
+
+install: cloak.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: cloak.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/denyop/Makefile b/contrib/slapd-modules/denyop/Makefile
new file mode 100644
index 0000000..711eee7
--- /dev/null
+++ b/contrib/slapd-modules/denyop/Makefile
@@ -0,0 +1,48 @@
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+CPPFLAGS+=-DSLAPD_OVER_DENYOP=SLAPD_MOD_DYNAMIC
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: denyop.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
+
+clean:
+	rm -rf *.lo *.la *.o .libs/
+
+install: denyop.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: denyop.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/dsaschema/Makefile b/contrib/slapd-modules/dsaschema/Makefile
new file mode 100644
index 0000000..90f711e
--- /dev/null
+++ b/contrib/slapd-modules/dsaschema/Makefile
@@ -0,0 +1,47 @@
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: dsaschema.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
+
+clean:
+	rm -rf *.lo *.la *.o .libs/
+
+install: dsaschema.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: dsaschema.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/dupent/Makefile b/contrib/slapd-modules/dupent/Makefile
index 81d2a07..c1e8997 100644
--- a/contrib/slapd-modules/dupent/Makefile
+++ b/contrib/slapd-modules/dupent/Makefile
@@ -1,8 +1,6 @@
 # $OpenLDAP$
-# This work is part of OpenLDAP Software <http://www.openldap.org/>.
-#
-# Copyright 1998-2012 The OpenLDAP Foundation.
-# Copyright 2004 Howard Chu, Symas Corp. All Rights Reserved.
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted only as authorized by the OpenLDAP
@@ -12,41 +10,39 @@
 # top-level directory of the distribution or, alternatively, at
 # <http://www.OpenLDAP.org/license.html>.
 
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+CPPFLAGS+=-DSLAPD_OVER_DUPENT=SLAPD_MOD_DYNAMIC -g -O2
 LIBTOOL=../../../libtool
-OPT=-DSLAPD_OVER_DUPENT=2 -g -O2
-#LIBTOOL=../../../../ldap-devel/libtool
-#OPT=-DSLAPD_OVER_DUPENT=2 -g -O0
-CC=gcc
-
-LDAP_INC=-I../../../include -I../../../servers/slapd
-#LDAP_INC=-I../../../include -I../../../servers/slapd -I../../../../ldap-devel/include
-INCS=$(LDAP_INC)
-
-LDAP_LIB=-lldap_r -llber
-LIBS=$(LDAP_LIB)
 
+ldap_subdir = openldap
 prefix=/usr/local
-exec_prefix=$(prefix)
-ldap_subdir=/openldap
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
 
-libdir=$(exec_prefix)/lib
-libexecdir=$(exec_prefix)/libexec
-moduledir = $(libexecdir)$(ldap_subdir)
+all: dupent.la
 
-all:	dupent.la
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
 
-
-dupent.lo:	dupent.c
-	$(LIBTOOL) --mode=compile $(CC) $(OPT) $(DEFS) $(INCS) -c $?
-
-dupent.la:	dupent.lo
-	$(LIBTOOL) --mode=link $(CC) $(OPT) -version-info 0:0:0 \
-	-rpath $(moduledir) -module -o $@ $? $(LIBS)
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm -f dupent.lo dupent.la
+	rm -rf *.lo *.la *.o .libs/
 
 install: dupent.la
 	mkdir -p $(DESTDIR)$(moduledir)
-	$(LIBTOOL) --mode=install cp dupent.la $(DESTDIR)$(moduledir)
-
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: dupent.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/kinit/Makefile b/contrib/slapd-modules/kinit/Makefile
new file mode 100644
index 0000000..750c7b9
--- /dev/null
+++ b/contrib/slapd-modules/kinit/Makefile
@@ -0,0 +1,47 @@
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: kinit.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $< -lkrb5
+
+clean:
+	rm -rf *.lo *.la *.o .libs/
+
+install: kinit.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: kinit.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/lastbind/Makefile b/contrib/slapd-modules/lastbind/Makefile
index ecc9ed1..643b0c1 100644
--- a/contrib/slapd-modules/lastbind/Makefile
+++ b/contrib/slapd-modules/lastbind/Makefile
@@ -1,5 +1,5 @@
 # $OpenLDAP$
-# Copyright 2009 Jonathan Clarke <jonathan@phillipoux.net>.
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -12,23 +12,37 @@
 
 CPPFLAGS+=-I../../../include -I../../../servers/slapd 
 CPPFLAGS+=-DSLAPD_OVER_LASTBIND=SLAPD_MOD_DYNAMIC
-#LIBTOOL=libtool
 LIBTOOL=../../../libtool
 
+ldap_subdir = openldap
 prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
 
 all: lastbind.la
 
-lastbind.lo:    lastbind.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
 
-lastbind.la:    lastbind.lo
+%.la:   %.lo
 	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-		   -rpath $(prefix)/lib -module -o $@ $?
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm -rf lastbind.lo lastbind.la lastbind.o .libs/
+	rm -rf *.lo *.la *.o .libs/
 
 install: lastbind.la
-	mkdir -p $(prefix)/libexec/openldap
-	$(LIBTOOL) --mode=install cp lastbind.la $(prefix)/libexec/openldap
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: lastbind.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/lastmod/Makefile b/contrib/slapd-modules/lastmod/Makefile
new file mode 100644
index 0000000..e9f0408
--- /dev/null
+++ b/contrib/slapd-modules/lastmod/Makefile
@@ -0,0 +1,48 @@
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+CPPFLAGS+=-DSLAPD_OVER_LASTMOD=SLAPD_MOD_DYNAMIC
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: lastmod.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
+
+clean:
+	rm -rf *.lo *.la *.o .libs/
+
+install: lastmod.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: lastmod.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/noopsrch/Makefile b/contrib/slapd-modules/noopsrch/Makefile
index 7be471c..7227582 100644
--- a/contrib/slapd-modules/noopsrch/Makefile
+++ b/contrib/slapd-modules/noopsrch/Makefile
@@ -1,8 +1,6 @@
 # $OpenLDAP$
-# This work is part of OpenLDAP Software <http://www.openldap.org/>.
-#
-# Copyright 1998-2012 The OpenLDAP Foundation.
-# Copyright 2004 Howard Chu, Symas Corp. All Rights Reserved.
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted only as authorized by the OpenLDAP
@@ -12,41 +10,39 @@
 # top-level directory of the distribution or, alternatively, at
 # <http://www.OpenLDAP.org/license.html>.
 
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+CPPFLAGS+=-DSLAPD_OVER_NOOPSRCH=SLAPD_MOD_DYNAMIC -g -O2
 LIBTOOL=../../../libtool
-OPT=-DSLAPD_OVER_NOOPSRCH=2 -g -O2
-#LIBTOOL=../../../../ldap-devel/libtool
-#OPT=-DSLAPD_OVER_NOOPSRCH=2 -g -O0
-CC=gcc
-
-LDAP_INC=-I../../../include -I../../../servers/slapd
-#LDAP_INC=-I../../../include -I../../../servers/slapd -I../../../../ldap-devel/include
-INCS=$(LDAP_INC)
-
-LDAP_LIB=-lldap_r -llber
-LIBS=$(LDAP_LIB)
 
+ldap_subdir = openldap
 prefix=/usr/local
-exec_prefix=$(prefix)
-ldap_subdir=/openldap
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
 
-libdir=$(exec_prefix)/lib
-libexecdir=$(exec_prefix)/libexec
-moduledir = $(libexecdir)$(ldap_subdir)
+all: noopsrch.la
 
-all:	noopsrch.la
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
 
-
-noopsrch.lo:	noopsrch.c
-	$(LIBTOOL) --mode=compile $(CC) $(OPT) $(DEFS) $(INCS) -c $?
-
-noopsrch.la:	noopsrch.lo
-	$(LIBTOOL) --mode=link $(CC) $(OPT) -version-info 0:0:0 \
-	-rpath $(moduledir) -module -o $@ $? $(LIBS)
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm -f noopsrch.lo noopsrch.la
+	rm -rf *.lo *.la *.o .libs/
 
 install: noopsrch.la
 	mkdir -p $(DESTDIR)$(moduledir)
-	$(LIBTOOL) --mode=install cp noopsrch.la $(DESTDIR)$(moduledir)
-
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: noopsrch.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/nops/Makefile b/contrib/slapd-modules/nops/Makefile
index fce44e0..6da5cd0 100644
--- a/contrib/slapd-modules/nops/Makefile
+++ b/contrib/slapd-modules/nops/Makefile
@@ -1,23 +1,48 @@
 # $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
 CPPFLAGS+=-I../../../include -I../../../servers/slapd 
 CPPFLAGS+=-DSLAPD_OVER_NOPS=SLAPD_MOD_DYNAMIC
-LIBS=-L$(PREFIX)/lib -lldap_r -llber -lcrypto
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
 
 all: nops.la
 
-nops.lo:    nops.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -c $?
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
 
-nops.la:    nops.lo
+%.la:   %.lo
 	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-		   -rpath $(PREFIX)/lib -module -o $@ $? $(LIBS)
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm -f nops.lo nops.la
+	rm -rf *.lo *.la *.o .libs/
 
 install: nops.la
-	mkdir -p $(PREFIX)/lib/openldap 
-	mkdir -p $(PREFIX)/man/man5
-	$(LIBTOOL) --mode=install cp nops.la $(PREFIX)/lib/openldap
-	$(LIBTOOL) --finish $(PREFIX)/lib
-	cp nops.5 $(PREFIX)/man/man5
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: nops.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/nssov/Makefile b/contrib/slapd-modules/nssov/Makefile
index c2a1304..cdce2c9 100644
--- a/contrib/slapd-modules/nssov/Makefile
+++ b/contrib/slapd-modules/nssov/Makefile
@@ -28,7 +28,7 @@ NLDAPD_INC=-Inss-pam-ldapd
 INCS=$(LDAP_INC) $(NLDAPD_INC)
 
 LDAP_LIB=-lldap_r -llber
-LIBS=$(LDAP_LIB)
+LIBS=-L../../../libraries/liblber -L../../../libraries/libldap_r $(LDAP_LIB)
 
 prefix=/usr/local
 exec_prefix=$(prefix)
@@ -39,6 +39,7 @@ libexecdir=$(exec_prefix)/libexec
 moduledir = $(libexecdir)$(ldap_subdir)
 sysconfdir = $(prefix)/etc$(ldap_subdir)
 schemadir = $(sysconfdir)/schema
+slapd=../../../servers/slapd/slapd
 
 all:	nssov.la
 
@@ -59,7 +60,7 @@ $(OBJS):	nssov.h
 
 nssov.la:	$(OBJS) $(XOBJS)
 	$(LIBTOOL) --mode=link $(CC) $(OPT) -version-info 0:0:0 \
-	-rpath $(libdir) -module -o $@ $(OBJS) $(XOBJS) $(LIBS)
+	-rpath $(moduledir) -module -o $@ $(OBJS) $(XOBJS) $(LIBS)
 
 install: nssov.la
 	mkdir -p $(DESTDIR)$(moduledir)
@@ -69,3 +70,11 @@ install: nssov.la
 clean:
 	rm -f *.*o *.la .libs/*
 	rm -rf .libs
+
+test: nssov.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/passwd/Makefile b/contrib/slapd-modules/passwd/Makefile
index 1e49e6a..748b4ce 100644
--- a/contrib/slapd-modules/passwd/Makefile
+++ b/contrib/slapd-modules/passwd/Makefile
@@ -1,46 +1,52 @@
 # $OpenLDAP$
-CPPFLAGS+=-I../../../include -I../../../servers/slapd
-
-all: kerberos.la netscape.la radius.la apr1.la
-
-kerberos.lo:	kerberos.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -DHAVE_KRB5 -Wall -c $?
-
-kerberos.la:	kerberos.lo
-	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-	-rpath $(PREFIX)/lib -module -o $@ $? -lkrb5
-
-netscape.lo:	netscape.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
-
-netscape.la:	netscape.lo
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+LIBTOOL=../../../libtool
+SUBDIRS = sha2
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: kerberos.la netscape.la radius.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+kerberos.la:   kerberos.lo
 	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-	-rpath $(PREFIX)/lib -module -o $@ $? 
-
-radius.lo:	radius.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
-
-radius.la:	radius.lo
-	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-	-rpath $(PREFIX)/lib -module -o $@ $? -lradius
-
-apr1.lo:	apr1.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
+		   -rpath $(moduledir) -module -o $@ $< -lkrb5
 
-apr1.la:	apr1.lo
+%.la:   %.lo
 	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-	-rpath $(PREFIX)/lib -module -o $@ $? 
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	rm -f kerberos.lo kerberos.la
-	rm -f netscape.lo netscape.la
-	rm -f radius.lo radius.la
-	rm -f apr1.lo apr1.la
-
-install: kerberos.la netscape.la radius.la apr1.la
-	mkdir -p $(PREFIX)/lib/openldap
-	$(LIBTOOL) --mode=install cp kerberos.la $(PREFIX)/lib/openldap
-	$(LIBTOOL) --mode=install cp netscape.la $(PREFIX)/lib/openldap
-	$(LIBTOOL) --mode=install cp radius.la $(PREFIX)/lib/openldap
-	$(LIBTOOL) --mode=install cp apr1.la $(PREFIX)/lib/openldap
-	$(LIBTOOL) --finish $(PREFIX)/lib
+	rm -rf *.lo *.la *.o .libs/
+
+install: kerberos.la netscape.la radius.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: kerberos.la netscape.la radius.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/passwd/sha2/Makefile b/contrib/slapd-modules/passwd/sha2/Makefile
index 5dcb1db..d03297d 100644
--- a/contrib/slapd-modules/passwd/sha2/Makefile
+++ b/contrib/slapd-modules/passwd/sha2/Makefile
@@ -1,15 +1,47 @@
 # $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
 
-OPENLDAP := ../../../..
+CPPFLAGS+=-I../../../../include -I../../../../servers/slapd 
+LIBTOOL=../../../../libtool
 
-#CCFLAGS = -Wall -g -DSLAPD_SHA2_DEBUG
-CCFLAGS = -Wall -g
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../../servers/slapd/slapd
 
-slapd-sha2.so: slapd-sha2.o sha2.o
-	$(CC) -I$(OPENLDAP)/include -shared -Wall -g $^ -o $@
+all: sha2.la
 
-%.o: %.c
-	$(CC) -I$(OPENLDAP)/include $(CCFLAGS) -c $<
+%.lo:	slapd-sha2.c sha2.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   slapd-sha2.lo sha2.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
 
 clean:
-	@rm -f slapd-sha2.so *.o
+	rm -rf *.lo *.la *.o .libs/
+
+install: sha2.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: sha2.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
diff --git a/contrib/slapd-modules/trace/Makefile b/contrib/slapd-modules/trace/Makefile
new file mode 100644
index 0000000..948ffef
--- /dev/null
+++ b/contrib/slapd-modules/trace/Makefile
@@ -0,0 +1,48 @@
+# $OpenLDAP$
+# Copyright 2011 Buchan Milne <bgmilne@staff.telkomsa.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted only as authorized by the OpenLDAP
+# Public License.
+#
+# A copy of this license is available in the file LICENSE in the
+# top-level directory of the distribution or, alternatively, at
+# <http://www.OpenLDAP.org/license.html>.
+
+CPPFLAGS+=-I../../../include -I../../../servers/slapd 
+CPPFLAGS+=-DSLAPD_OVER_TRACE=SLAPD_MOD_DYNAMIC
+LIBTOOL=../../../libtool
+
+ldap_subdir = openldap
+prefix=/usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+libexecdir = $(exec_prefix)/libexec
+moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
+slapd=../../../servers/slapd/slapd
+
+all: trace.la
+
+%.lo:	%.c
+	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $<
+
+%.la:   %.lo
+	$(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
+		   -rpath $(moduledir) -module -o $@ $<
+
+clean:
+	rm -rf *.lo *.la *.o .libs/
+
+install: trace.la
+	mkdir -p $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --mode=install cp $? $(DESTDIR)$(moduledir)
+	$(LIBTOOL) --finish $(DESTDIR)$(moduledir)
+
+test: trace.la
+	@for i in $?;do \
+		echo "Testing loading module $$i"; \
+		echo "modulepath ." > test-slapd.conf; \
+		echo "moduleload $$i" >> test-slapd.conf; \
+		$(slapd) -T test -f test-slapd.conf && rm -f test-slapd.conf; \
+	done
-- 
1.7.4.4