1 #===- ./Makefile -------------------------------------------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
12 # Top-Level LLVM Build Stages:
13 # 1. Build lib/System and lib/Support, which are used by utils (tblgen).
14 # 2. Build utils, which is used by VMCore.
15 # 3. Build VMCore, which builds the Intrinsics.inc file used by libs.
16 # 4. Build libs, which are needed by llvm-config.
17 # 5. Build llvm-config, which determines inter-lib dependencies for tools.
18 # 6. Build tools, runtime, docs.
20 # When cross-compiling, there are some things (tablegen) that need to
21 # be build for the build system first.
22 ifndef RC_ARCHS # Normal build (not "Apple-style").
23 ifeq ($(BUILD_DIRS_ONLY),1)
24 DIRS := lib/System lib/Support utils
27 DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \
28 tools runtime docs unittests
29 OPTIONAL_DIRS := examples projects bindings
32 EXTRA_DIST := test unittests llvm.spec include win32 Xcode
34 include $(LEVEL)/Makefile.config
36 # llvm-gcc4 doesn't need runtime libs. llvm-gcc4 is the only supported one.
37 # FIXME: Remove runtime entirely once we have an understanding of where
38 # libprofile etc should go.
39 #ifeq ($(LLVMGCC_MAJVERS),4)
40 # DIRS := $(filter-out runtime, $(DIRS))
43 ifeq ($(MAKECMDGOALS),libs-only)
44 DIRS := $(filter-out tools runtime docs, $(DIRS))
48 ifeq ($(MAKECMDGOALS),install-libs)
49 DIRS := $(filter-out tools runtime docs, $(DIRS))
50 OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
53 ifeq ($(MAKECMDGOALS),tools-only)
54 DIRS := $(filter-out runtime docs, $(DIRS))
58 ifeq ($(MAKECMDGOALS),install-clang)
59 DIRS := tools/clang/tools/driver tools/clang/tools/clang-cc \
60 tools/clang/lib/Headers tools/clang/docs
65 ifeq ($(MAKECMDGOALS),clang-only)
66 DIRS := $(filter-out tools runtime docs unittests, $(DIRS)) tools/clang
70 ifeq ($(MAKECMDGOALS),unittests)
71 DIRS := $(filter-out tools runtime docs, $(DIRS)) utils unittests
75 # Use NO_INSTALL define of the Makefile of each directory for deciding
76 # if the directory is installed or not
77 ifeq ($(MAKECMDGOALS),install)
78 OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
81 # If we're cross-compiling, build the build-hosted tools first
82 ifeq ($(LLVM_CROSS_COMPILING),1)
83 all:: cross-compile-build-tools
86 $(Verb) rm -rf BuildTools
88 cross-compile-build-tools:
89 $(Verb) if [ ! -f BuildTools/Makefile ]; then \
90 $(MKDIR) BuildTools; \
92 $(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
93 --host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE); \
96 ($(MAKE) -C BuildTools \
99 ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
100 ENABLE_PROFILING=$(ENABLE_PROFILING) \
101 ENABLE_COVERAGE=$(ENABLE_COVERAGE) \
102 DISABLE_ASSERTIONS=$(DISABLE_ASSERTIONS) \
103 ENABLE_EXPENSIVE_CHECKS=$(ENABLE_EXPENSIVE_CHECKS) \
107 # Include the main makefile machinery.
108 include $(LLVM_SRC_ROOT)/Makefile.rules
110 # Specify options to pass to configure script when we're
111 # running the dist-check target
112 DIST_CHECK_CONFIG_OPTIONS = --with-llvmgccdir=$(LLVMGCCDIR)
114 .PHONY: debug-opt-prof
116 $(Echo) Building Debug Version
119 $(Echo) Building Optimized Version
121 $(Verb) $(MAKE) ENABLE_OPTIMIZED=1
123 $(Echo) Building Profiling Version
125 $(Verb) $(MAKE) ENABLE_PROFILING=1
128 $(Echo) Eliminating files constructed by configure
130 $(TopDistDir)/include/llvm/Config/config.h \
131 $(TopDistDir)/include/llvm/Support/DataTypes.h \
132 $(TopDistDir)/include/llvm/Support/ThreadSupport.h
137 install-clang: install
138 install-libs: install
140 #------------------------------------------------------------------------
141 # Make sure the generated headers are up-to-date. This must be kept in
142 # sync with the AC_CONFIG_HEADER invocations in autoconf/configure.ac
143 #------------------------------------------------------------------------
145 include/llvm/Config/config.h \
146 include/llvm/Config/Targets.def \
147 include/llvm/Config/AsmPrinters.def \
148 include/llvm/Support/DataTypes.h \
149 tools/llvmc/plugins/Base/Base.td
150 FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
152 all-local:: $(FilesToConfigPATH)
153 $(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
154 $(Echo) Regenerating $*
155 $(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
156 .PRECIOUS: $(FilesToConfigPATH)
158 # NOTE: This needs to remain as the last target definition in this file so
159 # that it gets executed last.
160 ifneq ($(BUILD_DIRS_ONLY),1)
162 $(Echo) '*****' Completed $(BuildMode)$(AssertMode) Build
163 ifeq ($(BuildMode),Debug)
164 $(Echo) '*****' Note: Debug build can be 10 times slower than an
165 $(Echo) '*****' optimized build. Use 'make ENABLE_OPTIMIZED=1' to
166 $(Echo) '*****' make an optimized build. Alternatively you can
167 $(Echo) '*****' configure with --enable-optimized.
172 $(Verb)$(MAKE) check TESTSUITE=Feature RUNLLVM2CPP=1
175 $(Verb)$(MAKE) -C test check-one TESTONE=$(TESTONE)
177 srpm: $(LLVM_OBJ_ROOT)/llvm.spec
178 rpmbuild -bs $(LLVM_OBJ_ROOT)/llvm.spec
180 rpm: $(LLVM_OBJ_ROOT)/llvm.spec
181 rpmbuild -bb --target $(TARGET_TRIPLE) $(LLVM_OBJ_ROOT)/llvm.spec
184 $(Verb) du -sk $(LibDir)
185 $(Verb) du -sk $(ToolDir)
186 $(Verb) du -sk $(ExmplDir)
187 $(Verb) du -sk $(ObjDir)
190 $(Verb) if test ! -f ./config.status ; then \
191 ./configure --prefix="$(LLVM_TOP)/install" \
192 --with-llvm-gcc="$(LLVM_TOP)/llvm-gcc" ; \
194 $(Verb) $(MAKE) tools-only
199 SUB-SVN-DIRS = $(AWK) '/\?\ \ \ \ \ \ / {print $$2}' \
200 | LC_ALL=C xargs $(SVN) info 2>/dev/null \
201 | $(AWK) '/Path:\ / {print $$2}'
204 $(SVN) $(SVN-UPDATE-OPTIONS) update $(LLVM_SRC_ROOT)
205 @ $(SVN) status $(LLVM_SRC_ROOT) | $(SUB-SVN-DIRS) | xargs $(SVN) $(SVN-UPDATE-OPTIONS) update
207 happiness: update all check unittests
209 .PHONY: srpm rpm update happiness
211 # declare all targets at this level to be serial:
215 else # Building "Apple-style."
216 # N.B. In an Apple-style build, once configuration is done, lines
217 # marked "Apple-style" are removed with sed! See utils/buildit/build_llvm.
218 include utils/buildit/GNUmakefile # Building "Apple-style."
219 endif # Building "Apple-style."