diff --git a/libraries/libldap/Makefile.in b/libraries/libldap/Makefile.in
index 7e57c6f0cb773e5cf6c683a504f74b81a8627607..d18c4e0a9f1a8d195bfb545b32539ea3cebf4c32 100644
--- a/libraries/libldap/Makefile.in
+++ b/libraries/libldap/Makefile.in
@@ -21,13 +21,13 @@ OBJS	= bind.o open.o result.o error.o compare.o search.o \
 	getdn.o getentry.o getattr.o getvalues.o addentry.o \
 	request.o getdxbyname.o os-ip.o url.o charset.o
 
-LIBS = -L. -L../liblber -lldap -llber $(AC_LIBS)
+LIBS = -L$(LDAP_LIBDIR) -lldap -llber $(AC_LIBS)
 LIBLBER = ../liblber/liblber.a
 
 ltest:	$(LIBRARY) test.o $(LIBLBER)
 	$(CC) $(LDFLAGS) -o $@ test.o $(LIBS)
 ttest:	$(LIBRARY) tmpltest.o $(LIBLBER)
-	$(CC) $(LDFLAGS) -o $@ test.o $(LIBS)
+	$(CC) $(LDFLAGS) -o $@ tmpltest.o $(LIBS)
 
 CFFILES= ldapfilter.conf ldapfriendly ldaptemplates.conf ldapsearchprefs.conf