Issue
I'm trying make Ubuntu version specific distros of my tool so I want to get the os name and version. I have the following code:
ifeq ($(OS),Windows_NT)
OS_POD+=win
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS_VERS := $(shell lsb_release -a 2>/dev/null | grep Description | awk '{ print $2 "-" $3 }')
OS_POD=./dist/linux/$(OS_VERS)
endif
ifeq ($(UNAME_S),Darwin)
OS_POD=./dist/mac
endif
endif
I use the shell one-liner:
lsb_release -a 2>/dev/null | grep Description | awk '{ print $2 "-" $3 }'
Which properly returns Ubuntu-12.04.2
outside of the Makefile, but inside it it returns nothing. That is, the OS_VERS variable is just -
.
How can I fix this?
Solution
In a Makefile, $
is special. Use $$
where you want the shell to find a dollar.
OS_VERS := $(shell lsb_release -a 2>/dev/null | grep Description | awk '{ print $$2 "-" $$3 }')
Answered By - choroba