X-Git-Url: https://git.llucax.com/software/mutest.git/blobdiff_plain/cb606e44a187f9ece06dfd134e9ded8cdcf8f1b8..ab22fdd3f1e817a4ab3a05d76366f14c06dfad6d:/sample/Makefile diff --git a/sample/Makefile b/sample/Makefile index aa5ec8f..a225aa0 100644 --- a/sample/Makefile +++ b/sample/Makefile @@ -11,52 +11,66 @@ # # Show the tests summary -V=-v +V = -v + +# Set to 0 if you don't want to compile the C++ test suite +CPP_SUITE = 1 CFLAGS = -Wall -std=c89 +CXXFLAGS = -Wall -std=c++98 +LD = $(CC) TARGET = tester -SUITES_RUNNER_SRC = test_suite_runner.c +RUNNER_SRC = test_suite_runner.c MKMUTEST = ../mkmutest +MUTEST = ../mutest MUTEST_H = ../mutest.h MUTEST_C = ../mutest.c OBJS = factorial.o sum.o -TESTS = factorial_test.o sum_test.o init_fail_test.o -MUTEST = mutest.o -SUITES_RUNNER = $(SUITES_RUNNER_SRC:.c=.o) -SO = factorial.so sum.so init_fail_test.so -ALL = $(SUITES_RUNNER) $(OBJS) $(TESTS) $(MUTEST) +TEST_OBJS = factorial_test.o sum_test.o init_fail_test.o +MUTEST_OBJ = mutest.o +RUNNER_OBJ = $(RUNNER_SRC:.c=.o) +ALL_OBJS = $(RUNNER_OBJ) $(OBJS) $(TEST_OBJS) $(MUTEST_OBJ) +TEST_SOS = $(TEST_OBJS:.o=.so) + +ifeq ($(CPP_SUITE), 1) +TEST_OBJS += exception_test.o +LD = $(CXX) +endif all: $(TARGET) -py: $(SO) +py: $(TEST_SOS) -$(TARGET): $(ALL) - $(CC) $(LDFLAGS) -o $@ $^ +$(TARGET): $(ALL_OBJS) + $(LD) $(LDFLAGS) -o $@ $^ -$(SUITES_RUNNER_SRC): $(MKMUTEST) $(MUTEST_H) $(TESTS) - $(MKMUTEST) $(MUTEST_H) $(TESTS) > $@ +$(RUNNER_SRC): $(MKMUTEST_OBJ) $(MUTEST_H) $(TEST_OBJS) + $(MKMUTEST) $(MUTEST_H) $(TEST_OBJS) > $@ -factorial.so: factorial_test.c +factorial_test.so: factorial.c -sum.so: sum_test.c +sum_test.so: sum.c -$(MUTEST): ../mutest.c - $(CC) $(CFLAGS) -c -o mutest.o $^ +$(MUTEST_OBJ): $(MUTEST_C) + $(CC) $(CFLAGS) -c -o $@ $^ test: $(TARGET) ./$(TARGET) $(V) -test-py: $(SO) - ../py/mutest $(V) -a +test-py: $(TEST_SOS) + $(MUTEST) $(V) -a clean: - $(RM) $(TARGET) $(SO) $(ALL) $(SUITES_RUNNER_SRC) + $(RM) $(TARGET) $(TEST_SOS) $(ALL_OBJS) $(RUNNER_SRC) .c.so: $(CC) $(CFLAGS) $(LDFLAGS) -DMUTEST_PY -fPIC -shared -o $@ $^ +.cpp.so: + $(CXX) $(CXXFLAGS) $(LDFLAGS) -DMUTEST_PY -fPIC -shared -o $@ $^ + .SUFFIXES: .so .PHONY: all test clean