diff --git a/.gitignore b/.gitignore index 47405867..091434c2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ old/ tmp/ *_stringer.go mgmt +mgmt.static rpmbuild/ diff --git a/Makefile b/Makefile index d1affda4..4c243678 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ USERNAME := $(shell cat ~/.config/copr 2>/dev/null | grep username | awk -F '=' SERVER = 'dl.fedoraproject.org' REMOTE_PATH = 'pub/alt/$(USERNAME)/$(PROGRAM)' -all: docs +all: docs $(PROGRAM).static # show the current version version: @@ -72,6 +72,16 @@ else go build -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM); endif +$(PROGRAM).static: main.go + @echo "Building: $(PROGRAM).static, version: $(SVERSION)..." + go generate +ifneq ($(OLDGOLANG),) + @# avoid equals sign in old golang versions eg in: -X foo=bar + go build -a -installsuffix cgo -tags netgo -ldflags '-extldflags "-static" -X main.program $(PROGRAM) -X main.version $(SVERSION)' -o $(PROGRAM).static; +else + go build -a -installsuffix cgo -tags netgo -ldflags '-extldflags "-static" -X main.program=$(PROGRAM) -X main.version=$(SVERSION)' -o $(PROGRAM).static; +endif + clean: [ ! -e $(PROGRAM) ] || rm $(PROGRAM) rm -f *_stringer.go # generated by `go generate`