From 0e92eca46d1400b1aaba23b8b8c6d617ba5a1c8c Mon Sep 17 00:00:00 2001 From: Ben Gray Date: Thu, 28 Feb 2013 10:06:14 +0000 Subject: [PATCH] updated makefile to build each test from it's own source file as libtab uses the main entry point as it's test runner --- tests/Makefile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index e785ade584ded..d6ec593ca8689 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -3,9 +3,11 @@ # libtap.so and tap.h must be in the local directory or on the system path. # ODIR is realative, so we can use the one from the main Makefile -TEST_SOURCES = $(wildcard *.cpp) -TEST__OBJS = $(TEST_SOURCES:.cpp=.o) -TEST_OBJS = $(patsubst %,$(ODIR)/%,$(TEST__OBJS)) + +# As each test will have a main function we need to handle this file by file +TEST_SOURCES = $(wildcard *_test.cpp) +TEST_OBJS = $(TEST_SOURCES:%.cpp=$(ODIR)/%.o) +TESTS = $(TEST_SOURCES:.cpp=) # Brute force solution, relative paths to EVERY .o file SOURCE_OBJS = $(patsubst %,../$(ODIR)/%,$(filter-out main.o,$(_OBJS))) @@ -14,13 +16,16 @@ LDFLAGS += -L. -ltap -lpthread CXXFLAGS += -I.. -tests: line_test +tests: $(TESTS) -line_test: $(ODIR) $(DDIR) $(TEST__OBJS) - $(CXX) $(W32FLAGS) -o line_test $(DEFINES) $(TEST__OBJS) $(SOURCE_OBJS) $(LDFLAGS) +%_test: $(ODIR) $(DDIR) $(SOURCE_OBJS) $(TEST_OBJS) + $(CXX) $(W32FLAGS) -o $@ $(DEFINES) $(ODIR)/$@.o $(SOURCE_OBJS) $(LDFLAGS) $(ODIR): mkdir $(ODIR) $(DDIR): @mkdir $(DDIR) + +$(ODIR)/%.o: %.cpp + $(CXX) $(DEFINES) $(CXXFLAGS) -c $< -o $@