X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=Makefile;h=31c8de75570439fda17098e7b066c5a9e92e379d;hp=0f50a434d22379f8c49a6a69a3cd5946e715bb95;hb=1a6208bfbd2eeba3da5e570c33506515b115c42e;hpb=7d0886352cff30c5d79155d144f8ef2384b38829 diff --git a/Makefile b/Makefile index 0f50a434..31c8de75 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,44 @@ -PROGS=g_mime_test +# Default FLAGS, (can be overriden by user such as "make CFLAGS=-O2") +WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum +CFLAGS=-g -O0 -all: $(PROGS) +# Additional flags that we will append to whatever the user set. +# These aren't intended for the user to manipulate. +extra_cflags = -I./lib `pkg-config --cflags glib-2.0 gmime-2.4 talloc` +extra_cxxflags = `xapian-config --cxxflags` -g_mime_test: g_mime_test.c - $(CC) g_mime_test.c `pkg-config --cflags --libs gmime-2.4` -o g_mime_test +# Now smash together user's values with our extra values +override CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(extra_cflags) +override CXXFLAGS := $(CXXFLAGS) $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags) + +override LDFLAGS := $(LDFLAGS) `pkg-config --libs glib-2.0 gmime-2.4 talloc` \ + `xapian-config --libs` + +# Include our local Makfile.local first so that its first target is default +include Makefile.local +include lib/Makefile.local + +%.o: %.cc + $(CXX) -c $(CFLAGS) $(CXXFLAGS) $< -o $@ + +%.o: %.c + $(CC) -c $(CFLAGS) $< -o $@ + +.deps/%.d: %.c + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +.deps/%.d: %.cc + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +DEPS := $(SRCS:%.c=.deps/%.d) +DEPS := $(DEPS:%.cc=.deps/%.d) +-include $(DEPS) clean: - rm -f $(PROGS) + rm -f $(CLEAN); rm -rf .deps