llvm.org GIT mirror llvm / 569c45c
Proper way of doing llvm canadian-cross compilation. Patch by Jim Grosbach! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58981 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 10 years ago
2 changed file(s) with 39 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
1616 # 5. Build llvm-config, which determines inter-lib dependencies for tools.
1717 # 6. Build tools, runtime, docs.
1818 #
19 DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \
20 tools runtime docs
19 # When cross-compiling, there are some things (tablegen) that need to
20 # be build for the build system first.
21 ifeq ($(BUILD_DIRS_ONLY),1)
22 DIRS := lib/System lib/Support utils
23 OPTIONAL_DIRS :=
24 else
25 DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \
26 tools runtime docs
27 OPTIONAL_DIRS := examples projects bindings
28 endif
2129
22 OPTIONAL_DIRS := examples projects bindings
2330 EXTRA_DIST := test llvm.spec include win32 Xcode
2431
2532 include $(LEVEL)/Makefile.config
26
27 # When cross-compiling, there are some things (tablegen) that need to
28 # be build for the build system.
29 ifeq ($(LLVM_CROSS_COMPILING),1)
30 BUILD_TARGET_DIRS := lib/System lib/Support utils
31 endif
3233
3334 # llvm-gcc4 doesn't need runtime libs. llvm-gcc4 is the only supported one.
3435 # FIXME: Remove runtime entirely once we have an understanding of where
5758 ifeq ($(MAKECMDGOALS),install)
5859 DIRS := $(filter-out utils, $(DIRS))
5960 OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
61 endif
62
63 # If we're cross-compiling, build the build-hosted tools first
64 ifeq ($(LLVM_CROSS_COMPILING),1)
65 all:: cross-compile-build-tools
66
67 clean::
68 $(Verb) rm -rf BuildTools
69
70 cross-compile-build-tools:
71 $(Verb) if [ ! -f BuildTools/Makefile ]; then \
72 $(MKDIR) BuildTools; \
73 cd BuildTools ; \
74 $(PROJ_SRC_DIR)/configure ; \
75 cd .. ; \
76 fi; \
77 ($(MAKE) -C BuildTools BUILD_DIRS_ONLY=1 ) || exit 1;
6078 endif
6179
6280 # Include the main makefile machinery.
113131
114132 # NOTE: This needs to remain as the last target definition in this file so
115133 # that it gets executed last.
134 ifneq ($(BUILD_DIRS_ONLY),1)
116135 all::
117136 $(Echo) '*****' Completed $(BuildMode)$(AssertMode) Build
118137 ifeq ($(BuildMode),Debug)
120139 $(Echo) '*****' optimized build. Use 'make ENABLE_OPTIMIZED=1' to
121140 $(Echo) '*****' make an optimized build. Alternatively you can
122141 $(Echo) '*****' configure with --enable-optimized.
142 endif
123143 endif
124144
125145 check-llvm2cpp:
183183 $(UserTargets):: $(PreConditions)
184184
185185 all:: all-local
186 clean:: clean-local
186 clean:: clean-local
187187 clean-all:: clean-local clean-all-local
188188 install:: install-local
189189 uninstall:: uninstall-local
308308 #--------------------------------------------------------------------
309309 TargetMode :=
310310 ifeq ($(LLVM_CROSS_COMPILING),1)
311 ifeq ($(BUILD_COMPONENT),1)
312 TargetMode := Build
313 else
314 TargetMode := Host
315 endif
316 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/Build/bin
311 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
317312 endif
318313
319314 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
320 # It is very important that ObjDir not have an extra trailing
321 # slash. This ends up changing the rules so that dependency file (.d)
322 # information is not used at all!
323 ifeq ($(TargetMode),)
324 ObjDir := $(ObjRootDir)
325 else
326 ObjDir := $(ObjRootDir)/$(TargetMode)
327 endif
328 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib
329 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin
330 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples
331 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib
332 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin
333 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples
315 ObjDir := $(ObjRootDir)
316 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
317 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
318 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
319 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
320 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
321 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
334322 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
335323
336324 #--------------------------------------------------------------------
346334 endif
347335 ifndef TBLGEN
348336 ifeq ($(LLVM_CROSS_COMPILING),1)
349 TBLGEN := $(BuildLLVMToolDir)/tblgen$(EXEEXT)
337 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
350338 else
351339 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
352340 endif
593581 SubDirs += $(DIRS)
594582
595583 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
596 ifdef BUILD_TARGET_DIRS
597 $(RecursiveTargets)::
598 $(Verb) for dir in $(BUILD_TARGET_DIRS); do \
599 if [ ! -f $$dir/Makefile ]; then \
600 $(MKDIR) $$dir; \
601 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
602 fi; \
603 ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \
604 done
605 endif
606584 $(RecursiveTargets)::
607585 $(Verb) for dir in $(DIRS); do \
608586 if [ ! -f $$dir/Makefile ]; then \
612590 ($(MAKE) -C $$dir $@ ) || exit 1; \
613591 done
614592 else
615 ifdef BUILD_TARGET_DIRS
616 $(RecursiveTargets)::
617 $(Verb) for dir in $(BUILD_TARGET_DIRS); do \
618 ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \
619 done
620 endif
621593 $(RecursiveTargets)::
622594 $(Verb) for dir in $(DIRS); do \
623595 ($(MAKE) -C $$dir $@ ) || exit 1; \