Removed trailing whitespace.
[oota-llvm.git] / Makefile
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
10 LEVEL := .
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.
22 ifeq ($(BUILD_DIRS_ONLY),1)
23   DIRS := lib/System lib/Support utils
24   OPTIONAL_DIRS :=
25 else
26   DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \
27           tools runtime docs
28   OPTIONAL_DIRS := examples projects bindings
29 endif
30
31 EXTRA_DIST := test unittests llvm.spec include win32 Xcode
32
33 include $(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
42 ifeq ($(MAKECMDGOALS),libs-only)
43   DIRS := $(filter-out tools runtime docs, $(DIRS))
44   OPTIONAL_DIRS :=
45 endif
46
47 ifeq ($(MAKECMDGOALS),install-libs)
48   DIRS := $(filter-out tools runtime docs, $(DIRS))
49   OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
50 endif
51
52 ifeq ($(MAKECMDGOALS),tools-only)
53   DIRS := $(filter-out runtime docs, $(DIRS))
54   OPTIONAL_DIRS :=
55 endif
56
57 ifeq ($(MAKECMDGOALS),unittests)
58   DIRS := $(filter-out tools runtime docs, $(DIRS)) utils unittests
59   OPTIONAL_DIRS :=
60 endif
61
62 # Don't install utils, examples, or projects they are only used to
63 # build LLVM.
64 ifeq ($(MAKECMDGOALS),install)
65   DIRS := $(filter-out utils, $(DIRS))
66   OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
67 endif
68
69 # If we're cross-compiling, build the build-hosted tools first
70 ifeq ($(LLVM_CROSS_COMPILING),1)
71 all:: cross-compile-build-tools
72
73 clean::
74         $(Verb) rm -rf BuildTools
75
76 cross-compile-build-tools:
77         $(Verb) if [ ! -f BuildTools/Makefile ]; then \
78           $(MKDIR) BuildTools; \
79           cd BuildTools ; \
80           $(PROJ_SRC_DIR)/configure ; \
81           cd .. ; \
82         fi; \
83         ($(MAKE) -C BuildTools BUILD_DIRS_ONLY=1 ) || exit 1;
84 endif
85
86 # Include the main makefile machinery.
87 include $(LLVM_SRC_ROOT)/Makefile.rules
88
89 # Specify options to pass to configure script when we're
90 # running the dist-check target
91 DIST_CHECK_CONFIG_OPTIONS = --with-llvmgccdir=$(LLVMGCCDIR)
92
93 .PHONY: debug-opt-prof
94 debug-opt-prof:
95         $(Echo) Building Debug Version
96         $(Verb) $(MAKE)
97         $(Echo)
98         $(Echo) Building Optimized Version
99         $(Echo)
100         $(Verb) $(MAKE) ENABLE_OPTIMIZED=1
101         $(Echo)
102         $(Echo) Building Profiling Version
103         $(Echo)
104         $(Verb) $(MAKE) ENABLE_PROFILING=1
105
106 dist-hook::
107         $(Echo) Eliminating files constructed by configure
108         $(Verb) $(RM) -f \
109           $(TopDistDir)/include/llvm/ADT/hash_map.h  \
110           $(TopDistDir)/include/llvm/ADT/hash_set.h  \
111           $(TopDistDir)/include/llvm/ADT/iterator.h  \
112           $(TopDistDir)/include/llvm/Config/config.h  \
113           $(TopDistDir)/include/llvm/Support/DataTypes.h  \
114           $(TopDistDir)/include/llvm/Support/ThreadSupport.h
115
116 tools-only: all
117 libs-only: all
118 install-libs: install
119
120 #------------------------------------------------------------------------
121 # Make sure the generated headers are up-to-date. This must be kept in
122 # sync with the AC_CONFIG_HEADER invocations in autoconf/configure.ac
123 #------------------------------------------------------------------------
124 FilesToConfig := \
125   include/llvm/Config/config.h \
126   include/llvm/Support/DataTypes.h \
127   include/llvm/ADT/hash_map.h \
128   include/llvm/ADT/hash_set.h \
129   include/llvm/ADT/iterator.h
130 FilesToConfigPATH  := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
131
132 all-local:: $(FilesToConfigPATH)
133 $(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
134         $(Echo) Regenerating $*
135         $(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
136 .PRECIOUS: $(FilesToConfigPATH)
137
138 # NOTE: This needs to remain as the last target definition in this file so
139 # that it gets executed last.
140 ifneq ($(BUILD_DIRS_ONLY),1)
141 all::
142         $(Echo) '*****' Completed $(BuildMode)$(AssertMode) Build
143 ifeq ($(BuildMode),Debug)
144         $(Echo) '*****' Note: Debug build can be 10 times slower than an
145         $(Echo) '*****' optimized build. Use 'make ENABLE_OPTIMIZED=1' to
146         $(Echo) '*****' make an optimized build. Alternatively you can
147         $(Echo) '*****' configure with --enable-optimized.
148 endif
149 endif
150
151 check-llvm2cpp:
152         $(Verb)$(MAKE) check TESTSUITE=Feature RUNLLVM2CPP=1
153
154 check-one:
155         $(Verb)$(MAKE) -C test check-one TESTONE=$(TESTONE)
156
157 srpm: $(LLVM_OBJ_ROOT)/llvm.spec
158         rpmbuild -bs $(LLVM_OBJ_ROOT)/llvm.spec
159
160 rpm: $(LLVM_OBJ_ROOT)/llvm.spec
161         rpmbuild -bb --target $(TARGET_TRIPLE) $(LLVM_OBJ_ROOT)/llvm.spec
162
163 show-footprint:
164         $(Verb) du -sk $(LibDir)
165         $(Verb) du -sk $(ToolDir)
166         $(Verb) du -sk $(ExmplDir)
167         $(Verb) du -sk $(ObjDir)
168
169 build-for-llvm-top:
170         $(Verb) if test ! -f ./config.status ; then \
171           ./configure --prefix="$(LLVM_TOP)/install" \
172             --with-llvm-gcc="$(LLVM_TOP)/llvm-gcc" ; \
173         fi
174         $(Verb) $(MAKE) tools-only
175
176 SVN = svn
177 SVN-UPDATE-OPTIONS =
178 AWK = awk
179 SUB-SVN-DIRS = $(AWK) '/\?\ \ \ \ \ \ / {print $$2}'   \
180                 | LANG=C xargs $(SVN) info 2>/dev/null \
181                 | $(AWK) '/Path:\ / {print $$2}'
182
183 update:
184         $(SVN) $(SVN-UPDATE-OPTIONS) update $(LLVM_SRC_ROOT)
185         @ $(SVN) status $(LLVM_SRC_ROOT) | $(SUB-SVN-DIRS) | xargs $(SVN) $(SVN-UPDATE-OPTIONS) update
186
187 happiness: update all check unittests
188
189 .PHONY: srpm rpm update happiness
190
191 # declare all targets at this level to be serial:
192
193 .NOTPARALLEL:
194