blob: 1ecdc2c585be311d3846730fb970f93761f6a337 [file] [log] [blame]
Misha Brukman7426c892004-04-24 00:10:56 +00001#===- ./Makefile -------------------------------------------*- Makefile -*--===#
Misha Brukman2879c292009-01-08 02:11:55 +00002#
John Criswell4436c492003-10-20 22:26:57 +00003# The LLVM Compiler Infrastructure
4#
Chris Lattner11cc8b32007-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 Brukman2879c292009-01-08 02:11:55 +00007#
Misha Brukman7426c892004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner2ad80c22006-06-02 22:41:18 +00009
Chris Lattnerb85c3252006-07-26 19:10:34 +000010LEVEL := .
Chris Lattner31b4aa52006-09-04 04:27:07 +000011
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.
Reid Spencer4b8067f2006-11-17 03:32:33 +000018# 6. Build tools, runtime, docs.
Chris Lattner31b4aa52006-09-04 04:27:07 +000019#
Anton Korobeynikov8e58c522008-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 Hastings8de31d02009-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 Grosbachad637e92009-10-30 19:51:32 +000027ifneq ($(findstring llvmCore, $(RC_ProjectName)),llvmCore) # Normal build (not "Apple-style").
28
Anton Korobeynikov8e58c522008-11-10 07:33:13 +000029ifeq ($(BUILD_DIRS_ONLY),1)
30 DIRS := lib/System lib/Support utils
31 OPTIONAL_DIRS :=
32else
Jeffrey Yasskin6b718f72010-02-25 06:34:33 +000033 DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-shlib \
34 tools/llvm-config tools runtime docs unittests
Daniel Dunbar1aab2de2009-11-16 22:38:00 +000035 OPTIONAL_DIRS := projects bindings
36endif
37
38ifeq ($(BUILD_EXAMPLES),1)
39 OPTIONAL_DIRS += examples
Anton Korobeynikov8e58c522008-11-10 07:33:13 +000040endif
David Greeneb2e2be42007-07-11 23:44:08 +000041
Misha Brukmanbcf15382009-01-01 02:24:48 +000042EXTRA_DIST := test unittests llvm.spec include win32 Xcode
Chris Lattner2f7c9632001-06-06 20:29:01 +000043
Misha Brukman2879c292009-01-08 02:11:55 +000044include $(LEVEL)/Makefile.config
Reid Spenceraed84e42006-04-06 22:15:51 +000045
Jeffrey Yasskin6b718f72010-02-25 06:34:33 +000046ifneq ($(ENABLE_SHARED),1)
47 DIRS := $(filter-out tools/llvm-shlib, $(DIRS))
48endif
49
Chris Lattnerb85c3252006-07-26 19:10:34 +000050ifeq ($(MAKECMDGOALS),libs-only)
Reid Spencer4b8067f2006-11-17 03:32:33 +000051 DIRS := $(filter-out tools runtime docs, $(DIRS))
Chris Lattner2ad80c22006-06-02 22:41:18 +000052 OPTIONAL_DIRS :=
53endif
54
Nate Begeman938d8cb2007-12-13 02:17:17 +000055ifeq ($(MAKECMDGOALS),install-libs)
56 DIRS := $(filter-out tools runtime docs, $(DIRS))
57 OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
58endif
59
Chris Lattnerb85c3252006-07-26 19:10:34 +000060ifeq ($(MAKECMDGOALS),tools-only)
Reid Spencer4b8067f2006-11-17 03:32:33 +000061 DIRS := $(filter-out runtime docs, $(DIRS))
Chris Lattnerb85c3252006-07-26 19:10:34 +000062 OPTIONAL_DIRS :=
63endif
Chris Lattner2ad80c22006-06-02 22:41:18 +000064
Mike Stumpeb1e2002009-01-19 19:48:23 +000065ifeq ($(MAKECMDGOALS),install-clang)
Daniel Dunbare43fe7c2010-01-20 00:43:07 +000066 DIRS := tools/clang/tools/driver tools/clang/lib/Headers \
Daniel Dunbar4d92b642010-06-30 22:22:46 +000067 tools/clang/runtime tools/clang/docs
Mike Stumpeb1e2002009-01-19 19:48:23 +000068 OPTIONAL_DIRS :=
69 NO_INSTALL = 1
70endif
71
Daniel Dunbarf3ff59a2010-04-30 20:04:45 +000072ifeq ($(MAKECMDGOALS),install-clang-c)
73 DIRS := tools/clang/tools/driver tools/clang/lib/Headers \
Daniel Dunbar66ba55a2010-04-30 23:36:47 +000074 tools/clang/tools/libclang tools/clang/tools/c-index-test \
Daniel Dunbarf3ff59a2010-04-30 20:04:45 +000075 tools/clang/include/clang-c
76 OPTIONAL_DIRS :=
77 NO_INSTALL = 1
78endif
79
Mike Stumpeb1e2002009-01-19 19:48:23 +000080ifeq ($(MAKECMDGOALS),clang-only)
Torok Edwinfd5438e2009-09-26 20:18:58 +000081 DIRS := $(filter-out tools runtime docs unittests, $(DIRS)) tools/clang
Mike Stumpeb1e2002009-01-19 19:48:23 +000082 OPTIONAL_DIRS :=
83endif
84
Misha Brukmanbcf15382009-01-01 02:24:48 +000085ifeq ($(MAKECMDGOALS),unittests)
86 DIRS := $(filter-out tools runtime docs, $(DIRS)) utils unittests
87 OPTIONAL_DIRS :=
88endif
89
Chris Lattner8bbd76b2009-05-08 17:32:47 +000090# Use NO_INSTALL define of the Makefile of each directory for deciding
91# if the directory is installed or not
Chris Lattner31f99b92007-02-21 06:23:20 +000092ifeq ($(MAKECMDGOALS),install)
Gordon Henriksen37582f72007-09-18 12:49:39 +000093 OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
Chris Lattner31f99b92007-02-21 06:23:20 +000094endif
95
Anton Korobeynikov8e58c522008-11-10 07:33:13 +000096# If we're cross-compiling, build the build-hosted tools first
97ifeq ($(LLVM_CROSS_COMPILING),1)
98all:: cross-compile-build-tools
99
100clean::
101 $(Verb) rm -rf BuildTools
102
103cross-compile-build-tools:
104 $(Verb) if [ ! -f BuildTools/Makefile ]; then \
105 $(MKDIR) BuildTools; \
106 cd BuildTools ; \
Jim Grosbach885fdd32009-10-30 19:53:38 +0000107 unset CFLAGS ; \
108 unset CXXFLAGS ; \
Shantonu Sen96995e82009-09-02 23:52:23 +0000109 $(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
110 --host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE); \
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000111 cd .. ; \
112 fi; \
Shantonu Sen96995e82009-09-02 23:52:23 +0000113 ($(MAKE) -C BuildTools \
114 BUILD_DIRS_ONLY=1 \
115 UNIVERSAL= \
116 ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
117 ENABLE_PROFILING=$(ENABLE_PROFILING) \
118 ENABLE_COVERAGE=$(ENABLE_COVERAGE) \
119 DISABLE_ASSERTIONS=$(DISABLE_ASSERTIONS) \
120 ENABLE_EXPENSIVE_CHECKS=$(ENABLE_EXPENSIVE_CHECKS) \
Jim Grosbache8421402010-04-24 00:46:14 +0000121 CFLAGS= \
122 CXXFLAGS= \
Shantonu Sen96995e82009-09-02 23:52:23 +0000123 ) || exit 1;
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000124endif
125
Chris Lattner2ad80c22006-06-02 22:41:18 +0000126# Include the main makefile machinery.
Reid Spencer8ac50622006-04-08 02:14:37 +0000127include $(LLVM_SRC_ROOT)/Makefile.rules
128
Reid Spencer13f51932005-05-24 02:33:20 +0000129# Specify options to pass to configure script when we're
130# running the dist-check target
131DIST_CHECK_CONFIG_OPTIONS = --with-llvmgccdir=$(LLVMGCCDIR)
132
Reid Spencer33478272004-11-25 09:08:54 +0000133.PHONY: debug-opt-prof
134debug-opt-prof:
135 $(Echo) Building Debug Version
136 $(Verb) $(MAKE)
137 $(Echo)
138 $(Echo) Building Optimized Version
139 $(Echo)
140 $(Verb) $(MAKE) ENABLE_OPTIMIZED=1
141 $(Echo)
142 $(Echo) Building Profiling Version
143 $(Echo)
144 $(Verb) $(MAKE) ENABLE_PROFILING=1
145
Reid Spencer100080c2004-10-25 08:27:37 +0000146dist-hook::
Reid Spencerf88808a2004-10-30 09:19:36 +0000147 $(Echo) Eliminating files constructed by configure
148 $(Verb) $(RM) -f \
Reid Spencer4a9b5ff2004-10-26 07:05:09 +0000149 $(TopDistDir)/include/llvm/Config/config.h \
Chandler Carruth56869f22009-10-26 01:35:46 +0000150 $(TopDistDir)/include/llvm/System/DataTypes.h
Reid Spencer100080c2004-10-25 08:27:37 +0000151
Mike Stumpeb1e2002009-01-19 19:48:23 +0000152clang-only: all
Chris Lattner6bd75a62004-02-03 22:56:40 +0000153tools-only: all
Reid Spencerfec4f802005-05-25 21:03:17 +0000154libs-only: all
Mike Stumpeb1e2002009-01-19 19:48:23 +0000155install-clang: install
Daniel Dunbarf3ff59a2010-04-30 20:04:45 +0000156install-clang-c: install
Nate Begeman938d8cb2007-12-13 02:17:17 +0000157install-libs: install
Reid Spencer53846bc2005-08-25 04:59:49 +0000158
159#------------------------------------------------------------------------
160# Make sure the generated headers are up-to-date. This must be kept in
161# sync with the AC_CONFIG_HEADER invocations in autoconf/configure.ac
162#------------------------------------------------------------------------
163FilesToConfig := \
164 include/llvm/Config/config.h \
Douglas Gregor1b731d52009-06-16 20:12:29 +0000165 include/llvm/Config/Targets.def \
Daniel Dunbare8b8cce2009-11-25 04:46:58 +0000166 include/llvm/Config/AsmPrinters.def \
167 include/llvm/Config/AsmParsers.def \
168 include/llvm/Config/Disassemblers.def \
Chandler Carruth56869f22009-10-26 01:35:46 +0000169 include/llvm/System/DataTypes.h \
Daniel Dunbare8b8cce2009-11-25 04:46:58 +0000170 tools/llvmc/plugins/Base/Base.td
Reid Spencer53846bc2005-08-25 04:59:49 +0000171FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
172
173all-local:: $(FilesToConfigPATH)
Misha Brukman2879c292009-01-08 02:11:55 +0000174$(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
Reid Spencer53846bc2005-08-25 04:59:49 +0000175 $(Echo) Regenerating $*
176 $(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
177.PRECIOUS: $(FilesToConfigPATH)
Reid Spencer754cfec2006-04-07 15:58:18 +0000178
Chris Lattnere690a932006-04-07 16:21:59 +0000179# NOTE: This needs to remain as the last target definition in this file so
180# that it gets executed last.
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000181ifneq ($(BUILD_DIRS_ONLY),1)
Misha Brukman2879c292009-01-08 02:11:55 +0000182all::
Duncan Sands408bb192010-07-07 07:48:00 +0000183 $(Echo) '*****' Completed $(BuildMode) Build
Reid Spencer754cfec2006-04-07 15:58:18 +0000184ifeq ($(BuildMode),Debug)
185 $(Echo) '*****' Note: Debug build can be 10 times slower than an
186 $(Echo) '*****' optimized build. Use 'make ENABLE_OPTIMIZED=1' to
Gabor Greif76e70832008-02-28 11:48:14 +0000187 $(Echo) '*****' make an optimized build. Alternatively you can
188 $(Echo) '*****' configure with --enable-optimized.
Reid Spencer754cfec2006-04-07 15:58:18 +0000189endif
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000190endif
Chris Lattnere690a932006-04-07 16:21:59 +0000191
Reid Spencer9c226202006-06-01 07:27:53 +0000192check-llvm2cpp:
Reid Spencer6d4a4172007-04-15 06:22:48 +0000193 $(Verb)$(MAKE) check TESTSUITE=Feature RUNLLVM2CPP=1
Chris Lattnerb85c3252006-07-26 19:10:34 +0000194
Reid Spencera9482c82007-04-15 06:18:50 +0000195check-one:
Reid Spencer6d4a4172007-04-15 06:22:48 +0000196 $(Verb)$(MAKE) -C test check-one TESTONE=$(TESTONE)
Reid Spencera9482c82007-04-15 06:18:50 +0000197
Misha Brukman2879c292009-01-08 02:11:55 +0000198srpm: $(LLVM_OBJ_ROOT)/llvm.spec
Reid Spencerd14c6ca2006-08-16 00:43:50 +0000199 rpmbuild -bs $(LLVM_OBJ_ROOT)/llvm.spec
200
Misha Brukman2879c292009-01-08 02:11:55 +0000201rpm: $(LLVM_OBJ_ROOT)/llvm.spec
Reid Spencerd14c6ca2006-08-16 00:43:50 +0000202 rpmbuild -bb --target $(TARGET_TRIPLE) $(LLVM_OBJ_ROOT)/llvm.spec
203
Reid Spencer99a1e6b2007-02-05 23:18:58 +0000204show-footprint:
205 $(Verb) du -sk $(LibDir)
206 $(Verb) du -sk $(ToolDir)
207 $(Verb) du -sk $(ExmplDir)
208 $(Verb) du -sk $(ObjDir)
209
Reid Spencer64a26222007-07-08 03:50:22 +0000210build-for-llvm-top:
211 $(Verb) if test ! -f ./config.status ; then \
212 ./configure --prefix="$(LLVM_TOP)/install" \
213 --with-llvm-gcc="$(LLVM_TOP)/llvm-gcc" ; \
214 fi
215 $(Verb) $(MAKE) tools-only
216
Gabor Greifd71b4102008-02-28 13:06:50 +0000217SVN = svn
Gabor Greif376d2ce2008-02-28 14:58:14 +0000218SVN-UPDATE-OPTIONS =
Gabor Greifd71b4102008-02-28 13:06:50 +0000219AWK = awk
Gabor Greifa6e293a2008-02-28 18:46:56 +0000220SUB-SVN-DIRS = $(AWK) '/\?\ \ \ \ \ \ / {print $$2}' \
Gabor Greif33e834c2009-04-24 17:00:03 +0000221 | LC_ALL=C xargs $(SVN) info 2>/dev/null \
Gabor Greifa6e293a2008-02-28 18:46:56 +0000222 | $(AWK) '/Path:\ / {print $$2}'
Gabor Greifd71b4102008-02-28 13:06:50 +0000223
224update:
Gabor Greifa6c5b382008-03-21 22:17:07 +0000225 $(SVN) $(SVN-UPDATE-OPTIONS) update $(LLVM_SRC_ROOT)
226 @ $(SVN) status $(LLVM_SRC_ROOT) | $(SUB-SVN-DIRS) | xargs $(SVN) $(SVN-UPDATE-OPTIONS) update
Gabor Greifd71b4102008-02-28 13:06:50 +0000227
Gabor Greif9f228412010-03-21 22:23:02 +0000228happiness: update all check-all
Gabor Greifd71b4102008-02-28 13:06:50 +0000229
230.PHONY: srpm rpm update happiness
Reid Spencer64a26222007-07-08 03:50:22 +0000231
Gabor Greif76e70832008-02-28 11:48:14 +0000232# declare all targets at this level to be serial:
233
234.NOTPARALLEL:
235
Stuart Hastings8de31d02009-10-22 17:22:37 +0000236else # Building "Apple-style."
237# In an Apple-style build, once configuration is done, lines marked
238# "Apple-style" are removed with sed! Please don't remove these!
239# Look for the string "Apple-style" in utils/buildit/build_llvm.
240include $(shell find . -name GNUmakefile) # Building "Apple-style."
241endif # Building "Apple-style."