diff --git a/src/Makefile.in b/src/Makefile.in
index 9512aca..6b4388e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -17,7 +17,7 @@
 CFLAGS = @CFLAGS@ @CPPFLAGS@
 DEFS = @defs@
 INCDIR = -I. -I.. @INCDIR@ @sql_includes@
-LIBDIR = -L. -L../contrib/spamsum @LIBDIR@ @LDFLAGS@
+LIBDIR = -L. -L../contrib/spamsum @LIBDIR@
 LIBS = @LIBS@ @sql_libs@
 ##CLAMAV_EXTRA_LIBS = -lclamunrar_iface -lclamunrar
 OBJS = @OBJS@
@@ -40,13 +40,12 @@ install: install-clapf install-includes install-splitmbox @parsembox_install@ @s
 
 
 clapf: clapf.c libclapf.a
-	$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ clapf.c -lclapf $(LIBS) $(LDAP_LIBS) $(LIBDIR) @LDFLAGS@ @libclamav_extra_libs@
+	$(CC) $(CFLAGS) $(INCDIR) $(DEFS) @LDFLAGS@ -o $@ clapf.c -lclapf $(LIBS) $(LDAP_LIBS) $(LIBDIR) @libclamav_extra_libs@
 
 libclapf.a: $(OBJS) $(SQL_OBJS)
 	ar cr libclapf.a $(OBJS) $(SQL_OBJS)
 	ranlib libclapf.a
-	#$(CC) -shared -Wl,-soname,libclapf.so.$(CLAPF_VERSION) -o libclapf.so.$(LIBCLAPF_VERSION) $(OBJS) $(SQL_OBJS) $(LIBS) $(LDAP_LIBS) @LDFLAGS@
-	$(CC) -shared -Wl -o libclapf.so.$(LIBCLAPF_VERSION) $(OBJS) $(SQL_OBJS) $(LIBS) $(LDAP_LIBS) @LDFLAGS@
+	$(CC) @LDFLAGS@ -shared -Wl,-soname,libclapf.so.$(CLAPF_VERSION) -o libclapf.so.$(LIBCLAPF_VERSION) $(OBJS) $(SQL_OBJS) $(LIBS) $(LDAP_LIBS)
 	ln -sf libclapf.so.$(LIBCLAPF_VERSION) libclapf.so
 	ln -sf libclapf.so.$(LIBCLAPF_VERSION) libclapf.so.$(CLAPF_VERSION)
 
@@ -75,7 +75,7 @@
 	$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $^ $(LIBS) $(LDAP_LIBS) $(LIBDIR) -ltre
 
 test:
-	$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o spamtest $(srcdir)/test.c -lclapf $(LIBS) $(LDAP_LIBS) @spamsum_libs@ $(LIBDIR) @LDFLAGS@
+	$(CC) $(CFLAGS) $(INCDIR) $(DEFS) @LDFLAGS@ -o spamtest $(srcdir)/test.c -lclapf $(LIBS) $(LDAP_LIBS) @spamsum_libs@ $(LIBDIR)
 
 %.o: $(srcdir)/%.c
 	$(CC) $(CFLAGS) -fPIC $(INCDIR) $(DEFS) -c $< -o $@
