-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
58 lines (45 loc) · 1.08 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
ifeq ($(OS),Windows_NT)
SHELL := cmd.exe
LIB := parser.lib
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
SHELL := bash
LIB := libparser.a
endif
ifeq ($(UNAME_S),Darwin)
SHELL := zsh
LIB := libparser.a
endif
endif
CC := gcc -g
LEX := flex
YACC := bison
CFLAGS := -w -std=c11
DEBUG_CFLAGS := $(CFLAGS) -DDEBUG
LDCFLAGS := -w -std=c11 -fPIC
OBJS := lexer.o ast.o parser.tab.o
PROGRAMS := sql_parser
.SUFFIXES: .l .y .c .h
.PHONY: clean debug
# all: ${PROGRAMS}
static: parser.tab.o lexer.o ast.o
ar -rc $(LIB) $(OBJS)
dynamic: parser.tab.o lexer.o ast.o
${CC} ${LDCFLAGS} -shared $(OBJS) -o $(LIB)
parser: parser.tab.o lexer.o ast.o
$(CC) $(CFLAGS) -o $@ lexer.o ast.o parser.tab.o
lexer.o: lexer.c
$(CC) $(CFLAGS) -c $< -o $@
ast.o: ast.c ast.h
${CC} ${CFLAGS} -c $< -o $@
parser.tab.o: parser.tab.c
${CC} ${CFLAGS} -c parser.tab.c -o $@
parser.tab.c: parser.y lexer.c
${YACC} -vd parser.y
lexer.c: lexer.l
${LEX} -o $*.c $<
clean:
rm -f lexer.c *.o parser.tab.c parser.tab.h *.output lib*
debug:
$(CC) $(DEBUG_CFLAGS) -c parser.tab.c -o parser.o