@@ -8,24 +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)
13- CWD = $(dir $(realpath $(lastword $(MAKEFILE_LIST ) ) ) )
14-
15- # Used by ci-gradle-test target
16- DOCKERAPP_BINARY ?= $(CWD ) /bin/$(BIN_NAME ) -linux
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
1729
18- WINDOWS := no
19- ifneq ($(filter cmd.exe powershell.exe,$(subst /, ,$(SHELL ) ) ) ,)
20- WINDOWS := yes
21- 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 ) )
2235endif
2336
2437ifeq ($(BUILDTIME ) ,)
25- 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/')
2639endif
2740ifeq ($(BUILDTIME ) ,)
28- 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/')
2942endif
3043ifeq ($(BUILDTIME ) ,)
3144 $(error unable to set BUILDTIME, ensure that you have GNU date installed or set manually)
@@ -38,16 +51,6 @@ LDFLAGS := "-s -w \
3851 -X $(PKG_NAME ) /internal.Renderers=$(RENDERERS ) \
3952 -X $(PKG_NAME ) /internal.BuildTime=$(BUILDTIME ) "
4053
41- ifeq ($(WINDOWS ) ,yes)
42- mkdir = mkdir $(subst /,\,$(1 ) ) > nul 2>&1 || (exit 0)
43- rm = del /S /Q $(subst /,\,$(1 ) ) > nul 2>&1 || (exit 0)
44- chmod =
45- else
46- mkdir = mkdir -p $(1 )
47- rm = rm -rf $(1 )
48- chmod = chmod $(1 ) $(2 )
49- endif
50-
5154EXEC_EXT :=
5255ifeq ($(OS ) ,Windows_NT)
5356 EXEC_EXT := .exe
0 commit comments