makefile 955 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. SHELL := /bin/bash
  2. RAGEL := ragel
  3. GOFMT := go fmt
  4. export GO_TEST=env GOTRACEBACK=all go test $(GO_ARGS)
  5. .PHONY: build
  6. build: machine.go
  7. .PHONY: clean
  8. clean:
  9. @rm -rf docs
  10. @rm -f machine.go
  11. .PHONY: images
  12. images: docs/urn.png
  13. .PHONY: removecomments
  14. removecomments:
  15. @cd ./tools/removecomments; go build -o ../../removecomments .
  16. machine.go: machine.go.rl
  17. machine.go: removecomments
  18. machine.go:
  19. $(RAGEL) -Z -G2 -e -o $@ $<
  20. @./removecomments $@
  21. $(MAKE) -s file=$@ snake2camel
  22. $(GOFMT) $@
  23. docs/urn.dot: machine.go.rl
  24. @mkdir -p docs
  25. $(RAGEL) -Z -e -Vp $< -o $@
  26. docs/urn.png: docs/urn.dot
  27. dot $< -Tpng -o $@
  28. .PHONY: bench
  29. bench: *_test.go machine.go
  30. go test -bench=. -benchmem -benchtime=5s ./...
  31. .PHONY: tests
  32. tests: *_test.go
  33. $(GO_TEST) ./...
  34. .PHONY: snake2camel
  35. snake2camel:
  36. @awk -i inplace '{ \
  37. while ( match($$0, /(.*)([a-z]+[0-9]*)_([a-zA-Z0-9])(.*)/, cap) ) \
  38. $$0 = cap[1] cap[2] toupper(cap[3]) cap[4]; \
  39. print \
  40. }' $(file)