1

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 _

6
  • Why not using Powershell? STD_DATE := $(shell powershell -Command "Get-Date -Format 'yyyy_MM_dd_HH_mm_ss'") Commented Jul 28 at 15:41
  • process_begin: CreateProcess(NULL, powershell -Command "Get-Date -Format 'yyyy_MM_dd_HH_mm_ss'", ...) failed. Its failing. I am specifically looking for format: Sun_Jul_27_00:23:17_Coordinated_Universal_Time_2025 Commented Jul 29 at 5:05
  • It looks like an issue with the execution environment in which you are running make and/or the shell make is using to execute commands. But why use sed for this at all? You're assuming GNU make anyway, 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. Commented Aug 1 at 18:11
  • Could you please help suggest some solution with subst? Commented Aug 4 at 5:53
  • i tried another approach of using subst, Updated my question about the experiment, No luch. Commented Aug 15 at 7:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.