3
I have a question concerning a line in a Makefile. I have a target to "clean" my locally installed test/staging-server. Currently it looks like this:
clean:
rm -rf $(LOCAL_SERVER_PATH)/*
As long as the variable LOCAL_SERVER_PATH
is defined and looks like /srv/www/htdocs
or something like this, everything is fine. But ... what if a user made a mistake and mistyped the variable-definition, or some config-step went rouge, and the Makefile is created, with a wrong definition.
Essentially, I fear, that by mistake I could end up with a non-defined $(LOCAL_SERVER_PATH)
, and my target would then yield to:
clean:
rm -rf /*
Is it possible to refactor my Makefile to make it more robust against such errors? I don't want to end up with a Makefile, that could potentially wipe out my entire linux-installation (or even parts of it, since my user is not 'root').
5You could just check the variable beforehand, you know? ;) – Daniel B – 2015-06-10T15:57:05.750