Skip to content

Commit 8d6fa00

Browse files
silverwindlafrikstechknowlogick
authored
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 <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent e67c042 commit 8d6fa00

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Makefile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ IMPORT := code.gitea.io/gitea
2121
export GO111MODULE=on
2222

2323
GO ?= go
24-
SED_INPLACE := sed -i
2524
SHASUM ?= shasum -a 256
2625
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
2726
COMMA := ,
@@ -42,18 +41,16 @@ ifeq ($(HAS_GO), GO)
4241
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
4342
endif
4443

45-
4644
ifeq ($(OS), Windows_NT)
4745
EXECUTABLE ?= gitea.exe
4846
else
4947
EXECUTABLE ?= gitea
50-
UNAME_S := $(shell uname -s)
51-
ifeq ($(UNAME_S),Darwin)
52-
SED_INPLACE := sed -i ''
53-
endif
54-
ifeq ($(UNAME_S),FreeBSD)
55-
SED_INPLACE := sed -i ''
56-
endif
48+
endif
49+
50+
ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
51+
SED_INPLACE := sed -i
52+
else
53+
SED_INPLACE := sed -i ''
5754
endif
5855

5956
GOFMT ?= gofmt -s

0 commit comments

Comments
 (0)