Simplify build & update installation instructions #437

Merged
6543 merged 3 commits from noerw/tea:fix-build into master 2021-12-02 20:01:11 +00:00
2 changed files with 22 additions and 26 deletions

View File

@ -26,24 +26,20 @@ TEA_VERSION_TAG ?= $(shell sed 's/+/_/' <<< $(TEA_VERSION))
TAGS ?=
LDFLAGS := -X "main.Version=$(TEA_VERSION)" -X "main.Tags=$(TAGS)" -s -w
ifeq ($(STATIC),true)
# NOTE: clean up this mess, when https://github.com/golang/go/issues/26492 is resolved
# static_build is a defacto standard tag used in go packages
TAGS := osusergo,netgo,static_build,$(TAGS)
LDFLAGS := $(LDFLAGS) -linkmode=external -extldflags "-static-pie" -X "main.Tags=$(TAGS)"
export CGO_ENABLED=1 # needed for linkmode=external
endif
# override to allow passing additional goflags via make CLI
override GOFLAGS := $(GOFLAGS) -mod=vendor -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
# OS specific vars.
ifeq ($(OS), Windows_NT)
EXECUTABLE := tea.exe
else
EXECUTABLE := tea
ifneq ($(shell uname -s), OpenBSD)
override BUILDMODE := -buildmode=pie
endif
endif
.PHONY: all
@ -124,16 +120,13 @@ check: test
.PHONY: install
install: $(SOURCES)
@echo "installing to $(GOPATH)/bin/$(EXECUTABLE)"
$(GO) install -v -buildmode=pie $(GOFLAGS)
$(GO) install -v $(BUILDMODE) $(GOFLAGS)
.PHONY: build
build: $(EXECUTABLE)
$(EXECUTABLE): $(SOURCES)
ifeq ($(STATIC),true)
@echo "enabling static build, make sure you have glibc-static (or equivalent) installed"
endif
$(GO) build -buildmode=pie $(GOFLAGS) -o $@
$(GO) build $(BUILDMODE) $(GOFLAGS) -o $@
.PHONY: build-image
build-image:

View File

@ -85,29 +85,32 @@ There are different ways to get `tea`:
brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea
brew install tea
```
- arch linux ([gitea-tea](https://aur.archlinux.org/packages/gitea-tea), thirdparty)
- arch linux ([gitea-tea-git](https://aur.archlinux.org/packages/gitea-tea-git), thirdparty)
- alpine linux ([tea](https://pkgs.alpinelinux.org/packages?name=tea&branch=edge), thirdparty)
2. Use the prebuilt binaries from [dl.gitea.io](https://dl.gitea.io/tea/)
3. Install from source (go 1.13 or newer is required):
```sh
go get code.gitea.io/tea
go install code.gitea.io/tea
```
3. Install from source: [see *Compilation*](#compilation)
4. Docker (thirdparty): [tgerczei/tea](https://hub.docker.com/r/tgerczei/tea)
## Compilation
Make sure you have installed a current go version.
To compile the sources yourself run the following:
Make sure you have a current go version installed (1.13 or newer).
```sh
git clone https://gitea.com/gitea/tea.git
cd tea
make STATIC=true
```
- To compile the source yourself with the recommended flags & tags:
```sh
git clone https://gitea.com/gitea/tea.git # or: tea clone gitea.com/gitea/tea ;)
cd tea
make
```
Note that GNU Make (gmake on OpenBSD) is required.
- For a quick installation without `git` & `make`:
```sh
go get code.gitea.io/tea
go install code.gitea.io/tea
```
## Contributing