Skip to content

Instantly share code, notes, and snippets.

@r10r
Created February 10, 2014 15:15
Show Gist options
  • Save r10r/8917669 to your computer and use it in GitHub Desktop.
Save r10r/8917669 to your computer and use it in GitHub Desktop.
Ragel state machine generation
MACHINES=$(shell ls *.rl | xargs basename -s .rl)
CFLAGS= -O0 -g
RFLAGS= -V
# pattern rules
# see https://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html#Pattern-Rules
%.o : %.c
gcc $(CFLAGS) -o $@ $<
%.dot : %.rl
ragel -V -o $@ $<
%.png : %.dot
dot -Tpng $< -o $@
%.c : %.rl
ragel -o $@ $<
# static pattern rule (for tab completion sake)
# see http://www.gnu.org/software/make/manual/html_node/Static-Usage.html#Static-Usage
$(MACHINES): %: %.c %.png
gcc $(CFLAGS) -o $@ $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment