title: What's the DRY version of the following Makefile targets?
body: <p>I don't know how to execute a command stored as a variable or how to use <code>ifeq</code> inside of a target, so I have a <em>very</em> redundant Makefile at the moment!</p>
  
  <p>Ideally I'd like to have just one target (<code>all</code>) which would run the stored command on Mac and run it twice on Linux, once with -m32 and once with -m64.</p>
  
  <pre><code>all:
      echo PLEASE SELECT OS, e.g. make linux
      exit 1
  
  mac:
       gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS) -o $(BUILD_DIR)$(BUILD_NAME) $(SOURCE) $(LIBRARIES)
  
  linux:
      gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS) -o $(BUILD_DIR)$(BUILD_NAME64) $(SOURCE) $(LIBRARIES64) -m64
      gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS) -o $(BUILD_DIR)$(BUILD_NAME) $(SOURCE) $(LIBRARIES) -m32
  </code></pre>
  
  <p>UPDATE: This is what I ended up with, after reading the various suggestsions. (Yes I know I should use autoconf . .  .) Thanks everyone for your help!</p>
  
  <pre><code>ifeq($(PLATFORM), Linux)
      COMMON = -pthread -fPIC
      PLATFORM_CFLAGS = $(COMMON) -m32
      PLATFORM_CFLAGS64 = $(COMMON) -m64
  endif
  
  ifeq ($(PLATFORM), Darwin)
      PLATFORM_CFLAGS = -arch i386 -arch ppc -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
  endif
  
  all: $(PLATFORM)_all
  
  Darwin_all:
       mkdir -p ../../../../tmp
       gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS) -o $(BUILD_DIR)$(BUILD_NAME) $(SOURCE) $(LIBRARIES)
  
  Linux_all: Darwin_all
       gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS64) -o $(BUILD_DIR)$(BUILD_NAME64) $(SOURCE) $(LIBRARIES64)
  </code></pre>