-
Notifications
You must be signed in to change notification settings - Fork 58
/
Makefile
53 lines (42 loc) · 934 Bytes
/
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
# Macros para compilacao
CC = gcc
CFLAGS = -Wextra -lfl
DIR = src
FILENAME = $(DIR)/main.c
YYTABH = $(DIR)/y.tab.h
YYTABC = $(DIR)/y.tab.c
LEXOUT = $(DIR)/lex.yy.c
YACCFILE = $(DIR)/main.y
LEXFILE = $(DIR)/main.l
TARGET = ./main
BJS = $(SRCS:.c=.o)
YACC = bison
LEX = flex
# Macros para teste
BASH = sh
TEST_SCRIPT = test.sh
VERBOSE ?= 1
# Macros para construcao do zip
ZIP = zip
USERNAME ?= $(USER)
ZIPFILE = $(USERNAME).zip
EXTENSIONS = *.c *.h *.in *.out *.sh
.PHONY: depend clean
all:$(TARGET)
$(TARGET):$(LEXOUT) $(YYTABC)
$(CC) -o$(TARGET) $(LEXOUT) $(YYTABC) $(CFLAGS)
$(LEXOUT):$(LEXFILE) $(YYTABC)
$(LEX) -o$(LEXOUT) $(LEXFILE)
$(YYTABC):$(YACCFILE)
$(YACC) -o$(YYTABC) -dy $(YACCFILE)
test:all
$(BASH) $(TEST_SCRIPT) $(TARGET) $(VERBOSE)
zip:clean
$(ZIP) -R $(ZIPFILE) Makefile $(EXTENSIONS)
clean:
$(RM) $(YYTABC)
$(RM) $(YYTABH)
$(RM) $(LEXOUT)
$(RM) ./$(TARGET)
$(RM) $(DIR)/*.o
$(RM) ./$(ZIPFILE)