<p>I have a makefile template to compile a single DLL (for a plugin system).
The makefile of the user looks like this:</p>

<pre><code>EXTRA_SRCS=file1 file2
include makefile.in
</code></pre>

<p>In the <code>makefile.in</code> I have:</p>

<pre><code>plugin.dll: plugin.os $(patsubst %,%.os,$(EXTRA_SRCS))
</code></pre>

<p>Where <code>plugin.os</code> is the main C++ file to be compiled. Btw, the files ending is <code>.os</code> are the object files compiled for shared library (i.e. using the <code>-fpic</code> option with <code>gcc</code>)</p>

<p>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 <code>plugin.os</code> and the <code>file.cpp</code>, but only if they exist.</p>

<p>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.</p>

Use the "wildcard" function:
```
```
$(wildcard *.h)
```
```
EDIT: in order to match a specific list, do
```
```
$(wildcard $(HEADER_FILES))
```
```
There is no need to use $(filter ...), the wildcard function automatically filters files which don't exist.