-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
61 lines (49 loc) · 1.59 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
# Directories
SRC_DIR = ./src
OBJ_DIR = ./obj
COMMANDS_SRC_DIR = ./src/commands
COMMAND_OBJ_DIR = ./obj/commands
EXEC_DIR = ./bin
INCLUDE_DIR = ./include/
# Compiler flags
CXX = clang++ -std=c++11
CXXFLAGS = -g -I $(INCLUDE_DIR)
# Source files and corresponding object files
SRC := $(wildcard $(SRC_DIR)/*.cpp)
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRC))
COMMANDS_SRC := $(wildcard $(COMMANDS_SRC_DIR)/*.cpp)
COMMANDS_OBJS = $(patsubst $(COMMANDS_SRC_DIR)/%.cpp, $(COMMAND_OBJ_DIR)/%.o, $(COMMANDS_SRC))
LEXER_SRC = ./src/lexer.l
PARSER_SRC = ./src/parser.y
PARSER_OBJS = ./obj/parser.o ./obj/lexer.o
# ****************************************************
# Targets needed to bring the executable up to date
all: server
server: $(PARSER_OBJS) $(OBJS) $(COMMANDS_OBJS)
$(CXX) $(CXXFLAGS) -o ./bin/$@ $(OBJS) $(COMMANDS_OBJS) $(PARSER_OBJS)
# cp /Users/amit/Downloads/matrix.csv ./data/matrix.csv
./bin/server
print:
echo $(COMMANDS_OBJS)
echo "\n"
echo $(COMMAND_OBJ_DIR)
clean:
rm -rf obj/*
rm -f bin/server
rm -f log
rm -rf data/temp/*
rm -rf data/exports/*
mkdir ./obj/commands
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(INCLUDE_DIR)/globals.h
$(CXX) $(CXXFLAGS) -c -o $@ $<
$(COMMAND_OBJ_DIR)/%.o: $(COMMANDS_DIR)/.cpp $(INCLUDE_DIR)/globals.h
$(CXX) $(CXXFLAGS) -c -o $@ $<
$(PARSER_OBJS): $(LEXER_SRC) $(PARSER_SRC)
flex $(LEXER_SRC)
bison -d $(PARSER_SRC)
mv lex.yy.c lex.yy.cpp
mv parser.tab.c parser.tab.cpp
mv parser.tab.h include/parser.tab.h
$(CXX) $(CXXFLAGS) -c -o obj/lexer.o lex.yy.cpp
$(CXX) $(CXXFLAGS) -c -o obj/parser.o parser.tab.cpp
rm -f parser.tab.cpp lex.yy.cpp