OSDN Git Service

Subzero: Build both Debug and Release version of llvm2ice.
authorJim Stichnoth <stichnot@chromium.org>
Sat, 27 Sep 2014 01:53:41 +0000 (18:53 -0700)
committerJim Stichnoth <stichnot@chromium.org>
Sat, 27 Sep 2014 01:53:41 +0000 (18:53 -0700)
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

Makefile.standalone

index b6d0d17..a913497 100644 (file)
@@ -37,6 +37,14 @@ else
   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_LDFLAGS := `$(LLVM_BIN_PATH)/llvm-config --libs` \
                 `$(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 @@ SRCS= \
        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
+
+make_symlink: $(OBJDIR)/llvm2ice
+       rm -f llvm2ice
+       ln -s $(OBJDIR)/llvm2ice
 
-.PHONY: all
+.PHONY: all make_symlink
 
-llvm2ice: $(OBJS)
+$(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