I've been writing a Makefile that performs some dependency generation and I've found myself having to duplicate rules because the (legacy) codebase contains a mixture of .cpp
and .cc
files. It seems a bit unsightly. Is there anyway to specify that the prerequisites of a target can be either .cpp
or .cc
files?
So rather than having:
%.d : %.cpp
$(CPP) -MM $(CPPFLAGS) $<
%.d : %.cc
$(CPP) -MM $(CPPFLAGS) $<
Create something without the duplication like:
%.d : %.(cpp | cc)
$(CPP) -MM $(CPPFLAGS) $<
Or is this enforced redundancy just an unfortunate element of GNU Make's design?