1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
10 # This file is included by all of the LLVM makefiles. For details on how to use
11 # it properly, please see the document MakefileGuide.html in the docs directory.
13 #===-----------------------------------------------------------------------====#
15 ################################################################################
16 # TARGETS: Define standard targets that can be invoked
17 ################################################################################
19 #--------------------------------------------------------------------
20 # Define the various target sets
21 #--------------------------------------------------------------------
22 RecursiveTargets := all clean clean-all install uninstall install-bytecode \
24 LocalTargets := all-local clean-local clean-all-local check-local \
25 install-local printvars uninstall-local \
26 install-bytecode-local
27 TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
29 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30 InternalTargets := preconditions distdir dist-hook
32 ################################################################################
33 # INITIALIZATION: Basic things the makefile needs
34 ################################################################################
36 #--------------------------------------------------------------------
37 # Set the VPATH so that we can find source files.
38 #--------------------------------------------------------------------
41 #--------------------------------------------------------------------
42 # Reset the list of suffixes we know how to build.
43 #--------------------------------------------------------------------
45 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll
46 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
48 #--------------------------------------------------------------------
49 # Mark all of these targets as phony to avoid implicit rule search
50 #--------------------------------------------------------------------
51 .PHONY: $(UserTargets) $(InternalTargets)
53 #--------------------------------------------------------------------
54 # Make sure all the user-target rules are double colon rules and
55 # they are defined first.
56 #--------------------------------------------------------------------
60 ################################################################################
61 # PRECONDITIONS: that which must be built/checked first
62 ################################################################################
64 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
65 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
66 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
67 ConfigureScript := $(PROJ_SRC_ROOT)/configure
68 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
69 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
70 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
71 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
72 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
73 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
74 ifneq ($(MakefileCommonIn),)
75 PreConditions += $(MakefileCommon)
78 ifneq ($(MakefileConfigIn),)
79 PreConditions += $(MakefileConfig)
82 preconditions: $(PreConditions)
84 #------------------------------------------------------------------------
85 # Make sure the BUILT_SOURCES are built first
86 #------------------------------------------------------------------------
87 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
90 ifneq ($(strip $(BUILT_SOURCES)),)
91 -$(Verb) $(RM) -f $(BUILT_SOURCES)
94 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
96 $(Verb) if test -x config.status ; then \
97 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
98 $(MKDIR) .spotless.save ; \
99 $(MV) config.status .spotless.save ; \
100 $(MV) mklib .spotless.save ; \
101 $(MV) projects .spotless.save ; \
103 $(MV) .spotless.save/config.status . ; \
104 $(MV) .spotless.save/mklib . ; \
105 $(MV) .spotless.save/projects . ; \
106 $(RM) -rf .spotless.save ; \
107 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript) ; \
111 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
115 $(EchoCmd) "spotless target not supported for objdir == srcdir"
118 $(BUILT_SOURCES) : $(ObjMakefiles)
120 #------------------------------------------------------------------------
121 # Make sure we're not using a stale configuration
122 #------------------------------------------------------------------------
124 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
125 $(Verb) cd $(PROJ_OBJ_ROOT) && \
126 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
127 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
129 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
130 $(ConfigStatusScript)
132 # FIXME: The {PIC16,MSP430}/AsmPrinter line here is a hack to force a reconfigure to pick
133 # up AsmPrinter changes. Remove it after a reasonable delay from 2009-08-13.
135 .PRECIOUS: $(ConfigStatusScript)
136 $(ConfigStatusScript): $(ConfigureScript) $(LLVM_SRC_ROOT)/lib/Target/PIC16/AsmPrinter/Makefile $(LLVM_SRC_ROOT)/lib/Target/MSP430/AsmPrinter/Makefile
137 $(Echo) Reconfiguring with $<
138 $(Verb) cd $(PROJ_OBJ_ROOT) && \
139 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
140 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
142 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
143 $(ConfigStatusScript)
145 #------------------------------------------------------------------------
146 # Make sure the configuration makefile is up to date
147 #------------------------------------------------------------------------
148 ifneq ($(MakefileConfigIn),)
149 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
150 $(Echo) Regenerating $@
151 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
154 ifneq ($(MakefileCommonIn),)
155 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
156 $(Echo) Regenerating $@
157 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
160 #------------------------------------------------------------------------
161 # If the Makefile in the source tree has been updated, copy it over into the
162 # build tree. But, only do this if the source and object makefiles differ
163 #------------------------------------------------------------------------
164 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
166 Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
167 $(Echo) "Updating Makefile"
168 $(Verb) $(MKDIR) $(@D)
169 $(Verb) $(CP) -f $< $@
171 # Copy the Makefile.* files unless we're in the root directory which avoids
172 # the copying of Makefile.config.in or other things that should be explicitly
174 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
176 *Makefile.rules) ;; \
178 *) $(EchoCmd) "Updating $(@F)" ; \
185 #------------------------------------------------------------------------
186 # Set up the basic dependencies
187 #------------------------------------------------------------------------
188 $(UserTargets):: $(PreConditions)
192 clean-all:: clean-local clean-all-local
193 install:: install-local
194 uninstall:: uninstall-local
195 install-local:: all-local
196 install-bytecode:: install-bytecode-local
198 ###############################################################################
199 # LLVMC: Provide rules for compiling llvmc plugins
200 ###############################################################################
204 LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
205 CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
208 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
209 LD.Flags += -lCompilerDriver
212 # Build a dynamic library if the user runs `make` directly from the plugin
214 ifndef LLVMC_BUILTIN_PLUGIN
219 ifneq ($(BUILT_SOURCES),)
220 LLVMC_BUILD_AUTOGENERATED_INC=1
225 ifdef LLVMC_BASED_DRIVER
227 TOOLNAME = $(LLVMC_BASED_DRIVER)
231 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
232 LD.Flags += -lCompilerDriver
234 LLVMLIBS = CompilerDriver.a
235 LINK_COMPONENTS = support system
238 # Preprocessor magic that generates references to static variables in built-in
240 ifneq ($(LLVMC_BUILTIN_PLUGINS),)
242 USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
244 LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS))
245 LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS))
246 LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS))
247 LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS))
248 LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS))
249 LLVMC_BUILTIN_PLUGIN_6 = $(word 6, $(LLVMC_BUILTIN_PLUGINS))
250 LLVMC_BUILTIN_PLUGIN_7 = $(word 7, $(LLVMC_BUILTIN_PLUGINS))
251 LLVMC_BUILTIN_PLUGIN_8 = $(word 8, $(LLVMC_BUILTIN_PLUGINS))
252 LLVMC_BUILTIN_PLUGIN_9 = $(word 9, $(LLVMC_BUILTIN_PLUGINS))
253 LLVMC_BUILTIN_PLUGIN_10 = $(word 10, $(LLVMC_BUILTIN_PLUGINS))
256 ifneq ($(LLVMC_BUILTIN_PLUGIN_1),)
257 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1)
260 ifneq ($(LLVMC_BUILTIN_PLUGIN_2),)
261 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2)
264 ifneq ($(LLVMC_BUILTIN_PLUGIN_3),)
265 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3)
268 ifneq ($(LLVMC_BUILTIN_PLUGIN_4),)
269 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4)
272 ifneq ($(LLVMC_BUILTIN_PLUGIN_5),)
273 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5)
276 ifneq ($(LLVMC_BUILTIN_PLUGIN_6),)
277 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_6)
280 ifneq ($(LLVMC_BUILTIN_PLUGIN_7),)
281 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_7)
284 ifneq ($(LLVMC_BUILTIN_PLUGIN_8),)
285 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_8)
288 ifneq ($(LLVMC_BUILTIN_PLUGIN_9),)
289 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_9)
292 ifneq ($(LLVMC_BUILTIN_PLUGIN_10),)
293 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_10)
299 endif # LLVMC_BASED_DRIVER
301 ###############################################################################
302 # VARIABLES: Set up various variables based on configuration data
303 ###############################################################################
305 # Variable for if this make is for a "cleaning" target
306 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
310 #--------------------------------------------------------------------
311 # Variables derived from configuration we are building
312 #--------------------------------------------------------------------
315 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
316 # this can be overridden on the make command line.
317 ifndef OPTIMIZE_OPTION
318 ifneq ($(HOST_OS),MingW)
319 OPTIMIZE_OPTION := -O3
321 OPTIMIZE_OPTION := -O2
325 ifeq ($(ENABLE_OPTIMIZED),1)
327 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
328 ifneq ($(HOST_OS),FreeBSD)
329 ifneq ($(HOST_OS),Darwin)
330 OmitFramePointer := -fomit-frame-pointer
334 # Darwin requires -fstrict-aliasing to be explicitly enabled.
335 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
336 # with -fstrict-aliasing and ipa-type-escape radr://6756684
337 #ifeq ($(HOST_OS),Darwin)
338 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
340 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
341 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
342 LD.Flags += $(OPTIMIZE_OPTION)
344 BuildMode := $(BuildMode)+Debug
358 ifeq ($(ENABLE_PROFILING),1)
359 BuildMode := $(BuildMode)+Profile
360 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
361 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
362 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
366 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
367 # CXX.Flags += -fvisibility-inlines-hidden
370 # IF REQUIRES_EH=1 is specified then don't disable exceptions
372 CXX.Flags += -fno-exceptions
375 ifdef REQUIRES_FRAME_POINTER
376 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
377 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
378 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
381 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
382 ifeq ($(REQUIRES_RTTI), 1)
383 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
384 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
387 ifdef ENABLE_COVERAGE
388 BuildMode := $(BuildMode)+Coverage
389 CXX.Flags += -ftest-coverage -fprofile-arcs
390 C.Flags += -ftest-coverage -fprofile-arcs
393 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
394 # then disable assertions by defining the appropriate preprocessor symbols.
395 ifdef DISABLE_ASSERTIONS
396 # Indicate that assertions are turned off using a minus sign
397 BuildMode := $(BuildMode)-Asserts
398 CPP.Defines += -DNDEBUG
400 CPP.Defines += -D_DEBUG
403 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
404 # configured), then enable expensive checks by defining the
405 # appropriate preprocessor symbols.
406 ifdef ENABLE_EXPENSIVE_CHECKS
407 BuildMode := $(BuildMode)+Checks
408 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
411 # LOADABLE_MODULE implies several other things so we force them to be
413 ifdef LOADABLE_MODULE
415 LINK_LIBS_IN_SHARED := 1
423 ifeq ($(ENABLE_PIC),1)
424 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
425 # Nothing. Win32 defaults to PIC and warns when given -fPIC
427 ifeq ($(HOST_OS),Darwin)
428 # Common symbols not allowed in dylib files
429 CXX.Flags += -fno-common
430 C.Flags += -fno-common
432 # Linux and others; pass -fPIC
438 ifeq ($(HOST_OS),Darwin)
439 CXX.Flags += -mdynamic-no-pic
440 C.Flags += -mdynamic-no-pic
444 CXX.Flags += -Woverloaded-virtual
445 CPP.BaseFlags += $(CPP.Defines)
448 # Make Floating point IEEE compliant on Alpha.
451 CPP.BaseFlags += -mieee
452 ifeq ($(ENABLE_PIC),0)
454 CPP.BaseFlags += -fPIC
459 LD.Flags += -Wl,--no-relax
462 ifeq ($(HOST_OS),MingW)
463 ifeq ($(LLVM_CROSS_COMPILING),1)
464 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
466 LD.Flags += -Wl,--allow-multiple-definition
471 ifdef ENABLE_EXPENSIVE_CHECKS
472 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
473 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
474 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
475 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
478 #--------------------------------------------------------------------
479 # Directory locations
480 #--------------------------------------------------------------------
482 ifeq ($(LLVM_CROSS_COMPILING),1)
483 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
486 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
487 ObjDir := $(ObjRootDir)
488 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
489 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
490 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
491 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
492 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
493 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
494 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
496 #--------------------------------------------------------------------
497 # Full Paths To Compiled Tools and Utilities
498 #--------------------------------------------------------------------
499 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
502 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
505 ifeq ($(LLVM_CROSS_COMPILING),1)
506 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
508 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
511 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
513 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
516 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
519 LLI := $(LLVMToolDir)/lli$(EXEEXT)
522 LLC := $(LLVMToolDir)/llc$(EXEEXT)
525 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
528 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
531 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
533 ifeq ($(LLVMGCC_MAJVERS),3)
534 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
535 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
537 LLVMGCCWITHPATH := $(LLVMGCC)
538 LLVMGXXWITHPATH := $(LLVMGXX)
541 #--------------------------------------------------------------------
542 # Adjust to user's request
543 #--------------------------------------------------------------------
545 ifeq ($(HOST_OS),Darwin)
546 DARWIN_VERSION := `sw_vers -productVersion`
547 # Strip a number like 10.4.7 to 10.4
548 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
549 # Get "4" out of 10.4 for later pieces in the makefile.
550 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
552 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
555 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
558 ifeq ($(HOST_OS),Cygwin)
559 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
560 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
562 SharedLinkOptions=-shared
566 ifeq ($(TARGET_OS),Darwin)
568 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
572 # Adjust LD.Flags depending on the kind of library that is to be built. Note
573 # that if LOADABLE_MODULE is specified then the resulting shared library can
574 # be opened with dlopen.
575 ifdef LOADABLE_MODULE
580 ifneq ($(DARWIN_MAJVERS),4)
581 LD.Flags += $(RPATH) -Wl,$(LibDir)
592 # Adjust settings for verbose mode
595 AR.Flags += >/dev/null 2>/dev/null
596 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
598 ConfigureScriptFLAGS :=
601 # By default, strip symbol information from executable
603 Strip := $(PLATFORMSTRIPOPTS)
604 StripWarnMsg := "(without symbols)"
605 Install.StripFlag += -s
608 # Adjust linker flags for building an executable
609 ifneq ($(HOST_OS),Darwin)
610 ifneq ($(DARWIN_MAJVERS),4)
613 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
615 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
621 #----------------------------------------------------------
622 # Options To Invoke Tools
623 #----------------------------------------------------------
626 CompileCommonOpts += -pedantic -Wno-long-long
628 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
631 ifeq ($(HOST_OS),HP-UX)
632 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
635 # If we are building a universal binary on Mac OS/X, pass extra options. This
636 # is useful to people that want to link the LLVM libraries into their universal
639 # The following can be optionally specified:
640 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
641 # For Mac OS/X 10.4 Intel machines, the traditional one is:
642 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
643 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
644 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
647 ifndef UNIVERSAL_ARCH
648 UNIVERSAL_ARCH := i386 ppc
650 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
651 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
652 ifdef UNIVERSAL_SDK_PATH
653 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
656 # Building universal cannot compute dependencies automatically.
657 DISABLE_AUTO_DEPENDENCIES=1
659 ifeq ($(TARGET_OS),Darwin)
660 ifeq ($(ARCH),x86_64)
661 TargetCommonOpts = -m64
664 TargetCommonOpts = -m32
670 ifeq ($(HOST_OS),SunOS)
671 CPP.BaseFlags += -include llvm/System/Solaris.h
674 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
675 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
676 # All -I flags should go here, so that they don't confuse llvm-config.
677 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
678 $(patsubst %,-I%/include,\
679 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
680 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
683 ifeq ($(BUILD_COMPONENT), 1)
684 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
685 $(TargetCommonOpts) $(CompileCommonOpts) -c
686 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
688 $(TargetCommonOpts) $(CompileCommonOpts) -c
689 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
690 $(CompileCommonOpts) $(CXX.Flags) -E
691 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
693 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
695 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
696 $(TargetCommonOpts) $(CompileCommonOpts) -c
697 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
698 $(TargetCommonOpts) $(CompileCommonOpts) -c
699 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
700 $(CompileCommonOpts) $(CXX.Flags) -E
701 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
702 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
705 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CFLAGS) \
707 $(TargetCommonOpts) $(CompileCommonOpts)
708 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
709 $(TargetCommonOpts) $(CompileCommonOpts) -E
711 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
713 $(TargetCommonOpts) $(CompileCommonOpts)
715 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
716 ScriptInstall = $(INSTALL) -m 0755
717 DataInstall = $(INSTALL) -m 0644
719 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
720 # paths. In this case, the SYSPATH function (defined in
721 # Makefile.config) transforms Unix paths into Windows paths.
722 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
723 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
724 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
725 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
727 Archive = $(AR) $(AR.Flags)
728 LArchive = $(LLVMToolDir)/llvm-ar rcsf
735 #----------------------------------------------------------
736 # Get the list of source files and compute object file
738 #----------------------------------------------------------
741 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
742 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
744 Sources := $(SOURCES)
748 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
751 BaseNameSources := $(sort $(basename $(Sources)))
753 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
754 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
756 ###############################################################################
757 # DIRECTORIES: Handle recursive descent of directory structure
758 ###############################################################################
760 #---------------------------------------------------------
761 # Provide rules to make install dirs. This must be early
762 # in the file so they get built before dependencies
763 #---------------------------------------------------------
765 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
768 # To create other directories, as needed, and timestamp their creation
770 $(Verb) $(MKDIR) $* > /dev/null
773 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
774 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
776 #---------------------------------------------------------
777 # Handle the DIRS options for sequential construction
778 #---------------------------------------------------------
784 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
785 $(RecursiveTargets)::
786 $(Verb) for dir in $(DIRS); do \
787 if [ ! -f $$dir/Makefile ]; then \
789 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
791 ($(MAKE) -C $$dir $@ ) || exit 1; \
794 $(RecursiveTargets)::
795 $(Verb) for dir in $(DIRS); do \
796 ($(MAKE) -C $$dir $@ ) || exit 1; \
802 #---------------------------------------------------------
803 # Handle the EXPERIMENTAL_DIRS options ensuring success
804 # after each directory is built.
805 #---------------------------------------------------------
806 ifdef EXPERIMENTAL_DIRS
807 $(RecursiveTargets)::
808 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
809 if [ ! -f $$dir/Makefile ]; then \
811 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
813 ($(MAKE) -C $$dir $@ ) || exit 0; \
817 #-----------------------------------------------------------
818 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
819 #-----------------------------------------------------------
820 ifdef OPTIONAL_PARALLEL_DIRS
821 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
824 #-----------------------------------------------------------
825 # Handle the PARALLEL_DIRS options for parallel construction
826 #-----------------------------------------------------------
829 SubDirs += $(PARALLEL_DIRS)
831 # Unfortunately, this list must be maintained if new recursive targets are added
832 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
833 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
834 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
835 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
836 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
837 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
838 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
840 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
843 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
845 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
847 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
850 #---------------------------------------------------------
851 # Handle the OPTIONAL_DIRS options for directores that may
853 #---------------------------------------------------------
856 SubDirs += $(OPTIONAL_DIRS)
858 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
859 $(RecursiveTargets)::
860 $(Verb) for dir in $(OPTIONAL_DIRS); do \
861 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
862 if [ ! -f $$dir/Makefile ]; then \
864 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
866 ($(MAKE) -C$$dir $@ ) || exit 1; \
870 $(RecursiveTargets)::
871 $(Verb) for dir in $(OPTIONAL_DIRS); do \
872 ($(MAKE) -C$$dir $@ ) || exit 1; \
877 #---------------------------------------------------------
878 # Handle the CONFIG_FILES options
879 #---------------------------------------------------------
884 $(Echo) Install circumvented with NO_INSTALL
886 $(Echo) UnInstall circumvented with NO_INSTALL
888 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
889 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
890 $(Verb)for file in $(CONFIG_FILES); do \
891 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
892 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
893 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
894 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
896 $(ECHO) Error: cannot find config file $${file}. ; \
901 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
902 $(Verb)for file in $(CONFIG_FILES); do \
903 $(RM) -f $(PROJ_etcdir)/$${file} ; \
909 ###############################################################################
910 # Set up variables for building libararies
911 ###############################################################################
913 #---------------------------------------------------------
914 # Define various command line options pertaining to the
915 # libraries needed when linking. There are "Proj" libs
916 # (defined by the user's project) and "LLVM" libs (defined
917 # by the LLVM project).
918 #---------------------------------------------------------
921 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
922 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
923 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
924 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
928 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
929 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
930 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
931 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
934 ifndef IS_CLEANING_TARGET
935 ifdef LINK_COMPONENTS
937 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
938 # clean in tools, then do a make in tools (instead of at the top level).
940 @echo "*** llvm-config doesn't exist - rebuilding it."
941 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
943 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
945 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
946 LLVMLibsPaths += $(LLVM_CONFIG) \
947 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
951 ###############################################################################
952 # Library Build Rules: Four ways to build a library
953 ###############################################################################
955 #---------------------------------------------------------
956 # Bytecode Module Targets:
957 # If the user set MODULE_NAME then they want to build a
958 # bytecode module from the sources. We compile all the
959 # sources and link it together into a single bytecode
961 #---------------------------------------------------------
964 ifeq ($(strip $(LLVMGCC)),)
965 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
968 Module := $(LibDir)/$(MODULE_NAME).bc
969 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
972 ifdef EXPORTED_SYMBOL_FILE
973 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
976 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
977 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
978 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
980 all-local:: $(Module)
983 ifneq ($(strip $(Module)),)
984 -$(Verb) $(RM) -f $(Module)
987 ifdef BYTECODE_DESTINATION
988 ModuleDestDir := $(BYTECODE_DESTINATION)
990 ModuleDestDir := $(PROJ_libdir)
995 $(Echo) Install circumvented with NO_INSTALL
997 $(Echo) Uninstall circumvented with NO_INSTALL
999 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1001 install-module:: $(DestModule)
1002 install-local:: $(DestModule)
1004 $(DestModule): $(ModuleDestDir) $(Module)
1005 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
1006 $(Verb) $(DataInstall) $(Module) $(DestModule)
1009 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1010 -$(Verb) $(RM) -f $(DestModule)
1016 # if we're building a library ...
1019 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1020 LIBRARYNAME := $(strip $(LIBRARYNAME))
1021 ifdef LOADABLE_MODULE
1022 LibName.A := $(LibDir)/$(LIBRARYNAME).a
1023 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
1025 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
1026 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1028 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1029 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
1031 #---------------------------------------------------------
1032 # Shared Library Targets:
1033 # If the user asked for a shared library to be built
1034 # with the SHARED_LIBRARY variable, then we provide
1035 # targets for building them.
1036 #---------------------------------------------------------
1037 ifdef SHARED_LIBRARY
1039 all-local:: $(LibName.SO)
1041 ifdef LINK_LIBS_IN_SHARED
1042 ifdef LOADABLE_MODULE
1043 SharedLibKindMessage := "Loadable Module"
1045 SharedLibKindMessage := "Shared Library"
1047 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
1048 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1049 $(LIBRARYNAME)$(SHLIBEXT)
1050 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1051 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1053 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
1054 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
1055 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1059 ifneq ($(strip $(LibName.SO)),)
1060 -$(Verb) $(RM) -f $(LibName.SO)
1065 $(Echo) Install circumvented with NO_INSTALL
1067 $(Echo) Uninstall circumvented with NO_INSTALL
1069 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1071 install-local:: $(DestSharedLib)
1073 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
1074 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1075 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1078 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1079 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
1083 #---------------------------------------------------------
1084 # Bytecode Library Targets:
1085 # If the user asked for a bytecode library to be built
1086 # with the BYTECODE_LIBRARY variable, then we provide
1087 # targets for building them.
1088 #---------------------------------------------------------
1089 ifdef BYTECODE_LIBRARY
1090 ifeq ($(strip $(LLVMGCC)),)
1091 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
1094 all-local:: $(LibName.BCA)
1096 ifdef EXPORTED_SYMBOL_FILE
1097 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
1098 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1100 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1101 $(LLVMToolDir)/llvm-ar
1102 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1104 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1106 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1108 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1109 $(LLVMToolDir)/llvm-ar
1110 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1112 $(Verb) $(LArchive) $@ $(ObjectsBC)
1117 ifneq ($(strip $(LibName.BCA)),)
1118 -$(Verb) $(RM) -f $(LibName.BCA)
1121 ifdef BYTECODE_DESTINATION
1122 BytecodeDestDir := $(BYTECODE_DESTINATION)
1124 BytecodeDestDir := $(PROJ_libdir)
1127 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1129 install-bytecode-local:: $(DestBytecodeLib)
1133 $(Echo) Install circumvented with NO_INSTALL
1135 $(Echo) Uninstall circumvented with NO_INSTALL
1137 install-local:: $(DestBytecodeLib)
1139 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1140 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1141 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1144 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1145 -$(Verb) $(RM) -f $(DestBytecodeLib)
1150 #---------------------------------------------------------
1152 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1153 # building an archive.
1154 #---------------------------------------------------------
1155 ifndef BUILD_ARCHIVE
1156 ifndef LOADABLE_MODULE
1161 #---------------------------------------------------------
1162 # Archive Library Targets:
1163 # If the user wanted a regular archive library built,
1164 # then we provide targets for building them.
1165 #---------------------------------------------------------
1168 all-local:: $(LibName.A)
1170 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1171 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1172 -$(Verb) $(RM) -f $@
1173 $(Verb) $(Archive) $@ $(ObjectsO)
1174 $(Verb) $(Ranlib) $@
1177 ifneq ($(strip $(LibName.A)),)
1178 -$(Verb) $(RM) -f $(LibName.A)
1183 $(Echo) Install circumvented with NO_INSTALL
1185 $(Echo) Uninstall circumvented with NO_INSTALL
1187 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1189 install-local:: $(DestArchiveLib)
1191 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1192 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1193 $(Verb) $(MKDIR) $(PROJ_libdir)
1194 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1197 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1198 -$(Verb) $(RM) -f $(DestArchiveLib)
1205 ###############################################################################
1206 # Tool Build Rules: Build executable tool based on TOOLNAME option
1207 ###############################################################################
1211 #---------------------------------------------------------
1212 # Set up variables for building a tool.
1213 #---------------------------------------------------------
1215 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1217 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1220 #---------------------------------------------------------
1222 #---------------------------------------------------------
1224 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1225 # not exporting all of the weak symbols from the binary. This reduces dyld
1226 # startup time by 4x on darwin in some cases.
1227 ifdef TOOL_NO_EXPORTS
1228 ifeq ($(HOST_OS),Darwin)
1230 # Tiger tools don't support this.
1231 ifneq ($(DARWIN_MAJVERS),4)
1232 LD.Flags += -Wl,-exported_symbol -Wl,_main
1236 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
1237 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1242 #---------------------------------------------------------
1243 # Provide targets for building the tools
1244 #---------------------------------------------------------
1245 all-local:: $(ToolBuildPath)
1248 ifneq ($(strip $(ToolBuildPath)),)
1249 -$(Verb) $(RM) -f $(ToolBuildPath)
1253 $(ToolBuildPath): $(ExmplDir)/.dir
1255 $(ToolBuildPath): $(ToolDir)/.dir
1258 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1259 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1260 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1261 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1262 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1267 $(Echo) Install circumvented with NO_INSTALL
1269 $(Echo) Uninstall circumvented with NO_INSTALL
1271 DestTool = $(PROJ_bindir)/$(TOOLNAME)$(EXEEXT)
1273 install-local:: $(DestTool)
1275 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1276 $(Echo) Installing $(BuildMode) $(DestTool)
1277 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1280 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1281 -$(Verb) $(RM) -f $(DestTool)
1285 ###############################################################################
1286 # Object Build Rules: Build object files based on sources
1287 ###############################################################################
1289 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1290 ifeq ($(HOST_OS),HP-UX)
1291 DISABLE_AUTO_DEPENDENCIES=1
1294 # Provide rule sets for when dependency generation is enabled
1295 ifndef DISABLE_AUTO_DEPENDENCIES
1297 #---------------------------------------------------------
1298 # Create .o files in the ObjDir directory from the .cpp and .c files...
1299 #---------------------------------------------------------
1301 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1302 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1304 # If the build succeeded, move the dependency file over, otherwise
1306 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1307 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1309 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1310 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1311 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1314 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1315 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1316 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1319 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1320 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1321 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1324 #---------------------------------------------------------
1325 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1326 #---------------------------------------------------------
1328 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1329 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1331 # If the build succeeded, move the dependency file over, otherwise
1333 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1334 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1336 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1337 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1338 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1339 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1340 $(BC_DEPEND_MOVEFILE)
1342 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1343 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1344 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1345 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1346 $(BC_DEPEND_MOVEFILE)
1348 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1349 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1350 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1351 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1352 $(BC_DEPEND_MOVEFILE)
1354 # Provide alternate rule sets if dependencies are disabled
1357 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1358 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1359 $(Compile.CXX) $< -o $@
1361 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1362 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1363 $(Compile.CXX) $< -o $@
1365 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1366 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1367 $(Compile.C) $< -o $@
1369 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1370 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1371 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1373 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1374 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1375 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1377 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1378 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1379 $(BCCompile.C) $< -o $@ -S -emit-llvm
1384 ## Rules for building preprocessed (.i/.ii) outputs.
1385 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1386 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1387 $(Verb) $(Preprocess.CXX) $< -o $@
1389 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1390 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1391 $(Verb) $(Preprocess.CXX) $< -o $@
1393 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1394 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1395 $(Verb) $(Preprocess.C) $< -o $@
1398 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1399 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1400 $(Compile.CXX) $< -o $@ -S
1402 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1403 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1404 $(Compile.CXX) $< -o $@ -S
1406 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1407 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1408 $(Compile.C) $< -o $@ -S
1411 # make the C and C++ compilers strip debug info out of bytecode libraries.
1413 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1414 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1415 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1417 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1418 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1419 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1423 #---------------------------------------------------------
1424 # Provide rule to build .bc files from .ll sources,
1425 # regardless of dependencies
1426 #---------------------------------------------------------
1427 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1428 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1429 $(Verb) $(LLVMAS) $< -f -o $@
1431 ###############################################################################
1432 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1433 ###############################################################################
1436 TABLEGEN_INC_FILES_COMMON = 1
1439 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1440 TABLEGEN_INC_FILES_COMMON = 1
1443 ifdef TABLEGEN_INC_FILES_COMMON
1445 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1446 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1447 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1449 # INCFiles rule: All of the tblgen generated files are emitted to
1450 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1451 # us to only "touch" the real file if the contents of it change. IOW, if
1452 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1453 # dependencies of the .inc files are, unless the contents of the .inc file
1455 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1456 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1458 endif # TABLEGEN_INC_FILES_COMMON
1462 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1463 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1464 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1465 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1466 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1467 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1468 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1470 # All of these files depend on tblgen and the .td files.
1471 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1473 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1474 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1475 $(Echo) "Building $(<F) register names with tblgen"
1476 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1478 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1479 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1480 $(Echo) "Building $(<F) register information header with tblgen"
1481 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1483 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1484 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1485 $(Echo) "Building $(<F) register info implementation with tblgen"
1486 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1488 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1489 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1490 $(Echo) "Building $(<F) instruction names with tblgen"
1491 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1493 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1494 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1495 $(Echo) "Building $(<F) instruction information with tblgen"
1496 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1498 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1499 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1500 $(Echo) "Building $(<F) assembly writer with tblgen"
1501 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1503 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1504 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1505 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1506 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1508 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1509 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1510 $(Echo) "Building $(<F) assembly matcher with tblgen"
1511 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1513 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1514 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1515 $(Echo) "Building $(<F) code emitter with tblgen"
1516 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1518 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1519 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1520 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1521 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1523 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1524 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1525 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1526 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1528 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1529 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1530 $(Echo) "Building $(<F) subtarget information with tblgen"
1531 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1533 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1534 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1535 $(Echo) "Building $(<F) calling convention information with tblgen"
1536 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1538 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1539 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1540 $(Echo) "Building $(<F) calling convention information with tblgen"
1541 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1544 -$(Verb) $(RM) -f $(INCFiles)
1548 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1550 LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1551 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1553 TDFiles := $(LLVMCPluginSrc) \
1554 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1556 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1557 $(TBLGEN) $(TD_COMMON)
1558 $(Echo) "Building LLVMC configuration library with tblgen"
1559 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1561 endif # LLVMC_BUILD_AUTOGENERATED_INC
1563 ###############################################################################
1564 # OTHER RULES: Other rules needed
1565 ###############################################################################
1567 # To create postscript files from dot files...
1568 ifneq ($(DOT),false)
1570 $(DOT) -Tps < $< > $@
1573 $(Echo) "Cannot build $@: The program dot is not installed"
1576 # This rules ensures that header files that are removed still have a rule for
1577 # which they can be "generated." This allows make to ignore them and
1578 # reproduce the dependency lists.
1582 # Define clean-local to clean the current directory. Note that this uses a
1583 # very conservative approach ensuring that empty variables do not cause
1584 # errors or disastrous removal.
1586 ifneq ($(strip $(ObjRootDir)),)
1587 -$(Verb) $(RM) -rf $(ObjRootDir)
1589 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1590 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1591 -$(Verb) $(RM) -f *$(SHLIBEXT)
1595 -$(Verb) $(RM) -rf Debug Release Profile
1598 ###############################################################################
1599 # DEPENDENCIES: Include the dependency files if we should
1600 ###############################################################################
1601 ifndef DISABLE_AUTO_DEPENDENCIES
1603 # If its not one of the cleaning targets
1604 ifndef IS_CLEANING_TARGET
1606 # Get the list of dependency files
1607 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1608 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1610 # Include bitcode dependency files if using bitcode libraries
1611 ifdef BYTECODE_LIBRARY
1612 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1615 -include $(DependFiles) ""
1621 ###############################################################################
1622 # CHECK: Running the test suite
1623 ###############################################################################
1626 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1627 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1628 $(EchoCmd) Running test suite ; \
1629 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1630 TESTSUITE=$(TESTSUITE) ; \
1632 $(EchoCmd) No Makefile in test directory ; \
1635 $(EchoCmd) No test directory ; \
1639 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1640 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1641 $(EchoCmd) Running test suite ; \
1642 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
1644 $(EchoCmd) No Makefile in test directory ; \
1647 $(EchoCmd) No test directory ; \
1651 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1652 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1653 $(EchoCmd) Running test suite ; \
1654 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1656 $(EchoCmd) No Makefile in test directory ; \
1659 $(EchoCmd) No test directory ; \
1662 ###############################################################################
1663 # UNITTESTS: Running the unittests test suite
1664 ###############################################################################
1667 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1668 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1669 $(EchoCmd) Running unittests test suite ; \
1670 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1672 $(EchoCmd) No Makefile in unittests directory ; \
1675 $(EchoCmd) No unittests directory ; \
1678 ###############################################################################
1679 # DISTRIBUTION: Handle construction of a distribution tarball
1680 ###############################################################################
1682 #------------------------------------------------------------------------
1683 # Define distribution related variables
1684 #------------------------------------------------------------------------
1685 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1686 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1687 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1688 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1689 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1690 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1691 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1692 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1693 Makefile.config.in configure autoconf
1694 DistOther := $(notdir $(wildcard \
1695 $(PROJ_SRC_DIR)/*.h \
1696 $(PROJ_SRC_DIR)/*.td \
1697 $(PROJ_SRC_DIR)/*.def \
1698 $(PROJ_SRC_DIR)/*.ll \
1699 $(PROJ_SRC_DIR)/*.in))
1700 DistSubDirs := $(SubDirs)
1701 DistSources = $(Sources) $(EXTRA_DIST)
1702 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1704 #------------------------------------------------------------------------
1705 # We MUST build distribution with OBJ_DIR != SRC_DIR
1706 #------------------------------------------------------------------------
1707 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1708 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1709 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1713 #------------------------------------------------------------------------
1714 # Prevent attempt to run dist targets from anywhere but the top level
1715 #------------------------------------------------------------------------
1717 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1718 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1721 #------------------------------------------------------------------------
1722 # Provide the top level targets
1723 #------------------------------------------------------------------------
1725 dist-gzip:: $(DistTarGZip)
1727 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1728 $(Echo) Packing gzipped distribution tar file.
1729 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1730 $(GZIP) -c > "$(DistTarGZip)"
1732 dist-bzip2:: $(DistTarBZ2)
1734 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1735 $(Echo) Packing bzipped distribution tar file.
1736 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1737 $(BZIP2) -c >$(DistTarBZ2)
1739 dist-zip:: $(DistZip)
1741 $(DistZip) : $(TopDistDir)/.makedistdir
1742 $(Echo) Packing zipped distribution file.
1743 $(Verb) rm -f $(DistZip)
1744 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1746 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1747 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1749 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1751 dist-check:: $(DistTarGZip)
1752 $(Echo) Checking distribution tar file.
1753 $(Verb) if test -d $(DistCheckDir) ; then \
1754 $(RM) -rf $(DistCheckDir) ; \
1756 $(Verb) $(MKDIR) $(DistCheckDir)
1757 $(Verb) cd $(DistCheckDir) && \
1758 $(MKDIR) $(DistCheckDir)/build && \
1759 $(MKDIR) $(DistCheckDir)/install && \
1760 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1762 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1763 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1766 $(MAKE) unittests && \
1767 $(MAKE) install && \
1768 $(MAKE) uninstall && \
1769 $(MAKE) dist-clean && \
1770 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1773 $(Echo) Cleaning distribution files
1774 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1779 #------------------------------------------------------------------------
1780 # Provide the recursive distdir target for building the distribution directory
1781 #------------------------------------------------------------------------
1782 distdir: $(DistDir)/.makedistdir
1783 $(DistDir)/.makedistdir: $(DistSources)
1784 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1785 if test -d "$(DistDir)" ; then \
1786 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1789 $(EchoCmd) Removing old $(DistDir) ; \
1790 $(RM) -rf $(DistDir); \
1791 $(EchoCmd) Making 'all' to verify build ; \
1792 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1794 $(Echo) Building Distribution Directory $(DistDir)
1795 $(Verb) $(MKDIR) $(DistDir)
1796 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1797 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1798 for file in $(DistFiles) ; do \
1800 $(PROJ_SRC_DIR)/*) \
1801 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1803 $(PROJ_SRC_ROOT)/*) \
1804 file=`echo "$$file" | \
1805 sed "s#^$$srcrootstrip/##"` \
1808 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1809 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1810 from_dir="$(PROJ_SRC_DIR)" ; \
1811 elif test -f "$$file" || test -d "$$file" ; then \
1814 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1815 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1816 to_dir="$(DistDir)/$$dir"; \
1817 $(MKDIR) "$$to_dir" ; \
1819 to_dir="$(DistDir)"; \
1821 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1822 if test -n "$$mid_dir" ; then \
1823 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1825 if test -d "$$from_dir/$$file"; then \
1826 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1827 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1828 cd $(PROJ_SRC_DIR) ; \
1829 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1830 ( cd $$to_dir ; $(TAR) xf - ) ; \
1831 cd $(PROJ_OBJ_DIR) ; \
1834 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1835 ( cd $$to_dir ; $(TAR) xf - ) ; \
1836 cd $(PROJ_OBJ_DIR) ; \
1838 elif test -f "$$from_dir/$$file" ; then \
1839 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1840 elif test -L "$$from_dir/$$file" ; then \
1841 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1842 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1843 $(EchoCmd) "===== WARNING: Distribution Source " \
1844 "$$from_dir/$$file Not Found!" ; \
1845 elif test "$(Verb)" != '@' ; then \
1846 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1849 $(Verb) for subdir in $(DistSubDirs) ; do \
1850 if test "$$subdir" \!= "." ; then \
1851 new_distdir="$(DistDir)/$$subdir" ; \
1852 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1853 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1854 DistDir="$$new_distdir" distdir ) || exit 1; \
1857 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1858 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1859 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1860 -name .svn \) -print` ;\
1861 $(MAKE) dist-hook ; \
1862 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1863 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1864 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1865 -o ! -type d ! -perm -444 -exec \
1866 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1867 || chmod -R a+r $(DistDir) ; \
1870 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1876 ###############################################################################
1877 # TOP LEVEL - targets only to apply at the top level directory
1878 ###############################################################################
1882 #------------------------------------------------------------------------
1883 # Install support for the project's include files:
1884 #------------------------------------------------------------------------
1887 $(Echo) Install circumvented with NO_INSTALL
1889 $(Echo) Uninstall circumvented with NO_INSTALL
1892 $(Echo) Installing include files
1893 $(Verb) $(MKDIR) $(PROJ_includedir)
1894 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1895 cd $(PROJ_SRC_ROOT)/include && \
1896 for hdr in `find . -type f '!' '(' -name '*~' \
1897 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1898 grep -v .svn` ; do \
1899 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1900 if test \! -d "$$instdir" ; then \
1901 $(EchoCmd) Making install directory $$instdir ; \
1902 $(MKDIR) $$instdir ;\
1904 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1907 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1908 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1909 cd $(PROJ_OBJ_ROOT)/include && \
1910 for hdr in `find . -type f -print | grep -v CVS` ; do \
1911 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1917 $(Echo) Uninstalling include files
1918 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1919 cd $(PROJ_SRC_ROOT)/include && \
1920 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1921 '!' '(' -name '*~' -o -name '.#*' \
1922 -o -name '*.in' ')' -print ')' | \
1923 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1924 cd $(PROJ_SRC_ROOT)/include && \
1925 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1926 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1932 @echo searching for overlength lines in files: $(Sources)
1935 egrep -n '.{81}' $(Sources) /dev/null
1938 @echo searching for tabs in files: $(Sources)
1941 egrep -n ' ' $(Sources) /dev/null
1944 @ls -l $(LibDir) | awk '\
1945 BEGIN { sum = 0; } \
1947 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1948 @ls -l $(ToolDir) | awk '\
1949 BEGIN { sum = 0; } \
1951 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1952 #------------------------------------------------------------------------
1953 # Print out the directories used for building
1954 #------------------------------------------------------------------------
1956 $(Echo) "BuildMode : " '$(BuildMode)'
1957 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1958 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1959 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1960 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1961 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1962 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1963 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1964 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1965 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1966 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1967 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1968 $(Echo) "UserTargets : " '$(UserTargets)'
1969 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1970 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1971 $(Echo) "ObjDir : " '$(ObjDir)'
1972 $(Echo) "LibDir : " '$(LibDir)'
1973 $(Echo) "ToolDir : " '$(ToolDir)'
1974 $(Echo) "ExmplDir : " '$(ExmplDir)'
1975 $(Echo) "Sources : " '$(Sources)'
1976 $(Echo) "TDFiles : " '$(TDFiles)'
1977 $(Echo) "INCFiles : " '$(INCFiles)'
1978 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1979 $(Echo) "PreConditions: " '$(PreConditions)'
1980 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1981 $(Echo) "Compile.C : " '$(Compile.C)'
1982 $(Echo) "Archive : " '$(Archive)'
1983 $(Echo) "YaccFiles : " '$(YaccFiles)'
1984 $(Echo) "LexFiles : " '$(LexFiles)'
1985 $(Echo) "Module : " '$(Module)'
1986 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1987 $(Echo) "SubDirs : " '$(SubDirs)'
1988 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1989 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1994 # General debugging rule, use 'make dbg-print-XXX' to print the
1995 # definition, value and origin of XXX.
1997 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))