| # The following variables will likely need to be modified, depending on where | |
| # and how you built LLVM & Clang. They can be overridden in a command-line | |
| # invocation of make, like: | |
| # | |
| # make LLVM_SRC_PATH=<path> LLVM_BIN_PATH=<path> ... | |
| # | |
| # LLVM_SRC_PATH is the path to the root of the checked out source code. This | |
| # directory should contain the configure script, the include/ and lib/ | |
| # directories of LLVM, Clang in tools/clang/, etc. | |
| # Alternatively, if you're building vs. a binary download of LLVM, then | |
| # LLVM_SRC_PATH can point to the main untarred directory. | |
| LLVM_SRC_PATH ?= ../llvm | |
| # LLVM_BIN_PATH is the directory where binaries are placed by the LLVM build | |
| # process. It should contain the tools like opt, llc and clang. The default | |
| # reflects a debug build with autotools (configure & make). | |
| LLVM_BIN_PATH ?= $(shell readlink -e \ | |
| ../../out/llvm_i686_linux_work/Release+Asserts/bin) | |
| $(info -----------------------------------------------) | |
| $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH)) | |
| $(info Using LLVM_BIN_PATH = $(LLVM_BIN_PATH)) | |
| $(info -----------------------------------------------) | |
| LLVM_CXXFLAGS := `$(LLVM_BIN_PATH)/llvm-config --cxxflags` | |
| LLVM_LDFLAGS := `$(LLVM_BIN_PATH)/llvm-config --ldflags --libs` | |
| # It's recommended that CXX matches the compiler you used to build LLVM itself. | |
| OPTLEVEL := -O0 | |
| CXX := g++ | |
| CXXFLAGS := -Wall -Wextra -Werror -fno-rtti -fno-exceptions \ | |
| $(OPTLEVEL) -g $(LLVM_CXXFLAGS) -m32 -Wno-error=unused-parameter | |
| LDFLAGS := -m32 | |
| SRCS= \ | |
| IceCfg.cpp \ | |
| IceCfgNode.cpp \ | |
| IceConverter.cpp \ | |
| IceGlobalContext.cpp \ | |
| IceInst.cpp \ | |
| IceInstX8632.cpp \ | |
| IceIntrinsics.cpp \ | |
| IceLiveness.cpp \ | |
| IceOperand.cpp \ | |
| IceRegAlloc.cpp \ | |
| IceTargetLowering.cpp \ | |
| IceTargetLoweringX8632.cpp \ | |
| IceTranslator.cpp \ | |
| IceTypes.cpp \ | |
| llvm2ice.cpp \ | |
| PNaClTranslator.cpp | |
| OBJS=$(patsubst %.cpp, build/%.o, $(SRCS)) | |
| # Keep all the first target so it's the default. | |
| all: llvm2ice | |
| .PHONY: all | |
| llvm2ice: $(OBJS) | |
| $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) -ldl | |
| # TODO: Be more precise than "*.h" here and elsewhere. | |
| $(OBJS): build/%.o: src/%.cpp src/*.h src/*.def | |
| $(CXX) -c $(CXXFLAGS) $< -o $@ | |
| $(OBJS): | build | |
| build: | |
| @mkdir -p $@ | |
| check: llvm2ice | |
| LLVM_BIN_PATH=$(LLVM_BIN_PATH) \ | |
| $(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit | |
| (cd crosstest; LLVM_BIN_PATH=$(LLVM_BIN_PATH) ./runtests.sh) | |
| # TODO: Fix the use of wildcards. | |
| # Assumes clang-format is within $PATH. | |
| format: | |
| clang-format -style=LLVM -i src/*.h src/*.cpp | |
| # Assumes clang-format-diff.py is within $PATH, and that the | |
| # clang-format it calls is also within $PATH. This may require adding | |
| # a component to $PATH, or creating symlinks within some existing | |
| # $PATH component. Uses the one in /usr/lib/clang-format/ if it | |
| # exists. | |
| ifeq (,$(wildcard /usr/lib/clang-format/clang-format-diff.py)) | |
| CLANG_FORMAT_DIFF = clang-format-diff.py | |
| else | |
| CLANG_FORMAT_DIFF = /usr/lib/clang-format/clang-format-diff.py | |
| endif | |
| format-diff: | |
| git diff -U0 HEAD^ | \ | |
| $(CLANG_FORMAT_DIFF) -p1 -style=LLVM -i | |
| clean: | |
| rm -rf llvm2ice *.o build/ |