-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (42 loc) · 1.34 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
57
58
CXX ?= g++
INCLUDE_DIR ?= -I./include -Igfalibs/include
WARNINGS = -Wall -Wextra
CXXFLAGS = -g -std=gnu++17 -O3 $(INCLUDE_DIR) $(WARNINGS) $(CFLAGS)
TARGET = teloscope
TEST_TARGET = validate
GENERATE_TARGET = generate-tests
BUILD = build/bin
SOURCE = src
INCLUDE = include
BINDIR := $(BUILD)/.o
LIBS = -lz
LDFLAGS = -pthread
GFALIBS_DIR := $(CURDIR)/gfalibs
OBJS := main teloscope input tools
BINS := $(addprefix $(BINDIR)/, $(OBJS))
head: $(BINS) gfalibs | $(BUILD)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(BUILD)/$(TARGET) $(wildcard $(BINDIR)/*) $(GFALIBS_DIR)/*.o $(LIBS)
debug: CXXFLAGS += -DDEBUG
debug: CCFLAGS += -DDEBUG
debug: head
all: head validate regenerate
$(OBJS): %: $(BINDIR)/%
@
$(BINDIR)%: $(SOURCE)/%.cpp $(INCLUDE)/%.h | $(BINDIR)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -c $(SOURCE)/$(notdir $@).cpp -o $@
.PHONY: gfalibs
gfalibs:
$(MAKE) -j -C $(GFALIBS_DIR) CXXFLAGS="$(CXXFLAGS)"
validate: | $(BUILD)
$(CXX) $(CXXFLAGS) -o $(BUILD)/$(TARGET)-$(TEST_TARGET) $(SOURCE)/$(TEST_TARGET).cpp $(LIBS)
regenerate: | $(BUILD)
$(CXX) $(CXXFLAGS) -o $(BUILD)/$(TARGET)-$(GENERATE_TARGET) $(SOURCE)/$(GENERATE_TARGET).cpp $(LIBS)
$(BUILD):
-mkdir -p $@
$(BINDIR):
-mkdir -p $@
debug: CXXFLAGS += -DDEBUG -O0
debug: head
clean:
$(RM) -r build
$(MAKE) -C $(GFALIBS_DIR) clean