diff --git a/configure b/configure
index ae2aef4fe22fa80942db92d718f57007c743e60f..cf77f235f1d9f8e85ee12bc0d7c3c59a2466a5fd 100755
--- a/configure
+++ b/configure
@@ -1020,7 +1020,7 @@ int main( void ) { return (int) imlib_load_font("foo"); }
 EOF
 
 imlib2=no
-if $cc -o $TMPE $TMPC -lImlib2 -lm > /dev/null 2>&1  ; then
+if $cc $CFLAGS $LDFLAGS -o $TMPE $TMPC -lImlib2 -lm > /dev/null 2>&1  ; then
 imlib2=yes
 fi
 
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 9f2a8f33adfd9a9abc95b9aebf1f118fb8b836f3..42a26fe070ad7f124a70c1d90e894ed82ca3cd1f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -101,7 +101,7 @@ ifeq ($(CONFIG_WIN32),yes)
 	$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(PPOBJS) $(AVCLIBS) $(EXTRALIBS)
 	-lib /machine:i386 /def:$(@:.dll=.def)
 else
-	$(CC) $(SHFLAGS) -o $@ $(OBJS) $(PPOBJS) $(AVCLIBS) $(EXTRALIBS)
+	$(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(PPOBJS) $(AVCLIBS) $(EXTRALIBS)
 endif
 
 depend: $(SRCS)
diff --git a/vhook/Makefile b/vhook/Makefile
index c77ae144607b1d178b6dc10d69abea3bcf3ce399..aedd8d1668e6f4faa674efd07bd361a80ab27495 100644
--- a/vhook/Makefile
+++ b/vhook/Makefile
@@ -30,13 +30,13 @@ install:
 	install -m 755 $(HOOKS) "$(libdir)/vhook"
 
 imlib2.so: imlib2.o
-	$(CC) -g -o $@ $(SHFLAGS) $< -lImlib2
+	$(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< -lImlib2
 
 drawtext.so: drawtext.o
-	$(CC) -g -o $@ $(SHFLAGS) $< `freetype-config --libs`
+	$(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< `freetype-config --libs`
 
 %.so: %.o
-	$(CC) -g -o $@ $(SHFLAGS) $<
+	$(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $<
 
 clean:
 	rm -f *.o *.d .depend *.so *~