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
23 LocalTargets := all-local clean-local clean-all-local check-local \
24 install-local printvars uninstall-local \
25 install-bytecode-local unittests
26 TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
28 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29 InternalTargets := preconditions distdir dist-hook
31 ################################################################################
32 # INITIALIZATION: Basic things the makefile needs
33 ################################################################################
35 #--------------------------------------------------------------------
36 # Set the VPATH so that we can find source files.
37 #--------------------------------------------------------------------
40 #--------------------------------------------------------------------
41 # Reset the list of suffixes we know how to build.
42 #--------------------------------------------------------------------
44 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll
45 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
47 #--------------------------------------------------------------------
48 # Mark all of these targets as phony to avoid implicit rule search
49 #--------------------------------------------------------------------
50 .PHONY: $(UserTargets) $(InternalTargets)
52 #--------------------------------------------------------------------
53 # Make sure all the user-target rules are double colon rules and
54 # they are defined first.
55 #--------------------------------------------------------------------
59 ################################################################################
60 # PRECONDITIONS: that which must be built/checked first
61 ################################################################################
63 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
64 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66 ConfigureScript := $(PROJ_SRC_ROOT)/configure
67 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73 ifneq ($(MakefileCommonIn),)
74 PreConditions += $(MakefileCommon)
77 ifneq ($(MakefileConfigIn),)
78 PreConditions += $(MakefileConfig)
81 preconditions: $(PreConditions)
83 #------------------------------------------------------------------------
84 # Make sure the BUILT_SOURCES are built first
85 #------------------------------------------------------------------------
86 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
89 ifneq ($(strip $(BUILT_SOURCES)),)
90 -$(Verb) $(RM) -f $(BUILT_SOURCES)
93 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
95 $(Verb) if test -x config.status ; then \
96 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
97 $(MKDIR) .spotless.save ; \
98 $(MV) config.status .spotless.save ; \
99 $(MV) mklib .spotless.save ; \
100 $(MV) projects .spotless.save ; \
102 $(MV) .spotless.save/config.status . ; \
103 $(MV) .spotless.save/mklib . ; \
104 $(MV) .spotless.save/projects . ; \
105 $(RM) -rf .spotless.save ; \
106 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
107 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
108 $(ConfigStatusScript) ; \
110 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
114 $(EchoCmd) "spotless target not supported for objdir == srcdir"
117 $(BUILT_SOURCES) : $(ObjMakefiles)
119 #------------------------------------------------------------------------
120 # Make sure we're not using a stale configuration
121 #------------------------------------------------------------------------
123 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
124 $(Verb) cd $(PROJ_OBJ_ROOT) && \
125 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
126 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
128 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
129 $(ConfigStatusScript)
131 .PRECIOUS: $(ConfigStatusScript)
132 $(ConfigStatusScript): $(ConfigureScript)
133 $(Echo) Reconfiguring with $<
134 $(Verb) cd $(PROJ_OBJ_ROOT) && \
135 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
136 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
138 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
139 $(ConfigStatusScript)
141 #------------------------------------------------------------------------
142 # Make sure the configuration makefile is up to date
143 #------------------------------------------------------------------------
144 ifneq ($(MakefileConfigIn),)
145 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
146 $(Echo) Regenerating $@
147 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
150 ifneq ($(MakefileCommonIn),)
151 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
152 $(Echo) Regenerating $@
153 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
156 #------------------------------------------------------------------------
157 # If the Makefile in the source tree has been updated, copy it over into the
158 # build tree. But, only do this if the source and object makefiles differ
159 #------------------------------------------------------------------------
160 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
162 Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
163 $(Echo) "Updating Makefile"
164 $(Verb) $(MKDIR) $(@D)
165 $(Verb) $(CP) -f $< $@
167 # Copy the Makefile.* files unless we're in the root directory which avoids
168 # the copying of Makefile.config.in or other things that should be explicitly
170 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
172 *Makefile.rules) ;; \
174 *) $(EchoCmd) "Updating $(@F)" ; \
181 #------------------------------------------------------------------------
182 # Set up the basic dependencies
183 #------------------------------------------------------------------------
184 $(UserTargets):: $(PreConditions)
188 clean-all:: clean-local clean-all-local
189 install:: install-local
190 uninstall:: uninstall-local
191 install-local:: all-local
192 install-bytecode:: install-bytecode-local
194 ###############################################################################
195 # LLVMC: Provide rules for compiling llvmc plugins
196 ###############################################################################
200 LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
201 CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
204 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
205 LD.Flags += -lCompilerDriver
208 # Build a dynamic library if the user runs `make` directly from the plugin
210 ifndef LLVMC_BUILTIN_PLUGIN
215 ifneq ($(BUILT_SOURCES),)
216 LLVMC_BUILD_AUTOGENERATED_INC=1
221 ifdef LLVMC_BASED_DRIVER
223 TOOLNAME = $(LLVMC_BASED_DRIVER)
227 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
228 LD.Flags += -lCompilerDriver
230 LLVMLIBS = CompilerDriver.a
231 LINK_COMPONENTS = support system
234 # Preprocessor magic that generates references to static variables in built-in
236 ifneq ($(LLVMC_BUILTIN_PLUGINS),)
238 USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
240 LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS))
241 LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS))
242 LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS))
243 LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS))
244 LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS))
246 ifneq ($(LLVMC_BUILTIN_PLUGIN_1),)
247 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1)
250 ifneq ($(LLVMC_BUILTIN_PLUGIN_2),)
251 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2)
254 ifneq ($(LLVMC_BUILTIN_PLUGIN_3),)
255 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3)
258 ifneq ($(LLVMC_BUILTIN_PLUGIN_4),)
259 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4)
262 ifneq ($(LLVMC_BUILTIN_PLUGIN_5),)
263 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5)
268 endif # LLVMC_BASED_DRIVER
270 ###############################################################################
271 # VARIABLES: Set up various variables based on configuration data
272 ###############################################################################
274 # Variable for if this make is for a "cleaning" target
275 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
279 #--------------------------------------------------------------------
280 # Variables derived from configuration we are building
281 #--------------------------------------------------------------------
284 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
285 # this can be overridden on the make command line.
286 ifndef OPTIMIZE_OPTION
288 OPTIMIZE_OPTION := -O3
290 OPTIMIZE_OPTION := -O2
294 ifeq ($(ENABLE_OPTIMIZED),1)
296 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
297 ifneq ($(OS),FreeBSD)
299 OmitFramePointer := -fomit-frame-pointer
303 # Darwin requires -fstrict-aliasing to be explicitly enabled.
304 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
305 # with -fstrict-aliasing and ipa-type-escape radr://6756684
307 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
309 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
310 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
311 LD.Flags += $(OPTIMIZE_OPTION)
320 ifeq ($(ENABLE_PROFILING),1)
321 BuildMode := $(BuildMode)+Profile
322 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
323 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
324 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
328 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
329 # CXX.Flags += -fvisibility-inlines-hidden
332 # IF REQUIRES_EH=1 is specified then don't disable exceptions
334 CXX.Flags += -fno-exceptions
337 # IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
339 # CXX.Flags += -fno-rtti
342 ifdef ENABLE_COVERAGE
343 BuildMode := $(BuildMode)+Coverage
344 CXX.Flags += -ftest-coverage -fprofile-arcs
345 C.Flags += -ftest-coverage -fprofile-arcs
348 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
349 # then disable assertions by defining the appropriate preprocessor symbols.
350 ifdef DISABLE_ASSERTIONS
351 # Indicate that assertions are turned off using a minus sign
352 BuildMode := $(BuildMode)-Asserts
353 CPP.Defines += -DNDEBUG
355 CPP.Defines += -D_DEBUG
358 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
359 # configured), then enable expensive checks by defining the
360 # appropriate preprocessor symbols.
361 ifdef ENABLE_EXPENSIVE_CHECKS
362 BuildMode := $(BuildMode)+Checks
363 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
366 # LOADABLE_MODULE implies several other things so we force them to be
368 ifdef LOADABLE_MODULE
370 LINK_LIBS_IN_SHARED := 1
378 ifeq ($(ENABLE_PIC),1)
379 ifeq ($(OS), $(filter $(OS), Cygwin MingW))
380 # Nothing. Win32 defaults to PIC and warns when given -fPIC
383 # Common symbols not allowed in dylib files
384 CXX.Flags += -fno-common
385 C.Flags += -fno-common
387 # Linux and others; pass -fPIC
394 CXX.Flags += -mdynamic-no-pic
395 C.Flags += -mdynamic-no-pic
399 CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
401 CPP.Defines += $(CPPFLAGS)
402 CPP.BaseFlags += $(CPP.Defines)
403 LD.Flags += $(LDFLAGS)
406 # Make Floating point IEEE compliant on Alpha.
409 CPP.BaseFlags += -mieee
410 ifeq ($(ENABLE_PIC),0)
412 CPP.BaseFlags += -fPIC
417 LD.Flags += -Wl,--no-relax
421 ifeq ($(LLVM_CROSS_COMPILING),1)
422 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
424 LD.Flags += -Wl,--allow-multiple-definition
429 ifdef ENABLE_EXPENSIVE_CHECKS
430 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
431 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
432 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
435 #--------------------------------------------------------------------
436 # Directory locations
437 #--------------------------------------------------------------------
439 ifeq ($(LLVM_CROSS_COMPILING),1)
440 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
443 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
444 ObjDir := $(ObjRootDir)
445 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
446 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
447 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
448 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
449 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
450 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
451 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
453 #--------------------------------------------------------------------
454 # Full Paths To Compiled Tools and Utilities
455 #--------------------------------------------------------------------
456 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
459 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
462 ifeq ($(LLVM_CROSS_COMPILING),1)
463 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
465 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
468 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
470 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
473 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
476 LLI := $(LLVMToolDir)/lli$(EXEEXT)
479 LLC := $(LLVMToolDir)/llc$(EXEEXT)
482 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
485 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
488 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
490 ifeq ($(LLVMGCC_MAJVERS),3)
491 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
492 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
494 LLVMGCCWITHPATH := $(LLVMGCC)
495 LLVMGXXWITHPATH := $(LLVMGXX)
498 #--------------------------------------------------------------------
499 # Adjust to user's request
500 #--------------------------------------------------------------------
503 DARWIN_VERSION := `sw_vers -productVersion`
504 # Strip a number like 10.4.7 to 10.4
505 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
506 # Get "4" out of 10.4 for later pieces in the makefile.
507 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
509 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
510 -dynamiclib -mmacosx-version-min=$(DARWIN_VERSION)
511 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
514 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
515 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
517 SharedLinkOptions=-shared
521 # Adjust LD.Flags depending on the kind of library that is to be built. Note
522 # that if LOADABLE_MODULE is specified then the resulting shared library can
523 # be opened with dlopen.
524 ifdef LOADABLE_MODULE
529 ifneq ($(DARWIN_MAJVERS),4)
530 LD.Flags += $(RPATH) -Wl,$(LibDir)
541 # Adjust settings for verbose mode
544 AR.Flags += >/dev/null 2>/dev/null
545 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
547 ConfigureScriptFLAGS :=
550 # By default, strip symbol information from executable
552 Strip := $(PLATFORMSTRIPOPTS)
553 StripWarnMsg := "(without symbols)"
554 Install.StripFlag += -s
557 # Adjust linker flags for building an executable
559 ifneq ($(DARWIN_MAJVERS),4)
562 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
564 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
570 #----------------------------------------------------------
571 # Options To Invoke Tools
572 #----------------------------------------------------------
575 CompileCommonOpts += -pedantic -Wno-long-long
577 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
581 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
584 # If we are building a universal binary on Mac OS/X, pass extra options. This
585 # is useful to people that want to link the LLVM libraries into their universal
588 # The following can be optionally specified:
589 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
590 # For Mac OS/X 10.4 Intel machines, the traditional one is:
591 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
592 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
593 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
596 ifndef UNIVERSAL_ARCH
597 UNIVERSAL_ARCH := i386 ppc
599 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
600 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
601 ifdef UNIVERSAL_SDK_PATH
602 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
605 # Building universal cannot compute dependencies automatically.
606 DISABLE_AUTO_DEPENDENCIES=1
609 ifeq ($(ARCH),x86_64)
610 TargetCommonOpts = -m64
613 TargetCommonOpts = -m32
620 CPP.BaseFlags += -include llvm/System/Solaris.h
623 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
624 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
625 # All -I flags should go here, so that they don't confuse llvm-config.
626 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
627 $(patsubst %,-I%/include,\
628 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
629 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
632 ifeq ($(BUILD_COMPONENT), 1)
633 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) \
634 $(TargetCommonOpts) $(CompileCommonOpts) -c
635 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) \
636 $(TargetCommonOpts) $(CompileCommonOpts) -c
637 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(TargetCommonOpts) \
638 $(CompileCommonOpts) $(CXX.Flags) -E
639 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) \
640 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
642 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) \
643 $(TargetCommonOpts) $(CompileCommonOpts) -c
644 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) \
645 $(TargetCommonOpts) $(CompileCommonOpts) -c
646 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) \
647 $(CompileCommonOpts) $(CXX.Flags) -E
648 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) \
649 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
652 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) \
653 $(TargetCommonOpts) $(CompileCommonOpts)
654 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) \
655 $(TargetCommonOpts) $(CompileCommonOpts) -E
657 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
658 $(TargetCommonOpts) $(CompileCommonOpts)
660 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
661 ScriptInstall = $(INSTALL) -m 0755
662 DataInstall = $(INSTALL) -m 0644
664 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
665 # paths. In this case, the SYSPATH function (defined in
666 # Makefile.config) transforms Unix paths into Windows paths.
667 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
668 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
669 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
670 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
672 Archive = $(AR) $(AR.Flags)
673 LArchive = $(LLVMToolDir)/llvm-ar rcsf
680 #----------------------------------------------------------
681 # Get the list of source files and compute object file
683 #----------------------------------------------------------
686 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
687 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
689 Sources := $(SOURCES)
693 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
696 BaseNameSources := $(sort $(basename $(Sources)))
698 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
699 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
701 ###############################################################################
702 # DIRECTORIES: Handle recursive descent of directory structure
703 ###############################################################################
705 #---------------------------------------------------------
706 # Provide rules to make install dirs. This must be early
707 # in the file so they get built before dependencies
708 #---------------------------------------------------------
710 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
713 # To create other directories, as needed, and timestamp their creation
715 $(Verb) $(MKDIR) $* > /dev/null
718 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
719 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
721 #---------------------------------------------------------
722 # Handle the DIRS options for sequential construction
723 #---------------------------------------------------------
729 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
730 $(RecursiveTargets)::
731 $(Verb) for dir in $(DIRS); do \
732 if [ ! -f $$dir/Makefile ]; then \
734 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
736 ($(MAKE) -C $$dir $@ ) || exit 1; \
739 $(RecursiveTargets)::
740 $(Verb) for dir in $(DIRS); do \
741 ($(MAKE) -C $$dir $@ ) || exit 1; \
747 #---------------------------------------------------------
748 # Handle the EXPERIMENTAL_DIRS options ensuring success
749 # after each directory is built.
750 #---------------------------------------------------------
751 ifdef EXPERIMENTAL_DIRS
752 $(RecursiveTargets)::
753 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
754 if [ ! -f $$dir/Makefile ]; then \
756 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
758 ($(MAKE) -C $$dir $@ ) || exit 0; \
762 #-----------------------------------------------------------
763 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
764 #-----------------------------------------------------------
765 ifdef OPTIONAL_PARALLEL_DIRS
766 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
769 #-----------------------------------------------------------
770 # Handle the PARALLEL_DIRS options for parallel construction
771 #-----------------------------------------------------------
774 SubDirs += $(PARALLEL_DIRS)
776 # Unfortunately, this list must be maintained if new recursive targets are added
777 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
778 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
779 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
780 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
781 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
782 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
784 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
787 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
789 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
791 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
794 #---------------------------------------------------------
795 # Handle the OPTIONAL_DIRS options for directores that may
797 #---------------------------------------------------------
800 SubDirs += $(OPTIONAL_DIRS)
802 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
803 $(RecursiveTargets)::
804 $(Verb) for dir in $(OPTIONAL_DIRS); do \
805 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
806 if [ ! -f $$dir/Makefile ]; then \
808 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
810 ($(MAKE) -C$$dir $@ ) || exit 1; \
814 $(RecursiveTargets)::
815 $(Verb) for dir in $(OPTIONAL_DIRS); do \
816 ($(MAKE) -C$$dir $@ ) || exit 1; \
821 #---------------------------------------------------------
822 # Handle the CONFIG_FILES options
823 #---------------------------------------------------------
828 $(Echo) Install circumvented with NO_INSTALL
830 $(Echo) UnInstall circumvented with NO_INSTALL
832 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
833 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
834 $(Verb)for file in $(CONFIG_FILES); do \
835 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
836 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
837 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
838 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
840 $(ECHO) Error: cannot find config file $${file}. ; \
845 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
846 $(Verb)for file in $(CONFIG_FILES); do \
847 $(RM) -f $(PROJ_etcdir)/$${file} ; \
853 ###############################################################################
854 # Set up variables for building libararies
855 ###############################################################################
857 #---------------------------------------------------------
858 # Define various command line options pertaining to the
859 # libraries needed when linking. There are "Proj" libs
860 # (defined by the user's project) and "LLVM" libs (defined
861 # by the LLVM project).
862 #---------------------------------------------------------
865 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
866 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
867 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
868 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
872 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
873 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
874 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
875 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
878 ifndef IS_CLEANING_TARGET
879 ifdef LINK_COMPONENTS
881 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
882 # clean in tools, then do a make in tools (instead of at the top level).
884 @echo "*** llvm-config doesn't exist - rebuilding it."
885 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
887 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
889 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
890 LLVMLibsPaths += $(LLVM_CONFIG) \
891 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
895 ###############################################################################
896 # Library Build Rules: Four ways to build a library
897 ###############################################################################
899 #---------------------------------------------------------
900 # Bytecode Module Targets:
901 # If the user set MODULE_NAME then they want to build a
902 # bytecode module from the sources. We compile all the
903 # sources and link it together into a single bytecode
905 #---------------------------------------------------------
908 ifeq ($(strip $(LLVMGCC)),)
909 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
912 Module := $(LibDir)/$(MODULE_NAME).bc
913 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
916 ifdef EXPORTED_SYMBOL_FILE
917 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
920 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
921 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
922 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
924 all-local:: $(Module)
927 ifneq ($(strip $(Module)),)
928 -$(Verb) $(RM) -f $(Module)
931 ifdef BYTECODE_DESTINATION
932 ModuleDestDir := $(BYTECODE_DESTINATION)
934 ModuleDestDir := $(PROJ_libdir)
939 $(Echo) Install circumvented with NO_INSTALL
941 $(Echo) Uninstall circumvented with NO_INSTALL
943 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
945 install-module:: $(DestModule)
946 install-local:: $(DestModule)
948 $(DestModule): $(ModuleDestDir) $(Module)
949 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
950 $(Verb) $(DataInstall) $(Module) $(DestModule)
953 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
954 -$(Verb) $(RM) -f $(DestModule)
960 # if we're building a library ...
963 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
964 LIBRARYNAME := $(strip $(LIBRARYNAME))
965 ifdef LOADABLE_MODULE
966 LibName.A := $(LibDir)/$(LIBRARYNAME).a
967 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
969 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
970 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
972 LibName.O := $(LibDir)/$(LIBRARYNAME).o
973 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
975 #---------------------------------------------------------
976 # Shared Library Targets:
977 # If the user asked for a shared library to be built
978 # with the SHARED_LIBRARY variable, then we provide
979 # targets for building them.
980 #---------------------------------------------------------
983 all-local:: $(LibName.SO)
985 ifdef LINK_LIBS_IN_SHARED
986 ifdef LOADABLE_MODULE
987 SharedLibKindMessage := "Loadable Module"
989 SharedLibKindMessage := "Shared Library"
991 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
992 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
993 $(LIBRARYNAME)$(SHLIBEXT)
994 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
995 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
997 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
998 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
999 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1003 ifneq ($(strip $(LibName.SO)),)
1004 -$(Verb) $(RM) -f $(LibName.SO)
1009 $(Echo) Install circumvented with NO_INSTALL
1011 $(Echo) Uninstall circumvented with NO_INSTALL
1013 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1015 install-local:: $(DestSharedLib)
1017 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
1018 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1019 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1022 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1023 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
1027 #---------------------------------------------------------
1028 # Bytecode Library Targets:
1029 # If the user asked for a bytecode library to be built
1030 # with the BYTECODE_LIBRARY variable, then we provide
1031 # targets for building them.
1032 #---------------------------------------------------------
1033 ifdef BYTECODE_LIBRARY
1034 ifeq ($(strip $(LLVMGCC)),)
1035 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
1038 all-local:: $(LibName.BCA)
1040 ifdef EXPORTED_SYMBOL_FILE
1041 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
1042 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1044 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1045 $(LLVMToolDir)/llvm-ar
1046 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1048 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
1050 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
1052 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1053 $(LLVMToolDir)/llvm-ar
1054 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1056 $(Verb) $(LArchive) $@ $(ObjectsBC)
1061 ifneq ($(strip $(LibName.BCA)),)
1062 -$(Verb) $(RM) -f $(LibName.BCA)
1065 ifdef BYTECODE_DESTINATION
1066 BytecodeDestDir := $(BYTECODE_DESTINATION)
1068 BytecodeDestDir := $(PROJ_libdir)
1071 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1073 install-bytecode-local:: $(DestBytecodeLib)
1077 $(Echo) Install circumvented with NO_INSTALL
1079 $(Echo) Uninstall circumvented with NO_INSTALL
1081 install-local:: $(DestBytecodeLib)
1083 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1084 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1085 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1088 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1089 -$(Verb) $(RM) -f $(DestBytecodeLib)
1094 #---------------------------------------------------------
1096 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1097 # building an archive.
1098 #---------------------------------------------------------
1099 ifndef BUILD_ARCHIVE
1100 ifndef LOADABLE_MODULE
1105 #---------------------------------------------------------
1106 # Archive Library Targets:
1107 # If the user wanted a regular archive library built,
1108 # then we provide targets for building them.
1109 #---------------------------------------------------------
1112 all-local:: $(LibName.A)
1114 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1115 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1116 -$(Verb) $(RM) -f $@
1117 $(Verb) $(Archive) $@ $(ObjectsO)
1118 $(Verb) $(Ranlib) $@
1121 ifneq ($(strip $(LibName.A)),)
1122 -$(Verb) $(RM) -f $(LibName.A)
1127 $(Echo) Install circumvented with NO_INSTALL
1129 $(Echo) Uninstall circumvented with NO_INSTALL
1131 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1133 install-local:: $(DestArchiveLib)
1135 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1136 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1137 $(Verb) $(MKDIR) $(PROJ_libdir)
1138 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1141 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1142 -$(Verb) $(RM) -f $(DestArchiveLib)
1149 ###############################################################################
1150 # Tool Build Rules: Build executable tool based on TOOLNAME option
1151 ###############################################################################
1155 #---------------------------------------------------------
1156 # Set up variables for building a tool.
1157 #---------------------------------------------------------
1159 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1161 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1164 #---------------------------------------------------------
1166 #---------------------------------------------------------
1168 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1169 # not exporting all of the weak symbols from the binary. This reduces dyld
1170 # startup time by 4x on darwin in some cases.
1171 ifdef TOOL_NO_EXPORTS
1174 # Tiger tools don't support this.
1175 ifneq ($(DARWIN_MAJVERS),4)
1176 LD.Flags += -Wl,-exported_symbol -Wl,_main
1180 ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
1181 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1186 #---------------------------------------------------------
1187 # Provide targets for building the tools
1188 #---------------------------------------------------------
1189 all-local:: $(ToolBuildPath)
1192 ifneq ($(strip $(ToolBuildPath)),)
1193 -$(Verb) $(RM) -f $(ToolBuildPath)
1197 $(ToolBuildPath): $(ExmplDir)/.dir
1199 $(ToolBuildPath): $(ToolDir)/.dir
1202 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1203 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1204 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1205 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1206 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1211 $(Echo) Install circumvented with NO_INSTALL
1213 $(Echo) Uninstall circumvented with NO_INSTALL
1215 DestTool = $(PROJ_bindir)/$(TOOLNAME)
1217 install-local:: $(DestTool)
1219 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1220 $(Echo) Installing $(BuildMode) $(DestTool)
1221 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1224 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1225 -$(Verb) $(RM) -f $(DestTool)
1229 ###############################################################################
1230 # Object Build Rules: Build object files based on sources
1231 ###############################################################################
1233 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1235 DISABLE_AUTO_DEPENDENCIES=1
1238 # Provide rule sets for when dependency generation is enabled
1239 ifndef DISABLE_AUTO_DEPENDENCIES
1241 #---------------------------------------------------------
1242 # Create .o files in the ObjDir directory from the .cpp and .c files...
1243 #---------------------------------------------------------
1245 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1246 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1248 # If the build succeeded, move the dependency file over, otherwise
1250 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1251 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1253 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1254 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1255 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1258 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1259 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1260 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1263 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1264 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1265 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1268 #---------------------------------------------------------
1269 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1270 #---------------------------------------------------------
1272 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1273 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1275 # If the build succeeded, move the dependency file over, otherwise
1277 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1278 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1280 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1281 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1282 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1283 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1284 $(BC_DEPEND_MOVEFILE)
1286 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1287 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1288 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1289 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1290 $(BC_DEPEND_MOVEFILE)
1292 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1293 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1294 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1295 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1296 $(BC_DEPEND_MOVEFILE)
1298 # Provide alternate rule sets if dependencies are disabled
1301 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1302 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1303 $(Compile.CXX) $< -o $@
1305 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1306 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1307 $(Compile.CXX) $< -o $@
1309 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1310 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1311 $(Compile.C) $< -o $@
1313 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1314 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1315 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1317 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1318 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1319 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1321 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1322 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1323 $(BCCompile.C) $< -o $@ -S -emit-llvm
1328 ## Rules for building preprocessed (.i/.ii) outputs.
1329 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1330 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1331 $(Verb) $(Preprocess.CXX) $< -o $@
1333 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1334 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1335 $(Verb) $(Preprocess.CXX) $< -o $@
1337 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1338 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1339 $(Verb) $(Preprocess.C) $< -o $@
1342 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1343 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1344 $(Compile.CXX) $< -o $@ -S
1346 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1347 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1348 $(Compile.CXX) $< -o $@ -S
1350 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1351 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1352 $(Compile.C) $< -o $@ -S
1355 # make the C and C++ compilers strip debug info out of bytecode libraries.
1357 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1358 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1359 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
1361 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1362 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1363 $(Verb) $(LLVMAS) $< -o - | \
1364 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
1368 #---------------------------------------------------------
1369 # Provide rule to build .bc files from .ll sources,
1370 # regardless of dependencies
1371 #---------------------------------------------------------
1372 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1373 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1374 $(Verb) $(LLVMAS) $< -f -o $@
1376 ###############################################################################
1377 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1378 ###############################################################################
1381 TABLEGEN_INC_FILES_COMMON = 1
1384 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1385 TABLEGEN_INC_FILES_COMMON = 1
1388 ifdef TABLEGEN_INC_FILES_COMMON
1390 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1391 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1392 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1394 # INCFiles rule: All of the tblgen generated files are emitted to
1395 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1396 # us to only "touch" the real file if the contents of it change. IOW, if
1397 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1398 # dependencies of the .inc files are, unless the contents of the .inc file
1400 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1401 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1403 endif # TABLEGEN_INC_FILES_COMMON
1407 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1408 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1409 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1410 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1411 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1412 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1413 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1415 # All of these files depend on tblgen and the .td files.
1416 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1418 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1419 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1420 $(Echo) "Building $(<F) register names with tblgen"
1421 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1423 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1424 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1425 $(Echo) "Building $(<F) register information header with tblgen"
1426 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1428 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1429 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1430 $(Echo) "Building $(<F) register info implementation with tblgen"
1431 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1433 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1434 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1435 $(Echo) "Building $(<F) instruction names with tblgen"
1436 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1438 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1439 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1440 $(Echo) "Building $(<F) instruction information with tblgen"
1441 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1443 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1444 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1445 $(Echo) "Building $(<F) assembly writer with tblgen"
1446 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1448 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1449 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1450 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1451 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1453 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1454 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1455 $(Echo) "Building $(<F) code emitter with tblgen"
1456 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1458 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1459 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1460 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1461 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1463 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1464 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1465 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1466 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1468 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1469 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1470 $(Echo) "Building $(<F) subtarget information with tblgen"
1471 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1473 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1474 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1475 $(Echo) "Building $(<F) calling convention information with tblgen"
1476 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1478 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1479 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1480 $(Echo) "Building $(<F) calling convention information with tblgen"
1481 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1484 -$(Verb) $(RM) -f $(INCFiles)
1488 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1490 LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1491 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1493 TDFiles := $(LLVMCPluginSrc) \
1494 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1496 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1497 $(TBLGEN) $(TD_COMMON)
1498 $(Echo) "Building LLVMC configuration library with tblgen"
1499 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1501 endif # LLVMC_BUILD_AUTOGENERATED_INC
1503 ###############################################################################
1504 # OTHER RULES: Other rules needed
1505 ###############################################################################
1507 # To create postscript files from dot files...
1508 ifneq ($(DOT),false)
1510 $(DOT) -Tps < $< > $@
1513 $(Echo) "Cannot build $@: The program dot is not installed"
1516 # This rules ensures that header files that are removed still have a rule for
1517 # which they can be "generated." This allows make to ignore them and
1518 # reproduce the dependency lists.
1522 # Define clean-local to clean the current directory. Note that this uses a
1523 # very conservative approach ensuring that empty variables do not cause
1524 # errors or disastrous removal.
1526 ifneq ($(strip $(ObjRootDir)),)
1527 -$(Verb) $(RM) -rf $(ObjRootDir)
1529 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1530 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1531 -$(Verb) $(RM) -f *$(SHLIBEXT)
1535 -$(Verb) $(RM) -rf Debug Release Profile
1538 ###############################################################################
1539 # DEPENDENCIES: Include the dependency files if we should
1540 ###############################################################################
1541 ifndef DISABLE_AUTO_DEPENDENCIES
1543 # If its not one of the cleaning targets
1544 ifndef IS_CLEANING_TARGET
1546 # Get the list of dependency files
1547 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1548 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1550 # Include bitcode dependency files if using bitcode libraries
1551 ifdef BYTECODE_LIBRARY
1552 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1555 -include $(DependFiles) ""
1561 ###############################################################################
1562 # CHECK: Running the test suite
1563 ###############################################################################
1566 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1567 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1568 $(EchoCmd) Running test suite ; \
1569 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1570 TESTSUITE=$(TESTSUITE) ; \
1572 $(EchoCmd) No Makefile in test directory ; \
1575 $(EchoCmd) No test directory ; \
1578 ###############################################################################
1579 # UNITTESTS: Running the unittests test suite
1580 ###############################################################################
1583 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1584 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1585 $(EchoCmd) Running unittests test suite ; \
1586 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
1588 $(EchoCmd) No Makefile in unittests directory ; \
1591 $(EchoCmd) No unittests directory ; \
1594 ###############################################################################
1595 # DISTRIBUTION: Handle construction of a distribution tarball
1596 ###############################################################################
1598 #------------------------------------------------------------------------
1599 # Define distribution related variables
1600 #------------------------------------------------------------------------
1601 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1602 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1603 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1604 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1605 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1606 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1607 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1608 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1609 Makefile.config.in configure autoconf
1610 DistOther := $(notdir $(wildcard \
1611 $(PROJ_SRC_DIR)/*.h \
1612 $(PROJ_SRC_DIR)/*.td \
1613 $(PROJ_SRC_DIR)/*.def \
1614 $(PROJ_SRC_DIR)/*.ll \
1615 $(PROJ_SRC_DIR)/*.in))
1616 DistSubDirs := $(SubDirs)
1617 DistSources = $(Sources) $(EXTRA_DIST)
1618 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1620 #------------------------------------------------------------------------
1621 # We MUST build distribution with OBJ_DIR != SRC_DIR
1622 #------------------------------------------------------------------------
1623 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1624 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1625 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1629 #------------------------------------------------------------------------
1630 # Prevent attempt to run dist targets from anywhere but the top level
1631 #------------------------------------------------------------------------
1633 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1634 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1637 #------------------------------------------------------------------------
1638 # Provide the top level targets
1639 #------------------------------------------------------------------------
1641 dist-gzip:: $(DistTarGZip)
1643 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1644 $(Echo) Packing gzipped distribution tar file.
1645 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1646 $(GZIP) -c > "$(DistTarGZip)"
1648 dist-bzip2:: $(DistTarBZ2)
1650 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1651 $(Echo) Packing bzipped distribution tar file.
1652 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1653 $(BZIP2) -c >$(DistTarBZ2)
1655 dist-zip:: $(DistZip)
1657 $(DistZip) : $(TopDistDir)/.makedistdir
1658 $(Echo) Packing zipped distribution file.
1659 $(Verb) rm -f $(DistZip)
1660 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1662 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1663 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1665 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1667 dist-check:: $(DistTarGZip)
1668 $(Echo) Checking distribution tar file.
1669 $(Verb) if test -d $(DistCheckDir) ; then \
1670 $(RM) -rf $(DistCheckDir) ; \
1672 $(Verb) $(MKDIR) $(DistCheckDir)
1673 $(Verb) cd $(DistCheckDir) && \
1674 $(MKDIR) $(DistCheckDir)/build && \
1675 $(MKDIR) $(DistCheckDir)/install && \
1676 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1678 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1679 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1682 $(MAKE) unittests && \
1683 $(MAKE) install && \
1684 $(MAKE) uninstall && \
1685 $(MAKE) dist-clean && \
1686 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1689 $(Echo) Cleaning distribution files
1690 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1695 #------------------------------------------------------------------------
1696 # Provide the recursive distdir target for building the distribution directory
1697 #------------------------------------------------------------------------
1698 distdir: $(DistDir)/.makedistdir
1699 $(DistDir)/.makedistdir: $(DistSources)
1700 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1701 if test -d "$(DistDir)" ; then \
1702 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1705 $(EchoCmd) Removing old $(DistDir) ; \
1706 $(RM) -rf $(DistDir); \
1707 $(EchoCmd) Making 'all' to verify build ; \
1708 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1710 $(Echo) Building Distribution Directory $(DistDir)
1711 $(Verb) $(MKDIR) $(DistDir)
1712 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1713 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1714 for file in $(DistFiles) ; do \
1716 $(PROJ_SRC_DIR)/*) \
1717 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1719 $(PROJ_SRC_ROOT)/*) \
1720 file=`echo "$$file" | \
1721 sed "s#^$$srcrootstrip/##"` \
1724 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1725 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1726 from_dir="$(PROJ_SRC_DIR)" ; \
1727 elif test -f "$$file" || test -d "$$file" ; then \
1730 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1731 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1732 to_dir="$(DistDir)/$$dir"; \
1733 $(MKDIR) "$$to_dir" ; \
1735 to_dir="$(DistDir)"; \
1737 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1738 if test -n "$$mid_dir" ; then \
1739 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1741 if test -d "$$from_dir/$$file"; then \
1742 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1743 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1744 cd $(PROJ_SRC_DIR) ; \
1745 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1746 ( cd $$to_dir ; $(TAR) xf - ) ; \
1747 cd $(PROJ_OBJ_DIR) ; \
1750 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1751 ( cd $$to_dir ; $(TAR) xf - ) ; \
1752 cd $(PROJ_OBJ_DIR) ; \
1754 elif test -f "$$from_dir/$$file" ; then \
1755 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1756 elif test -L "$$from_dir/$$file" ; then \
1757 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1758 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1759 $(EchoCmd) "===== WARNING: Distribution Source " \
1760 "$$from_dir/$$file Not Found!" ; \
1761 elif test "$(Verb)" != '@' ; then \
1762 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1765 $(Verb) for subdir in $(DistSubDirs) ; do \
1766 if test "$$subdir" \!= "." ; then \
1767 new_distdir="$(DistDir)/$$subdir" ; \
1768 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1769 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1770 DistDir="$$new_distdir" distdir ) || exit 1; \
1773 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1774 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1775 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1776 -name .svn \) -print` ;\
1777 $(MAKE) dist-hook ; \
1778 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1779 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1780 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1781 -o ! -type d ! -perm -444 -exec \
1782 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1783 || chmod -R a+r $(DistDir) ; \
1786 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1792 ###############################################################################
1793 # TOP LEVEL - targets only to apply at the top level directory
1794 ###############################################################################
1798 #------------------------------------------------------------------------
1799 # Install support for the project's include files:
1800 #------------------------------------------------------------------------
1803 $(Echo) Install circumvented with NO_INSTALL
1805 $(Echo) Uninstall circumvented with NO_INSTALL
1808 $(Echo) Installing include files
1809 $(Verb) $(MKDIR) $(PROJ_includedir)
1810 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1811 cd $(PROJ_SRC_ROOT)/include && \
1812 for hdr in `find . -type f '!' '(' -name '*~' \
1813 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1814 grep -v .svn` ; do \
1815 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1816 if test \! -d "$$instdir" ; then \
1817 $(EchoCmd) Making install directory $$instdir ; \
1818 $(MKDIR) $$instdir ;\
1820 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1823 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1824 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1825 cd $(PROJ_OBJ_ROOT)/include && \
1826 for hdr in `find . -type f -print | grep -v CVS` ; do \
1827 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1833 $(Echo) Uninstalling include files
1834 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1835 cd $(PROJ_SRC_ROOT)/include && \
1836 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1837 '!' '(' -name '*~' -o -name '.#*' \
1838 -o -name '*.in' ')' -print ')' | \
1839 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1840 cd $(PROJ_SRC_ROOT)/include && \
1841 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1842 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1848 @echo searching for overlength lines in files: $(Sources)
1851 egrep -n '.{81}' $(Sources) /dev/null
1854 @echo searching for tabs in files: $(Sources)
1857 egrep -n ' ' $(Sources) /dev/null
1860 @ls -l $(LibDir) | awk '\
1861 BEGIN { sum = 0; } \
1863 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1864 @ls -l $(ToolDir) | awk '\
1865 BEGIN { sum = 0; } \
1867 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1868 #------------------------------------------------------------------------
1869 # Print out the directories used for building
1870 #------------------------------------------------------------------------
1872 $(Echo) "BuildMode : " '$(BuildMode)'
1873 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1874 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1875 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1876 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1877 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1878 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1879 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1880 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1881 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1882 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1883 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1884 $(Echo) "UserTargets : " '$(UserTargets)'
1885 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1886 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1887 $(Echo) "ObjDir : " '$(ObjDir)'
1888 $(Echo) "LibDir : " '$(LibDir)'
1889 $(Echo) "ToolDir : " '$(ToolDir)'
1890 $(Echo) "ExmplDir : " '$(ExmplDir)'
1891 $(Echo) "Sources : " '$(Sources)'
1892 $(Echo) "TDFiles : " '$(TDFiles)'
1893 $(Echo) "INCFiles : " '$(INCFiles)'
1894 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1895 $(Echo) "PreConditions: " '$(PreConditions)'
1896 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1897 $(Echo) "Compile.C : " '$(Compile.C)'
1898 $(Echo) "Archive : " '$(Archive)'
1899 $(Echo) "YaccFiles : " '$(YaccFiles)'
1900 $(Echo) "LexFiles : " '$(LexFiles)'
1901 $(Echo) "Module : " '$(Module)'
1902 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1903 $(Echo) "SubDirs : " '$(SubDirs)'
1904 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1905 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1910 # General debugging rule, use 'make dbg-print-XXX' to print the
1911 # definition, value and origin of XXX.
1913 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))