summarylogtreecommitdiffstats
path: root/mattermost-ldflags.patch
blob: 0adc81b740d74fedb844f5dbd7510c4ae6bc11a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--- Makefile	2019-12-28 12:38:41.471311251 +0100
+++ Makefile.new	2019-12-28 12:41:37.194305874 +0100
@@ -48,14 +48,23 @@
 # Golang Flags
 export GO111MODULE=on
 GOPATH ?= $(shell go env GOPATH)
-GOFLAGS ?= $(GOFLAGS:) -mod=vendor
+GOFLAGS ?= $(GOFLAGS:) -mod=vendor
 GO=go
 DELVE=dlv
-LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildNumber=$(BUILD_NUMBER)"
+
+# We need to use the second flavour of makefile variables and use a dedicated
+# variable here, otherwise this will cause an infinite loop.
+# src.: https://www.gnu.org/software/make/manual/make.html#Flavors
+LDFLAGS_MATTERMOST := $(LDFLAGS)
+LDFLAGS  = -X "github.com/mattermost/mattermost-server/v5/model.BuildNumber=$(BUILD_NUMBER)"
 LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildDate=$(BUILD_DATE)"
 LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildHash=$(BUILD_HASH)"
 LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildHashEnterprise=$(BUILD_HASH_ENTERPRISE)"
 LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)"
+# The link mode needs to be at the end of the LDFLAGS statement otherwise the
+# build pieces of info won't be populated to the about dialog in the app.
+LDFLAGS += -linkmode external -extldflags '$(LDFLAGS_MATTERMOST)' -s -w
+
 GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
 GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
 MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1