-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (85 loc) · 2.48 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
CC = g++
LEXER = flex
PARSER = bison
CFLAGS = -std=c++11 -g -Iinclude/
LDFLAGS =
BUILDDIR = build
DEPSDIR = include
LEXDIR = flex
PARSEDIR = bison
DESCDIR = rdparser
SYMDIR = symtable
CODDIR = codegen
TARGET = rjicomp
FLEXTARGET = rjilex
BISONTARGET = rjiparse
DRPTARGET = parser
SYMTARGET = symtable
CODTARGET = codegen
RJIDIST = romaji-diegosainzdemedrano.zip
# necessary files
COD_O = $(BUILDDIR)/$(CODTARGET).o
COD_C = $(CODDIR)/$(CODTARGET).cpp
PAR_O = $(BUILDDIR)/$(DRPTARGET).o
PAR_C = $(DESCDIR)/$(DRPTARGET).cpp
SYM_O = $(BUILDDIR)/$(SYMTARGET).o
SYM_C = $(SYMDIR)/$(SYMTARGET).cpp
TAB_O = $(BUILDDIR)/$(BISONTARGET).tab.o
TAB_C = $(BUILDDIR)/$(BISONTARGET).tab.c
TAB_Y = $(PARSEDIR)/$(BISONTARGET).y
LEX_O = $(BUILDDIR)/$(FLEXTARGET).yy.o
LEX_C = $(BUILDDIR)/$(FLEXTARGET).yy.c
LEX_L = $(LEXDIR)/$(FLEXTARGET).l
.PHONY: all clean clean_compiled pack
all: before rdparser_comp
@echo "Target \"$(TARGET)\" built. Bailing."
before:
[ -d $(BUILDDIR) ] || mkdir -p $(BUILDDIR)
clean:
rm -f $(BUILDDIR)/*.o $(BUILDDIR)/*.c $(BUILDDIR)/*.h $(BUILDDIR)/*.output $(DEPSDIR)/*.gch $(TARGET) ./source/valid/*.q.c ./$(RJIDIST)
clean_compiled:
rm -f ./source/valid/*.q.c
pack:
@echo -e "Generando comprimido de la distribución de Romaji..."
@git archive --format=zip -o $(RJIDIST) master
rdparser_comp: $(PAR_O) $(LEX_O) $(SYM_O) $(COD_O)
@echo -e "\nLinking $^"
$(CC) -o $(TARGET) $^ $(LDFLAGS)
@echo -e "------------"
bison_comp: _lexer_with_bison _bison_comp
_bison_comp: $(TAB_O) $(LEX_O)
@echo -e "\nLinking $^"
$(CC) -o $(TARGET) $^ $(LDFLAGS)
@echo -e "------------"
$(COD_O): $(COD_C)
@echo -e "\nCompiling the code generation module"
$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "------------"
$(PAR_O): $(PAR_C)
@echo -e "\nCompiling the recursive descent parser"
$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "------------"
$(SYM_O): $(SYM_C)
@echo -e "\nCompiling the symbol table module"
$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "------------"
$(TAB_O): $(TAB_C)
@echo -e "\nCompiling $^"
$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "------------"
_lexer_with_bison: $(LEX_C)
@echo -e "\nCompiling $^ (using the bison parser)"
$(CC) -o $@ -c $< $(CFLAGS) -D_USING_BISON_PARSER
@echo -e "------------"
$(LEX_O): $(LEX_C)
@echo -e "\nCompiling $^"
$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "------------"
$(TAB_C): $(TAB_Y)
@echo -e "\nGenerating parser"
$(PARSER) -dv $< -o $@
@echo -e "------------"
$(LEX_C): $(LEX_L)
@echo -e "\nGenerating lex scanner"
$(LEXER) -o $@ $<
@echo -e "------------"