R – Convert hex to decimal in make script

base-conversionhexmakefile

A make script is attempting to set a variable as follows:

VER_DEC=$( perl -e "print hex(\"$(VER_HEX)\");" )

where VER_HEX happens to have a value of 0a.

Perl seems to think that VER_HEX is zero, implying that the variable isn't set (but it is, according to a debug echo in the makefile).

Does make have a simpler way to convert bases?

If so, what version of make is required?

UPDATE: This is a GNU Makefile. The invocation of perl is missing the word shell inside the $( ) as well as potentially having escaping issues with the double-quotes.

Best Answer

VER_DEC=$(shell printf "%d" 0x$(VER_HEX))

if you're talking about Makefile. Because your doesn't look like Makefile to me, more like shell. (I think $(shell ) is GNU extension, but most of time you can safely replace it with backticks).