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))
203 # Build a dynamic library if the user runs `make` directly from the plugin
205 ifndef LLVMC_BUILTIN_PLUGIN
210 ifneq ($(BUILT_SOURCES),)
211 LLVMC_BUILD_AUTOGENERATED_INC=1
216 ###############################################################################
217 # VARIABLES: Set up various variables based on configuration data
218 ###############################################################################
220 # Variable for if this make is for a "cleaning" target
221 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
225 #--------------------------------------------------------------------
226 # Variables derived from configuration we are building
227 #--------------------------------------------------------------------
230 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
231 # this can be overridden on the make command line.
233 OPTIMIZE_OPTION := -O3
235 OPTIMIZE_OPTION := -O2
238 ifdef ENABLE_PROFILING
240 CXX.Flags += $(OPTIMIZE_OPTION) -pg -g
241 C.Flags += $(OPTIMIZE_OPTION) -pg -g
242 LD.Flags += $(OPTIMIZE_OPTION) -pg -g
245 ifeq ($(ENABLE_OPTIMIZED),1)
247 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
248 ifneq ($(OS),FreeBSD)
250 OmitFramePointer := -fomit-frame-pointer
254 # Darwin requires -fstrict-aliasing to be explicitly enabled.
256 EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
259 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
260 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
261 LD.Flags += $(OPTIMIZE_OPTION)
271 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
272 # CXX.Flags += -fvisibility-inlines-hidden
275 # IF REQUIRES_EH=1 is specified then don't disable exceptions
277 CXX.Flags += -fno-exceptions
280 # IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
282 # CXX.Flags += -fno-rtti
285 ifdef ENABLE_COVERAGE
286 BuildMode := $(BuildMode)+Coverage
287 # These only go to .NoRelink because otherwise we will end up
288 # linking -lgcov into the .o libraries that get built.
289 CXX.Flags.NoRelink += -ftest-coverage -fprofile-arcs
290 C.Flags.NoRelink += -ftest-coverage -fprofile-arcs
293 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
294 # then disable assertions by defining the appropriate preprocessor symbols.
295 ifdef DISABLE_ASSERTIONS
296 BuildMode := $(BuildMode)-Asserts
297 CPP.Defines += -DNDEBUG
299 CPP.Defines += -D_DEBUG
302 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
303 # configured), then enable expensive checks by defining the
304 # appropriate preprocessor symbols.
305 ifdef ENABLE_EXPENSIVE_CHECKS
306 BuildMode := $(BuildMode)+Checks
307 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
310 # LOADABLE_MODULE implies several other things so we force them to be
312 ifdef LOADABLE_MODULE
314 DONT_BUILD_RELINKED := 1
315 LINK_LIBS_IN_SHARED := 1
323 ifeq ($(ENABLE_PIC),1)
324 ifeq ($(OS), $(filter $(OS), Cygwin MingW))
325 # Nothing. Win32 defaults to PIC and warns when given -fPIC
328 # Common symbols not allowed in dylib files
329 CXX.Flags += -fno-common
330 C.Flags += -fno-common
332 # Linux and others; pass -fPIC
339 CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
341 CPP.Defines += $(CPPFLAGS)
342 CPP.BaseFlags += $(CPP.Defines)
343 LD.Flags += $(LDFLAGS)
346 # Make Floating point IEEE compliant on Alpha.
349 CPP.BaseFlags += -mieee
350 ifeq ($(ENABLE_PIC),0)
352 CPP.BaseFlags += -fPIC
357 LD.Flags += -Wl,--no-relax
360 #--------------------------------------------------------------------
361 # Directory locations
362 #--------------------------------------------------------------------
364 ifeq ($(LLVM_CROSS_COMPILING),1)
365 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
368 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
369 ObjDir := $(ObjRootDir)
370 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
371 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
372 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
373 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
374 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
375 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
376 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
378 #--------------------------------------------------------------------
379 # Full Paths To Compiled Tools and Utilities
380 #--------------------------------------------------------------------
381 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
384 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
387 ifeq ($(LLVM_CROSS_COMPILING),1)
388 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
390 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
393 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
395 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
398 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
401 LLI := $(LLVMToolDir)/lli$(EXEEXT)
404 LLC := $(LLVMToolDir)/llc$(EXEEXT)
407 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
410 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
413 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
415 ifeq ($(LLVMGCC_MAJVERS),3)
416 UPGRADE_MSG = $(Echo) "Upgrading $(1) assembly to latest."
417 UPGRADE_LL = $(Verb)$(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1)
418 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
419 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
423 LLVMGCCWITHPATH := $(LLVMGCC)
424 LLVMGXXWITHPATH := $(LLVMGXX)
427 #--------------------------------------------------------------------
428 # Adjust to user's request
429 #--------------------------------------------------------------------
432 DARWIN_VERSION := `sw_vers -productVersion`
433 # Strip a number like 10.4.7 to 10.4
434 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
435 # Get "4" out of 10.4 for later pieces in the makefile.
436 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
438 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -Wl,-dylib \
439 -mmacosx-version-min=$(DARWIN_VERSION)
440 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
443 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
444 -Wl,--enable-auto-import -Wl,--enable-auto-image-base \
445 -Wl,--enable-runtime-pseudo-relocs
447 SharedLinkOptions=-shared
451 # Adjust LD.Flags depending on the kind of library that is to be built. Note
452 # that if LOADABLE_MODULE is specified then the resulting shared library can
453 # be opened with dlopen.
454 ifdef LOADABLE_MODULE
459 ifneq ($(DARWIN_MAJVERS),4)
460 LD.Flags += $(RPATH) -Wl,$(LibDir)
471 # Adjust settings for verbose mode
474 AR.Flags += >/dev/null 2>/dev/null
475 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
477 ConfigureScriptFLAGS :=
480 # By default, strip symbol information from executable
482 Strip := $(PLATFORMSTRIPOPTS)
483 StripWarnMsg := "(without symbols)"
484 Install.StripFlag += -s
487 # Adjust linker flags for building an executable
489 ifneq ($(DARWIN_MAJVERS),4)
492 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
494 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
500 #----------------------------------------------------------
501 # Options To Invoke Tools
502 #----------------------------------------------------------
504 CompileCommonOpts += -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
505 -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
508 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
511 # If we are building a universal binary on Mac OS/X, pass extra options. This
512 # is useful to people that want to link the LLVM libraries into their universal
515 # The following can be optionally specified:
516 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
517 # For Mac OS/X 10.4 Intel machines, the traditional one is:
518 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
519 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
520 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
523 ifndef UNIVERSAL_ARCH
524 UNIVERSAL_ARCH := i386 ppc
526 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
527 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
528 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS)
529 ifdef UNIVERSAL_SDK_PATH
530 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
531 Relink.Flags += -isysroot $(UNIVERSAL_SDK_PATH)
534 # Building universal cannot compute dependencies automatically.
535 DISABLE_AUTO_DEPENDENCIES=1
538 ifeq ($(ARCH),x86_64)
539 TargetCommonOpts = -m64
542 TargetCommonOpts = -m32
549 CPP.BaseFlags += -include llvm/System/Solaris.h
552 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
553 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
554 # All -I flags should go here, so that they don't confuse llvm-config.
555 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
556 $(patsubst %,-I%/include,\
557 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
558 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
561 ifeq ($(BUILD_COMPONENT), 1)
562 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
563 $(TargetCommonOpts) $(CompileCommonOpts) -c
564 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
565 $(TargetCommonOpts) $(CompileCommonOpts) -c
566 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(TargetCommonOpts) \
567 $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
568 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
569 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
570 Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
571 $(CompileCommonOpts) $(Relink.Flags)
573 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
574 $(TargetCommonOpts) $(CompileCommonOpts) -c
575 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
576 $(TargetCommonOpts) $(CompileCommonOpts) -c
577 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) \
578 $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
579 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
580 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
581 Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
582 $(CompileCommonOpts) $(Relink.Flags)
585 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) \
586 $(TargetCommonOpts) $(CompileCommonOpts)
587 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) \
588 $(TargetCommonOpts) $(CompileCommonOpts) -E
590 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
591 $(TargetCommonOpts) $(CompileCommonOpts)
593 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
594 ScriptInstall = $(INSTALL) -m 0755
595 DataInstall = $(INSTALL) -m 0644
597 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
598 # paths. In this case, the SYSPATH function (defined in
599 # Makefile.config) transforms Unix paths into Windows paths.
600 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
601 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
602 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
603 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
605 Archive = $(AR) $(AR.Flags)
606 LArchive = $(LLVMToolDir)/llvm-ar rcsf
613 #----------------------------------------------------------
614 # Get the list of source files and compute object file
616 #----------------------------------------------------------
619 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
620 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
622 Sources := $(SOURCES)
626 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
629 BaseNameSources := $(sort $(basename $(Sources)))
631 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
632 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
634 ###############################################################################
635 # DIRECTORIES: Handle recursive descent of directory structure
636 ###############################################################################
638 #---------------------------------------------------------
639 # Provide rules to make install dirs. This must be early
640 # in the file so they get built before dependencies
641 #---------------------------------------------------------
643 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
646 # To create other directories, as needed, and timestamp their creation
648 $(Verb) $(MKDIR) $* > /dev/null
651 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
652 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
654 #---------------------------------------------------------
655 # Handle the DIRS options for sequential construction
656 #---------------------------------------------------------
662 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
663 $(RecursiveTargets)::
664 $(Verb) for dir in $(DIRS); do \
665 if [ ! -f $$dir/Makefile ]; then \
667 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
669 ($(MAKE) -C $$dir $@ ) || exit 1; \
672 $(RecursiveTargets)::
673 $(Verb) for dir in $(DIRS); do \
674 ($(MAKE) -C $$dir $@ ) || exit 1; \
680 #---------------------------------------------------------
681 # Handle the EXPERIMENTAL_DIRS options ensuring success
682 # after each directory is built.
683 #---------------------------------------------------------
684 ifdef EXPERIMENTAL_DIRS
685 $(RecursiveTargets)::
686 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
687 if [ ! -f $$dir/Makefile ]; then \
689 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
691 ($(MAKE) -C $$dir $@ ) || exit 0; \
695 #-----------------------------------------------------------
696 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
697 #-----------------------------------------------------------
698 ifdef OPTIONAL_PARALLEL_DIRS
699 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
702 #-----------------------------------------------------------
703 # Handle the PARALLEL_DIRS options for parallel construction
704 #-----------------------------------------------------------
707 SubDirs += $(PARALLEL_DIRS)
709 # Unfortunately, this list must be maintained if new recursive targets are added
710 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
711 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
712 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
713 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
714 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
715 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
717 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
720 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
722 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
724 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
727 #---------------------------------------------------------
728 # Handle the OPTIONAL_DIRS options for directores that may
730 #---------------------------------------------------------
733 SubDirs += $(OPTIONAL_DIRS)
735 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
736 $(RecursiveTargets)::
737 $(Verb) for dir in $(OPTIONAL_DIRS); do \
738 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
739 if [ ! -f $$dir/Makefile ]; then \
741 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
743 ($(MAKE) -C$$dir $@ ) || exit 1; \
747 $(RecursiveTargets)::
748 $(Verb) for dir in $(OPTIONAL_DIRS); do \
749 ($(MAKE) -C$$dir $@ ) || exit 1; \
754 #---------------------------------------------------------
755 # Handle the CONFIG_FILES options
756 #---------------------------------------------------------
761 $(Echo) Install circumvented with NO_INSTALL
763 $(Echo) UnInstall circumvented with NO_INSTALL
765 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
766 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
767 $(Verb)for file in $(CONFIG_FILES); do \
768 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
769 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
770 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
771 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
773 $(ECHO) Error: cannot find config file $${file}. ; \
778 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
779 $(Verb)for file in $(CONFIG_FILES); do \
780 $(RM) -f $(PROJ_etcdir)/$${file} ; \
786 ###############################################################################
787 # Set up variables for building libararies
788 ###############################################################################
790 #---------------------------------------------------------
791 # Define various command line options pertaining to the
792 # libraries needed when linking. There are "Proj" libs
793 # (defined by the user's project) and "LLVM" libs (defined
794 # by the LLVM project).
795 #---------------------------------------------------------
798 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
799 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
800 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
801 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
805 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
806 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
807 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
808 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
811 ifndef IS_CLEANING_TARGET
812 ifdef LINK_COMPONENTS
814 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
815 # clean in tools, then do a make in tools (instead of at the top level).
817 @echo "*** llvm-config doesn't exist - rebuilding it."
818 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
820 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
822 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
823 LLVMLibsPaths += $(LLVM_CONFIG) \
824 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
828 ###############################################################################
829 # Library Build Rules: Four ways to build a library
830 ###############################################################################
832 #---------------------------------------------------------
833 # Bytecode Module Targets:
834 # If the user set MODULE_NAME then they want to build a
835 # bytecode module from the sources. We compile all the
836 # sources and link it together into a single bytecode
838 #---------------------------------------------------------
841 ifeq ($(strip $(LLVMGCC)),)
842 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
845 Module := $(LibDir)/$(MODULE_NAME).bc
846 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
849 ifdef EXPORTED_SYMBOL_FILE
850 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
853 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
854 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
855 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
857 all-local:: $(Module)
860 ifneq ($(strip $(Module)),)
861 -$(Verb) $(RM) -f $(Module)
864 ifdef BYTECODE_DESTINATION
865 ModuleDestDir := $(BYTECODE_DESTINATION)
867 ModuleDestDir := $(PROJ_libdir)
872 $(Echo) Install circumvented with NO_INSTALL
874 $(Echo) Uninstall circumvented with NO_INSTALL
876 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
878 install-module:: $(DestModule)
879 install-local:: $(DestModule)
881 $(DestModule): $(ModuleDestDir) $(Module)
882 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
883 $(Verb) $(DataInstall) $(Module) $(DestModule)
886 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
887 -$(Verb) $(RM) -f $(DestModule)
893 # if we're building a library ...
896 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
897 LIBRARYNAME := $(strip $(LIBRARYNAME))
898 ifdef LOADABLE_MODULE
899 LibName.A := $(LibDir)/$(LIBRARYNAME).a
900 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
902 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
903 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
905 LibName.O := $(LibDir)/$(LIBRARYNAME).o
906 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
908 #---------------------------------------------------------
909 # Shared Library Targets:
910 # If the user asked for a shared library to be built
911 # with the SHARED_LIBRARY variable, then we provide
912 # targets for building them.
913 #---------------------------------------------------------
916 all-local:: $(LibName.SO)
918 ifdef LINK_LIBS_IN_SHARED
919 ifdef LOADABLE_MODULE
920 SharedLibKindMessage := "Loadable Module"
922 SharedLibKindMessage := "Shared Library"
924 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
925 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
926 $(LIBRARYNAME)$(SHLIBEXT)
927 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
928 $(ProjLibsOptions) $(LLVMLibsOptions)
930 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
931 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
932 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
936 ifneq ($(strip $(LibName.SO)),)
937 -$(Verb) $(RM) -f $(LibName.SO)
942 $(Echo) Install circumvented with NO_INSTALL
944 $(Echo) Uninstall circumvented with NO_INSTALL
946 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
948 install-local:: $(DestSharedLib)
950 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
951 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
952 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
955 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
956 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
960 #---------------------------------------------------------
961 # Bytecode Library Targets:
962 # If the user asked for a bytecode library to be built
963 # with the BYTECODE_LIBRARY variable, then we provide
964 # targets for building them.
965 #---------------------------------------------------------
966 ifdef BYTECODE_LIBRARY
967 ifeq ($(strip $(LLVMGCC)),)
968 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
971 all-local:: $(LibName.BCA)
973 ifdef EXPORTED_SYMBOL_FILE
974 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
975 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
977 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
978 $(LLVMToolDir)/llvm-ar
979 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
981 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
983 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
985 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
986 $(LLVMToolDir)/llvm-ar
987 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
989 $(Verb) $(LArchive) $@ $(ObjectsBC)
994 ifneq ($(strip $(LibName.BCA)),)
995 -$(Verb) $(RM) -f $(LibName.BCA)
998 ifdef BYTECODE_DESTINATION
999 BytecodeDestDir := $(BYTECODE_DESTINATION)
1001 BytecodeDestDir := $(PROJ_libdir)
1004 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
1006 install-bytecode-local:: $(DestBytecodeLib)
1010 $(Echo) Install circumvented with NO_INSTALL
1012 $(Echo) Uninstall circumvented with NO_INSTALL
1014 install-local:: $(DestBytecodeLib)
1016 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1017 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1018 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1021 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1022 -$(Verb) $(RM) -f $(DestBytecodeLib)
1027 #---------------------------------------------------------
1028 # ReLinked Library Targets:
1029 # If the user explicitly requests a relinked library with
1030 # BUILD_RELINKED, provide it. Otherwise, if they specify
1031 # neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
1033 #---------------------------------------------------------
1034 ifndef BUILD_ARCHIVE
1035 ifndef DONT_BUILD_RELINKED
1040 ifdef BUILD_RELINKED
1042 all-local:: $(LibName.O)
1044 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
1045 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
1046 $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO)
1049 ifneq ($(strip $(LibName.O)),)
1050 -$(Verb) $(RM) -f $(LibName.O)
1055 $(Echo) Install circumvented with NO_INSTALL
1057 $(Echo) Uninstall circumvented with NO_INSTALL
1059 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
1061 install-local:: $(DestRelinkedLib)
1063 $(DestRelinkedLib): $(LibName.O) $(PROJ_libdir)
1064 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
1065 $(Verb) $(INSTALL) $(LibName.O) $(DestRelinkedLib)
1068 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
1069 -$(Verb) $(RM) -f $(DestRelinkedLib)
1073 #---------------------------------------------------------
1074 # Archive Library Targets:
1075 # If the user wanted a regular archive library built,
1076 # then we provide targets for building them.
1077 #---------------------------------------------------------
1080 all-local:: $(LibName.A)
1082 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1083 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1084 -$(Verb) $(RM) -f $@
1085 $(Verb) $(Archive) $@ $(ObjectsO)
1086 $(Verb) $(Ranlib) $@
1089 ifneq ($(strip $(LibName.A)),)
1090 -$(Verb) $(RM) -f $(LibName.A)
1095 $(Echo) Install circumvented with NO_INSTALL
1097 $(Echo) Uninstall circumvented with NO_INSTALL
1099 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1101 install-local:: $(DestArchiveLib)
1103 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1104 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1105 $(Verb) $(MKDIR) $(PROJ_libdir)
1106 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1109 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1110 -$(Verb) $(RM) -f $(DestArchiveLib)
1117 ###############################################################################
1118 # Tool Build Rules: Build executable tool based on TOOLNAME option
1119 ###############################################################################
1123 #---------------------------------------------------------
1124 # Set up variables for building a tool.
1125 #---------------------------------------------------------
1127 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1129 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1132 #---------------------------------------------------------
1134 #---------------------------------------------------------
1136 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1137 # not exporting all of the weak symbols from the binary. This reduces dyld
1138 # startup time by 4x on darwin in some cases.
1139 ifdef TOOL_NO_EXPORTS
1142 # Tiger tools don't support this.
1143 ifneq ($(DARWIN_MAJVERS),4)
1144 LD.Flags += -Wl,-exported_symbol -Wl,_main
1148 ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
1149 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1154 #---------------------------------------------------------
1155 # Provide targets for building the tools
1156 #---------------------------------------------------------
1157 all-local:: $(ToolBuildPath)
1160 ifneq ($(strip $(ToolBuildPath)),)
1161 -$(Verb) $(RM) -f $(ToolBuildPath)
1165 $(ToolBuildPath): $(ExmplDir)/.dir
1167 $(ToolBuildPath): $(ToolDir)/.dir
1170 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1171 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1172 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1173 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1174 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1179 $(Echo) Install circumvented with NO_INSTALL
1181 $(Echo) Uninstall circumvented with NO_INSTALL
1183 DestTool = $(PROJ_bindir)/$(TOOLNAME)
1185 install-local:: $(DestTool)
1187 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1188 $(Echo) Installing $(BuildMode) $(DestTool)
1189 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1192 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1193 -$(Verb) $(RM) -f $(DestTool)
1197 ###############################################################################
1198 # Object Build Rules: Build object files based on sources
1199 ###############################################################################
1201 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1203 DISABLE_AUTO_DEPENDENCIES=1
1206 # Provide rule sets for when dependency generation is enabled
1207 ifndef DISABLE_AUTO_DEPENDENCIES
1209 #---------------------------------------------------------
1210 # Create .o files in the ObjDir directory from the .cpp and .c files...
1211 #---------------------------------------------------------
1213 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1214 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1216 # If the build succeeded, move the dependency file over. If it failed, put an
1218 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1219 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1221 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1222 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1223 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1226 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1227 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1228 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1231 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1232 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1233 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1236 #---------------------------------------------------------
1237 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1238 #---------------------------------------------------------
1240 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1241 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1242 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1243 $< -o $@ -S -emit-llvm ; \
1244 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1245 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1246 $(call UPGRADE_MSG,$@)
1247 $(call UPGRADE_LL,$@)
1249 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1250 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1251 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1252 $< -o $@ -S -emit-llvm ; \
1253 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1254 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1255 $(call UPGRADE_MSG,$@)
1256 $(call UPGRADE_LL,$@)
1258 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1259 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1260 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1261 $< -o $@ -S -emit-llvm ; \
1262 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1263 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
1264 $(call UPGRADE_MSG,$@)
1265 $(call UPGRADE_LL,$@)
1267 # Provide alternate rule sets if dependencies are disabled
1270 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1271 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1272 $(Compile.CXX) $< -o $@
1274 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1275 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1276 $(Compile.CXX) $< -o $@
1278 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1279 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1280 $(Compile.C) $< -o $@
1282 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1283 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1284 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1285 $(call UPGRADE_MSG,$@)
1286 $(call UPGRADE_LL,$@)
1288 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1289 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1290 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1291 $(call UPGRADE_MSG,$@)
1292 $(call UPGRADE_LL,$@)
1294 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1295 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1296 $(BCCompile.C) $< -o $@ -S -emit-llvm
1297 $(call UPGRADE_MSG,@)
1298 $(call UPGRADE_LL,@)
1303 ## Rules for building preprocessed (.i/.ii) outputs.
1304 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1305 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1306 $(Verb) $(Preprocess.CXX) $< -o $@
1308 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1309 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1310 $(Verb) $(Preprocess.CXX) $< -o $@
1312 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1313 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1314 $(Verb) $(Preprocess.C) $< -o $@
1317 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1318 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1319 $(Compile.CXX) $< -o $@ -S
1321 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1322 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1323 $(Compile.CXX) $< -o $@ -S
1325 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1326 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1327 $(Compile.C) $< -o $@ -S
1330 # make the C and C++ compilers strip debug info out of bytecode libraries.
1332 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1333 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1334 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
1336 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1337 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1338 $(Verb) $(LLVMAS) $< -o - | \
1339 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
1343 #---------------------------------------------------------
1344 # Provide rule to build .bc files from .ll sources,
1345 # regardless of dependencies
1346 #---------------------------------------------------------
1347 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1348 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1349 $(Verb) $(LLVMAS) $< -f -o $@
1351 ###############################################################################
1352 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1353 ###############################################################################
1356 TABLEGEN_INC_FILES_COMMON = 1
1359 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1360 TABLEGEN_INC_FILES_COMMON = 1
1363 ifdef CLANG_BUILD_DIAGNOSTICS_INC
1364 TABLEGEN_INC_FILES_COMMON = 1
1367 ifdef TABLEGEN_INC_FILES_COMMON
1369 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1370 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1371 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1373 # INCFiles rule: All of the tblgen generated files are emitted to
1374 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1375 # us to only "touch" the real file if the contents of it change. IOW, if
1376 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1377 # dependencies of the .inc files are, unless the contents of the .inc file
1379 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1380 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1382 endif # TABLEGEN_INC_FILES_COMMON
1386 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1387 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1388 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1389 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1390 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1391 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1392 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1394 # All of these files depend on tblgen and the .td files.
1395 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1397 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1398 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1399 $(Echo) "Building $(<F) register names with tblgen"
1400 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1402 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1403 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1404 $(Echo) "Building $(<F) register information header with tblgen"
1405 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1407 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1408 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1409 $(Echo) "Building $(<F) register info implementation with tblgen"
1410 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1412 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1413 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1414 $(Echo) "Building $(<F) instruction names with tblgen"
1415 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1417 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1418 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1419 $(Echo) "Building $(<F) instruction information with tblgen"
1420 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1422 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1423 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1424 $(Echo) "Building $(<F) assembly writer with tblgen"
1425 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1427 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1428 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1429 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1430 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1432 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1433 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1434 $(Echo) "Building $(<F) code emitter with tblgen"
1435 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1437 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1438 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1439 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1440 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1442 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1443 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1444 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1445 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1447 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1448 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1449 $(Echo) "Building $(<F) subtarget information with tblgen"
1450 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1452 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1453 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1454 $(Echo) "Building $(<F) calling convention information with tblgen"
1455 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1457 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1458 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1459 $(Echo) "Building $(<F) calling convention information with tblgen"
1460 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1463 -$(Verb) $(RM) -f $(INCFiles)
1467 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1469 LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
1471 TDFiles := $(LLVMCPluginSrc) \
1472 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1474 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1475 $(TBLGEN) $(TD_COMMON)
1476 $(Echo) "Building LLVMC configuration library with tblgen"
1477 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1479 endif # LLVMC_BUILD_AUTOGENERATED_INC
1481 ifdef CLANG_BUILD_DIAGNOSTICS_INC
1483 $(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(TBLGEN)
1484 $(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
1485 $(Verb) $(MKDIR) $(@D)
1486 $(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
1490 ###############################################################################
1491 # OTHER RULES: Other rules needed
1492 ###############################################################################
1494 # To create postscript files from dot files...
1495 ifneq ($(DOT),false)
1497 $(DOT) -Tps < $< > $@
1500 $(Echo) "Cannot build $@: The program dot is not installed"
1503 # This rules ensures that header files that are removed still have a rule for
1504 # which they can be "generated." This allows make to ignore them and
1505 # reproduce the dependency lists.
1509 # Define clean-local to clean the current directory. Note that this uses a
1510 # very conservative approach ensuring that empty variables do not cause
1511 # errors or disastrous removal.
1513 ifneq ($(strip $(ObjRootDir)),)
1514 -$(Verb) $(RM) -rf $(ObjRootDir)
1516 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1517 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1518 -$(Verb) $(RM) -f *$(SHLIBEXT)
1522 -$(Verb) $(RM) -rf Debug Release Profile
1525 ###############################################################################
1526 # DEPENDENCIES: Include the dependency files if we should
1527 ###############################################################################
1528 ifndef DISABLE_AUTO_DEPENDENCIES
1530 # If its not one of the cleaning targets
1531 ifndef IS_CLEANING_TARGET
1533 # Get the list of dependency files
1534 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1535 DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1537 -include $(DependFiles) ""
1543 ###############################################################################
1544 # CHECK: Running the test suite
1545 ###############################################################################
1548 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1549 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1550 $(EchoCmd) Running test suite ; \
1551 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1552 TESTSUITE=$(TESTSUITE) ; \
1554 $(EchoCmd) No Makefile in test directory ; \
1557 $(EchoCmd) No test directory ; \
1560 ###############################################################################
1561 # UNITTESTS: Running the unittests test suite
1562 ###############################################################################
1565 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1566 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1567 $(EchoCmd) Running unittests test suite ; \
1568 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
1570 $(EchoCmd) No Makefile in unittests directory ; \
1573 $(EchoCmd) No unittests directory ; \
1576 ###############################################################################
1577 # DISTRIBUTION: Handle construction of a distribution tarball
1578 ###############################################################################
1580 #------------------------------------------------------------------------
1581 # Define distribution related variables
1582 #------------------------------------------------------------------------
1583 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1584 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1585 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1586 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1587 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1588 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1589 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1590 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1591 Makefile.config.in configure autoconf
1592 DistOther := $(notdir $(wildcard \
1593 $(PROJ_SRC_DIR)/*.h \
1594 $(PROJ_SRC_DIR)/*.td \
1595 $(PROJ_SRC_DIR)/*.def \
1596 $(PROJ_SRC_DIR)/*.ll \
1597 $(PROJ_SRC_DIR)/*.in))
1598 DistSubDirs := $(SubDirs)
1599 DistSources = $(Sources) $(EXTRA_DIST)
1600 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1602 #------------------------------------------------------------------------
1603 # We MUST build distribution with OBJ_DIR != SRC_DIR
1604 #------------------------------------------------------------------------
1605 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1606 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1607 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1611 #------------------------------------------------------------------------
1612 # Prevent attempt to run dist targets from anywhere but the top level
1613 #------------------------------------------------------------------------
1615 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1616 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1619 #------------------------------------------------------------------------
1620 # Provide the top level targets
1621 #------------------------------------------------------------------------
1623 dist-gzip:: $(DistTarGZip)
1625 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1626 $(Echo) Packing gzipped distribution tar file.
1627 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1628 $(GZIP) -c > "$(DistTarGZip)"
1630 dist-bzip2:: $(DistTarBZ2)
1632 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1633 $(Echo) Packing bzipped distribution tar file.
1634 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1635 $(BZIP2) -c >$(DistTarBZ2)
1637 dist-zip:: $(DistZip)
1639 $(DistZip) : $(TopDistDir)/.makedistdir
1640 $(Echo) Packing zipped distribution file.
1641 $(Verb) rm -f $(DistZip)
1642 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1644 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1645 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1647 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1649 dist-check:: $(DistTarGZip)
1650 $(Echo) Checking distribution tar file.
1651 $(Verb) if test -d $(DistCheckDir) ; then \
1652 $(RM) -rf $(DistCheckDir) ; \
1654 $(Verb) $(MKDIR) $(DistCheckDir)
1655 $(Verb) cd $(DistCheckDir) && \
1656 $(MKDIR) $(DistCheckDir)/build && \
1657 $(MKDIR) $(DistCheckDir)/install && \
1658 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1660 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1661 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1664 $(MAKE) unittests && \
1665 $(MAKE) install && \
1666 $(MAKE) uninstall && \
1667 $(MAKE) dist-clean && \
1668 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1671 $(Echo) Cleaning distribution files
1672 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1677 #------------------------------------------------------------------------
1678 # Provide the recursive distdir target for building the distribution directory
1679 #------------------------------------------------------------------------
1680 distdir: $(DistDir)/.makedistdir
1681 $(DistDir)/.makedistdir: $(DistSources)
1682 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1683 if test -d "$(DistDir)" ; then \
1684 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1687 $(EchoCmd) Removing old $(DistDir) ; \
1688 $(RM) -rf $(DistDir); \
1689 $(EchoCmd) Making 'all' to verify build ; \
1690 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1692 $(Echo) Building Distribution Directory $(DistDir)
1693 $(Verb) $(MKDIR) $(DistDir)
1694 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1695 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1696 for file in $(DistFiles) ; do \
1698 $(PROJ_SRC_DIR)/*) \
1699 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1701 $(PROJ_SRC_ROOT)/*) \
1702 file=`echo "$$file" | \
1703 sed "s#^$$srcrootstrip/##"` \
1706 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1707 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1708 from_dir="$(PROJ_SRC_DIR)" ; \
1709 elif test -f "$$file" || test -d "$$file" ; then \
1712 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1713 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1714 to_dir="$(DistDir)/$$dir"; \
1715 $(MKDIR) "$$to_dir" ; \
1717 to_dir="$(DistDir)"; \
1719 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1720 if test -n "$$mid_dir" ; then \
1721 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1723 if test -d "$$from_dir/$$file"; then \
1724 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1725 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1726 cd $(PROJ_SRC_DIR) ; \
1727 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1728 ( cd $$to_dir ; $(TAR) xf - ) ; \
1729 cd $(PROJ_OBJ_DIR) ; \
1732 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1733 ( cd $$to_dir ; $(TAR) xf - ) ; \
1734 cd $(PROJ_OBJ_DIR) ; \
1736 elif test -f "$$from_dir/$$file" ; then \
1737 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1738 elif test -L "$$from_dir/$$file" ; then \
1739 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1740 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1741 $(EchoCmd) "===== WARNING: Distribution Source " \
1742 "$$from_dir/$$file Not Found!" ; \
1743 elif test "$(Verb)" != '@' ; then \
1744 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1747 $(Verb) for subdir in $(DistSubDirs) ; do \
1748 if test "$$subdir" \!= "." ; then \
1749 new_distdir="$(DistDir)/$$subdir" ; \
1750 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1751 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1752 DistDir="$$new_distdir" distdir ) || exit 1; \
1755 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1756 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1757 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1758 -name .svn \) -print` ;\
1759 $(MAKE) dist-hook ; \
1760 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1761 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1762 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1763 -o ! -type d ! -perm -444 -exec \
1764 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1765 || chmod -R a+r $(DistDir) ; \
1768 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1774 ###############################################################################
1775 # TOP LEVEL - targets only to apply at the top level directory
1776 ###############################################################################
1780 #------------------------------------------------------------------------
1781 # Install support for the project's include files:
1782 #------------------------------------------------------------------------
1785 $(Echo) Install circumvented with NO_INSTALL
1787 $(Echo) Uninstall circumvented with NO_INSTALL
1790 $(Echo) Installing include files
1791 $(Verb) $(MKDIR) $(PROJ_includedir)
1792 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1793 cd $(PROJ_SRC_ROOT)/include && \
1794 for hdr in `find . -type f '!' '(' -name '*~' \
1795 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1796 grep -v .svn` ; do \
1797 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1798 if test \! -d "$$instdir" ; then \
1799 $(EchoCmd) Making install directory $$instdir ; \
1800 $(MKDIR) $$instdir ;\
1802 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1805 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1806 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1807 cd $(PROJ_OBJ_ROOT)/include && \
1808 for hdr in `find . -type f -print | grep -v CVS` ; do \
1809 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1815 $(Echo) Uninstalling include files
1816 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1817 cd $(PROJ_SRC_ROOT)/include && \
1818 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1819 '!' '(' -name '*~' -o -name '.#*' \
1820 -o -name '*.in' ')' -print ')' | \
1821 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1822 cd $(PROJ_SRC_ROOT)/include && \
1823 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1824 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1830 @echo searching for overlength lines in files: $(Sources)
1833 egrep -n '.{81}' $(Sources) /dev/null
1836 @echo searching for tabs in files: $(Sources)
1839 egrep -n ' ' $(Sources) /dev/null
1842 @ls -l $(LibDir) | awk '\
1843 BEGIN { sum = 0; } \
1845 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1846 @ls -l $(ToolDir) | awk '\
1847 BEGIN { sum = 0; } \
1849 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1850 #------------------------------------------------------------------------
1851 # Print out the directories used for building
1852 #------------------------------------------------------------------------
1854 $(Echo) "BuildMode : " '$(BuildMode)'
1855 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1856 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1857 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1858 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1859 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1860 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1861 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1862 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1863 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1864 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1865 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1866 $(Echo) "UserTargets : " '$(UserTargets)'
1867 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1868 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1869 $(Echo) "ObjDir : " '$(ObjDir)'
1870 $(Echo) "LibDir : " '$(LibDir)'
1871 $(Echo) "ToolDir : " '$(ToolDir)'
1872 $(Echo) "ExmplDir : " '$(ExmplDir)'
1873 $(Echo) "Sources : " '$(Sources)'
1874 $(Echo) "TDFiles : " '$(TDFiles)'
1875 $(Echo) "INCFiles : " '$(INCFiles)'
1876 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1877 $(Echo) "PreConditions: " '$(PreConditions)'
1878 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1879 $(Echo) "Compile.C : " '$(Compile.C)'
1880 $(Echo) "Archive : " '$(Archive)'
1881 $(Echo) "YaccFiles : " '$(YaccFiles)'
1882 $(Echo) "LexFiles : " '$(LexFiles)'
1883 $(Echo) "Module : " '$(Module)'
1884 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1885 $(Echo) "SubDirs : " '$(SubDirs)'
1886 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1887 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1892 # General debugging rule, use 'make dbg-print-XXX' to print the
1893 # definition, value and origin of XXX.
1895 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))