-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (41 loc) · 1.32 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
50
51
52
53
54
55
56
CXXFLAGS := -g -std=c++11 -Wall -pedantic -DDEBUG
MAKEFLAGS += --quiet
LIB := -L lib -lstdc++
INC := -I include
INC_TEST := -I external/catch -I test/include
BIN_DIR := bin
SRC_DIR := src
BUILD_DIR := build
TEST_DIR := test
LIB_TARGET := $(BIN_DIR)/libgfs.a
TEST_TARGET := $(BIN_DIR)/testrunner
TICKET_TARGET := $(BIN_DIR)/ticket
SRC_EXT := cpp
SOURCES := $(shell find $(SRC_DIR) -type f -name *.$(SRC_EXT))
TESTS := $(shell find $(TEST_DIR) -type f -name *.$(SRC_EXT))
OBJECTS := $(patsubst $(SRC_DIR)/%,$(BUILD_DIR)/%,$(SOURCES:.$(SRC_EXT)=.o))
$(LIB_TARGET): $(OBJECTS)
@echo 'linking... $@'
mkdir -p $(BIN_DIR)
ar rcs $@ $^
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.$(SRC_EXT)
@echo 'compiling $^'
mkdir -p $(BUILD_DIR)/ecs $(BUILD_DIR)/math $(BUILD_DIR)/event
$(CXX) $(CXXFLAGS) $(INC) -c -o $@ $<
clean:
@echo 'cleaning...'
$(RM) -r $(BUILD_DIR) $(LIB_TARGET) $(TEST_TARGET) $(TICKET_TARGET)
$(RM) -r $(TEST_TARGET).dSYM $(TICKET_TARGET).dSYM
test: $(TEST_TARGET)
@echo 'running tests...'
./$<
$(TEST_TARGET): $(TESTS) $(LIB_TARGET)
@echo 'building test runner...'
$(CXX) $(CXXFLAGS) $(LIB) $(INC) $(INC_TEST) -o $@ $^
ticket: $(TICKET_TARGET)
@echo 'running ticket'
./$<
$(TICKET_TARGET): spikes/ticket.cpp $(LIB_TARGET)
@echo 'building ticket...'
$(CXX) $(CXXFLAGS) $(LIB) $(LIB_TARGET) $(INC) $^ -o $@
.PHONY: clean