Hi there
I'm trying to write a make file to deploy software in a production setup.
The first thing I'm trying to do is detect if the user running the make is root.
From the documentation scattered about, I came up with this:
Code:
USERID=$(shell id -u)
all:
$(info User Id is $(USERID))
ifeq ($(REQUIRED_USER),0)
$(info Running as root... OK)
else
$(error You must be root to execute this command)
endif
When I run this as root, I get the following output:
Quote:
$ > make
User Id is 0
Running as root... OK
Makefile:6: *** You must be root to execute this command. Stop.
|
When I run this as another user:
Quote:
$ > make
User Id is 496
Running as root... OK
Makefile:6: *** You must be root to execute this command. Stop.
|
As you can see, in both situations, make executes both branches of the conditional.
How to do this the correct way?
Thanks for your help.