X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=Makefile;h=436dacfc4c6318e76f076c007771afe34153f52f;hp=614c57600917cc6e25559ee7147962f8e6460a37;hb=e12a6b91ac795fb6e930b810f6aca2939ca5900e;hpb=11f99eb8eac3206f200a40a536ff3657ba577594 diff --git a/Makefile b/Makefile index 614c5760..436dacfc 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,47 @@ -PROGS=g_mime_test 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 -MYCXXFLAGS=-Wall +# 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` -all: $(PROGS) +# Now smash together user's values with our extra values +override CFLAGS += $(WARN_FLAGS) $(extra_cflags) +override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags) -g_mime_test: g_mime_test.c - $(CC) $(CFLAGS) $(MYCFLAGS) g_mime_test.c `pkg-config --cflags --libs gmime-2.4` -o g_mime_test +override LDFLAGS += `pkg-config --libs glib-2.0 gmime-2.4 talloc` \ + `xapian-config --libs` -xapian-dump: xapian-dump.cc - $(CXX) $(CXXFLAGS) $(MYCXXFLAGS) xapian-dump.cc `xapian-config --libs --cxxflags` -o xapian-dump +# 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 $(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,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +.deps/%.d: %.cc + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \ + sed 's,'$$(basename $*)'\.o[ :]*,$*.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