I am working on Windows OS. And here is my makefile snippet.
COMPILER_ROOT := C:/Users/kpt
DATE := $(COMPILER_ROOT)/build/busybox_glob.exe date
SED := $(COMPILER_ROOT)/build/busybox_glob.exe sed
STD_DATE := "$(shell $(DATE) | $(SED) "s/ /_/g")"
$(info STD_DATE $(STD_DATE))
Above is my makefile snippet.
I am not getting null value for a STD_DATE variable, With warning: 'C:' is not recognized as an internal or external command,
I tried multiple options, But nothing works.
When i just assign STD_DATE := "$(shell $(DATE) , I can able to see the value of STD_DATE in the log, But when i try to do SED to replace space with _, It fails with above warning.
Hardcoding paths with \ worked.
DATE := C:\Users\kpt\build\busybox_glob.exe date
SED := C:\Users\kpt\build\busybox_glob.exe sed
STD_DATE := "$(shell $(DATE) | $(SED) "s/ /_/g")"
$(info STD_DATE $(STD_DATE))
Since sed command with pipe is causing issue , i tried another approach as follows:
DATE := C:\test\busybox_glob.exe date
STD_DATE = $(shell $(DATE))
space := $(empty) $(empty) # define a space
empty :=
hello := $(subst $(space),_,$(STD_DATE))
$(info hello value is $(hello))
Output: hello value is Fri Aug 15 12:20:09 India Standard Time 2025 cumake: *** No targets. Stop.
its not actually replacing space with _
STD_DATE := $(shell powershell -Command "Get-Date -Format 'yyyy_MM_dd_HH_mm_ss'")makeand/or the shellmakeis using to execute commands. But why usesedfor this at all? You're assuming GNUmakeanyway, so you could use its built-in$(subst)function. That's a bit complicated by the fact that the first argument starts with (is) a space character, but it can be done.