-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (38 loc) · 1.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CXXFLAGS = -g -O2 -Wall -fmessage-length=0 -I.
# -g -fprofile-arcs -ftest-coverage
SOURCES := $(wildcard std/*.cpp)
TESTS := $(wildcard test/*.cpp)
OBJECTS := $(SOURCES:%.cpp=%.o)
TEST_OBJECTS := $(TESTS:.cpp=.o)
DEPS := $(OBJECTS:.o=.d)
TEST_DEPS := $(TEST_OBJECTS:.o=.d)
GTEST := ../googletest
GTEST_I := -I$(GTEST)/include -I.
GTEST_L := -L$(GTEST) -L.
TARGET = libstdcore.a
TEST_TARGET = test_stdcore
-include $(DEPS)
-include $(TEST_DEPS)
all: lib
lib: $(TARGET)
test: lib $(TEST_TARGET)
check: test
./$(TEST_TARGET)
$(TARGET): $(OBJECTS)
ar rvs $(TARGET) $(OBJECTS)
std/%.o: std/%.cpp
$(CXX) $(CXXFLAGS) -MM -MF $(patsubst %.o,%.d,$@) -MT $@ -c $<
$(CXX) $(CXXFLAGS) -c -o $@ $<
$(TEST_TARGET): $(TEST_OBJECTS) test/gtest_main.o
$(CXX) $(CXXFLAGS) $(GTEST_L) $^ -pthread -lstdcore -lgtest -o $(TEST_TARGET)
test/%.o: test/%.cpp
$(CXX) $(CXXFLAGS) $(GTEST_I) -MM -MF $(patsubst %.o,%.d,$@) -MT $@ -c $<
$(CXX) $(CXXFLAGS) $(GTEST_I) $< -c -o $@
test/gtest_main.o: $(GTEST)/src/gtest_main.cc
$(CXX) $(CXXFLAGS) $(GTEST_I) $< -c -o $@
clean:
rm -f std/*.o test/*.o
rm -f std/*.d test/*.d
rm -f std/*.gcda test/*.gcda
rm -f std/*.gcno test/*.gcno
rm -f $(TARGET) $(TEST_TARGET)