lex/ast-lex-yacc/Makefile

29 lines
566 B
Makefile
Raw Normal View History

BUILDDIR = build
OUT = main
SRC_DIR = src
INCLUDE_DIR = inc
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 -Wall -I$(INCLUDE_DIR) $(SRC_DIR)/extio.c $(BUILDDIR)/yacc.yy.c $(BUILDDIR)/lex.yy.c -o $(BUILDDIR)/$(OUT)
# generate c file for lex
lex.yy.c:
flex -o $(BUILDDIR)/lex.yy.c $(SRC_DIR)/lexer.l
# generate c file for yacc
yacc.yy.c:
yacc -d -o $(BUILDDIR)/yacc.yy.c $(SRC_DIR)/parser.y
clean: # wipe the build directory
rm -f $(BUILDDIR)/*