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 -bundle \
439 -mmacosx-version-min=$(DARWIN_VERSION)
440 CompileCommonOpts += -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 CompileCommonOpts += -m64
542 CompileCommonOpts += -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 $(CompileCommonOpts) -c
564 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
565 $(CompileCommonOpts) -c
566 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) \
567 $(CXX.Flags.NoRelink) -E
568 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
569 $(CompileCommonOpts) $(LD.Flags) $(Strip)
570 Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
573 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
574 $(CompileCommonOpts) -c
575 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
576 $(CompileCommonOpts) -c
577 Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) \
578 $(CXX.Flags.NoRelink) -E
579 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
580 $(CompileCommonOpts) $(LD.Flags) $(Strip)
581 Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
585 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts)
586 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -E
588 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
591 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
592 ScriptInstall = $(INSTALL) -m 0755
593 DataInstall = $(INSTALL) -m 0644
595 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
596 # paths. In this case, the SYSPATH function (defined in
597 # Makefile.config) transforms Unix paths into Windows paths.
598 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
599 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
600 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
601 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
603 Archive = $(AR) $(AR.Flags)
604 LArchive = $(LLVMToolDir)/llvm-ar rcsf
611 #----------------------------------------------------------
612 # Get the list of source files and compute object file
614 #----------------------------------------------------------
617 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
618 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
620 Sources := $(SOURCES)
624 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
627 BaseNameSources := $(sort $(basename $(Sources)))
629 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
630 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
632 ###############################################################################
633 # DIRECTORIES: Handle recursive descent of directory structure
634 ###############################################################################
636 #---------------------------------------------------------
637 # Provide rules to make install dirs. This must be early
638 # in the file so they get built before dependencies
639 #---------------------------------------------------------
641 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
644 # To create other directories, as needed, and timestamp their creation
646 $(Verb) $(MKDIR) $* > /dev/null
649 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
650 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
652 #---------------------------------------------------------
653 # Handle the DIRS options for sequential construction
654 #---------------------------------------------------------
660 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
661 $(RecursiveTargets)::
662 $(Verb) for dir in $(DIRS); do \
663 if [ ! -f $$dir/Makefile ]; then \
665 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
667 ($(MAKE) -C $$dir $@ ) || exit 1; \
670 $(RecursiveTargets)::
671 $(Verb) for dir in $(DIRS); do \
672 ($(MAKE) -C $$dir $@ ) || exit 1; \
678 #---------------------------------------------------------
679 # Handle the EXPERIMENTAL_DIRS options ensuring success
680 # after each directory is built.
681 #---------------------------------------------------------
682 ifdef EXPERIMENTAL_DIRS
683 $(RecursiveTargets)::
684 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
685 if [ ! -f $$dir/Makefile ]; then \
687 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
689 ($(MAKE) -C $$dir $@ ) || exit 0; \
693 #-----------------------------------------------------------
694 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
695 #-----------------------------------------------------------
696 ifdef OPTIONAL_PARALLEL_DIRS
697 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
700 #-----------------------------------------------------------
701 # Handle the PARALLEL_DIRS options for parallel construction
702 #-----------------------------------------------------------
705 SubDirs += $(PARALLEL_DIRS)
707 # Unfortunately, this list must be maintained if new recursive targets are added
708 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
709 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
710 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
711 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
712 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
713 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
715 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
718 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
720 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
722 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
725 #---------------------------------------------------------
726 # Handle the OPTIONAL_DIRS options for directores that may
728 #---------------------------------------------------------
731 SubDirs += $(OPTIONAL_DIRS)
733 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
734 $(RecursiveTargets)::
735 $(Verb) for dir in $(OPTIONAL_DIRS); do \
736 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
737 if [ ! -f $$dir/Makefile ]; then \
739 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
741 ($(MAKE) -C$$dir $@ ) || exit 1; \
745 $(RecursiveTargets)::
746 $(Verb) for dir in $(OPTIONAL_DIRS); do \
747 ($(MAKE) -C$$dir $@ ) || exit 1; \
752 #---------------------------------------------------------
753 # Handle the CONFIG_FILES options
754 #---------------------------------------------------------
759 $(Echo) Install circumvented with NO_INSTALL
761 $(Echo) UnInstall circumvented with NO_INSTALL
763 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
764 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
765 $(Verb)for file in $(CONFIG_FILES); do \
766 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
767 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
768 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
769 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
771 $(ECHO) Error: cannot find config file $${file}. ; \
776 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
777 $(Verb)for file in $(CONFIG_FILES); do \
778 $(RM) -f $(PROJ_etcdir)/$${file} ; \
784 ###############################################################################
785 # Set up variables for building libararies
786 ###############################################################################
788 #---------------------------------------------------------
789 # Define various command line options pertaining to the
790 # libraries needed when linking. There are "Proj" libs
791 # (defined by the user's project) and "LLVM" libs (defined
792 # by the LLVM project).
793 #---------------------------------------------------------
796 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
797 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
798 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
799 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
803 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
804 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
805 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
806 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
809 ifndef IS_CLEANING_TARGET
810 ifdef LINK_COMPONENTS
812 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
813 # clean in tools, then do a make in tools (instead of at the top level).
815 @echo "*** llvm-config doesn't exist - rebuilding it."
816 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
818 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
820 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
821 LLVMLibsPaths += $(LLVM_CONFIG) \
822 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
826 ###############################################################################
827 # Library Build Rules: Four ways to build a library
828 ###############################################################################
830 #---------------------------------------------------------
831 # Bytecode Module Targets:
832 # If the user set MODULE_NAME then they want to build a
833 # bytecode module from the sources. We compile all the
834 # sources and link it together into a single bytecode
836 #---------------------------------------------------------
839 ifeq ($(strip $(LLVMGCC)),)
840 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
843 Module := $(LibDir)/$(MODULE_NAME).bc
844 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
847 ifdef EXPORTED_SYMBOL_FILE
848 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
851 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
852 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
853 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
855 all-local:: $(Module)
858 ifneq ($(strip $(Module)),)
859 -$(Verb) $(RM) -f $(Module)
862 ifdef BYTECODE_DESTINATION
863 ModuleDestDir := $(BYTECODE_DESTINATION)
865 ModuleDestDir := $(PROJ_libdir)
870 $(Echo) Install circumvented with NO_INSTALL
872 $(Echo) Uninstall circumvented with NO_INSTALL
874 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
876 install-module:: $(DestModule)
877 install-local:: $(DestModule)
879 $(DestModule): $(ModuleDestDir) $(Module)
880 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
881 $(Verb) $(DataInstall) $(Module) $(DestModule)
884 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
885 -$(Verb) $(RM) -f $(DestModule)
891 # if we're building a library ...
894 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
895 LIBRARYNAME := $(strip $(LIBRARYNAME))
896 ifdef LOADABLE_MODULE
897 LibName.A := $(LibDir)/$(LIBRARYNAME).a
898 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
900 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
901 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
903 LibName.O := $(LibDir)/$(LIBRARYNAME).o
904 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
906 #---------------------------------------------------------
907 # Shared Library Targets:
908 # If the user asked for a shared library to be built
909 # with the SHARED_LIBRARY variable, then we provide
910 # targets for building them.
911 #---------------------------------------------------------
914 all-local:: $(LibName.SO)
916 ifdef LINK_LIBS_IN_SHARED
917 ifdef LOADABLE_MODULE
918 SharedLibKindMessage := "Loadable Module"
920 SharedLibKindMessage := "Shared Library"
922 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
923 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
924 $(LIBRARYNAME)$(SHLIBEXT)
925 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
926 $(ProjLibsOptions) $(LLVMLibsOptions)
928 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
929 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
930 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
934 ifneq ($(strip $(LibName.SO)),)
935 -$(Verb) $(RM) -f $(LibName.SO)
940 $(Echo) Install circumvented with NO_INSTALL
942 $(Echo) Uninstall circumvented with NO_INSTALL
944 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
946 install-local:: $(DestSharedLib)
948 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
949 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
950 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
953 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
954 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
958 #---------------------------------------------------------
959 # Bytecode Library Targets:
960 # If the user asked for a bytecode library to be built
961 # with the BYTECODE_LIBRARY variable, then we provide
962 # targets for building them.
963 #---------------------------------------------------------
964 ifdef BYTECODE_LIBRARY
965 ifeq ($(strip $(LLVMGCC)),)
966 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
969 all-local:: $(LibName.BCA)
971 ifdef EXPORTED_SYMBOL_FILE
972 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
973 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
975 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
976 $(LLVMToolDir)/llvm-ar
977 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
979 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
981 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
983 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
984 $(LLVMToolDir)/llvm-ar
985 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
987 $(Verb) $(LArchive) $@ $(ObjectsBC)
992 ifneq ($(strip $(LibName.BCA)),)
993 -$(Verb) $(RM) -f $(LibName.BCA)
996 ifdef BYTECODE_DESTINATION
997 BytecodeDestDir := $(BYTECODE_DESTINATION)
999 BytecodeDestDir := $(PROJ_libdir)
1002 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
1004 install-bytecode-local:: $(DestBytecodeLib)
1008 $(Echo) Install circumvented with NO_INSTALL
1010 $(Echo) Uninstall circumvented with NO_INSTALL
1012 install-local:: $(DestBytecodeLib)
1014 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1015 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1016 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1019 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1020 -$(Verb) $(RM) -f $(DestBytecodeLib)
1025 #---------------------------------------------------------
1026 # ReLinked Library Targets:
1027 # If the user explicitly requests a relinked library with
1028 # BUILD_RELINKED, provide it. Otherwise, if they specify
1029 # neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
1031 #---------------------------------------------------------
1032 ifndef BUILD_ARCHIVE
1033 ifndef DONT_BUILD_RELINKED
1038 ifdef BUILD_RELINKED
1040 all-local:: $(LibName.O)
1042 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
1043 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
1044 $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO)
1047 ifneq ($(strip $(LibName.O)),)
1048 -$(Verb) $(RM) -f $(LibName.O)
1053 $(Echo) Install circumvented with NO_INSTALL
1055 $(Echo) Uninstall circumvented with NO_INSTALL
1057 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
1059 install-local:: $(DestRelinkedLib)
1061 $(DestRelinkedLib): $(LibName.O) $(PROJ_libdir)
1062 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
1063 $(Verb) $(INSTALL) $(LibName.O) $(DestRelinkedLib)
1066 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
1067 -$(Verb) $(RM) -f $(DestRelinkedLib)
1071 #---------------------------------------------------------
1072 # Archive Library Targets:
1073 # If the user wanted a regular archive library built,
1074 # then we provide targets for building them.
1075 #---------------------------------------------------------
1078 all-local:: $(LibName.A)
1080 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1081 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1082 -$(Verb) $(RM) -f $@
1083 $(Verb) $(Archive) $@ $(ObjectsO)
1084 $(Verb) $(Ranlib) $@
1087 ifneq ($(strip $(LibName.A)),)
1088 -$(Verb) $(RM) -f $(LibName.A)
1093 $(Echo) Install circumvented with NO_INSTALL
1095 $(Echo) Uninstall circumvented with NO_INSTALL
1097 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1099 install-local:: $(DestArchiveLib)
1101 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1102 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1103 $(Verb) $(MKDIR) $(PROJ_libdir)
1104 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1107 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1108 -$(Verb) $(RM) -f $(DestArchiveLib)
1115 ###############################################################################
1116 # Tool Build Rules: Build executable tool based on TOOLNAME option
1117 ###############################################################################
1121 #---------------------------------------------------------
1122 # Set up variables for building a tool.
1123 #---------------------------------------------------------
1125 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1127 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1130 #---------------------------------------------------------
1132 #---------------------------------------------------------
1134 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1135 # not exporting all of the weak symbols from the binary. This reduces dyld
1136 # startup time by 4x on darwin in some cases.
1137 ifdef TOOL_NO_EXPORTS
1140 # Tiger tools don't support this.
1141 ifneq ($(DARWIN_MAJVERS),4)
1142 LD.Flags += -Wl,-exported_symbol -Wl,_main
1146 ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
1147 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1152 #---------------------------------------------------------
1153 # Provide targets for building the tools
1154 #---------------------------------------------------------
1155 all-local:: $(ToolBuildPath)
1158 ifneq ($(strip $(ToolBuildPath)),)
1159 -$(Verb) $(RM) -f $(ToolBuildPath)
1163 $(ToolBuildPath): $(ExmplDir)/.dir
1165 $(ToolBuildPath): $(ToolDir)/.dir
1168 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1169 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1170 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1171 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1172 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1177 $(Echo) Install circumvented with NO_INSTALL
1179 $(Echo) Uninstall circumvented with NO_INSTALL
1181 DestTool = $(PROJ_bindir)/$(TOOLNAME)
1183 install-local:: $(DestTool)
1185 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1186 $(Echo) Installing $(BuildMode) $(DestTool)
1187 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1190 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1191 -$(Verb) $(RM) -f $(DestTool)
1195 ###############################################################################
1196 # Object Build Rules: Build object files based on sources
1197 ###############################################################################
1199 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1201 DISABLE_AUTO_DEPENDENCIES=1
1204 # Provide rule sets for when dependency generation is enabled
1205 ifndef DISABLE_AUTO_DEPENDENCIES
1207 #---------------------------------------------------------
1208 # Create .o files in the ObjDir directory from the .cpp and .c files...
1209 #---------------------------------------------------------
1211 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1212 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1214 # If the build succeeded, move the dependency file over. If it failed, put an
1216 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1217 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1219 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1220 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1221 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1224 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1225 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1226 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1229 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1230 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1231 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1234 #---------------------------------------------------------
1235 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1236 #---------------------------------------------------------
1238 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1239 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1240 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1241 $< -o $@ -S -emit-llvm ; \
1242 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1243 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1244 $(call UPGRADE_MSG,$@)
1245 $(call UPGRADE_LL,$@)
1247 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1248 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1249 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1250 $< -o $@ -S -emit-llvm ; \
1251 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1252 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1253 $(call UPGRADE_MSG,$@)
1254 $(call UPGRADE_LL,$@)
1256 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1257 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1258 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1259 $< -o $@ -S -emit-llvm ; \
1260 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1261 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
1262 $(call UPGRADE_MSG,$@)
1263 $(call UPGRADE_LL,$@)
1265 # Provide alternate rule sets if dependencies are disabled
1268 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1269 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1270 $(Compile.CXX) $< -o $@
1272 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1273 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1274 $(Compile.CXX) $< -o $@
1276 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1277 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1278 $(Compile.C) $< -o $@
1280 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1281 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1282 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1283 $(call UPGRADE_MSG,$@)
1284 $(call UPGRADE_LL,$@)
1286 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1287 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1288 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1289 $(call UPGRADE_MSG,$@)
1290 $(call UPGRADE_LL,$@)
1292 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1293 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1294 $(BCCompile.C) $< -o $@ -S -emit-llvm
1295 $(call UPGRADE_MSG,@)
1296 $(call UPGRADE_LL,@)
1301 ## Rules for building preprocessed (.i/.ii) outputs.
1302 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1303 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1304 $(Verb) $(Preprocess.CXX) $< -o $@
1306 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1307 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1308 $(Verb) $(Preprocess.CXX) $< -o $@
1310 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1311 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1312 $(Verb) $(Preprocess.C) $< -o $@
1315 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1316 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1317 $(Compile.CXX) $< -o $@ -S
1319 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1320 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1321 $(Compile.CXX) $< -o $@ -S
1323 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1324 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1325 $(Compile.C) $< -o $@ -S
1328 # make the C and C++ compilers strip debug info out of bytecode libraries.
1330 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1331 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1332 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
1334 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1335 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1336 $(Verb) $(LLVMAS) $< -o - | \
1337 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
1341 #---------------------------------------------------------
1342 # Provide rule to build .bc files from .ll sources,
1343 # regardless of dependencies
1344 #---------------------------------------------------------
1345 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1346 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1347 $(Verb) $(LLVMAS) $< -f -o $@
1349 ###############################################################################
1350 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1351 ###############################################################################
1354 TABLEGEN_INC_FILES_COMMON = 1
1357 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1358 TABLEGEN_INC_FILES_COMMON = 1
1361 ifdef CLANG_BUILD_DIAGNOSTICS_INC
1362 TABLEGEN_INC_FILES_COMMON = 1
1365 ifdef TABLEGEN_INC_FILES_COMMON
1367 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1368 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1369 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1371 # INCFiles rule: All of the tblgen generated files are emitted to
1372 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1373 # us to only "touch" the real file if the contents of it change. IOW, if
1374 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1375 # dependencies of the .inc files are, unless the contents of the .inc file
1377 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1378 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1380 endif # TABLEGEN_INC_FILES_COMMON
1384 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1385 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1386 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1387 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1388 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1389 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1390 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1392 # All of these files depend on tblgen and the .td files.
1393 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1395 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1396 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1397 $(Echo) "Building $(<F) register names with tblgen"
1398 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1400 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1401 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1402 $(Echo) "Building $(<F) register information header with tblgen"
1403 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1405 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1406 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1407 $(Echo) "Building $(<F) register info implementation with tblgen"
1408 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1410 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1411 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1412 $(Echo) "Building $(<F) instruction names with tblgen"
1413 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1415 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1416 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1417 $(Echo) "Building $(<F) instruction information with tblgen"
1418 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1420 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1421 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1422 $(Echo) "Building $(<F) assembly writer with tblgen"
1423 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1425 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1426 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1427 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1428 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1430 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1431 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1432 $(Echo) "Building $(<F) code emitter with tblgen"
1433 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1435 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1436 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1437 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1438 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1440 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1441 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1442 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1443 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1445 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1446 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1447 $(Echo) "Building $(<F) subtarget information with tblgen"
1448 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1450 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1451 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1452 $(Echo) "Building $(<F) calling convention information with tblgen"
1453 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1455 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1456 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1457 $(Echo) "Building $(<F) calling convention information with tblgen"
1458 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1461 -$(Verb) $(RM) -f $(INCFiles)
1465 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1467 LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
1469 TDFiles := $(LLVMCPluginSrc) \
1470 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1472 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1473 $(TBLGEN) $(TD_COMMON)
1474 $(Echo) "Building LLVMC configuration library with tblgen"
1475 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1477 endif # LLVMC_BUILD_AUTOGENERATED_INC
1479 ifdef CLANG_BUILD_DIAGNOSTICS_INC
1481 $(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(TBLGEN)
1482 $(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
1483 $(Verb) $(MKDIR) $(@D)
1484 $(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
1488 ###############################################################################
1489 # OTHER RULES: Other rules needed
1490 ###############################################################################
1492 # To create postscript files from dot files...
1493 ifneq ($(DOT),false)
1495 $(DOT) -Tps < $< > $@
1498 $(Echo) "Cannot build $@: The program dot is not installed"
1501 # This rules ensures that header files that are removed still have a rule for
1502 # which they can be "generated." This allows make to ignore them and
1503 # reproduce the dependency lists.
1507 # Define clean-local to clean the current directory. Note that this uses a
1508 # very conservative approach ensuring that empty variables do not cause
1509 # errors or disastrous removal.
1511 ifneq ($(strip $(ObjRootDir)),)
1512 -$(Verb) $(RM) -rf $(ObjRootDir)
1514 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1515 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1516 -$(Verb) $(RM) -f *$(SHLIBEXT)
1520 -$(Verb) $(RM) -rf Debug Release Profile
1523 ###############################################################################
1524 # DEPENDENCIES: Include the dependency files if we should
1525 ###############################################################################
1526 ifndef DISABLE_AUTO_DEPENDENCIES
1528 # If its not one of the cleaning targets
1529 ifndef IS_CLEANING_TARGET
1531 # Get the list of dependency files
1532 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1533 DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1535 -include $(DependFiles) ""
1541 ###############################################################################
1542 # CHECK: Running the test suite
1543 ###############################################################################
1546 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1547 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1548 $(EchoCmd) Running test suite ; \
1549 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1550 TESTSUITE=$(TESTSUITE) ; \
1552 $(EchoCmd) No Makefile in test directory ; \
1555 $(EchoCmd) No test directory ; \
1558 ###############################################################################
1559 # UNITTESTS: Running the unittests test suite
1560 ###############################################################################
1563 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1564 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1565 $(EchoCmd) Running unittests test suite ; \
1566 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
1568 $(EchoCmd) No Makefile in unittests directory ; \
1571 $(EchoCmd) No unittests directory ; \
1574 ###############################################################################
1575 # DISTRIBUTION: Handle construction of a distribution tarball
1576 ###############################################################################
1578 #------------------------------------------------------------------------
1579 # Define distribution related variables
1580 #------------------------------------------------------------------------
1581 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1582 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1583 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1584 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1585 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1586 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1587 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1588 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1589 Makefile.config.in configure autoconf
1590 DistOther := $(notdir $(wildcard \
1591 $(PROJ_SRC_DIR)/*.h \
1592 $(PROJ_SRC_DIR)/*.td \
1593 $(PROJ_SRC_DIR)/*.def \
1594 $(PROJ_SRC_DIR)/*.ll \
1595 $(PROJ_SRC_DIR)/*.in))
1596 DistSubDirs := $(SubDirs)
1597 DistSources = $(Sources) $(EXTRA_DIST)
1598 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1600 #------------------------------------------------------------------------
1601 # We MUST build distribution with OBJ_DIR != SRC_DIR
1602 #------------------------------------------------------------------------
1603 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1604 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1605 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1609 #------------------------------------------------------------------------
1610 # Prevent attempt to run dist targets from anywhere but the top level
1611 #------------------------------------------------------------------------
1613 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1614 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1617 #------------------------------------------------------------------------
1618 # Provide the top level targets
1619 #------------------------------------------------------------------------
1621 dist-gzip:: $(DistTarGZip)
1623 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1624 $(Echo) Packing gzipped distribution tar file.
1625 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1626 $(GZIP) -c > "$(DistTarGZip)"
1628 dist-bzip2:: $(DistTarBZ2)
1630 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1631 $(Echo) Packing bzipped distribution tar file.
1632 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1633 $(BZIP2) -c >$(DistTarBZ2)
1635 dist-zip:: $(DistZip)
1637 $(DistZip) : $(TopDistDir)/.makedistdir
1638 $(Echo) Packing zipped distribution file.
1639 $(Verb) rm -f $(DistZip)
1640 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1642 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1643 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1645 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1647 dist-check:: $(DistTarGZip)
1648 $(Echo) Checking distribution tar file.
1649 $(Verb) if test -d $(DistCheckDir) ; then \
1650 $(RM) -rf $(DistCheckDir) ; \
1652 $(Verb) $(MKDIR) $(DistCheckDir)
1653 $(Verb) cd $(DistCheckDir) && \
1654 $(MKDIR) $(DistCheckDir)/build && \
1655 $(MKDIR) $(DistCheckDir)/install && \
1656 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1658 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1659 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1662 $(MAKE) unittests && \
1663 $(MAKE) install && \
1664 $(MAKE) uninstall && \
1665 $(MAKE) dist-clean && \
1666 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1669 $(Echo) Cleaning distribution files
1670 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1675 #------------------------------------------------------------------------
1676 # Provide the recursive distdir target for building the distribution directory
1677 #------------------------------------------------------------------------
1678 distdir: $(DistDir)/.makedistdir
1679 $(DistDir)/.makedistdir: $(DistSources)
1680 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1681 if test -d "$(DistDir)" ; then \
1682 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1685 $(EchoCmd) Removing old $(DistDir) ; \
1686 $(RM) -rf $(DistDir); \
1687 $(EchoCmd) Making 'all' to verify build ; \
1688 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1690 $(Echo) Building Distribution Directory $(DistDir)
1691 $(Verb) $(MKDIR) $(DistDir)
1692 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1693 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1694 for file in $(DistFiles) ; do \
1696 $(PROJ_SRC_DIR)/*) \
1697 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1699 $(PROJ_SRC_ROOT)/*) \
1700 file=`echo "$$file" | \
1701 sed "s#^$$srcrootstrip/##"` \
1704 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1705 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1706 from_dir="$(PROJ_SRC_DIR)" ; \
1707 elif test -f "$$file" || test -d "$$file" ; then \
1710 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1711 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1712 to_dir="$(DistDir)/$$dir"; \
1713 $(MKDIR) "$$to_dir" ; \
1715 to_dir="$(DistDir)"; \
1717 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1718 if test -n "$$mid_dir" ; then \
1719 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1721 if test -d "$$from_dir/$$file"; then \
1722 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1723 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1724 cd $(PROJ_SRC_DIR) ; \
1725 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1726 ( cd $$to_dir ; $(TAR) xf - ) ; \
1727 cd $(PROJ_OBJ_DIR) ; \
1730 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1731 ( cd $$to_dir ; $(TAR) xf - ) ; \
1732 cd $(PROJ_OBJ_DIR) ; \
1734 elif test -f "$$from_dir/$$file" ; then \
1735 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1736 elif test -L "$$from_dir/$$file" ; then \
1737 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1738 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1739 $(EchoCmd) "===== WARNING: Distribution Source " \
1740 "$$from_dir/$$file Not Found!" ; \
1741 elif test "$(Verb)" != '@' ; then \
1742 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1745 $(Verb) for subdir in $(DistSubDirs) ; do \
1746 if test "$$subdir" \!= "." ; then \
1747 new_distdir="$(DistDir)/$$subdir" ; \
1748 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1749 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1750 DistDir="$$new_distdir" distdir ) || exit 1; \
1753 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1754 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1755 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1756 -name .svn \) -print` ;\
1757 $(MAKE) dist-hook ; \
1758 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1759 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1760 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1761 -o ! -type d ! -perm -444 -exec \
1762 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1763 || chmod -R a+r $(DistDir) ; \
1766 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1772 ###############################################################################
1773 # TOP LEVEL - targets only to apply at the top level directory
1774 ###############################################################################
1778 #------------------------------------------------------------------------
1779 # Install support for the project's include files:
1780 #------------------------------------------------------------------------
1783 $(Echo) Install circumvented with NO_INSTALL
1785 $(Echo) Uninstall circumvented with NO_INSTALL
1788 $(Echo) Installing include files
1789 $(Verb) $(MKDIR) $(PROJ_includedir)
1790 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1791 cd $(PROJ_SRC_ROOT)/include && \
1792 for hdr in `find . -type f '!' '(' -name '*~' \
1793 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1794 grep -v .svn` ; do \
1795 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1796 if test \! -d "$$instdir" ; then \
1797 $(EchoCmd) Making install directory $$instdir ; \
1798 $(MKDIR) $$instdir ;\
1800 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1803 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1804 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1805 cd $(PROJ_OBJ_ROOT)/include && \
1806 for hdr in `find . -type f -print | grep -v CVS` ; do \
1807 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1813 $(Echo) Uninstalling include files
1814 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1815 cd $(PROJ_SRC_ROOT)/include && \
1816 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1817 '!' '(' -name '*~' -o -name '.#*' \
1818 -o -name '*.in' ')' -print ')' | \
1819 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1820 cd $(PROJ_SRC_ROOT)/include && \
1821 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1822 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1828 @echo searching for overlength lines in files: $(Sources)
1831 egrep -n '.{81}' $(Sources) /dev/null
1834 @echo searching for tabs in files: $(Sources)
1837 egrep -n ' ' $(Sources) /dev/null
1840 @ls -l $(LibDir) | awk '\
1841 BEGIN { sum = 0; } \
1843 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1844 @ls -l $(ToolDir) | awk '\
1845 BEGIN { sum = 0; } \
1847 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1848 #------------------------------------------------------------------------
1849 # Print out the directories used for building
1850 #------------------------------------------------------------------------
1852 $(Echo) "BuildMode : " '$(BuildMode)'
1853 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1854 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1855 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1856 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1857 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1858 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1859 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1860 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1861 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1862 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1863 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1864 $(Echo) "UserTargets : " '$(UserTargets)'
1865 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1866 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1867 $(Echo) "ObjDir : " '$(ObjDir)'
1868 $(Echo) "LibDir : " '$(LibDir)'
1869 $(Echo) "ToolDir : " '$(ToolDir)'
1870 $(Echo) "ExmplDir : " '$(ExmplDir)'
1871 $(Echo) "Sources : " '$(Sources)'
1872 $(Echo) "TDFiles : " '$(TDFiles)'
1873 $(Echo) "INCFiles : " '$(INCFiles)'
1874 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1875 $(Echo) "PreConditions: " '$(PreConditions)'
1876 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1877 $(Echo) "Compile.C : " '$(Compile.C)'
1878 $(Echo) "Archive : " '$(Archive)'
1879 $(Echo) "YaccFiles : " '$(YaccFiles)'
1880 $(Echo) "LexFiles : " '$(LexFiles)'
1881 $(Echo) "Module : " '$(Module)'
1882 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1883 $(Echo) "SubDirs : " '$(SubDirs)'
1884 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1885 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1890 # General debugging rule, use 'make dbg-print-XXX' to print the
1891 # definition, value and origin of XXX.
1893 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))