summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2017-07-23 22:24:32 -0500
committerBobby Bingham <koorogi@koorogi.info>2017-07-24 21:19:10 -0500
commitc8a0b7157d544f2359f2373160dcc69cdef8f4de (patch)
tree2fa9c2cc4646cab3886025a9663289b177ad4c55 /Makefile
Initial commit
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 $@