Makefile - just do the installation (copy the files), there is no purpose for the assembly

I have a simple makefile project where I just want to make install copy the files to the target folder, i.e.:

 all: @echo "Nothing to build" install: cp ./*.wav /usr/share/snd my_custom_target: @echo "For testing purposes" 

However, whenever I try to create any goals (i.e.: clean, all, install, my_custom_target, etc.), each of them is just an echo of " Nothing to be done for 'clean' ", " Nothing to be done for 'all' "etc. I assume that the makefile project expects at least something built (like a C / C ++ file, etc.).

Does anyone have any suggestions on how to do this?

Thanks.

+4
source share
1 answer

This seems to indicate that make cannot find or cannot parse your Makefile correctly. What is a file?

Also, make sure that the commands in each rule (for example, cp ./*.wav /usr/share/snd ) are prefixed with the actual tab character, not spaces. In the sample you inserted, they are prefixed with just three spaces, but for make for them to parse correctly, they must be prefixes with the actual tab character.

One more thing to check if there are files named all , install or my_custom_target . Make does not care if any C or C ++ file is built; rules can do whatever you want. But it checks to see if there is a file with a name similar to the rule, and whether it is newer than the dependencies of the rule. If there is a file and it is newer than all the dependencies (or there are no dependencies, as in this example), then it will decide that there is nothing to do. To avoid this, add a .PHONY declaration to indicate that these are fake targets and do not match the actual files to be built; then make will always run these recipes, regardless of whether it has an updated file with the same name.

 .PHONY: all install my_custom_target 
+6
source

Source: https://habr.com/ru/post/1436191/


All Articles