title: How to use the include directive in a makefile for a specific target
body: <p>I want to use the include directive only for a specific target. I do not want to run the other makefiles when the target is not needed because it means the makefiles are generated needlessly.</p>
  
  <p>So is there a way to conditionally use the include directive, which is conditional on a target? Or somehow to make the include directive a prerequisite of a target.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code># Flags
  
  INCDIR = $(CURDIR)/include
  CFLAGS = -Wall -Wno-overflow -Wno-uninitialized -pedantic -std=c99 -I$(INCDIR) -O3
  LFLAGS = -flat_namespace -dynamiclib -undefined dynamic_lookup
  
  # Directory names
  
  # Set vpath search paths
  
  vpath %.h include
  vpath %.c src
  vpath %.o build
  vpath %.d build
  
  # Get files for the core library
  
  CORE_FILES = $(wildcard src/*.c)
  CORE_OBJS = $(patsubst src/%.c, build/%.o, $(CORE_FILES))
  CORE_DEPS = $(CORE_OBJS:.o=.d)
  
  # Core library target linking
  
  core : $(CORE_OBJS) | bin
      $(CC) $(LFLAGS) -o bin/libcbitcoin.2.0.dylib $(CORE_OBJS)
  
  # Include header prerequisites (How to do only for "core" target?)
  
  include $(CORE_DEPS)
  
  # Makefiles for header dependencies. 
  
  $(CORE_DEPS): build/%.d: src/%.c | build
      rm -f $@; \
      $(CC) -I$(INCDIR) -MM $&lt; -MT '$(@:.d=.o) $@' &gt; $@
  
  # Objects depend on directory
  
  $(CORE_OBS) : | build
  
  # Create build directory
  
  build:
      mkdir build
  
  # Create bin directory
  
  bin:
      mkdir bin
  
  # Core Compilation
  
  $(CORE_OBJS): build/%.o: src/%.c
      $(CC) -c $(CFLAGS) $&lt; -o $@
  
  # Depencies require include/CBDependencies.h as a prerequisite
  
  build/CBOpenSSLCrypto.o: include/CBDependencies.h
  
  # Crypto library target linking
  
  crypto : build/CBOpenSSLCrypto.o -lcrypto -lssl | bin
      $(CC) $(LFLAGS) -o bin/libcbitcoin-crypto.2.0.dylib build/CBOpenSSLCrypto.o -lcrypto -lssl
  
  # Crypto library compile
  
  build/CBOpenSSLCrypto.o: dependencies/crypto/CBOpenSSLCrypto.c
      $(CC) -c $(CFLAGS) $&lt; -o $@
  
  #Clean
  
  clean:
      rm -f $(CORE_OBJS) $(CORE_DEPS) build/CBOpenSSLCrypto.o
  </code></pre>
  
  <p>As you should be able to tell I do not need to include the ".d" files for "crypto" but I do for "core" (default goal).</p>
  
  <p>Thank you for any help.</p>