summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorThomas Boerger <thomas@webhippie.de>2017-03-07 14:49:24 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2017-03-07 21:49:24 +0800
commit7ed00b6e8d571ab8efc99aa69d545cce609dd900 (patch)
treef9cb28d8c60eb293bfac996d7963f2a8c754bf31 /Makefile
parent288226e13ca86c033d8417238dd7e1e1deb7173c (diff)
downloadgitea-7ed00b6e8d571ab8efc99aa69d545cce609dd900.tar.gz
gitea-7ed00b6e8d571ab8efc99aa69d545cce609dd900.zip
Split the binary build (#985)
As we can not compile darwin binaries with static flags I have split the build process into different make tasks. Now we get static linked binaries especially for linux so that it also can run on older versions of CenOS and so on. Signed-off-by: Thomas Boerger <thomas@webhippie.de>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 24 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index d09d31ed5f..63dab1680a 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,6 @@ JAVASCRIPTS :=
LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')" -X "main.Tags=$(TAGS)"
-TARGETS ?= linux/*,darwin/*,windows/*
PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations,$(shell go list ./... | grep -v /vendor/))
SOURCES ?= $(shell find . -name "*.go" -type f)
@@ -102,18 +101,38 @@ docker:
docker build -t gitea/gitea:latest .
.PHONY: release
-release: release-dirs release-build release-copy release-check
+release: release-dirs release-windows release-linux release-darwin release-copy release-check
.PHONY: release-dirs
release-dirs:
mkdir -p $(DIST)/binaries $(DIST)/release
-.PHONY: release-build
-release-build:
+.PHONY: release-windows
+release-windows:
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/karalabe/xgo; \
fi
- xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets '$(TARGETS)' -out $(EXECUTABLE)-$(VERSION) .
+ xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
+ifeq ($(CI),drone)
+ mv /build/* $(DIST)/binaries
+endif
+
+.PHONY: release-linux
+release-linux:
+ @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
+ go get -u github.com/karalabe/xgo; \
+ fi
+ xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out gitea-$(VERSION) .
+ifeq ($(CI),drone)
+ mv /build/* $(DIST)/binaries
+endif
+
+.PHONY: release-darwin
+release-darwin:
+ @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
+ go get -u github.com/karalabe/xgo; \
+ fi
+ xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
ifeq ($(CI),drone)
mv /build/* $(DIST)/binaries
endif