27 lines
504 B
Makefile
27 lines
504 B
Makefile
|
|
||
|
BUILDDIR = build
|
||
|
TARGET_SRC = main
|
||
|
|
||
|
build: mkdir main
|
||
|
all: mkdir main run
|
||
|
|
||
|
mkdir: # create build directory
|
||
|
mkdir -p $(BUILDDIR)
|
||
|
|
||
|
run: # run binary
|
||
|
./$(BUILDDIR)/main
|
||
|
|
||
|
main: lex.yy.c yacc.yy.c
|
||
|
cc $(BUILDDIR)/yacc.yy.c $(BUILDDIR)/lex.yy.c -o $(BUILDDIR)/$(TARGET_SRC) -lfl
|
||
|
|
||
|
# generate c file for lex
|
||
|
lex.yy.c:
|
||
|
flex -o $(BUILDDIR)/lex.yy.c $(TARGET_SRC).l
|
||
|
|
||
|
# generate c file for yacc
|
||
|
yacc.yy.c:
|
||
|
yacc -d -o $(BUILDDIR)/yacc.yy.c $(TARGET_SRC).y
|
||
|
|
||
|
clean: # wipe the build directory
|
||
|
rm -f $(BUILDDIR)/*
|