1 #-------------------------------------------------------------------------------
2 # Sample makefile for building the code samples. Read inline comments for
5 # Eli Bendersky (eliben@gmail.com)
6 # This code is in the public domain
7 #-------------------------------------------------------------------------------
9 # The following variables will likely need to be customized, depending on where
10 # and how you built LLVM & Clang. They can be overridden by setting them on the
11 # make command line: "make VARNAME=VALUE", etc.
15 # CXX has to be a fairly modern C++ compiler that supports C++11. gcc 4.8 and
16 # higher or Clang 3.2 and higher are recommended. Best of all, if you build LLVM
17 # from sources, use the same compiler you built LLVM with.
18 CXX := clang++$(LLVM_VERSION)
19 CXXFLAGS := -fno-rtti -g
20 PLUGIN_CXXFLAGS := -fpic
22 LLVM_CXXFLAGS := `llvm-config$(LLVM_VERSION) --cxxflags`
23 LLVM_LDFLAGS := `llvm-config$(LLVM_VERSION) --ldflags --libs --system-libs`
25 # Plugins shouldn't link LLVM and Clang libs statically, because they are
26 # already linked into the main executable (opt or clang). LLVM doesn't like its
27 # libs to be linked more than once because it uses globals for configuration
28 # and plugin registration, and these trample over each other.
29 LLVM_LDFLAGS_NOLIBS := `llvm-config$(LLVM_VERSION) --ldflags`
30 PLUGIN_LDFLAGS := -shared
32 CLANG_INCLUDES := -I/usr/lib/llvm$(LLVM_VERSION)/include
34 # List of Clang libraries to link. The proper -L will be provided by the
36 # Note that I'm using -Wl,--{start|end}-group around the Clang libs; this is
37 # because there are circular dependencies that make the correct order difficult
38 # to specify and maintain. The linker group options make the linking somewhat
39 # slower, but IMHO they're still perfectly fine for tools that link with Clang.
55 -lclangRewriteFrontend \
56 -lclangStaticAnalyzerFrontend \
57 -lclangStaticAnalyzerCheckers \
58 -lclangStaticAnalyzerCore \
59 -lclangSerialization \
64 # Internal paths in this project: where to find sources, and where to put
72 $(BUILDDIR)/add_mc2_annotations
75 test: emit_build_config
76 python3 test/all_tests.py
78 .PHONY: emit_build_config
79 emit_build_config: make_builddir
80 @echo $(LLVM_BIN_PATH) > $(BUILDDIR)/_build_config
84 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
86 $(BUILDDIR)/add_mc2_annotations: $(SRC_DIR)/add_mc2_annotations.cpp
87 $(CXX) $(CXXFLAGS) $(LLVM_CXXFLAGS) $(CLANG_INCLUDES) $^ \
88 $(CLANG_LIBS) $(LLVM_LDFLAGS) -o $@
92 rm -rf $(BUILDDIR)/* *.dot test/*.pyc test/__pycache__