Suppose I am working on a makefile and I have the following variable declaration at the top:
FILES = file1.cpp file2.cpp file3.cpp
Now suppose I want to compile each of those with a special command without specifying each target like this:
file1.o : file1.cpp
custom_command file1.cpp
file2.o : file2.cpp
custom_command file2.cpp
file3.o : file3.cpp
custom_command file3.cpp
Is there a better way to do this using the $(FILES)
variable I declared above?
Something like:
$(FILES:.cpp=.o) : $(FILES)
custom_command $(FILES)
...only it needs to do this for each file in the $(FILES)
variable.