-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
57 lines (43 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
57
# Makefile for Insanity C Compiler
CC=g++
CFLAGS=-std=c++11 -Iinclude
PROGRAM=icc.out
OBJECTS=\
Parser/insanity.tab.o \
Parser/insanity.yy.o \
ICC.o \
InsanityProgram.o \
CodeSegments.o \
Statement/Statement.o \
Statement/CommandStatement.o \
Statement/LabelStatement.o \
Statement/JumpStatement.o \
Statement/SubroutineStatement.o \
Statement/LibraryCallStatement.o \
Statement/IfStatement.o \
Statement/StatementList.o
# Add the source directory
OBJECTS := $(OBJECTS:%=src/%)
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 $@ $<
# 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/insanity.tab.cpp src/Parser/insanity.yy.cpp
rm -f src/Parser/insanity.tab.h src/Parser/insanity.yy.h