I am trying to build some software on Windows using both GNU make 3.81 and an ancient make distributed with Wind River Tornado (make 3.76).
So far, I managed to capture the date from windows:
NOW=\"$(shell cmd /C date /T) $(shell cmd /C time /T)\"
but when I am passing it on the compiler
CFLAGS = ... -DBUILD_TIMESTAMP=$(NOW) ...
I am getting build errors because of the spaces and colons and slashes in the timestamp. If I echo the $(NOW) variable, it is properly quoted, but when I echo the $(CFLAGS) variable, the quotes disappear.
You want to quote the variable for the shell (so it isn't subject to word splitting) and quote it again for C (so when it's substituted by cpp, you have a string literal). Try this:
NOW := "\"$(shell cmd /C date /T) $(shell cmd /C time /T)\""
Note also that I'm using := instead of =. Unless your old make doesn't support it, use :=, which evaluates the substitution at the point of definition, not the point of expansion. Using = will make it call those two shell commands twice every time you try to compile a file. Not so good for performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With