NAME = cbook
NAMES = $(NAME) cutils
-TEST =
-TESTS =
+TEST = tests-cbook
+TESTS = $(TEST)
PREFIX = /usr/local
endif
.PHONY: all build install uninstall clean mrpropre mrpropre \
- $(NAMES)
+ $(NAMES) deps run
SOURCES=$(wildcard $(srcdir)/*.c)
-HEADERS=$(wildcard $(srcdir)/*.h)
OBJECTS=$(SOURCES:%.c=%.o)
# Main targets
build: $(NAMES)
-cbook: $(dstdir)/cbook
+$(NAME): deps $(dstdir)/$(NAME)
################
# Dependencies #
################
-OBJECTS+=$(dstdir)/libcutils.o
-$(dstdir)/libcutils.o:
+## Libs (if needed)
+deps:
$(MAKE) --no-print-directory -C cutils/ cutils
+DEPS=$(dstdir)/libcutils.o
+
+## Headers
+DEPENDS=$(SOURCES:%.c=%.d)
+-include $(DEPENDS)
+%.o: %.c
+ $(CC) $(CFLAGS) -MMD -MP -c $< -o $@
################
-$(dstdir)/cbook: $(OBJECTS)
+$(dstdir)/$(NAME): $(DEPS) $(OBJECTS)
mkdir -p $(dstdir)
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) $(DEPS) $(OBJECTS) -o $@
+
+run:
+ @echo
+ $(dstdir)/$(NAME)
clean:
- rm -f $(srcdir)/*.o
+ rm -f $(OBJECTS) $(DEPENDS)
mrproper: mrpropre
mrpropre: clean
- rm -f $(dstdir)/cbook
+ rm -f $(dstdir)/$(NAME)
rmdir $(dstdir) 2>/dev/null || true
-Subproject commit 7f42ed22b8dab3f7bd1d9e675e2217797cdc29cc
+Subproject commit 70e6676e68300c59384ffb1127fd1330e1d644e7
--- /dev/null
+#include <check.h>
+#include "cutils/check/launcher.h"
+
+// The tests we intend to run:
+
+// SRunner *test_XXX(SRunner *runner, int more);
+// ...
+
+SRunner *get_tests(int more) {
+ SRunner *runner = NULL;
+
+ // runner = test_XXX(runner, more);
+ // ...
+
+ return runner;
+}
+
+int main(int argc, char **argv) {
+ return launch_tests(argc, argv);
+}
+
--- /dev/null
+# Note: 99+ required for for-loop initial declaration (CentOS 6)
+
+NAME = tests-cbook
+NAMES = $(NAME)
+srcdir = $(NAME)
+dstdir = ../bin
+
+CFLAGS += -Wall -pedantic -I./ -std=c99
+CXXFLAGS += -Wall -pedantic -I./
+LDFLAGS += -lcheck
+PREFIX = /usr/local
+
+ifdef DEBUG
+CFLAGS += -ggdb -O0
+CXXFLAGS += -ggdb -O0
+endif
+
+.PHONY: all build install uninstall clean mrpropre mrpropre \
+ $(NAME) deps test run run-test run-test-more
+
+SOURCES=$(wildcard $(srcdir)/*.c)
+OBJECTS=$(SOURCES:%.c=%.o)
+
+# Main target
+
+all: build
+
+build: $(NAMES)
+
+$(NAME): deps $(dstdir)/$(NAME)
+
+################
+# Dependencies #
+################
+## Libs (if needed)
+deps:
+ $(MAKE) --no-print-directory -C cutils/ check
+DEPS=$(dstdir)/libcutils-check.o
+
+## Headers
+DEPENDS=$(SOURCES:%.c=%.d)
+-include $(DEPENDS)
+%.o: %.c
+ $(CC) $(CFLAGS) -MMD -MP -c $< -o $@
+################
+
+$(dstdir)/$(NAME): $(DEPS) $(OBJECTS)
+ mkdir -p $(dstdir)
+ $(CC) $(CFLAGS) $(LDFLAGS) $(DEPS) $(OBJECTS) -o $@
+
+# Test program, so running = running tests
+run: run-test
+test: build
+
+run-test: test
+ @echo
+ $(dstdir)/$(NAME)
+run-test-more: test
+ @echo
+ $(dstdir)/$(NAME) --more
+
+clean:
+ rm -f $(OBJECTS) $(DEPENDS)
+
+mrproper: mrpropre
+mrpropre: clean
+ rm -f $(dstdir)/$(NAME)
+ rmdir $(dstdir) 2>/dev/null || true
+
+++ /dev/null
-# Note: 99+ required for for-loop initial declaration (CentOS 6)
-
-srcdir = tests
-dstdir = ../bin
-
-CFLAGS += -Wall -pedantic -I./ -std=c99
-CXXFLAGS += -Wall -pedantic -I./
-LDFLAGS += -lcheck $(dstdir)/libcutils.o
-
-ifdef DEBUG
-CFLAGS += -ggdb -O0
-CXXFLAGS += -ggdb -O0
-endif
-
-.PHONY: all install uninstall clean mrpropre mrpropre \
- test run run-test run-test-more
-
-all: test
-
-test: $(dstdir)/tests
-
-run: run-test
-run-test: test
- $(dstdir)/tests
-
-run-test-more: test
- $(dstdir)/tests --more
-
-SOURCES=$(wildcard $(srcdir)/*.c)
-HEADERS=$(wildcard $(srcdir)/*.h)
-OBJECTS=$(SOURCES:%.c=%.o)
-
-$(dstdir)/tests: $(OBJECTS) $(dstdir)/libcutils-check.o
- mkdir -p $(dstdir)
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(dstdir)/libcutils-check.o -o $@
-
-clean:
- rm -f $(srcdir)/*.o
-
-mrproper: mrpropre
-mrpropre: clean
- rm -f $(dstdir)/tests
- rmdir $(dstdir) 2>/dev/null || true
-
+++ /dev/null
-#include <check.h>
-#include <stdio.h>
-
-#include "cutils/cutils.h"
-#include "cutils/check/launcher.h"
-
-SRunner *runner = NULL;
-void add_test(Suite *test);
-
-SRunner *get_tests(int more) {
- return runner;
-}
-
-void add_test(Suite *test) {
- if (!runner) {
- runner = srunner_create(test);
- } else {
- srunner_add_suite(runner, test);
- }
-}
-