title: Makefile conditional include
body: <p>I'm trying to write an application that needs either ALSA or OSS headers. Basically, I want to pass a define to the compiler if /etc/oss.conf does not exist, since that probably means the soundcard.h header doesn't exist (feel free to correct me on that one, I'm still new to working with OSS). Per the OSS documentation, you would use the include directive like so:</p>
  
  <pre><code>include /etc/oss.conf
  CFLAGS := -I$(OSSLIBDIR)/include/sys
  </code></pre>
  
  <p>One problem. OSS support is optional, so I'd want to check if the header exists, and if does, pass a define to the compiler. The problem is, AFAIK there is no way to check if a file exists outside of a makefile <em>rule</em>. Inside the rule, if I use an if statement, for some reason, trying to set CFLAGS doesn't alter it:</p>
  
  <pre><code>test: $(objects)
      @if [ -f ${OSS_CONFIG} ]; then \
      . ${OSS_CONFIG}; \
      CFLAGS+=" -I${OSSLIBDIR} -DUSE_OSS"; \
      fi
      @echo ${CFLAGS}
  </code></pre>
  
  <p>(The above just outputs the original value of CFLAGS, even if <code>${OSS_CONFIG}</code> exists.) This is, of course, extremely ugly, and I'm wondering if there's a cleaner way to do it. Or is the way I'm going about this going to trigger a worldwide cataclysmic event involving the genocide of kittens? </p>
  
  <p>Oh, and please don't tell me to use autoconf.</p>