-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
169 lines (150 loc) · 4.2 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Makefile for Insanity C Compiler
CC=g++
CFLAGS=-std=c++11 -Iinclude -g
PROGRAM=scc.out
OBJECTS=\
parser/c.tab.o \
parser/c.yy.o \
parser/specifiers.tab.o \
\
datatype/CTypes.o \
datatype/DataType.o \
datatype/PrimitiveDataType.o \
datatype/VoidDataType.o \
datatype/CharDataType.o \
datatype/UnsignedCharDataType.o \
datatype/ShortDataType.o \
datatype/UnsignedShortDataType.o \
datatype/IntDataType.o \
datatype/UnsignedIntDataType.o \
datatype/LongDataType.o \
datatype/UnsignedLongDataType.o \
datatype/LongLongDataType.o \
datatype/UnsignedLongLongDataType.o \
datatype/FloatDataType.o \
datatype/DoubleDataType.o \
datatype/LongDoubleDataType.o \
datatype/PointerDataType.o \
datatype/ArrayDataType.o \
datatype/FunctionDataType.o \
datatype/CollectionDataType.o \
datatype/StructDataType.o \
datatype/UnionDataType.o \
datatype/EnumDataType.o \
\
expression/Expression.o \
expression/CommaExpression.o \
expression/AssignmentExpression.o \
expression/CastExpression.o \
expression/ConstantExpression.o \
expression/StringExpression.o \
expression/IdentifierExpression.o \
expression/BracketExpression.o \
expression/FunctionCallExpression.o \
expression/UnaryExpression.o \
expression/MinusExpression.o \
expression/NotExpression.o \
expression/ComplementExpression.o \
expression/DereferenceExpression.o \
expression/AddressOfExpression.o \
expression/SizeofExpression.o \
expression/AlignofExpression.o \
expression/BinaryExpression.o \
expression/AdditionExpression.o \
expression/SubtractionExpression.o \
expression/MultiplicationExpression.o \
expression/DivisionExpression.o \
expression/ModulusExpression.o \
expression/LeftShiftExpression.o \
expression/RightShiftExpression.o \
expression/LessThanExpression.o \
expression/GreaterThanExpression.o \
expression/LessThanOrEqualExpression.o \
expression/GreaterThanOrEqualExpression.o \
expression/EqualsExpression.o \
expression/NotEqualsExpression.o \
expression/BitwiseAndExpression.o \
expression/BitwiseOrExpression.o \
expression/BitwiseXorExpression.o \
expression/LogicalAndExpression.o \
expression/LogicalOrExpression.o \
expression/ConditionalExpression.o \
expression/OperatorEvaluator.o \
\
statement/Statement.o \
statement/EmptyStatement.o \
statement/DeclarationStatement.o \
statement/LabelStatement.o \
statement/CaseStatement.o \
statement/DefaultCaseStatement.o \
statement/CompoundStatement.o \
statement/ExpressionStatement.o \
statement/IfStatement.o \
statement/SwitchStatement.o \
statement/GotoStatement.o \
statement/WhileStatement.o \
statement/DoWhileStatement.o \
statement/ForStatement.o \
statement/ContinueStatement.o \
statement/BreakStatement.o \
statement/ReturnStatement.o \
\
visitor/ExpressionVisitor.o \
visitor/StatementVisitor.o \
visitor/DataTypeVisitor.o \
visitor/PrintDataType.o \
visitor/PrintExpression.o \
visitor/PrintStatement.o \
\
declaration/Declaration.o \
declaration/Declarator.o \
declaration/Parameter.o \
declaration/Member.o \
declaration/EnumConstant.o \
declaration/FunctionDefinition.o \
declaration/SpecifierQualifierBuilder.o \
\
factory/DataTypeFactory.o \
factory/PointerFactory.o \
factory/ArrayFactory.o \
factory/FunctionFactory.o \
\
TranslationUnit.o \
scc.o \
# Add the source directory
OBJECTS := $(OBJECTS:%=src/%)
SOURCES := $(OBJECTS:%.o=%.cpp)
all: $(PROGRAM)
$(PROGRAM): $(OBJECTS)
$(CC) $(CFLAGS) $^ -o $@
%.o: %.cpp
$(CC) -c $(CFLAGS) $< -o $@
# Build the parser (using a Bison file)
%.tab.o: %.tab.cpp
%.tab.cpp: %.y
bison --defines=$(@:%.cpp=%.h) -o $@ $< -v
# Build the lexer (using a Flex file)
%.yy.o: %.yy.cpp
%.yy.cpp: %.l
flex --header-file=$(@:%.cpp=%.h) -o $@ $<
# Run the linters
# Add targets for linting the code
ALL_SOURCE_FILES = $(shell find ./ -regex '.*\.\(c\|cpp\|h\|hpp\)$$')
.PHONY: lint
lint: format tidy
.PHONY: format
format:
clang-format -i -style=file $(ALL_SOURCE_FILES)
.PHONY: tidy
tidy:
clang-tidy $(ALL_SOURCE_FILES) -config='' -fix-errors -- -Iinclude
# Run the file
.PHONY: run
run: $(PROGRAM)
./$(PROGRAM)
# Remove all files
.PHONY: clean
clean:
rm -f $(PROGRAM) $(OBJECTS)
rm -f src/parser/c.tab.cpp src/parser/c.yy.cpp src/parser/c.output
rm -f src/parser/c.tab.h src/parser/c.yy.h