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