dir := test
-.PHONY: test
-test: all
- @${dir}/notmuch-test
+extra_cflags += -I.
+
+smtp_dummy_srcs = \
+ $(notmuch_compat_srcs) \
+ $(dir)/smtp-dummy.c
+
+smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)
+
+$(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a
+ $(call quiet,CC) -I. $^ -o $@
+
+$(dir)/smtp-dummy: $(smtp_dummy_modules)
+ $(call quiet,CC) $^ -o $@
+
+$(dir)/symbol-test: $(dir)/symbol-test.o
+ $(call quiet,CXX) $^ -o $@ -Llib -lnotmuch -lxapian
+
+.PHONY: test check
+
+test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test
+
+test: all test-binaries
+ @${dir}/notmuch-test $(OPTIONS)
+
+check: test
+
+CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \
+ $(dir)/symbol-test $(dir)/symbol-test.o \
+ $(dir)/arg-test $(dir)/arg-test.o