-
Notifications
You must be signed in to change notification settings - Fork 118
/
Makefile
48 lines (38 loc) · 866 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
# Macros para compilacao
CC = gcc
CFLAGS = -Wextra
DIR = src
FILENAME = $(DIR)/main.c
OBJNAME = $(DIR)/main.o
TARGET = ./main
SRCS := $(shell find $(DIR) -name '*.c')
OBJS = $(SRCS:.c=.o)
LEX = lex
LEXSRCS := $(shell find $(DIR) -name '*.l')
LEXFLAGS = -ll
# Macros para teste
BASH = sh
TEST_SCRIPT = test.sh
VERBOSE ?= 1
# Macros para construcao do zip
ZIP = zip
USERNAME ?= $(USER)
ZIPFILE = $(USERNAME).zip
EXTENSIONS = *.l *.c *.h *.in *.out *.sh
.PHONY: depend clean
all:lex $(TARGET)
$(TARGET):$(OBJNAME)
$(CC) -o$(TARGET) $(OBJNAME) $(CFLAGS) $(LEXFLAGS)
$(OBJNAME):$(FILENAME)
$(CC) $(CFLAGS) -c $< -o $@
lex:$(LEXSRCS)
$(LEX) -o$(FILENAME) $(LEXSRCS)
test:all
$(BASH) $(TEST_SCRIPT) $(TARGET) $(VERBOSE)
zip:clean
$(ZIP) -R $(ZIPFILE) Makefile $(EXTENSIONS)
clean:
$(RM) $(FILENAME)
$(RM) ./$(TARGET)
$(RM) $(DIR)/*.o
$(RM) ./$(ZIPFILE)