title: Symbolic link in makefile
body: <p>Consider the following makefile:</p>
  
  <pre><code>SHELL = /bin/sh
  
  MY_DIR := $(realpath ./)
  
  BASE_DIR := $(realpath ../..)
  BASE_SRC_DIR = $(BASE_DIR)/src
  BASE_INC_DIR = $(BASE_DIR)/include
  
  HUL_DIR = $(MY_DIR)/hul
  
  JNI_DIR = $(HUL_DIR)/jni
  JNI_SRC_DIR = $(JNI_DIR)/src
  JNI_INC_DIR = $(JNI_DIR)/include
  
  dirs: $(JNI_SRC_DIR) $(JNI_INC_DIR)
  
  $(JNI_SRC_DIR): $(JNI_DIR)
      ln -s $(BASE_SRC_DIR) $@
  
  $(JNI_INC_DIR): $(JNI_DIR)
      ln -s $(BASE_INC_DIR) $@
  
  $(JNI_DIR):
      mkdir -p $(JNI_DIR)
  </code></pre>
  
  <p>This makefile creates two symbolic links (<code>JNI_SRC_DIR</code> and <code>JNI_INC_DIR</code>) and sets a <code>JNI_DIR</code> as a dependency for those. All is fine except one thing: calling <code>make dirs</code> twice creates the links and then links inside those folders. I know this is the standard <code>ln</code> behaviour when symlinking folders that already exist, I just don't know of any <code>ln</code> option flag to prevent it without an error (<code>-n</code> does it but with an error). Anyway, what I'd like to change is <code>make</code> running the rules for the second time. Apparently it also follows the symlinks, but I just want it to check whether they are there:</p>
  
  <p>Here's a sample output, with three calls:</p>
  
  <pre><code>$ make dirs
  mkdir -p /Users/fratelli/Documents/hul/platform/android/hul/jni
  ln -s /Users/fratelli/Documents/hul/src /Users/fratelli/Documents/hul/platform/android/hul/jni/src
  ln -s /Users/fratelli/Documents/hul/include /Users/fratelli/Documents/hul/platform/android/hul/jni/include
  
  $ make dirs
  ln -s /Users/fratelli/Documents/hul/src /Users/fratelli/Documents/hul/platform/android/hul/jni/src
  ln -s /Users/fratelli/Documents/hul/include /Users/fratelli/Documents/hul/platform/android/hul/jni/include
  
  $ make dirs
  make: Nothing to be done for `dirs'.
  </code></pre>
  
  <p>I'd like the second time to behave as the third, as the symlinks are already there.</p>