I have an rule that creates a directory
bin:
-mkdir $@
However after the first time the directory has been generated, I receive this output:
mkdir bin
mkdir: cannot create directory `bin': File exists
make: [bin] Error 1 (ignored)
Is there some way I can only run the rule if the directory doesn’t exist, or suppress the output when the directory already exists?
The traditional way to handle directory creation is to use a stamp file that is depended on and creates the dir as a side effect. Remove the stamp file when making
distcleanor whatever your “really clean” target is:The reason for this is as follows: whenever a file in
binis created/removed, the mtime of the containing directory is updated. If a target depends onbin, then the next timemakeruns, it will then recreate files that it doesn’t need to.