This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
54 lines (44 loc) · 2.13 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
CC = gcc
CCFLAGS = -g -Wall -Wpedantic
DEFINES = __NO_DEBUG __MY_OWN_DATA_ELE
AST_DIR = ./ast
LEXER_DIR = ./lexer
PARSER_DIR = ./parser
ST_DIR = ./symboltable
UTILS_DIR = ./utils
TYPECHECK_DIR = ./typecheck
CODEGEN_DIR = ./codegen
AST_CFILES_NAMES = ast.c semantic_functions_ast.c to_remove.c
LEXER_CFILES_NAMES = lexer.c populate_dfa.c token.c transition.c twin_buffer.c
PARSER_CFILES_NAMES = parser.c populate_grammer.c parse_table.c tree_utils.c
ST_CFILES_NAMES = symbolTable.c st_utils.c
UTILS_CFILES_NAMES = hash.c SeqList.c Stack.c tree_to_json.c
TYPECHECK_CFILES_NAMES = typecheck.c typecheck_functions.c
CODEGEN_CFILES_NAMES = code_gen.c code_gen_semantic.c
MAIN_FILE = ./driver.c
INCLUDES = $(addprefix -I , $(addsuffix /includes, $(AST_DIR) $(LEXER_DIR) $(PARSER_DIR) $(ST_DIR) $(UTILS_DIR) $(TYPECHECK_DIR) $(CODEGEN_DIR) ) )
DEFINE_ARGS = $(addprefix -D ,$(DEFINES))
GCC_CMD = $(CC) $(CCFLAGS) $(DEFINE_ARGS) $(INCLUDES)
AST_CFILES = $(addprefix $(AST_DIR)/,$(AST_CFILES_NAMES))
AST_OFILES = $(addsuffix .o, $(basename $(AST_CFILES)))
LEXER_CFILES = $(addprefix $(LEXER_DIR)/,$(LEXER_CFILES_NAMES))
LEXER_OFILES = $(addsuffix .o, $(basename $(LEXER_CFILES)))
PARSER_CFILES = $(addprefix $(PARSER_DIR)/,$(PARSER_CFILES_NAMES))
PARSER_OFILES = $(addsuffix .o, $(basename $(PARSER_CFILES)))
ST_CFILES = $(addprefix $(ST_DIR)/,$(ST_CFILES_NAMES))
ST_OFILES = $(addsuffix .o, $(basename $(ST_CFILES)))
UTILS_CFILES = $(addprefix $(UTILS_DIR)/,$(UTILS_CFILES_NAMES))
UTILS_OFILES = $(addsuffix .o, $(basename $(UTILS_CFILES)))
TYPECHECK_CFILES = $(addprefix $(TYPECHECK_DIR)/,$(TYPECHECK_CFILES_NAMES))
TYPECHECK_OFILES = $(addsuffix .o, $(basename $(TYPECHECK_CFILES)))
CODEGEN_CFILES = $(addprefix $(CODEGEN_DIR)/,$(CODEGEN_CFILES_NAMES))
CODEGEN_OFILES = $(addsuffix .o, $(basename $(CODEGEN_CFILES)))
ALL_CFILES = $(AST_CFILES) $(LEXER_CFILES) $(PARSER_CFILES) $(ST_CFILES) $(UTILS_CFILES) $(TYPECHECK_CFILES) $(CODEGEN_CFILES)
ALL_OFILES = $(addsuffix .o, $(basename $(ALL_CFILES)))
all: compiler
compiler: $(ALL_OFILES) $(MAIN_FILE)
$(GCC_CMD) $(ALL_OFILES) $(MAIN_FILE) -o compiler
%.o: %.c $(ALL_CFILES)
$(GCC_CMD) -c -o $@ $<
clean:
rm $(ALL_OFILES)