X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=Makefile;h=436dacfc4c6318e76f076c007771afe34153f52f;hp=b7ebfb816802cb4a4a1ff7ee3b2c0330a1fe33d2;hb=58b659f893084fde2c79b8d0ce053b3bc4946b7c;hpb=0e777a8f800af062aba39a95a003f3e1d8f33793 diff --git a/Makefile b/Makefile index b7ebfb81..436dacfc 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,47 @@ -PROGS=notmuch notmuch-index-message xapian-dump +# Default FLAGS, (can be overriden by user such as "make CFLAGS=-O2") +WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum +CFLAGS=-O2 -MYCFLAGS=-Wall -O0 -g `pkg-config --cflags glib-2.0` -MYCXXFLAGS=$(MYCFLAGS) `xapian-config --cxxflags` +# Additional flags that we will append to whatever the user set. +# These aren't intended for the user to manipulate. +extra_cflags = `pkg-config --cflags glib-2.0 gmime-2.4 talloc` +extra_cxxflags = `xapian-config --cxxflags` -MYLDFLAGS=`pkg-config --libs glib-2.0` `xapian-config --libs` +# Now smash together user's values with our extra values +override CFLAGS += $(WARN_FLAGS) $(extra_cflags) +override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags) -all: $(PROGS) +override 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 + +# And get user settings from the output of configure +include Makefile.config %.o: %.cc - $(CXX) -c $(CXXFLAGS) $(MYCXXFLAGS) $^ -o $@ + $(CXX) -c $(CFLAGS) $(CXXFLAGS) $< -o $@ %.o: %.c - $(CC) -c $(CFLAGS) $(MYCFLAGS) $^ -o $@ + $(CC) -c $(CFLAGS) $< -o $@ -notmuch: notmuch.o database.o message.o xutil.o - $(CC) $(MYLDFLAGS) $^ -o $@ +.deps/%.d: %.c + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \ + sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -notmuch-index-message: notmuch-index-message.cc - $(CXX) $(CXXFLAGS) $(MYCXXFLAGS) notmuch-index-message.cc `pkg-config --cflags --libs gmime-2.4` `xapian-config --cxxflags --libs` -o notmuch-index-message +.deps/%.d: %.cc + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \ + sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -xapian-dump: xapian-dump.cc - $(CXX) $(CXXFLAGS) $(MYCXXFLAGS) xapian-dump.cc `xapian-config --libs --cxxflags` -o xapian-dump +DEPS := $(SRCS:%.c=.deps/%.d) +DEPS := $(DEPS:%.cc=.deps/%.d) +-include $(DEPS) clean: - rm -f $(PROGS) *.o + rm -f $(CLEAN); rm -rf .deps