github.com/XiaoMi/Gaea@v1.2.5/parser/Makefile (about)

     1  .PHONY: all parser clean
     2  
     3  ARCH:="$(shell uname -s)"
     4  MAC:="Darwin"
     5  LINUX:="Linux"
     6  GOYACCBIN:=""
     7  ifeq ($(ARCH), $(LINUX))
     8  	GOYACCBIN=./goyacc
     9  else
    10  	ifeq ($(ARCH), $(MAC))
    11  		GOYACCBIN=./goyacc
    12  	else
    13  		GOYACCBIN=./goyacc
    14  	endif
    15  endif
    16  
    17  all: parser.go fmt
    18  
    19  test: parser.go fmt
    20  	sh test.sh
    21  
    22  parser.go: parser.y
    23  	make parser
    24  
    25  parser: goyacc
    26  	${GOYACCBIN} -o /dev/null parser.y
    27  	$(GOYACCBIN) -o parser.go parser.y 2>&1 | egrep "(shift|reduce)/reduce" | awk '{print} END {if (NR > 0) {print "Find conflict in parser.y. Please check y.output for more information."; exit 1;}}'
    28  	rm -f y.output
    29  
    30  	@if [ $(ARCH) = $(LINUX) ]; \
    31  	then \
    32  		sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' parser.go; \
    33  	elif [ $(ARCH) = $(MAC) ]; \
    34  	then \
    35  		/usr/bin/sed -i "" 's|//line.*||' parser.go; \
    36  		/usr/bin/sed -i "" 's/yyEofCode/yyEOFCode/' parser.go; \
    37  	fi
    38  
    39  	@awk 'BEGIN{print "// Code generated by goyacc DO NOT EDIT."} {print $0}' parser.go > tmp_parser.go && mv tmp_parser.go parser.go;
    40  
    41  #bin/goyacc: goyacc/main.go
    42  goyacc:
    43  	#GO111MODULE=on go build -o bin/goyacc goyacc/main.go
    44  
    45  fmt:
    46  	#@echo "gofmt (simplify)"
    47  	#@ gofmt -s -l -w . 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
    48  
    49  clean:
    50  	go clean -i ./...
    51  	rm -rf *.out
    52  	rm parser.go