summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 31 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e62c90c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,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 $@