blob: 079f32106c8aac32baa2e0b20e73f3f1c06d33b2 (
plain)
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
|
CC = gcc
LEX = flex
YAXX = bison
CFLAGS = -Wall -Wextra -std=c11 -g -I. -D_GNU_SOURCE
LDFLAGS = -lfl
ifneq ($(DEBUG),)
CFLAGS += -DDEBUG=$(value DEBUG)
endif
ifeq ($(shell uname), Darwin)
LDFLAGS += -L/usr/local/opt/flex/lib
CFLAGS += -I/usr/local/opt/flex/include
endif
TARGET = ccomp
.PHONY: all clean
all: $(TARGET)
clean:
rm -f $(TARGET) *.o
rm -rf bison-out
bison-out/y.tab.c bison-out/y.tab.h: c.y
@mkdir -p bison-out
bison -d -b bison-out/y c.y
bison-out/lex.yy.c: c.l
@mkdir -p bison-out
flex -o bison-out/lex.yy.c c.l
$(TARGET): $(wildcard *.c) $(wildcard *.h) bison-out/y.tab.c bison-out/lex.yy.c
$(CC) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@
|