-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
56 lines (42 loc) · 1.06 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
# Makefile for Truth Table Evaluator
CC=g++
CFLAGS=-std=c++11 -Iinclude -Wall
PROGRAM=TruthTable.out
OBJECTS = \
Parser/truthtable.tab.o \
Parser/truthtable.yy.o \
Main.o \
TruthTable.o \
Statement/TruthStatement.o \
Statement/IdentifierStatement.o \
Statement/LiteralStatement.o \
Statement/UnaryOperator.o \
Statement/UnaryStatement.o \
Statement/BinaryOperator.o \
Statement/BinaryStatement.o \
Statement/StatementList.o
# Add the source directory
OBJECTS := $(OBJECTS:%=src/%)
all: $(PROGRAM)
$(PROGRAM): $(OBJECTS)
$(CC) $^ -o $@
%.o: %.cpp
$(CC) -c $(CFLAGS) $< -o $@
# Build the parser (using a Bison file)
%.tab.o: %.tab.cpp
%.tab.cpp: %.y
bison -v --defines=$(@:%.cpp=%.h) -o $@ $<
# Build the lexer (using a Flex file)
%.yy.o: %.yy.cpp
%.yy.cpp: %.l
flex --header-file=$(@:%.cpp=%.h) -o $@ $<
# Run the file
.PHONY: run
run: $(PROGRAM)
./$(PROGRAM)
# Remove all files
.PHONY: clean
clean:
rm -f $(PROGRAM) $(OBJECTS)
rm -f src/Parser/truthtable.tab.cpp src/Parser/truthtable.yy.cpp
rm -f src/Parser/truthtable.tab.h src/Parser/truthtable.yy.h