Reputation: 609
I'm really struggling with this Makefile. I have an application that I want to build on an old Fedora computer but also on a new CentOS computer. I want to change a variable depending on which computer I am using.
This is what I've tried but it doesn't seem to work.
UNAME := $(uname -r)
ifeq ($(UNAME),2.6.32.11-99.fc12.x86_64)
DIRS = Control Simulator
else
DIRS = Control
endif
My question is, how can I get this to work in some standalone Makefile to test? This gives me the "*** No targets. Stop" error currently. After that I should be able to implement it in my real Makefile.
Upvotes: 0
Views: 119
Reputation: 100916
As the error says, you need to provide a target to build. A makefile that doesn't contain anything other than variable assignments won't do anything. Maybe you want to add:
all:
@echo 'DIRS = $(DIRS)'
to see what value you obtained.
However, I can already see that this won't work as written. Makefile syntax is not shell syntax, so the statement $(uname -r)
is trying to expand a make variable named uname -r
(just like $(FOO)
is trying to expand a make variable named FOO
). That variable is not set, so UNAME
will always be set to the empty string.
You probably want this instead:
UNAME := $(shell uname -r)
to invoke the make shell
function to run a shell script and expand to the results.
Upvotes: 1