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 print-regex.o regex.o $(TARGETS): $(CC) $(CFLAGS) $^ -o $@