-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (65 loc) · 2.38 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
SYNFIREOUT = synfire
SYNFIRESRC = SynfireMain1.cpp
SYNFIREOBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(SYNFIRESRC))
ANSWEROUT = answer
ANSWERSRC = AnsMain1.cpp ans_t.cpp \
circuit_t.cpp Device_t.cpp \
drawpix_t.cpp event_t.cpp
ANSWEROBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(ANSWERSRC))
TREEOUT = tree
TREESRC = TreeMain1.cpp
TREEOBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(TREESRC))
EXPT1OUT = expt1
EXPT1SRC = Expt1Main.cpp ans_t.cpp \
circuit_t.cpp Device_t.cpp \
drawpix_t.cpp event_t.cpp
EXPT1OBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(EXPT1SRC))
GENERICS_DIR = Generics
OBJ_DIR = obj
BIN_DIR = bin
GENERICSSRC = rand.cpp flat.cpp filename.cpp lex.cpp dumpchan.cpp dfprintf.cpp
GENERICSOBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(GENERICSSRC))
# Bash is used over sh for hashtables when building orchestrate (and probably
# other reasons).
SHELL = /bin/bash
# Smart directory creation.
MKDIR = mkdir --parents
VPATH := $(GENERICS_DIR)
OUT = gentest
CC = g++
FLAGS = -g -c -Wall -I$(GENERICS_DIR)
LFLAGS = -I$(GENERICS_DIR)
all: generics synfire answer tree
generics: check-and-reinit-submodules $(GENERICSOBJS)
synfire: $(SYNFIREOBJS) generics
@$(shell $(MKDIR) $(BIN_DIR))
$(CC) -g $(SYNFIREOBJS) $(GENERICSOBJS) -o $(BIN_DIR)/$(SYNFIREOUT) $(LFLAGS)
answer: $(ANSWEROBJS) generics
@$(shell $(MKDIR) $(BIN_DIR))
$(CC) -g $(ANSWEROBJS) $(GENERICSOBJS) -o $(BIN_DIR)/$(ANSWEROUT) $(LFLAGS)
tree: $(TREEOBJS) generics
@$(shell $(MKDIR) $(BIN_DIR))
$(CC) -g $(TREEOBJS) $(GENERICSOBJS) -o $(BIN_DIR)/$(TREEOUT) $(LFLAGS)
expt1: $(EXPT1OBJS) generics
@$(shell $(MKDIR) $(BIN_DIR))
$(CC) -g $(EXPT1OBJS) $(GENERICSOBJS) -o $(BIN_DIR)/$(EXPT1OUT) $(LFLAGS)
# Make .o files for the common things we need from the generics dir
.SECONDEXPANSION:
$(GENERICSOBJS): $$(patsubst $$(OBJ_DIR)/%.o,$$(GENERICS_DIR)/%.cpp,$$@)
@$(shell $(MKDIR) $(OBJ_DIR))
$(CC) $(FLAGS) -o $@ $< -std=c++11
# Generic rule for .o files
$(OBJ_DIR)/%.o: %.cpp
@$(shell $(MKDIR) $(OBJ_DIR))
$(CC) $(FLAGS) -o $@ $< -std=c++11
%.o: %.cpp
$(CC) $(FLAGS) -o $@ $< -std=c++11
clean:
rm -rf $(OBJ_DIR) $(BIN_DIR)
# Automagically pull in the submodule
.PHONY: check-and-reinit-submodules
check-and-reinit-submodules:
@if git submodule status | egrep -q '^[-]|^[+]' ; then \
echo "INFO: Need to reinitialize git submodules"; \
git submodule update --init; \
fi