Subzero: Build both Debug and Release version of llvm2ice.

Separate objects are built with -O0 and -O2.

Separate executables are built:
  build/Release/llvm2ice - Release build
  build/Debug/llvm2ice - Debug build

The executable built depends on whether the DEBUG make variable is set:
  make -f Makefile.standalone
  make -f Makefile.standalone DEBUG=1

The llvm2ice file in the top-level directory is always removed and symlinked to the appropriate build.

BUG= none
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/605093002
diff --git a/Makefile.standalone b/Makefile.standalone
index b6d0d17..a913497 100644
--- a/Makefile.standalone
+++ b/Makefile.standalone
@@ -37,6 +37,14 @@
   endif
 endif
 
+ifdef DEBUG
+  OBJDIR = build/Debug
+  OPTLEVEL = -O0
+else
+  OBJDIR = build/Release
+  OPTLEVEL = -O2
+endif
+
 $(info -----------------------------------------------)
 $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
 $(info Using LLVM_BIN_PATH = $(LLVM_BIN_PATH))
@@ -50,7 +58,6 @@
                 `$(LLVM_BIN_PATH)/llvm-config --ldflags`
 
 # It's recommended that CXX matches the compiler you used to build LLVM itself.
-OPTLEVEL := -O0
 CCACHE := `command -v ccache`
 CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++
 
@@ -82,24 +89,28 @@
 	llvm2ice.cpp \
 	PNaClTranslator.cpp
 
-OBJS=$(patsubst %.cpp, build/%.o, $(SRCS))
+OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
 
 # Keep all the first target so it's the default.
-all: llvm2ice
+all: $(OBJDIR)/llvm2ice make_symlink
 
-.PHONY: all
+make_symlink: $(OBJDIR)/llvm2ice
+	rm -f llvm2ice
+	ln -s $(OBJDIR)/llvm2ice
 
-llvm2ice: $(OBJS)
+.PHONY: all make_symlink
+
+$(OBJDIR)/llvm2ice: $(OBJS)
 	$(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) -ldl \
                -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib)
 
 # TODO: Be more precise than "*.h" here and elsewhere.
-$(OBJS): build/%.o: src/%.cpp src/*.h src/*.def
+$(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
 	$(CXX) -c $(CXXFLAGS) $< -o $@
 
-$(OBJS): | build
+$(OBJS): | $(OBJDIR)
 
-build:
+$(OBJDIR):
 	@mkdir -p $@
 
 check-lit: llvm2ice