@@ -8,20 +8,37 @@ EXPERIMENTAL := off
88# Comma-separated list of renderers
99RENDERERS := "none"
1010
11- TAG ?= $(shell git describe --always --dirty 2>/dev/null)
12- COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null)
11+ # Failing to resolve sh.exe to a full path denotes a windows vanilla shell.
12+ # Although 'simple' commands are still exec'ed, 'complex' ones are batch'ed instead of sh'ed.
13+ ifeq ($(SHELL ) ,sh.exe)
14+ mkdir = mkdir $(subst /,\,$(1 ) ) > nul 2>&1 || (exit 0)
15+ rm = del /F /Q $(subst /,\,$(1 ) ) > nul 2>&1 || (exit 0)
16+ rmdir = rmdir /S /Q $(subst /,\,$(1 ) ) > nul 2>&1 || (exit 0)
17+ chmod =
18+ BUILDTIME ?= unknown
19+ NULL := nul
20+ else
21+ # The no-op redirection forces make to shell out the commands instead of spawning a process as
22+ # the latter can fail on windows running cmd or powershell while having a unix style shell in the path.
23+ mkdir = mkdir -p $(1 ) 1>&1
24+ rm = rm -rf $(1 ) 1>&1
25+ rmdir = rm -rf $(1 ) 1>&1
26+ chmod = chmod $(1 ) $(2 ) 1>&1
27+ NULL := /dev/null
28+ endif
1329
14- WINDOWS := no
15- ifneq ($(filter cmd.exe powershell.exe,$(subst /, ,$(SHELL ) ) ) ,)
16- WINDOWS := yes
17- BUILDTIME := unknown
30+ ifeq ($(TAG ) ,)
31+ TAG := $(shell git describe --always --dirty 2> $(NULL ) )
32+ endif
33+ ifeq ($(COMMIT ) ,)
34+ COMMIT := $(shell git rev-parse --short HEAD 2> $(NULL ) )
1835endif
1936
2037ifeq ($(BUILDTIME ) ,)
21- BUILDTIME := ${ shell date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/'}
38+ BUILDTIME := $( shell date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
2239endif
2340ifeq ($(BUILDTIME ) ,)
24- BUILDTIME := ${ shell gdate --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/'}
41+ BUILDTIME := $( shell gdate --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
2542endif
2643ifeq ($(BUILDTIME ) ,)
2744 $(error unable to set BUILDTIME, ensure that you have GNU date installed or set manually)
@@ -34,16 +51,6 @@ LDFLAGS := "-s -w \
3451 -X $(PKG_NAME ) /internal.Renderers=$(RENDERERS ) \
3552 -X $(PKG_NAME ) /internal.BuildTime=$(BUILDTIME ) "
3653
37- ifeq ($(WINDOWS ) ,yes)
38- mkdir = mkdir $(subst /,\,$(1 ) ) > nul 2>&1 || (exit 0)
39- rm = del /S /Q $(subst /,\,$(1 ) ) > nul 2>&1 || (exit 0)
40- chmod =
41- else
42- mkdir = mkdir -p $(1 )
43- rm = rm -rf $(1 )
44- chmod = chmod $(1 ) $(2 )
45- endif
46-
4754EXEC_EXT :=
4855ifeq ($(OS ) ,Windows_NT)
4956 EXEC_EXT := .exe
0 commit comments