Explorar el Código

Update build flags in Makefile

tags/v2.0.0-rc1
9seconds hace 5 años
padre
commit
8566cede74
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  1. 8
    2
      Makefile

+ 8
- 2
Makefile Ver fichero

9
 VERSION_GO         := $(shell go version)
9
 VERSION_GO         := $(shell go version)
10
 VERSION_DATE       := $(shell date -Ru)
10
 VERSION_DATE       := $(shell date -Ru)
11
 VERSION_TAG        := $(shell git describe --tags --always)
11
 VERSION_TAG        := $(shell git describe --tags --always)
12
-COMMON_BUILD_FLAGS := -mod=readonly -ldflags="-s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
12
+COMMON_BUILD_FLAGS := -mod=readonly -ldflags="-extldflags '-static' -s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
13
 
13
 
14
 GOBIN  := $(ROOT_DIR)/.bin
14
 GOBIN  := $(ROOT_DIR)/.bin
15
 GOTOOL := env "GOBIN=$(GOBIN)" "PATH=$(ROOT_DIR)/.bin:$(PATH)"
15
 GOTOOL := env "GOBIN=$(GOBIN)" "PATH=$(ROOT_DIR)/.bin:$(PATH)"
27
 
27
 
28
 .PHONY: static
28
 .PHONY: static
29
 static:
29
 static:
30
-	@env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
30
+	@env CGO_ENABLED=0 GOOS=linux go build \
31
+		$(COMMON_BUILD_FLAGS) \
32
+		-tags netgo \
33
+		-a \
34
+		-o "$(APP_NAME)"
31
 
35
 
32
 $(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
36
 $(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
33
 $(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
37
 $(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
35
 	@env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
39
 	@env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
36
 		go build \
40
 		go build \
37
 		$(COMMON_BUILD_FLAGS) \
41
 		$(COMMON_BUILD_FLAGS) \
42
+		-tags netgo \
43
+		-a \
38
 		-o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
44
 		-o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
39
 
45
 
40
 .PHONY: ccbuilds
46
 .PHONY: ccbuilds

Loading…
Cancelar
Guardar