BUILD: Fix LDFLAGS vs. LIBS re linking order in various makefiles

Libraries should always be listed last. Should be backported to 1.8.

Signed-off-by: Christian Ruppert <idl0r@qasl.de>
diff --git a/contrib/mod_defender/Makefile b/contrib/mod_defender/Makefile
index ac17774..efc7d7f 100644
--- a/contrib/mod_defender/Makefile
+++ b/contrib/mod_defender/Makefile
@@ -28,9 +28,8 @@
 endif
 
 CFLAGS  += -g -Wall -pthread
-LDFLAGS += -lpthread  $(EVENT_LIB) -levent_pthreads -lapr-1 -laprutil-1 -lstdc++ -lm
 INCS += -I../../include -I../../ebtree -I$(MOD_DEFENDER_SRC) -I$(APACHE2_INC) -I$(APR_INC) -I$(EVENT_INC)
-LIBS =
+LIBS += -lpthread  $(EVENT_LIB) -levent_pthreads -lapr-1 -laprutil-1 -lstdc++ -lm
 
 CXXFLAGS = -g -std=gnu++11
 CXXINCS += -I$(MOD_DEFENDER_SRC) -I$(MOD_DEFENDER_SRC)/deps -I$(APACHE2_INC) -I$(APR_INC)
@@ -43,7 +42,7 @@
 CXXOBJS = $(patsubst %.cpp, %.o, $(CXXSRCS))
 
 defender: $(OBJS) $(CXXOBJS)
-	$(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
+	$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 install: defender
 	install defender $(DESTDIR)$(BINDIR)