summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-07-27 22:13:15 +0200
committerGitHub <noreply@github.com>2020-07-27 16:13:15 -0400
commit8d6fa00da06e52cba1aaed5ba2a187fed8cd63de (patch)
tree4b7adf51a674146e08e152af1e646f031ba0f82a
parente67c042511f859029f141a94d30824a4522898b9 (diff)
downloadgitea-8d6fa00da06e52cba1aaed5ba2a187fed8cd63de.tar.gz
gitea-8d6fa00da06e52cba1aaed5ba2a187fed8cd63de.zip
Detect version of sed in Makefile (#12319)
* Detect version of sed in Makefile It's possible to install GNU sed on Darwin or FreeBSD so it's better to not assume BSD sed on those platforms but to instead perform version detection for the `GNU` string and only use BSD syntax if absent. * silence stderr Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
-rw-r--r--Makefile15
1 files changed, 6 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index b1acbe2295..f39080340d 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,6 @@ IMPORT := code.gitea.io/gitea
export GO111MODULE=on
GO ?= go
-SED_INPLACE := sed -i
SHASUM ?= shasum -a 256
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
COMMA := ,
@@ -42,18 +41,16 @@ ifeq ($(HAS_GO), GO)
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
endif
-
ifeq ($(OS), Windows_NT)
EXECUTABLE ?= gitea.exe
else
EXECUTABLE ?= gitea
- UNAME_S := $(shell uname -s)
- ifeq ($(UNAME_S),Darwin)
- SED_INPLACE := sed -i ''
- endif
- ifeq ($(UNAME_S),FreeBSD)
- SED_INPLACE := sed -i ''
- endif
+endif
+
+ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
+ SED_INPLACE := sed -i
+else
+ SED_INPLACE := sed -i ''
endif
GOFMT ?= gofmt -s