From 2a0a69c917c4108632cb6b186d5042c22e6b39c4 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Tue, 5 Apr 2016 04:16:46 -0400 Subject: [PATCH] Update Makefile to be more useful for hackers --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4c243678..16f8f328 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ # along with this program. If not, see . SHELL = /bin/bash -.PHONY: all version program path deps run race build clean test format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms copr +.PHONY: all version program path deps run race generate build clean test format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms copr .SILENT: clean SVERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --dirty --always) @@ -60,16 +60,18 @@ run: race: find -maxdepth 1 -type f -name '*.go' -not -name '*_test.go' | xargs go run -race -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" +generate: + go generate + build: $(PROGRAM) $(PROGRAM): main.go @echo "Building: $(PROGRAM), version: $(SVERSION)..." - go generate ifneq ($(OLDGOLANG),) @# avoid equals sign in old golang versions eg in: -X foo=bar - go build -ldflags "-X main.program $(PROGRAM) -X main.version $(SVERSION)" -o $(PROGRAM); + time go build -ldflags "-X main.program $(PROGRAM) -X main.version $(SVERSION)" -o $(PROGRAM); else - go build -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM); + time go build -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM); endif $(PROGRAM).static: main.go @@ -84,13 +86,13 @@ endif clean: [ ! -e $(PROGRAM) ] || rm $(PROGRAM) - rm -f *_stringer.go # generated by `go generate` + #rm -f *_stringer.go # generated by `go generate` test: ./test.sh format: - find -type f -name '*.go' -not -path './old/*' -not -path './tmp/*' -exec gofmt -w {} \; + find -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not -path './tmp/*' -exec gofmt -w {} \; find -type f -name '*.yaml' -not -path './old/*' -not -path './tmp/*' -not -path './omv.yaml' -exec ruby -e "require 'yaml'; x=YAML.load_file('{}').to_yaml.each_line.map(&:rstrip).join(10.chr)+10.chr; File.open('{}', 'w').write x" \; docs: $(PROGRAM)-documentation.pdf