edit libinterface docs
[satcheck.git] / clang / Makefile
1 #-------------------------------------------------------------------------------
2 # Sample makefile for building the code samples. Read inline comments for
3 # documentation.
4 #
5 # Eli Bendersky (eliben@gmail.com)
6 # This code is in the public domain
7 #-------------------------------------------------------------------------------
8
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.
12
13 LLVM_VERSION := -3.8
14
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
21
22 LLVM_CXXFLAGS := `llvm-config$(LLVM_VERSION) --cxxflags`
23 LLVM_LDFLAGS := `llvm-config$(LLVM_VERSION) --ldflags --libs --system-libs`
24
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
31
32 CLANG_INCLUDES := -I/usr/lib/llvm$(LLVM_VERSION)/include
33
34 # List of Clang libraries to link. The proper -L will be provided by the
35 # call to llvm-config
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.
40 CLANG_LIBS := \
41         -Wl,--start-group \
42         -lclangAST \
43         -lclangAnalysis \
44         -lclangBasic \
45         -lclangDriver \
46         -lclangEdit \
47         -lclangFrontend \
48         -lclangFrontendTool \
49         -lclangLex \
50         -lclangParse \
51         -lclangSema \
52         -lclangEdit \
53         -lclangASTMatchers \
54         -lclangRewrite \
55         -lclangRewriteFrontend \
56         -lclangStaticAnalyzerFrontend \
57         -lclangStaticAnalyzerCheckers \
58         -lclangStaticAnalyzerCore \
59         -lclangSerialization \
60         -lclangToolingCore \
61         -lclangTooling \
62         -Wl,--end-group
63
64 # Internal paths in this project: where to find sources, and where to put
65 # build artifacts.
66 SRC_DIR := src
67 BUILDDIR := build
68
69 .PHONY: all
70 all: make_builddir \
71         emit_build_config \
72         $(BUILDDIR)/add_mc2_annotations 
73
74 .PHONY: test
75 test: emit_build_config
76         python3 test/all_tests.py
77
78 .PHONY: emit_build_config
79 emit_build_config: make_builddir
80         @echo $(LLVM_BIN_PATH) > $(BUILDDIR)/_build_config
81
82 .PHONY: make_builddir
83 make_builddir:
84         @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
85
86 $(BUILDDIR)/add_mc2_annotations: $(SRC_DIR)/add_mc2_annotations.cpp
87         $(CXX) $(CXXFLAGS) $(LLVM_CXXFLAGS) $(CLANG_INCLUDES) $^ \
88                 $(CLANG_LIBS) $(LLVM_LDFLAGS) -o $@
89
90 .PHONY: clean
91 clean:
92         rm -rf $(BUILDDIR)/* *.dot test/*.pyc test/__pycache__