X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=Makefile;h=b6861e9c665c97055499dc28c6f1c82a5188e73e;hp=26ab8da8e748b32beb143e4f92d7ab02707a5eb2;hb=5d0a01dceb67e9bdcb95bcb2328baef5e7ea7d52;hpb=2b819ae83dbe2b13000e711b8b795b08a4471852 diff --git a/Makefile b/Makefile index 26ab8da8..b6861e9c 100644 --- a/Makefile +++ b/Makefile @@ -1,49 +1,60 @@ -PROGS=notmuch - +# Default FLAGS, (can be overridden by user such as "make CFLAGS=-O2") WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum +CFLAGS=-O2 + +# Additional flags that we will append to whatever the user set. +# These aren't intended for the user to manipulate. +extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc) +extra_cxxflags := $(shell xapian-config --cxxflags) + +emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir) +# Hard-code if this system doesn't have an emacs.pc file +ifeq ($(emacs_lispdir),) + emacs_lispdir = $(prefix)/share/site-lisp +endif -CDEPENDS_FLAGS=`pkg-config --cflags glib-2.0 gmime-2.4 talloc` -CXXDEPENDS_FLAGS=$(CDEPENDS_FLAGS) `xapian-config --cxxflags` +all_deps = Makefile Makefile.local Makefile.config \ + lib/Makefile lib/Makefile.local -MYCFLAGS=$(WARN_FLAGS) -O0 -g $(CDEPENDS_FLAGS) -MYCXXFLAGS=$(WARN_FLAGS) -O0 -g $(CXXDEPENDS_FLAGS) +# Now smash together user's values with our extra values +override CFLAGS += $(WARN_FLAGS) $(extra_cflags) +override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags) -MYLDFLAGS=`pkg-config --libs glib-2.0 gmime-2.4 talloc` `xapian-config --libs` +override LDFLAGS += \ + $(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \ + $(shell xapian-config --libs) -LIBRARY= \ - database.o \ - date.o \ - index.o \ - libsha1.o \ - message.o \ - message-file.o \ - query.o \ - sha1.o \ - tags.o \ - thread.o \ - xutil.o +# Include our local Makefile.local first so that its first target is default +include Makefile.local +include lib/Makefile.local -MAIN= \ - notmuch.o +# And get user settings from the output of configure +include Makefile.config -all: $(PROGS) +%.o: %.cc $(all_deps) + $(CXX) -c $(CFLAGS) $(CXXFLAGS) $< -o $@ -%.o: %.cc - $(CXX) -c $(CFLAGS) $(CXXFLAGS) $(MYCXXFLAGS) $< -o $@ +%.o: %.c $(all_deps) + $(CC) -c $(CFLAGS) $< -o $@ -%.o: %.c - $(CC) -c $(CFLAGS) $(MYCFLAGS) $< -o $@ +%.elc: %.el + emacs -batch -f batch-byte-compile $< -notmuch: $(MAIN) $(LIBRARY) - $(CC) $(MYLDFLAGS) $^ -o $@ +.deps/%.d: %.c $(all_deps) + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \ + sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -Makefile.dep: *.c *.cc - $(CXX) -M $(CPPFLAGS) $(CDEPENDS_FLAGS) $(CXXDEPENDS_FLAGS) $^ > $@ --include Makefile.dep +.deps/%.d: %.cc $(all_deps) + @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ + $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \ + sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -install: - install -C -D notmuch $(DESTDIR)/usr/bin/notmuch - install -C -D notmuch-completion.bash $(DESTDIR)/etc/bash_completion.d/notmuch +DEPS := $(SRCS:%.c=.deps/%.d) +DEPS := $(DEPS:%.cc=.deps/%.d) +-include $(DEPS) clean: - rm -f $(PROGS) *.o Makefile.dep + rm -f $(CLEAN); rm -rf .deps