blob: 2b9468af205381d5b7e25d4dd8873ed560819006 [file] [log] [blame]
Misha Brukman6d5ab862004-04-24 00:10:56 +00001#===- ./Makefile -------------------------------------------*- Makefile -*--===#
Misha Brukmanef5dc702009-01-08 02:11:55 +00002#
John Criswelle488e932003-10-20 22:26:57 +00003# The LLVM Compiler Infrastructure
4#
Chris Lattner57360d12007-12-29 20:11:13 +00005# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
Misha Brukmanef5dc702009-01-08 02:11:55 +00007#
Misha Brukman6d5ab862004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner22033b22006-06-02 22:41:18 +00009
Chris Lattner5720be42006-07-26 19:10:34 +000010LEVEL := .
Chris Lattner87b51012006-09-04 04:27:07 +000011
12# Top-Level LLVM Build Stages:
Peter Collingbourne7c788882011-10-01 16:41:13 +000013# 1. Build lib/Support and lib/TableGen, which are used by utils (tblgen).
Chandler Carruthfe4c10c2013-01-02 09:27:25 +000014# 2. Build utils, which is used by IR.
15# 3. Build IR, which builds the Intrinsics.inc file used by libs.
Daniel Dunbar1ad92132011-11-10 19:59:35 +000016# 4. Build libs, which are needed by llvm-config.
17# 5. Build llvm-config, which determines inter-lib dependencies for tools.
Stephen Hines36b56882014-04-23 16:57:46 -070018# 6. Build tools, docs, and cmake modules.
Chris Lattner87b51012006-09-04 04:27:07 +000019#
Anton Korobeynikov569c45c2008-11-10 07:33:13 +000020# When cross-compiling, there are some things (tablegen) that need to
21# be build for the build system first.
Stuart Hastings4a53e1e2009-10-22 17:22:37 +000022
23# If "RC_ProjectName" exists in the environment, and its value is
24# "llvmCore", then this is an "Apple-style" build; search for
25# "Apple-style" in the comments for more info. Anything else is a
26# normal build.
Jim Grosbach2cdc80c2009-10-30 19:51:32 +000027ifneq ($(findstring llvmCore, $(RC_ProjectName)),llvmCore) # Normal build (not "Apple-style").
28
Anton Korobeynikov569c45c2008-11-10 07:33:13 +000029ifeq ($(BUILD_DIRS_ONLY),1)
Daniel Dunbarcb497b82011-12-01 20:18:09 +000030 DIRS := lib/Support lib/TableGen utils tools/llvm-config
Peter Collingbourne0be07d32011-10-08 00:27:38 +000031 OPTIONAL_DIRS := tools/clang/utils/TableGen
Anton Korobeynikov569c45c2008-11-10 07:33:13 +000032else
Chandler Carruthfe4c10c2013-01-02 09:27:25 +000033 DIRS := lib/Support lib/TableGen utils lib/IR lib tools/llvm-shlib \
Stephen Hines36b56882014-04-23 16:57:46 -070034 tools/llvm-config tools docs cmake unittests
Daniel Dunbarda589a32009-11-16 22:38:00 +000035 OPTIONAL_DIRS := projects bindings
36endif
37
38ifeq ($(BUILD_EXAMPLES),1)
39 OPTIONAL_DIRS += examples
Anton Korobeynikov569c45c2008-11-10 07:33:13 +000040endif
David Greenedf93e572007-07-11 23:44:08 +000041
Misha Brukman8fb520e2009-01-01 02:24:48 +000042EXTRA_DIST := test unittests llvm.spec include win32 Xcode
Chris Lattner00950542001-06-06 20:29:01 +000043
Misha Brukmanef5dc702009-01-08 02:11:55 +000044include $(LEVEL)/Makefile.config
Reid Spencer93bc3cd2006-04-06 22:15:51 +000045
Jeffrey Yasskinc9017192010-02-25 06:34:33 +000046ifneq ($(ENABLE_SHARED),1)
47 DIRS := $(filter-out tools/llvm-shlib, $(DIRS))
48endif
49
Rafael Espindola9d9ae9f2010-11-12 19:24:06 +000050ifneq ($(ENABLE_DOCS),1)
51 DIRS := $(filter-out docs, $(DIRS))
52endif
53
Chris Lattner5720be42006-07-26 19:10:34 +000054ifeq ($(MAKECMDGOALS),libs-only)
Chandler Carruthdd5d86d2013-10-02 15:42:23 +000055 DIRS := $(filter-out tools docs, $(DIRS))
Chris Lattner22033b22006-06-02 22:41:18 +000056 OPTIONAL_DIRS :=
57endif
58
Nate Begeman544f83d2007-12-13 02:17:17 +000059ifeq ($(MAKECMDGOALS),install-libs)
Chandler Carruthdd5d86d2013-10-02 15:42:23 +000060 DIRS := $(filter-out tools docs, $(DIRS))
Nate Begeman544f83d2007-12-13 02:17:17 +000061 OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
62endif
63
Chris Lattner5720be42006-07-26 19:10:34 +000064ifeq ($(MAKECMDGOALS),tools-only)
Chandler Carruthdd5d86d2013-10-02 15:42:23 +000065 DIRS := $(filter-out docs, $(DIRS))
Chris Lattner5720be42006-07-26 19:10:34 +000066 OPTIONAL_DIRS :=
67endif
Chris Lattner22033b22006-06-02 22:41:18 +000068
Mike Stumpb76ace32009-01-19 19:48:23 +000069ifeq ($(MAKECMDGOALS),install-clang)
Daniel Dunbar6b8dfed2010-01-20 00:43:07 +000070 DIRS := tools/clang/tools/driver tools/clang/lib/Headers \
Bob Wilson4e33d942012-10-24 22:56:32 +000071 tools/clang/tools/libclang \
Argyrios Kyrtzidis9d8c6782012-11-06 19:54:46 +000072 tools/clang/tools/c-index-test \
Bob Wilson9fbf6172011-11-27 00:26:22 +000073 tools/clang/include/clang-c \
Daniel Dunbare160a522010-07-16 01:29:50 +000074 tools/clang/runtime tools/clang/docs \
Chandler Carruthdd5d86d2013-10-02 15:42:23 +000075 tools/lto
Mike Stumpb76ace32009-01-19 19:48:23 +000076 OPTIONAL_DIRS :=
77 NO_INSTALL = 1
78endif
79
80ifeq ($(MAKECMDGOALS),clang-only)
Bill Wendlinga1f21e62011-06-10 21:47:14 +000081 DIRS := $(filter-out tools docs unittests, $(DIRS)) \
Daniel Dunbare160a522010-07-16 01:29:50 +000082 tools/clang tools/lto
Mike Stumpb76ace32009-01-19 19:48:23 +000083 OPTIONAL_DIRS :=
84endif
85
Misha Brukman8fb520e2009-01-01 02:24:48 +000086ifeq ($(MAKECMDGOALS),unittests)
Chandler Carruthdd5d86d2013-10-02 15:42:23 +000087 DIRS := $(filter-out tools docs, $(DIRS)) utils unittests
Misha Brukman8fb520e2009-01-01 02:24:48 +000088 OPTIONAL_DIRS :=
89endif
90
Chris Lattnerc8914652009-05-08 17:32:47 +000091# Use NO_INSTALL define of the Makefile of each directory for deciding
92# if the directory is installed or not
Chris Lattner122c0552007-02-21 06:23:20 +000093ifeq ($(MAKECMDGOALS),install)
Gordon Henriksen8ef426b2007-09-18 12:49:39 +000094 OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
Chris Lattner122c0552007-02-21 06:23:20 +000095endif
96
Daniel Dunbara1e13192010-11-27 06:59:16 +000097# Don't build unittests when ONLY_TOOLS is set.
98ifneq ($(ONLY_TOOLS),)
99 DIRS := $(filter-out unittests, $(DIRS))
100endif
101
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000102# If we're cross-compiling, build the build-hosted tools first
103ifeq ($(LLVM_CROSS_COMPILING),1)
104all:: cross-compile-build-tools
105
106clean::
107 $(Verb) rm -rf BuildTools
108
109cross-compile-build-tools:
110 $(Verb) if [ ! -f BuildTools/Makefile ]; then \
111 $(MKDIR) BuildTools; \
112 cd BuildTools ; \
Jim Grosbach1f22d6f2009-10-30 19:53:38 +0000113 unset CFLAGS ; \
114 unset CXXFLAGS ; \
Stephen Hines36b56882014-04-23 16:57:46 -0700115 AR=$(BUILD_AR) ; \
116 AS=$(BUILD_AS) ; \
117 LD=$(BUILD_LD) ; \
118 CC=$(BUILD_CC) ; \
119 CXX=$(BUILD_CXX) ; \
Daniel Dunbarde659472012-08-22 22:01:01 +0000120 unset SDKROOT ; \
Bob Wilsonc9d0c702012-09-24 22:51:19 +0000121 unset UNIVERSAL_SDK_PATH ; \
Stephen Hines36b56882014-04-23 16:57:46 -0700122 configure_opts= ; \
123 if test "$(ENABLE_LIBCPP)" -ne 0 ; then \
124 configure_opts="$$configure_opts --enable-libcpp"; \
125 fi; \
Shantonu Sen5e869c32009-09-02 23:52:23 +0000126 $(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
Peter Collingbourne0be07d32011-10-08 00:27:38 +0000127 --host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE) \
Stephen Hines36b56882014-04-23 16:57:46 -0700128 --disable-polly $$configure_opts; \
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000129 cd .. ; \
130 fi; \
Bob Wilsonc9d0c702012-09-24 22:51:19 +0000131 ($(MAKE) -C BuildTools \
Shantonu Sen5e869c32009-09-02 23:52:23 +0000132 BUILD_DIRS_ONLY=1 \
133 UNIVERSAL= \
Bob Wilsonc9d0c702012-09-24 22:51:19 +0000134 UNIVERSAL_SDK_PATH= \
135 SDKROOT= \
Daniel Dunbara7de1d62011-11-12 00:18:02 +0000136 TARGET_NATIVE_ARCH="$(TARGET_NATIVE_ARCH)" \
Daniel Dunbar01b825d2011-11-11 22:59:45 +0000137 TARGETS_TO_BUILD="$(TARGETS_TO_BUILD)" \
Stephen Hines36b56882014-04-23 16:57:46 -0700138 TARGET_LIBS="$(LIBS)" \
Shantonu Sen5e869c32009-09-02 23:52:23 +0000139 ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
140 ENABLE_PROFILING=$(ENABLE_PROFILING) \
141 ENABLE_COVERAGE=$(ENABLE_COVERAGE) \
142 DISABLE_ASSERTIONS=$(DISABLE_ASSERTIONS) \
143 ENABLE_EXPENSIVE_CHECKS=$(ENABLE_EXPENSIVE_CHECKS) \
Eric Christopherbee515f2011-11-11 22:51:42 +0000144 ENABLE_LIBCPP=$(ENABLE_LIBCPP) \
Jim Grosbach37ff5c62010-04-24 00:46:14 +0000145 CFLAGS= \
146 CXXFLAGS= \
Shantonu Sen5e869c32009-09-02 23:52:23 +0000147 ) || exit 1;
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000148endif
149
Chris Lattner22033b22006-06-02 22:41:18 +0000150# Include the main makefile machinery.
Reid Spencer06a801a2006-04-08 02:14:37 +0000151include $(LLVM_SRC_ROOT)/Makefile.rules
152
Reid Spencer45eeed92005-05-24 02:33:20 +0000153# Specify options to pass to configure script when we're
154# running the dist-check target
155DIST_CHECK_CONFIG_OPTIONS = --with-llvmgccdir=$(LLVMGCCDIR)
156
Reid Spencerdf561f42004-11-25 09:08:54 +0000157.PHONY: debug-opt-prof
158debug-opt-prof:
159 $(Echo) Building Debug Version
160 $(Verb) $(MAKE)
161 $(Echo)
162 $(Echo) Building Optimized Version
163 $(Echo)
164 $(Verb) $(MAKE) ENABLE_OPTIMIZED=1
165 $(Echo)
166 $(Echo) Building Profiling Version
167 $(Echo)
168 $(Verb) $(MAKE) ENABLE_PROFILING=1
169
Reid Spencer151f8ba2004-10-25 08:27:37 +0000170dist-hook::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000171 $(Echo) Eliminating files constructed by configure
172 $(Verb) $(RM) -f \
Reid Spencer90c29492004-10-26 07:05:09 +0000173 $(TopDistDir)/include/llvm/Config/config.h \
Michael J. Spencer1f6efa32010-11-29 18:16:10 +0000174 $(TopDistDir)/include/llvm/Support/DataTypes.h
Reid Spencer151f8ba2004-10-25 08:27:37 +0000175
Mike Stumpb76ace32009-01-19 19:48:23 +0000176clang-only: all
Chris Lattner9cf662b2004-02-03 22:56:40 +0000177tools-only: all
Reid Spencer8b1f7672005-05-25 21:03:17 +0000178libs-only: all
Mike Stumpb76ace32009-01-19 19:48:23 +0000179install-clang: install
Nate Begeman544f83d2007-12-13 02:17:17 +0000180install-libs: install
Reid Spencerca739c62005-08-25 04:59:49 +0000181
Daniel Dunbar58194302011-04-11 22:37:39 +0000182# If SHOW_DIAGNOSTICS is enabled, clear the diagnostics file first.
183ifeq ($(SHOW_DIAGNOSTICS),1)
184clean-diagnostics:
185 $(Verb) rm -f $(LLVM_OBJ_ROOT)/$(BuildMode)/diags
186.PHONY: clean-diagnostics
187
188all-local:: clean-diagnostics
189endif
190
Reid Spencerca739c62005-08-25 04:59:49 +0000191#------------------------------------------------------------------------
Dylan Noblesmithf214b802012-01-17 02:56:49 +0000192# Make sure the generated files are up-to-date. This must be kept in
193# sync with the AC_CONFIG_HEADER and AC_CONFIG_FILE invocations in
194# autoconf/configure.ac.
195# Note that Makefile.config is covered by its own separate rule
196# in Makefile.rules where it can be reused by sub-projects.
Reid Spencerca739c62005-08-25 04:59:49 +0000197#------------------------------------------------------------------------
198FilesToConfig := \
Dylan Noblesmithf214b802012-01-17 02:56:49 +0000199 bindings/ocaml/llvm/META.llvm \
200 docs/doxygen.cfg \
201 llvm.spec \
Reid Spencerca739c62005-08-25 04:59:49 +0000202 include/llvm/Config/config.h \
Dylan Noblesmithf214b802012-01-17 02:56:49 +0000203 include/llvm/Config/llvm-config.h \
Douglas Gregor1555a232009-06-16 20:12:29 +0000204 include/llvm/Config/Targets.def \
Daniel Dunbarf87ea4d2009-11-25 04:46:58 +0000205 include/llvm/Config/AsmPrinters.def \
206 include/llvm/Config/AsmParsers.def \
207 include/llvm/Config/Disassemblers.def \
Eric Christopherf1175062011-09-19 23:22:41 +0000208 include/llvm/Support/DataTypes.h
Reid Spencerca739c62005-08-25 04:59:49 +0000209FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
210
211all-local:: $(FilesToConfigPATH)
Misha Brukmanef5dc702009-01-08 02:11:55 +0000212$(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
Reid Spencerca739c62005-08-25 04:59:49 +0000213 $(Echo) Regenerating $*
214 $(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
215.PRECIOUS: $(FilesToConfigPATH)
Reid Spencere22f3c02006-04-07 15:58:18 +0000216
Chris Lattner38ab6d82006-04-07 16:21:59 +0000217# NOTE: This needs to remain as the last target definition in this file so
218# that it gets executed last.
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000219ifneq ($(BUILD_DIRS_ONLY),1)
Misha Brukmanef5dc702009-01-08 02:11:55 +0000220all::
Duncan Sands8246adc2010-07-07 07:48:00 +0000221 $(Echo) '*****' Completed $(BuildMode) Build
Duncan Sands2b48c332010-07-07 16:48:16 +0000222ifneq ($(ENABLE_OPTIMIZED),1)
Reid Spencere22f3c02006-04-07 15:58:18 +0000223 $(Echo) '*****' Note: Debug build can be 10 times slower than an
224 $(Echo) '*****' optimized build. Use 'make ENABLE_OPTIMIZED=1' to
Gabor Greif2ae19552008-02-28 11:48:14 +0000225 $(Echo) '*****' make an optimized build. Alternatively you can
226 $(Echo) '*****' configure with --enable-optimized.
Daniel Dunbar58194302011-04-11 22:37:39 +0000227ifeq ($(SHOW_DIAGNOSTICS),1)
228 $(Verb) if test -s $(LLVM_OBJ_ROOT)/$(BuildMode)/diags; then \
Daniel Dunbarb16ec682011-11-02 19:48:19 +0000229 $(LLVM_SRC_ROOT)/utils/clang-parse-diagnostics-file -a \
Daniel Dunbar58194302011-04-11 22:37:39 +0000230 $(LLVM_OBJ_ROOT)/$(BuildMode)/diags; \
231 fi
232endif
Reid Spencere22f3c02006-04-07 15:58:18 +0000233endif
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000234endif
Chris Lattner38ab6d82006-04-07 16:21:59 +0000235
Reid Spencer5b30ee12006-06-01 07:27:53 +0000236check-llvm2cpp:
Reid Spencer42f98e52007-04-15 06:22:48 +0000237 $(Verb)$(MAKE) check TESTSUITE=Feature RUNLLVM2CPP=1
Chris Lattner5720be42006-07-26 19:10:34 +0000238
Misha Brukmanef5dc702009-01-08 02:11:55 +0000239srpm: $(LLVM_OBJ_ROOT)/llvm.spec
Reid Spencerf7c75a62006-08-16 00:43:50 +0000240 rpmbuild -bs $(LLVM_OBJ_ROOT)/llvm.spec
241
Misha Brukmanef5dc702009-01-08 02:11:55 +0000242rpm: $(LLVM_OBJ_ROOT)/llvm.spec
Reid Spencerf7c75a62006-08-16 00:43:50 +0000243 rpmbuild -bb --target $(TARGET_TRIPLE) $(LLVM_OBJ_ROOT)/llvm.spec
244
Reid Spencer1e46ae42007-02-05 23:18:58 +0000245show-footprint:
246 $(Verb) du -sk $(LibDir)
247 $(Verb) du -sk $(ToolDir)
248 $(Verb) du -sk $(ExmplDir)
249 $(Verb) du -sk $(ObjDir)
250
Reid Spencer51cf6422007-07-08 03:50:22 +0000251build-for-llvm-top:
252 $(Verb) if test ! -f ./config.status ; then \
253 ./configure --prefix="$(LLVM_TOP)/install" \
254 --with-llvm-gcc="$(LLVM_TOP)/llvm-gcc" ; \
255 fi
256 $(Verb) $(MAKE) tools-only
257
Gabor Greif1d7ca712008-02-28 13:06:50 +0000258SVN = svn
Gabor Greif9fa42262008-02-28 14:58:14 +0000259SVN-UPDATE-OPTIONS =
Gabor Greif1d7ca712008-02-28 13:06:50 +0000260AWK = awk
Edwin Vane410b46a2013-01-28 03:19:57 +0000261
262# Multiline variable defining a recursive function for finding svn repos rooted at
263# a given path. svnup() requires one argument: the root to search from.
264define SUB_SVN_DIRS
265svnup() {
Craig Topperbf361f52013-07-03 14:48:37 +0000266 dirs=`svn status --no-ignore $$1 | awk '/^(I|\?) / {print $$2}' | LC_ALL=C xargs svn info 2>/dev/null | awk '/^Path:\ / {print $$2}'`;
Edwin Vane410b46a2013-01-28 03:19:57 +0000267 if [ "$$dirs" = "" ]; then
268 return;
269 fi;
270 for f in $$dirs; do
271 echo $$f;
272 svnup $$f;
273 done
274}
275endef
276export SUB_SVN_DIRS
Gabor Greif1d7ca712008-02-28 13:06:50 +0000277
278update:
Gabor Greif8e0c20b2008-03-21 22:17:07 +0000279 $(SVN) $(SVN-UPDATE-OPTIONS) update $(LLVM_SRC_ROOT)
Edwin Vane410b46a2013-01-28 03:19:57 +0000280 @eval $$SUB_SVN_DIRS; $(SVN) status --no-ignore $(LLVM_SRC_ROOT) | svnup $(LLVM_SRC_ROOT) | xargs $(SVN) $(SVN-UPDATE-OPTIONS) update
Gabor Greif1d7ca712008-02-28 13:06:50 +0000281
Gabor Greif312fa752010-03-21 22:23:02 +0000282happiness: update all check-all
Gabor Greif1d7ca712008-02-28 13:06:50 +0000283
284.PHONY: srpm rpm update happiness
Reid Spencer51cf6422007-07-08 03:50:22 +0000285
Gabor Greif2ae19552008-02-28 11:48:14 +0000286# declare all targets at this level to be serial:
287
288.NOTPARALLEL:
289
Stuart Hastings4a53e1e2009-10-22 17:22:37 +0000290else # Building "Apple-style."
291# In an Apple-style build, once configuration is done, lines marked
292# "Apple-style" are removed with sed! Please don't remove these!
293# Look for the string "Apple-style" in utils/buildit/build_llvm.
294include $(shell find . -name GNUmakefile) # Building "Apple-style."
295endif # Building "Apple-style."