-WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum
+# We want the all target to be the implicit target (if no target is
+# given explicitly on the command line) so mention it first.
+all:
-NOTMUCH_DEPENDS_FLAGS=-I./lib `pkg-config --cflags glib-2.0 gmime-2.4 talloc`
-NOTMUCH_CXX_DEPENDS_FLAGS=$(NOTMUCH_DEPENDS_FLAGS) `xapian-config --cxxflags`
-
-NOTMUCH_CFLAGS=$(WARN_FLAGS) -O0 -g $(NOTMUCH_DEPENDS_FLAGS)
-NOTMUCH_CXXFLAGS=$(WARN_FLAGS) -O0 -g $(NOTMUCH_CXX_DEPENDS_FLAGS)
-
-NOTMUCH_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) $(NOTMUCH_CXXFLAGS) $< -o $@
-
-%.o: %.c
- $(CC) -c $(CFLAGS) $(NOTMUCH_CFLAGS) $< -o $@
-
-.depends: $(SRCS)
- $(CXX) -M $(CPPFLAGS) $(NOTMUCH_DEPENDS_FLAGS) \
- $(NOTMUCH_CXX_DEPENDS_FLAGS) $^ > $@
--include .depends
-
-CLEAN := $(CLEAN) .depends
-
-clean:
- rm -f $(CLEAN)
+# List all subdirectories here. Each contains its own Makefile.local
+subdirs = compat completion emacs lib
+# We make all targets depend on the Makefiles themselves.
+global_deps = Makefile Makefile.local \
+ $(subdirs:%=%/Makefile) $(subdirs:%=%/Makefile.local)
+# Finally, include all of the Makefile.local fragments where all the
+# real work is done.
+include Makefile.local $(subdirs:%=%/Makefile.local)