Reputation: 1680
I have makefile if condition like this outside of rules:
ifneq ("$(wildcard ${EXT}/CHECK)","")
$(info "external binaries exist")
else
@mkdir -p ${EXT}; \
cd ${EXT}; \
scp [email protected]:/media/data/external/${BINARY} . ; \
echo "" > CHECK; \
cd ..;
endif
I am ggeting following error:
*** recipe commences before first target. Stop.
at this line: @mkdir -p ${EXT}; \
I want to make sure this lines are running before any rule. Because I set some variables based on this.
Upvotes: 0
Views: 139
Reputation: 100781
This doesn't have anything to do with if conditions.
Makefiles are not shell scripts. You can't just write a shell script into a makefile and expect them to be executed. They are syntax errors, as you've seen, because makefiles are not shell scripts.
Makefiles can contain shell scripts, but only in the context of a recipe of a rule.
I don't understand why you want to do this outside the context of a rule but the only way to do it is with the shell
function:
_dummy := $(shell mkdir -p ${EXT} && \
cd ${EXT} && \
scp [email protected]:/media/data/external/${BINARY} . && \
echo "" > CHECK)
Upvotes: 1