I have a makefile template to compile a single DLL (for a plugin system). The makefile of the user looks like this:
EXTRA_SRCS=file1 file2
include makefile.in
In the makefile.in
I have:
plugin.dll: plugin.os $(patsubst %,%.os,$(EXTRA_SRCS))
Where plugin.os
is the main C++ file to be compiled. Btw, the files ending is .os
are the object files compiled for shared library (i.e. using the -fpic
option with gcc
)
Now, the problem is that the extra sources will probably (but not necessarily) be header files. Ideally I would like to add them as dependencies for the target plugin.os
and the file.cpp
, but only if they exist.
The method should work for both windows and linux, or at least be adaptable to each. However, I only use the GNU version of make.