diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /support/xhpast/parser.yacc.output /support/xhpast/node_names.hpp /support/xhpast/xhpast +/support/xhpast/xhpast.exe /src/parser/xhpast/bin/xhpast ## NOTE: Don't .gitignore these files! Even though they're build artifacts, we @@ -23,9 +24,6 @@ # This is an OS X build artifact. /support/xhpast/xhpast.dSYM -# This is a Windows build artifact. -/support/xhpast/xhpast.exe - # libphutil /src/.phutil_module_cache /support/phutiltestlib/.phutil_module_cache diff --git a/support/xhpast/Makefile b/support/xhpast/Makefile --- a/support/xhpast/Makefile +++ b/support/xhpast/Makefile @@ -1,4 +1,4 @@ -BISONFLAGS = --verbose -d -Wall +BISONFLAGS = --verbose -Wall CPPFLAGS = -fPIC -Wall FLEXFLAGS = -CFr @@ -24,47 +24,45 @@ ROOT = ../../src/parser/xhpast +.PHONY: all all: xhpast clean: - -rm xhpast parser.yacc.output libxhpast.a *.o 2>/dev/null + rm --force xhpast parser.yacc.output libxhpast.a *.o cleanall: clean - -rm scanner.lex.cpp scanner.lex.hpp parser.yacc.cpp parser.yacc.hpp + rm --force scanner.lex.hpp scanner.lex.cpp parser.yacc.hpp parser.yacc.cpp + rm --force node_names.hpp parser_nodes.php +.PHONY: install install: xhpast cp xhpast $(ROOT)/bin/xhpast -scanner: scanner.l - flex $(FLEXFLAGS) --header-file=scanner.lex.hpp --outfile=scanner.lex.cpp $< - echo '/* @gen''er''ated */' >> scanner.lex.cpp - echo '/* @gen''er''ated */' >> scanner.lex.hpp +.PHONY: parser scanner +parser: parser.yacc.hpp parser.yacc.cpp +scanner: scanner.lex.hpp scanner.lex.cpp -parser: parser.y - bison $(BISONFLAGS) --output=parser.yacc.cpp $< - echo '/* @gen''er''ated */' >> parser.yacc.cpp - echo '/* @gen''er''ated */' >> parser.yacc.hpp +%.lex.hpp %.lex.cpp: %.l + flex $(FLEXFLAGS) --header-file=$*.lex.hpp --outfile=$*.lex.cpp $< + @echo '/* @gen''er''ated */' >> $*.lex.hpp + @echo '/* @gen''er''ated */' >> $*.lex.cpp -node_names.hpp: generate_nodes.php - php -f generate_nodes.php - cp parser_nodes.php $(ROOT)/ +%.yacc.hpp %.yacc.cpp: %.y + bison $(BISONFLAGS) --defines=$*.yacc.hpp --output=$*.yacc.cpp $< + @echo '/* @gen''er''ated */' >> $*.yacc.hpp + @echo '/* @gen''er''ated */' >> $*.yacc.cpp %.o: %.cpp $(CXX) -c $(CPPFLAGS) -o $@ $< -needparserscanner: - @([ -e parser.yacc.hpp ] && [ -e parser.yacc.cpp ] && \ - [ -e scanner.lex.hpp ] && [ -e scanner.lex.cpp ]) \ - || (echo "Run 'make parser scanner' first.'" && exit 1) +node_names.hpp parser_nodes.php: generate_nodes.php + php -f $< -parser.yacc.o: needparserscanner scanner.lex.hpp - -scanner.lex.o: needparserscanner parser.yacc.hpp node_names.hpp scanner.lex.hpp +parser.yacc.o: scanner.lex.hpp +scanner.lex.o: parser.yacc.hpp node_names.hpp scanner.lex.hpp libxhpast.a: scanner.lex.o parser.yacc.o $(AR) -crs $@ $^ xhpast: xhpast.cpp libxhpast.a $(CXX) $(CPPFLAGS) -o $@ $^ - -.PHONY: all clean