+diff --git a/Makefile b/Makefile
+index 7c13b9275e0f..25765f76110e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -19,7 +19,7 @@
+ #
+ # Authors: Tim Stoakes <tim@stoakes.net>
+
+-CFLAGS = -g -O2 -std=c99 -Wall -Werror -D_FILE_OFFSET_BITS=64
++ALL_CFLAGS = -std=c99 -D_FILE_OFFSET_BITS=64 $(CFLAGS)
+
+ OBJS = notmuchfs.o
+
+@@ -28,16 +28,10 @@ LIBS = -lnotmuch -lfuse
+ all: notmuchfs
+
+ notmuchfs: $(OBJS)
+- $(CC) -o $@ $+ $(LIBS)
++ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
+
+ clean:
+ rm -f *.o *.dep notmuchfs
+
+ %.o : %.c
+- $(COMPILE.c) -MD -o $@ $<
+- @cp $*.d $*.dep; \
+- sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+- -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.dep; \
+- rm -f $*.d
+-
+--include $(OBJS:.o=.dep)
++ $(CC) $(ALL_CFLAGS) -c -o $@ $<