Makefile revision bdd040fba2b1b21bac887bac9c19df6d439a3ba4
1#===- ./Makefile -------------------------------------------*- Makefile -*--===#
2#
3#                     The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8#===------------------------------------------------------------------------===#
9
10LEVEL := .
11
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.
19#
20# When cross-compiling, there are some things (tablegen) that need to
21# be build for the build system first.
22ifeq ($(BUILD_DIRS_ONLY),1)
23  DIRS := lib/System lib/Support utils
24  OPTIONAL_DIRS :=
25else
26  DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \
27          tools runtime docs unittests
28  OPTIONAL_DIRS := examples projects bindings
29endif
30
31EXTRA_DIST := test unittests llvm.spec include win32 Xcode
32
33include $(LEVEL)/Makefile.config
34
35# llvm-gcc4 doesn't need runtime libs.  llvm-gcc4 is the only supported one.
36# FIXME: Remove runtime entirely once we have an understanding of where
37# libprofile etc should go.
38#ifeq ($(LLVMGCC_MAJVERS),4)
39#  DIRS := $(filter-out runtime, $(DIRS))
40#endif
41
42ifeq ($(MAKECMDGOALS),libs-only)
43  DIRS := $(filter-out tools runtime docs, $(DIRS))
44  OPTIONAL_DIRS :=
45endif
46
47ifeq ($(MAKECMDGOALS),install-libs)
48  DIRS := $(filter-out tools runtime docs, $(DIRS))
49  OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
50endif
51
52ifeq ($(MAKECMDGOALS),tools-only)
53  DIRS := $(filter-out runtime docs, $(DIRS))
54  OPTIONAL_DIRS :=
55endif
56
57ifeq ($(MAKECMDGOALS),install-clang)
58  DIRS := tools/clang/tools/driver tools/clang/tools/clang-cc \
59	tools/clang/lib/Headers tools/clang/docs
60  OPTIONAL_DIRS :=
61  NO_INSTALL = 1
62endif
63
64ifeq ($(MAKECMDGOALS),clang-only)
65  DIRS := $(filter-out tools runtime docs unittests, $(DIRS)) tools/clang
66  OPTIONAL_DIRS :=
67endif
68
69ifeq ($(MAKECMDGOALS),unittests)
70  DIRS := $(filter-out tools runtime docs, $(DIRS)) utils unittests
71  OPTIONAL_DIRS :=
72endif
73
74# Use NO_INSTALL define of the Makefile of each directory for deciding
75# if the directory is installed or not
76ifeq ($(MAKECMDGOALS),install)
77  OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
78endif
79
80# If we're cross-compiling, build the build-hosted tools first
81ifeq ($(LLVM_CROSS_COMPILING),1)
82all:: cross-compile-build-tools
83
84clean::
85	$(Verb) rm -rf BuildTools
86
87cross-compile-build-tools:
88	$(Verb) if [ ! -f BuildTools/Makefile ]; then \
89          $(MKDIR) BuildTools; \
90	  cd BuildTools ; \
91	  $(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
92		--host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE); \
93	  cd .. ; \
94	fi; \
95        ($(MAKE) -C BuildTools \
96	  BUILD_DIRS_ONLY=1 \
97	  UNIVERSAL= \
98	  ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
99	  ENABLE_PROFILING=$(ENABLE_PROFILING) \
100	  ENABLE_COVERAGE=$(ENABLE_COVERAGE) \
101	  DISABLE_ASSERTIONS=$(DISABLE_ASSERTIONS) \
102	  ENABLE_EXPENSIVE_CHECKS=$(ENABLE_EXPENSIVE_CHECKS) \
103	) || exit 1;
104endif
105
106# Include the main makefile machinery.
107include $(LLVM_SRC_ROOT)/Makefile.rules
108
109# Specify options to pass to configure script when we're
110# running the dist-check target
111DIST_CHECK_CONFIG_OPTIONS = --with-llvmgccdir=$(LLVMGCCDIR)
112
113.PHONY: debug-opt-prof
114debug-opt-prof:
115	$(Echo) Building Debug Version
116	$(Verb) $(MAKE)
117	$(Echo)
118	$(Echo) Building Optimized Version
119	$(Echo)
120	$(Verb) $(MAKE) ENABLE_OPTIMIZED=1
121	$(Echo)
122	$(Echo) Building Profiling Version
123	$(Echo)
124	$(Verb) $(MAKE) ENABLE_PROFILING=1
125
126dist-hook::
127	$(Echo) Eliminating files constructed by configure
128	$(Verb) $(RM) -f \
129	  $(TopDistDir)/include/llvm/Config/config.h  \
130	  $(TopDistDir)/include/llvm/Support/DataTypes.h  \
131	  $(TopDistDir)/include/llvm/Support/ThreadSupport.h
132
133clang-only: all
134tools-only: all
135libs-only: all
136install-clang: install
137install-libs: install
138
139#------------------------------------------------------------------------
140# Make sure the generated headers are up-to-date. This must be kept in
141# sync with the AC_CONFIG_HEADER invocations in autoconf/configure.ac
142#------------------------------------------------------------------------
143FilesToConfig := \
144  include/llvm/Config/config.h \
145  include/llvm/Config/Targets.def \
146	include/llvm/Config/AsmPrinters.def \
147  include/llvm/Support/DataTypes.h \
148	tools/llvmc/plugins/Base/Base.td
149FilesToConfigPATH  := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
150
151all-local:: $(FilesToConfigPATH)
152$(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
153	$(Echo) Regenerating $*
154	$(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
155.PRECIOUS: $(FilesToConfigPATH)
156
157# NOTE: This needs to remain as the last target definition in this file so
158# that it gets executed last.
159ifneq ($(BUILD_DIRS_ONLY),1)
160all::
161	$(Echo) '*****' Completed $(BuildMode)$(AssertMode) Build
162ifeq ($(BuildMode),Debug)
163	$(Echo) '*****' Note: Debug build can be 10 times slower than an
164	$(Echo) '*****' optimized build. Use 'make ENABLE_OPTIMIZED=1' to
165	$(Echo) '*****' make an optimized build. Alternatively you can
166	$(Echo) '*****' configure with --enable-optimized.
167endif
168endif
169
170check-llvm2cpp:
171	$(Verb)$(MAKE) check TESTSUITE=Feature RUNLLVM2CPP=1
172
173check-one:
174	$(Verb)$(MAKE) -C test check-one TESTONE=$(TESTONE)
175
176srpm: $(LLVM_OBJ_ROOT)/llvm.spec
177	rpmbuild -bs $(LLVM_OBJ_ROOT)/llvm.spec
178
179rpm: $(LLVM_OBJ_ROOT)/llvm.spec
180	rpmbuild -bb --target $(TARGET_TRIPLE) $(LLVM_OBJ_ROOT)/llvm.spec
181
182show-footprint:
183	$(Verb) du -sk $(LibDir)
184	$(Verb) du -sk $(ToolDir)
185	$(Verb) du -sk $(ExmplDir)
186	$(Verb) du -sk $(ObjDir)
187
188build-for-llvm-top:
189	$(Verb) if test ! -f ./config.status ; then \
190	  ./configure --prefix="$(LLVM_TOP)/install" \
191	    --with-llvm-gcc="$(LLVM_TOP)/llvm-gcc" ; \
192	fi
193	$(Verb) $(MAKE) tools-only
194
195SVN = svn
196SVN-UPDATE-OPTIONS =
197AWK = awk
198SUB-SVN-DIRS = $(AWK) '/\?\ \ \ \ \ \ / {print $$2}'   \
199		| LC_ALL=C xargs $(SVN) info 2>/dev/null \
200		| $(AWK) '/Path:\ / {print $$2}'
201
202update:
203	$(SVN) $(SVN-UPDATE-OPTIONS) update $(LLVM_SRC_ROOT)
204	@ $(SVN) status $(LLVM_SRC_ROOT) | $(SUB-SVN-DIRS) | xargs $(SVN) $(SVN-UPDATE-OPTIONS) update
205
206happiness: update all check unittests
207
208.PHONY: srpm rpm update happiness
209
210# declare all targets at this level to be serial:
211
212.NOTPARALLEL:
213
214