summaryrefslogtreecommitdiff
path: root/Makefile
blob: e62c90c6530f67f2b450462a3eda83060dbe5298 (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
OPTFLAGS = -O2
CFLAGS   = -std=c99 -D_POSIX_C_SOURCE=200809L $(OPTFLAGS)

TARGETS  = pattern2regex
LEXERS   = $(wildcard *.l)
PARSERS  = $(wildcard *.y)
SOURCES  = $(wildcard *.c)
OBJECTS  = $(sort $(SOURCES:.c=.o) $(LEXERS:.l=.o) $(PARSERS:.y=.o))

all: $(TARGETS)

clean:
	rm -f $(TARGETS)
	rm -f $(OBJECTS)
	rm -f $(LEXERS:.l=.c) $(LEXERS:.l=.h)
	rm -f $(PARSERS:.y=.c) $(PARSERS:.y=.h)

lex-%.c lex-%.h: lex-%.l
	flex $<

parse-%.c parse-%.h: parse-%.y
	bison $<

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

pattern2regex.o: lex-pattern.h parse-pattern.h
pattern2regex: pattern2regex.o lex-pattern.o parse-pattern.o ast.o

$(TARGETS):
	$(CC) $(CFLAGS) $^ -o $@