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 # FIXME: The {PIC16,MSP430}/AsmPrinter line here is a hack to force a reconfigure to pick
132 # up AsmPrinter changes. Remove it after a reasonable delay from 2009-08-13.
134 .PRECIOUS: $(ConfigStatusScript)
135 $(ConfigStatusScript): $(ConfigureScript) $(LLVM_SRC_ROOT)/lib/Target/PIC16/AsmPrinter/Makefile $(LLVM_SRC_ROOT)/lib/Target/MSP430/AsmPrinter/Makefile
136 $(Echo) Reconfiguring with $<
137 $(Verb) cd $(PROJ_OBJ_ROOT) && \
138 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
139 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
141 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
142 $(ConfigStatusScript)
144 #------------------------------------------------------------------------
145 # Make sure the configuration makefile is up to date
146 #------------------------------------------------------------------------
147 ifneq ($(MakefileConfigIn),)
148 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
149 $(Echo) Regenerating $@
150 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
153 ifneq ($(MakefileCommonIn),)
154 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
155 $(Echo) Regenerating $@
156 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
159 #------------------------------------------------------------------------
160 # If the Makefile in the source tree has been updated, copy it over into the
161 # build tree. But, only do this if the source and object makefiles differ
162 #------------------------------------------------------------------------
163 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
165 Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
166 $(Echo) "Updating Makefile"
167 $(Verb) $(MKDIR) $(@D)
168 $(Verb) $(CP) -f $< $@
170 # Copy the Makefile.* files unless we're in the root directory which avoids
171 # the copying of Makefile.config.in or other things that should be explicitly
173 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
175 *Makefile.rules) ;; \
177 *) $(EchoCmd) "Updating $(@F)" ; \
184 #------------------------------------------------------------------------
185 # Set up the basic dependencies
186 #------------------------------------------------------------------------
187 $(UserTargets):: $(PreConditions)
191 clean-all:: clean-local clean-all-local
192 install:: install-local
193 uninstall:: uninstall-local
194 install-local:: all-local
195 install-bytecode:: install-bytecode-local
197 ###############################################################################
198 # LLVMC: Provide rules for compiling llvmc plugins
199 ###############################################################################
203 LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
204 CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
207 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
208 LD.Flags += -lCompilerDriver
211 # Build a dynamic library if the user runs `make` directly from the plugin
213 ifndef LLVMC_BUILTIN_PLUGIN
218 ifneq ($(BUILT_SOURCES),)
219 LLVMC_BUILD_AUTOGENERATED_INC=1
224 ifdef LLVMC_BASED_DRIVER
226 TOOLNAME = $(LLVMC_BASED_DRIVER)
230 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
231 LD.Flags += -lCompilerDriver
233 LLVMLIBS = CompilerDriver.a
234 LINK_COMPONENTS = support system
237 # Preprocessor magic that generates references to static variables in built-in
239 ifneq ($(LLVMC_BUILTIN_PLUGINS),)
241 USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
243 LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS))
244 LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS))
245 LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS))
246 LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS))
247 LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS))
249 ifneq ($(LLVMC_BUILTIN_PLUGIN_1),)
250 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1)
253 ifneq ($(LLVMC_BUILTIN_PLUGIN_2),)
254 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2)
257 ifneq ($(LLVMC_BUILTIN_PLUGIN_3),)
258 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3)
261 ifneq ($(LLVMC_BUILTIN_PLUGIN_4),)
262 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4)
265 ifneq ($(LLVMC_BUILTIN_PLUGIN_5),)
266 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5)
271 endif # LLVMC_BASED_DRIVER
273 ###############################################################################
274 # VARIABLES: Set up various variables based on configuration data
275 ###############################################################################
277 # Variable for if this make is for a "cleaning" target
278 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
282 #--------------------------------------------------------------------
283 # Variables derived from configuration we are building
284 #--------------------------------------------------------------------
287 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
288 # this can be overridden on the make command line.
289 ifndef OPTIMIZE_OPTION
290 ifneq ($(HOST_OS),MingW)
291 OPTIMIZE_OPTION := -O3
293 OPTIMIZE_OPTION := -O2
297 ifeq ($(ENABLE_OPTIMIZED),1)
299 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
300 ifneq ($(HOST_OS),FreeBSD)
301 ifneq ($(HOST_OS),Darwin)
302 OmitFramePointer := -fomit-frame-pointer
306 # Darwin requires -fstrict-aliasing to be explicitly enabled.
307 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
308 # with -fstrict-aliasing and ipa-type-escape radr://6756684
309 #ifeq ($(HOST_OS),Darwin)
310 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
312 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
313 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
314 LD.Flags += $(OPTIMIZE_OPTION)
323 ifeq ($(ENABLE_PROFILING),1)
324 BuildMode := $(BuildMode)+Profile
325 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
326 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
327 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
331 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
332 # CXX.Flags += -fvisibility-inlines-hidden
335 # IF REQUIRES_EH=1 is specified then don't disable exceptions
337 CXX.Flags += -fno-exceptions
340 ifdef REQUIRES_FRAME_POINTER
341 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
342 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
343 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
346 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
347 ifeq ($(REQUIRES_RTTI), 1)
348 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
349 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
352 ifdef ENABLE_COVERAGE
353 BuildMode := $(BuildMode)+Coverage
354 CXX.Flags += -ftest-coverage -fprofile-arcs
355 C.Flags += -ftest-coverage -fprofile-arcs
358 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
359 # then disable assertions by defining the appropriate preprocessor symbols.
360 ifdef DISABLE_ASSERTIONS
361 # Indicate that assertions are turned off using a minus sign
362 BuildMode := $(BuildMode)-Asserts
363 CPP.Defines += -DNDEBUG
365 CPP.Defines += -D_DEBUG
368 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
369 # configured), then enable expensive checks by defining the
370 # appropriate preprocessor symbols.
371 ifdef ENABLE_EXPENSIVE_CHECKS
372 BuildMode := $(BuildMode)+Checks
373 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
376 # LOADABLE_MODULE implies several other things so we force them to be
378 ifdef LOADABLE_MODULE
380 LINK_LIBS_IN_SHARED := 1
388 ifeq ($(ENABLE_PIC),1)
389 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
390 # Nothing. Win32 defaults to PIC and warns when given -fPIC
392 ifeq ($(HOST_OS),Darwin)
393 # Common symbols not allowed in dylib files
394 CXX.Flags += -fno-common
395 C.Flags += -fno-common
397 # Linux and others; pass -fPIC
403 ifeq ($(HOST_OS),Darwin)
404 CXX.Flags += -mdynamic-no-pic
405 C.Flags += -mdynamic-no-pic
409 CXX.Flags += -Woverloaded-virtual
410 CPP.BaseFlags += $(CPP.Defines)
413 # Make Floating point IEEE compliant on Alpha.
416 CPP.BaseFlags += -mieee
417 ifeq ($(ENABLE_PIC),0)
419 CPP.BaseFlags += -fPIC
424 LD.Flags += -Wl,--no-relax
427 ifeq ($(HOST_OS),MingW)
428 ifeq ($(LLVM_CROSS_COMPILING),1)
429 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
431 LD.Flags += -Wl,--allow-multiple-definition
436 ifdef ENABLE_EXPENSIVE_CHECKS
437 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
438 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
439 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
440 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
443 #--------------------------------------------------------------------
444 # Directory locations
445 #--------------------------------------------------------------------
447 ifeq ($(LLVM_CROSS_COMPILING),1)
448 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
451 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
452 ObjDir := $(ObjRootDir)
453 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
454 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
455 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
456 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
457 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
458 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
459 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
461 #--------------------------------------------------------------------
462 # Full Paths To Compiled Tools and Utilities
463 #--------------------------------------------------------------------
464 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
467 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
470 ifeq ($(LLVM_CROSS_COMPILING),1)
471 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
473 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
476 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
478 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
481 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
484 LLI := $(LLVMToolDir)/lli$(EXEEXT)
487 LLC := $(LLVMToolDir)/llc$(EXEEXT)
490 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
493 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
496 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
498 ifeq ($(LLVMGCC_MAJVERS),3)
499 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
500 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
502 LLVMGCCWITHPATH := $(LLVMGCC)
503 LLVMGXXWITHPATH := $(LLVMGXX)
506 #--------------------------------------------------------------------
507 # Adjust to user's request
508 #--------------------------------------------------------------------
510 ifeq ($(HOST_OS),Darwin)
511 DARWIN_VERSION := `sw_vers -productVersion`
512 # Strip a number like 10.4.7 to 10.4
513 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
514 # Get "4" out of 10.4 for later pieces in the makefile.
515 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
517 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
520 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
523 ifeq ($(HOST_OS),Cygwin)
524 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
525 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
527 SharedLinkOptions=-shared
531 ifeq ($(TARGET_OS),Darwin)
533 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
537 # Adjust LD.Flags depending on the kind of library that is to be built. Note
538 # that if LOADABLE_MODULE is specified then the resulting shared library can
539 # be opened with dlopen.
540 ifdef LOADABLE_MODULE
545 ifneq ($(DARWIN_MAJVERS),4)
546 LD.Flags += $(RPATH) -Wl,$(LibDir)
557 # Adjust settings for verbose mode
560 AR.Flags += >/dev/null 2>/dev/null
561 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
563 ConfigureScriptFLAGS :=
566 # By default, strip symbol information from executable
568 Strip := $(PLATFORMSTRIPOPTS)
569 StripWarnMsg := "(without symbols)"
570 Install.StripFlag += -s
573 # Adjust linker flags for building an executable
574 ifneq ($(HOST_OS),Darwin)
575 ifneq ($(DARWIN_MAJVERS),4)
578 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
580 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
586 #----------------------------------------------------------
587 # Options To Invoke Tools
588 #----------------------------------------------------------
591 CompileCommonOpts += -pedantic -Wno-long-long
593 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
596 ifeq ($(HOST_OS),HP-UX)
597 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
600 # If we are building a universal binary on Mac OS/X, pass extra options. This
601 # is useful to people that want to link the LLVM libraries into their universal
604 # The following can be optionally specified:
605 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
606 # For Mac OS/X 10.4 Intel machines, the traditional one is:
607 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
608 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
609 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
612 ifndef UNIVERSAL_ARCH
613 UNIVERSAL_ARCH := i386 ppc
615 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
616 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
617 ifdef UNIVERSAL_SDK_PATH
618 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
621 # Building universal cannot compute dependencies automatically.
622 DISABLE_AUTO_DEPENDENCIES=1
624 ifeq ($(TARGET_OS),Darwin)
625 ifeq ($(ARCH),x86_64)
626 TargetCommonOpts = -m64
629 TargetCommonOpts = -m32
635 ifeq ($(HOST_OS),SunOS)
636 CPP.BaseFlags += -include llvm/System/Solaris.h
639 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
640 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
641 # All -I flags should go here, so that they don't confuse llvm-config.
642 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
643 $(patsubst %,-I%/include,\
644 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
645 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
648 ifeq ($(BUILD_COMPONENT), 1)
649 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
650 $(TargetCommonOpts) $(CompileCommonOpts) -c
651 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
653 $(TargetCommonOpts) $(CompileCommonOpts) -c
654 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
655 $(CompileCommonOpts) $(CXX.Flags) -E
656 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
658 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
660 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
661 $(TargetCommonOpts) $(CompileCommonOpts) -c
662 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
663 $(TargetCommonOpts) $(CompileCommonOpts) -c
664 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
665 $(CompileCommonOpts) $(CXX.Flags) -E
666 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
667 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
670 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CFLAGS) \
672 $(TargetCommonOpts) $(CompileCommonOpts)
673 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
674 $(TargetCommonOpts) $(CompileCommonOpts) -E
676 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
678 $(TargetCommonOpts) $(CompileCommonOpts)
680 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
681 ScriptInstall = $(INSTALL) -m 0755
682 DataInstall = $(INSTALL) -m 0644
684 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
685 # paths. In this case, the SYSPATH function (defined in
686 # Makefile.config) transforms Unix paths into Windows paths.
687 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
688 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
689 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
690 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
692 Archive = $(AR) $(AR.Flags)
693 LArchive = $(LLVMToolDir)/llvm-ar rcsf
700 #----------------------------------------------------------
701 # Get the list of source files and compute object file
703 #----------------------------------------------------------
706 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
707 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
709 Sources := $(SOURCES)
713 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
716 BaseNameSources := $(sort $(basename $(Sources)))
718 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
719 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
721 ###############################################################################
722 # DIRECTORIES: Handle recursive descent of directory structure
723 ###############################################################################
725 #---------------------------------------------------------
726 # Provide rules to make install dirs. This must be early
727 # in the file so they get built before dependencies
728 #---------------------------------------------------------
730 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
733 # To create other directories, as needed, and timestamp their creation
735 $(Verb) $(MKDIR) $* > /dev/null
738 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
739 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
741 #---------------------------------------------------------
742 # Handle the DIRS options for sequential construction
743 #---------------------------------------------------------
749 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
750 $(RecursiveTargets)::
751 $(Verb) for dir in $(DIRS); do \
752 if [ ! -f $$dir/Makefile ]; then \
754 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
756 ($(MAKE) -C $$dir $@ ) || exit 1; \
759 $(RecursiveTargets)::
760 $(Verb) for dir in $(DIRS); do \
761 ($(MAKE) -C $$dir $@ ) || exit 1; \
767 #---------------------------------------------------------
768 # Handle the EXPERIMENTAL_DIRS options ensuring success
769 # after each directory is built.
770 #---------------------------------------------------------
771 ifdef EXPERIMENTAL_DIRS
772 $(RecursiveTargets)::
773 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
774 if [ ! -f $$dir/Makefile ]; then \
776 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
778 ($(MAKE) -C $$dir $@ ) || exit 0; \
782 #-----------------------------------------------------------
783 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
784 #-----------------------------------------------------------
785 ifdef OPTIONAL_PARALLEL_DIRS
786 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
789 #-----------------------------------------------------------
790 # Handle the PARALLEL_DIRS options for parallel construction
791 #-----------------------------------------------------------
794 SubDirs += $(PARALLEL_DIRS)
796 # Unfortunately, this list must be maintained if new recursive targets are added
797 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
798 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
799 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
800 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
801 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
802 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
804 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
807 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
809 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
811 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
814 #---------------------------------------------------------
815 # Handle the OPTIONAL_DIRS options for directores that may
817 #---------------------------------------------------------
820 SubDirs += $(OPTIONAL_DIRS)
822 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
823 $(RecursiveTargets)::
824 $(Verb) for dir in $(OPTIONAL_DIRS); do \
825 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
826 if [ ! -f $$dir/Makefile ]; then \
828 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
830 ($(MAKE) -C$$dir $@ ) || exit 1; \
834 $(RecursiveTargets)::
835 $(Verb) for dir in $(OPTIONAL_DIRS); do \
836 ($(MAKE) -C$$dir $@ ) || exit 1; \
841 #---------------------------------------------------------
842 # Handle the CONFIG_FILES options
843 #---------------------------------------------------------
848 $(Echo) Install circumvented with NO_INSTALL
850 $(Echo) UnInstall circumvented with NO_INSTALL
852 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
853 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
854 $(Verb)for file in $(CONFIG_FILES); do \
855 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
856 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
857 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
858 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
860 $(ECHO) Error: cannot find config file $${file}. ; \
865 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
866 $(Verb)for file in $(CONFIG_FILES); do \
867 $(RM) -f $(PROJ_etcdir)/$${file} ; \
873 ###############################################################################
874 # Set up variables for building libararies
875 ###############################################################################
877 #---------------------------------------------------------
878 # Define various command line options pertaining to the
879 # libraries needed when linking. There are "Proj" libs
880 # (defined by the user's project) and "LLVM" libs (defined
881 # by the LLVM project).
882 #---------------------------------------------------------
885 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
886 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
887 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
888 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
892 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
893 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
894 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
895 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
898 ifndef IS_CLEANING_TARGET
899 ifdef LINK_COMPONENTS
901 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
902 # clean in tools, then do a make in tools (instead of at the top level).
904 @echo "*** llvm-config doesn't exist - rebuilding it."
905 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
907 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
909 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
910 LLVMLibsPaths += $(LLVM_CONFIG) \
911 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
915 ###############################################################################
916 # Library Build Rules: Four ways to build a library
917 ###############################################################################
919 #---------------------------------------------------------
920 # Bytecode Module Targets:
921 # If the user set MODULE_NAME then they want to build a
922 # bytecode module from the sources. We compile all the
923 # sources and link it together into a single bytecode
925 #---------------------------------------------------------
928 ifeq ($(strip $(LLVMGCC)),)
929 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
932 Module := $(LibDir)/$(MODULE_NAME).bc
933 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
936 ifdef EXPORTED_SYMBOL_FILE
937 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
940 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
941 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
942 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
944 all-local:: $(Module)
947 ifneq ($(strip $(Module)),)
948 -$(Verb) $(RM) -f $(Module)
951 ifdef BYTECODE_DESTINATION
952 ModuleDestDir := $(BYTECODE_DESTINATION)
954 ModuleDestDir := $(PROJ_libdir)
959 $(Echo) Install circumvented with NO_INSTALL
961 $(Echo) Uninstall circumvented with NO_INSTALL
963 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
965 install-module:: $(DestModule)
966 install-local:: $(DestModule)
968 $(DestModule): $(ModuleDestDir) $(Module)
969 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
970 $(Verb) $(DataInstall) $(Module) $(DestModule)
973 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
974 -$(Verb) $(RM) -f $(DestModule)
980 # if we're building a library ...
983 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
984 LIBRARYNAME := $(strip $(LIBRARYNAME))
985 ifdef LOADABLE_MODULE
986 LibName.A := $(LibDir)/$(LIBRARYNAME).a
987 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
989 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
990 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
992 LibName.O := $(LibDir)/$(LIBRARYNAME).o
993 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
995 #---------------------------------------------------------
996 # Shared Library Targets:
997 # If the user asked for a shared library to be built
998 # with the SHARED_LIBRARY variable, then we provide
999 # targets for building them.
1000 #---------------------------------------------------------
1001 ifdef SHARED_LIBRARY
1003 all-local:: $(LibName.SO)
1005 ifdef LINK_LIBS_IN_SHARED
1006 ifdef LOADABLE_MODULE
1007 SharedLibKindMessage := "Loadable Module"
1009 SharedLibKindMessage := "Shared Library"
1011 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
1012 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1013 $(LIBRARYNAME)$(SHLIBEXT)
1014 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1015 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1017 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
1018 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
1019 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1023 ifneq ($(strip $(LibName.SO)),)
1024 -$(Verb) $(RM) -f $(LibName.SO)
1029 $(Echo) Install circumvented with NO_INSTALL
1031 $(Echo) Uninstall circumvented with NO_INSTALL
1033 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1035 install-local:: $(DestSharedLib)
1037 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
1038 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1039 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1042 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1043 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
1047 #---------------------------------------------------------
1048 # Bytecode Library Targets:
1049 # If the user asked for a bytecode library to be built
1050 # with the BYTECODE_LIBRARY variable, then we provide
1051 # targets for building them.
1052 #---------------------------------------------------------
1053 ifdef BYTECODE_LIBRARY
1054 ifeq ($(strip $(LLVMGCC)),)
1055 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
1058 all-local:: $(LibName.BCA)
1060 ifdef EXPORTED_SYMBOL_FILE
1061 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
1062 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1064 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1065 $(LLVMToolDir)/llvm-ar
1066 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1068 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1070 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1072 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1073 $(LLVMToolDir)/llvm-ar
1074 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1076 $(Verb) $(LArchive) $@ $(ObjectsBC)
1081 ifneq ($(strip $(LibName.BCA)),)
1082 -$(Verb) $(RM) -f $(LibName.BCA)
1085 ifdef BYTECODE_DESTINATION
1086 BytecodeDestDir := $(BYTECODE_DESTINATION)
1088 BytecodeDestDir := $(PROJ_libdir)
1091 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1093 install-bytecode-local:: $(DestBytecodeLib)
1097 $(Echo) Install circumvented with NO_INSTALL
1099 $(Echo) Uninstall circumvented with NO_INSTALL
1101 install-local:: $(DestBytecodeLib)
1103 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1104 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1105 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1108 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1109 -$(Verb) $(RM) -f $(DestBytecodeLib)
1114 #---------------------------------------------------------
1116 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1117 # building an archive.
1118 #---------------------------------------------------------
1119 ifndef BUILD_ARCHIVE
1120 ifndef LOADABLE_MODULE
1125 #---------------------------------------------------------
1126 # Archive Library Targets:
1127 # If the user wanted a regular archive library built,
1128 # then we provide targets for building them.
1129 #---------------------------------------------------------
1132 all-local:: $(LibName.A)
1134 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1135 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1136 -$(Verb) $(RM) -f $@
1137 $(Verb) $(Archive) $@ $(ObjectsO)
1138 $(Verb) $(Ranlib) $@
1141 ifneq ($(strip $(LibName.A)),)
1142 -$(Verb) $(RM) -f $(LibName.A)
1147 $(Echo) Install circumvented with NO_INSTALL
1149 $(Echo) Uninstall circumvented with NO_INSTALL
1151 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1153 install-local:: $(DestArchiveLib)
1155 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1156 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1157 $(Verb) $(MKDIR) $(PROJ_libdir)
1158 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1161 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1162 -$(Verb) $(RM) -f $(DestArchiveLib)
1169 ###############################################################################
1170 # Tool Build Rules: Build executable tool based on TOOLNAME option
1171 ###############################################################################
1175 #---------------------------------------------------------
1176 # Set up variables for building a tool.
1177 #---------------------------------------------------------
1179 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1181 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1184 #---------------------------------------------------------
1186 #---------------------------------------------------------
1188 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1189 # not exporting all of the weak symbols from the binary. This reduces dyld
1190 # startup time by 4x on darwin in some cases.
1191 ifdef TOOL_NO_EXPORTS
1192 ifeq ($(HOST_OS),Darwin)
1194 # Tiger tools don't support this.
1195 ifneq ($(DARWIN_MAJVERS),4)
1196 LD.Flags += -Wl,-exported_symbol -Wl,_main
1200 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
1201 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1206 #---------------------------------------------------------
1207 # Provide targets for building the tools
1208 #---------------------------------------------------------
1209 all-local:: $(ToolBuildPath)
1212 ifneq ($(strip $(ToolBuildPath)),)
1213 -$(Verb) $(RM) -f $(ToolBuildPath)
1217 $(ToolBuildPath): $(ExmplDir)/.dir
1219 $(ToolBuildPath): $(ToolDir)/.dir
1222 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1223 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1224 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1225 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1226 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1231 $(Echo) Install circumvented with NO_INSTALL
1233 $(Echo) Uninstall circumvented with NO_INSTALL
1235 DestTool = $(PROJ_bindir)/$(TOOLNAME)$(EXEEXT)
1237 install-local:: $(DestTool)
1239 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1240 $(Echo) Installing $(BuildMode) $(DestTool)
1241 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1244 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1245 -$(Verb) $(RM) -f $(DestTool)
1249 ###############################################################################
1250 # Object Build Rules: Build object files based on sources
1251 ###############################################################################
1253 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1254 ifeq ($(HOST_OS),HP-UX)
1255 DISABLE_AUTO_DEPENDENCIES=1
1258 # Provide rule sets for when dependency generation is enabled
1259 ifndef DISABLE_AUTO_DEPENDENCIES
1261 #---------------------------------------------------------
1262 # Create .o files in the ObjDir directory from the .cpp and .c files...
1263 #---------------------------------------------------------
1265 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1266 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1268 # If the build succeeded, move the dependency file over, otherwise
1270 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1271 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1273 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1274 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1275 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1278 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1279 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1280 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1283 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1284 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1285 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1288 #---------------------------------------------------------
1289 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1290 #---------------------------------------------------------
1292 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1293 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1295 # If the build succeeded, move the dependency file over, otherwise
1297 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1298 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1300 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1301 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1302 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1303 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1304 $(BC_DEPEND_MOVEFILE)
1306 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1307 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1308 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1309 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1310 $(BC_DEPEND_MOVEFILE)
1312 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1313 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1314 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1315 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1316 $(BC_DEPEND_MOVEFILE)
1318 # Provide alternate rule sets if dependencies are disabled
1321 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1322 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1323 $(Compile.CXX) $< -o $@
1325 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1326 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1327 $(Compile.CXX) $< -o $@
1329 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1330 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1331 $(Compile.C) $< -o $@
1333 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1334 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1335 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1337 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1338 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1339 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1341 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1342 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1343 $(BCCompile.C) $< -o $@ -S -emit-llvm
1348 ## Rules for building preprocessed (.i/.ii) outputs.
1349 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1350 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1351 $(Verb) $(Preprocess.CXX) $< -o $@
1353 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1354 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1355 $(Verb) $(Preprocess.CXX) $< -o $@
1357 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1358 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1359 $(Verb) $(Preprocess.C) $< -o $@
1362 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1363 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1364 $(Compile.CXX) $< -o $@ -S
1366 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1367 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1368 $(Compile.CXX) $< -o $@ -S
1370 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1371 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1372 $(Compile.C) $< -o $@ -S
1375 # make the C and C++ compilers strip debug info out of bytecode libraries.
1377 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1378 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1379 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1381 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1382 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1383 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1387 #---------------------------------------------------------
1388 # Provide rule to build .bc files from .ll sources,
1389 # regardless of dependencies
1390 #---------------------------------------------------------
1391 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1392 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1393 $(Verb) $(LLVMAS) $< -f -o $@
1395 ###############################################################################
1396 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1397 ###############################################################################
1400 TABLEGEN_INC_FILES_COMMON = 1
1403 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1404 TABLEGEN_INC_FILES_COMMON = 1
1407 ifdef TABLEGEN_INC_FILES_COMMON
1409 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1410 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1411 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1413 # INCFiles rule: All of the tblgen generated files are emitted to
1414 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1415 # us to only "touch" the real file if the contents of it change. IOW, if
1416 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1417 # dependencies of the .inc files are, unless the contents of the .inc file
1419 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1420 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1422 endif # TABLEGEN_INC_FILES_COMMON
1426 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1427 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1428 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1429 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1430 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1431 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1432 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1434 # All of these files depend on tblgen and the .td files.
1435 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1437 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1438 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1439 $(Echo) "Building $(<F) register names with tblgen"
1440 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1442 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1443 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1444 $(Echo) "Building $(<F) register information header with tblgen"
1445 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1447 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1448 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1449 $(Echo) "Building $(<F) register info implementation with tblgen"
1450 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1452 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1453 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1454 $(Echo) "Building $(<F) instruction names with tblgen"
1455 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1457 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1458 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1459 $(Echo) "Building $(<F) instruction information with tblgen"
1460 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1462 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1463 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1464 $(Echo) "Building $(<F) assembly writer with tblgen"
1465 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1467 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1468 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1469 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1470 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1472 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1473 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1474 $(Echo) "Building $(<F) assembly matcher with tblgen"
1475 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1477 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1478 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1479 $(Echo) "Building $(<F) code emitter with tblgen"
1480 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1482 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1483 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1484 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1485 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1487 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1488 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1489 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1490 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1492 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1493 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1494 $(Echo) "Building $(<F) subtarget information with tblgen"
1495 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1497 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1498 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1499 $(Echo) "Building $(<F) calling convention information with tblgen"
1500 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1502 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1503 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1504 $(Echo) "Building $(<F) calling convention information with tblgen"
1505 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1508 -$(Verb) $(RM) -f $(INCFiles)
1512 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1514 LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1515 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1517 TDFiles := $(LLVMCPluginSrc) \
1518 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1520 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1521 $(TBLGEN) $(TD_COMMON)
1522 $(Echo) "Building LLVMC configuration library with tblgen"
1523 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1525 endif # LLVMC_BUILD_AUTOGENERATED_INC
1527 ###############################################################################
1528 # OTHER RULES: Other rules needed
1529 ###############################################################################
1531 # To create postscript files from dot files...
1532 ifneq ($(DOT),false)
1534 $(DOT) -Tps < $< > $@
1537 $(Echo) "Cannot build $@: The program dot is not installed"
1540 # This rules ensures that header files that are removed still have a rule for
1541 # which they can be "generated." This allows make to ignore them and
1542 # reproduce the dependency lists.
1546 # Define clean-local to clean the current directory. Note that this uses a
1547 # very conservative approach ensuring that empty variables do not cause
1548 # errors or disastrous removal.
1550 ifneq ($(strip $(ObjRootDir)),)
1551 -$(Verb) $(RM) -rf $(ObjRootDir)
1553 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1554 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1555 -$(Verb) $(RM) -f *$(SHLIBEXT)
1559 -$(Verb) $(RM) -rf Debug Release Profile
1562 ###############################################################################
1563 # DEPENDENCIES: Include the dependency files if we should
1564 ###############################################################################
1565 ifndef DISABLE_AUTO_DEPENDENCIES
1567 # If its not one of the cleaning targets
1568 ifndef IS_CLEANING_TARGET
1570 # Get the list of dependency files
1571 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1572 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1574 # Include bitcode dependency files if using bitcode libraries
1575 ifdef BYTECODE_LIBRARY
1576 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1579 -include $(DependFiles) ""
1585 ###############################################################################
1586 # CHECK: Running the test suite
1587 ###############################################################################
1590 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1591 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1592 $(EchoCmd) Running test suite ; \
1593 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1594 TESTSUITE=$(TESTSUITE) ; \
1596 $(EchoCmd) No Makefile in test directory ; \
1599 $(EchoCmd) No test directory ; \
1603 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1604 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1605 $(EchoCmd) Running test suite ; \
1606 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
1608 $(EchoCmd) No Makefile in test directory ; \
1611 $(EchoCmd) No test directory ; \
1614 ###############################################################################
1615 # UNITTESTS: Running the unittests test suite
1616 ###############################################################################
1619 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1620 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1621 $(EchoCmd) Running unittests test suite ; \
1622 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
1624 $(EchoCmd) No Makefile in unittests directory ; \
1627 $(EchoCmd) No unittests directory ; \
1630 ###############################################################################
1631 # DISTRIBUTION: Handle construction of a distribution tarball
1632 ###############################################################################
1634 #------------------------------------------------------------------------
1635 # Define distribution related variables
1636 #------------------------------------------------------------------------
1637 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1638 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1639 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1640 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1641 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1642 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1643 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1644 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1645 Makefile.config.in configure autoconf
1646 DistOther := $(notdir $(wildcard \
1647 $(PROJ_SRC_DIR)/*.h \
1648 $(PROJ_SRC_DIR)/*.td \
1649 $(PROJ_SRC_DIR)/*.def \
1650 $(PROJ_SRC_DIR)/*.ll \
1651 $(PROJ_SRC_DIR)/*.in))
1652 DistSubDirs := $(SubDirs)
1653 DistSources = $(Sources) $(EXTRA_DIST)
1654 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1656 #------------------------------------------------------------------------
1657 # We MUST build distribution with OBJ_DIR != SRC_DIR
1658 #------------------------------------------------------------------------
1659 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1660 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1661 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1665 #------------------------------------------------------------------------
1666 # Prevent attempt to run dist targets from anywhere but the top level
1667 #------------------------------------------------------------------------
1669 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1670 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1673 #------------------------------------------------------------------------
1674 # Provide the top level targets
1675 #------------------------------------------------------------------------
1677 dist-gzip:: $(DistTarGZip)
1679 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1680 $(Echo) Packing gzipped distribution tar file.
1681 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1682 $(GZIP) -c > "$(DistTarGZip)"
1684 dist-bzip2:: $(DistTarBZ2)
1686 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1687 $(Echo) Packing bzipped distribution tar file.
1688 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1689 $(BZIP2) -c >$(DistTarBZ2)
1691 dist-zip:: $(DistZip)
1693 $(DistZip) : $(TopDistDir)/.makedistdir
1694 $(Echo) Packing zipped distribution file.
1695 $(Verb) rm -f $(DistZip)
1696 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1698 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1699 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1701 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1703 dist-check:: $(DistTarGZip)
1704 $(Echo) Checking distribution tar file.
1705 $(Verb) if test -d $(DistCheckDir) ; then \
1706 $(RM) -rf $(DistCheckDir) ; \
1708 $(Verb) $(MKDIR) $(DistCheckDir)
1709 $(Verb) cd $(DistCheckDir) && \
1710 $(MKDIR) $(DistCheckDir)/build && \
1711 $(MKDIR) $(DistCheckDir)/install && \
1712 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1714 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1715 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1718 $(MAKE) unittests && \
1719 $(MAKE) install && \
1720 $(MAKE) uninstall && \
1721 $(MAKE) dist-clean && \
1722 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1725 $(Echo) Cleaning distribution files
1726 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1731 #------------------------------------------------------------------------
1732 # Provide the recursive distdir target for building the distribution directory
1733 #------------------------------------------------------------------------
1734 distdir: $(DistDir)/.makedistdir
1735 $(DistDir)/.makedistdir: $(DistSources)
1736 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1737 if test -d "$(DistDir)" ; then \
1738 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1741 $(EchoCmd) Removing old $(DistDir) ; \
1742 $(RM) -rf $(DistDir); \
1743 $(EchoCmd) Making 'all' to verify build ; \
1744 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1746 $(Echo) Building Distribution Directory $(DistDir)
1747 $(Verb) $(MKDIR) $(DistDir)
1748 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1749 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1750 for file in $(DistFiles) ; do \
1752 $(PROJ_SRC_DIR)/*) \
1753 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1755 $(PROJ_SRC_ROOT)/*) \
1756 file=`echo "$$file" | \
1757 sed "s#^$$srcrootstrip/##"` \
1760 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1761 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1762 from_dir="$(PROJ_SRC_DIR)" ; \
1763 elif test -f "$$file" || test -d "$$file" ; then \
1766 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1767 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1768 to_dir="$(DistDir)/$$dir"; \
1769 $(MKDIR) "$$to_dir" ; \
1771 to_dir="$(DistDir)"; \
1773 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1774 if test -n "$$mid_dir" ; then \
1775 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1777 if test -d "$$from_dir/$$file"; then \
1778 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1779 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1780 cd $(PROJ_SRC_DIR) ; \
1781 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1782 ( cd $$to_dir ; $(TAR) xf - ) ; \
1783 cd $(PROJ_OBJ_DIR) ; \
1786 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1787 ( cd $$to_dir ; $(TAR) xf - ) ; \
1788 cd $(PROJ_OBJ_DIR) ; \
1790 elif test -f "$$from_dir/$$file" ; then \
1791 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1792 elif test -L "$$from_dir/$$file" ; then \
1793 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1794 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1795 $(EchoCmd) "===== WARNING: Distribution Source " \
1796 "$$from_dir/$$file Not Found!" ; \
1797 elif test "$(Verb)" != '@' ; then \
1798 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1801 $(Verb) for subdir in $(DistSubDirs) ; do \
1802 if test "$$subdir" \!= "." ; then \
1803 new_distdir="$(DistDir)/$$subdir" ; \
1804 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1805 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1806 DistDir="$$new_distdir" distdir ) || exit 1; \
1809 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1810 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1811 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1812 -name .svn \) -print` ;\
1813 $(MAKE) dist-hook ; \
1814 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1815 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1816 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1817 -o ! -type d ! -perm -444 -exec \
1818 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1819 || chmod -R a+r $(DistDir) ; \
1822 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1828 ###############################################################################
1829 # TOP LEVEL - targets only to apply at the top level directory
1830 ###############################################################################
1834 #------------------------------------------------------------------------
1835 # Install support for the project's include files:
1836 #------------------------------------------------------------------------
1839 $(Echo) Install circumvented with NO_INSTALL
1841 $(Echo) Uninstall circumvented with NO_INSTALL
1844 $(Echo) Installing include files
1845 $(Verb) $(MKDIR) $(PROJ_includedir)
1846 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1847 cd $(PROJ_SRC_ROOT)/include && \
1848 for hdr in `find . -type f '!' '(' -name '*~' \
1849 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1850 grep -v .svn` ; do \
1851 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1852 if test \! -d "$$instdir" ; then \
1853 $(EchoCmd) Making install directory $$instdir ; \
1854 $(MKDIR) $$instdir ;\
1856 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1859 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1860 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1861 cd $(PROJ_OBJ_ROOT)/include && \
1862 for hdr in `find . -type f -print | grep -v CVS` ; do \
1863 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1869 $(Echo) Uninstalling include files
1870 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1871 cd $(PROJ_SRC_ROOT)/include && \
1872 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1873 '!' '(' -name '*~' -o -name '.#*' \
1874 -o -name '*.in' ')' -print ')' | \
1875 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1876 cd $(PROJ_SRC_ROOT)/include && \
1877 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1878 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1884 @echo searching for overlength lines in files: $(Sources)
1887 egrep -n '.{81}' $(Sources) /dev/null
1890 @echo searching for tabs in files: $(Sources)
1893 egrep -n ' ' $(Sources) /dev/null
1896 @ls -l $(LibDir) | awk '\
1897 BEGIN { sum = 0; } \
1899 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1900 @ls -l $(ToolDir) | awk '\
1901 BEGIN { sum = 0; } \
1903 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1904 #------------------------------------------------------------------------
1905 # Print out the directories used for building
1906 #------------------------------------------------------------------------
1908 $(Echo) "BuildMode : " '$(BuildMode)'
1909 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1910 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1911 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1912 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1913 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1914 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1915 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1916 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1917 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1918 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1919 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1920 $(Echo) "UserTargets : " '$(UserTargets)'
1921 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1922 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1923 $(Echo) "ObjDir : " '$(ObjDir)'
1924 $(Echo) "LibDir : " '$(LibDir)'
1925 $(Echo) "ToolDir : " '$(ToolDir)'
1926 $(Echo) "ExmplDir : " '$(ExmplDir)'
1927 $(Echo) "Sources : " '$(Sources)'
1928 $(Echo) "TDFiles : " '$(TDFiles)'
1929 $(Echo) "INCFiles : " '$(INCFiles)'
1930 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1931 $(Echo) "PreConditions: " '$(PreConditions)'
1932 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1933 $(Echo) "Compile.C : " '$(Compile.C)'
1934 $(Echo) "Archive : " '$(Archive)'
1935 $(Echo) "YaccFiles : " '$(YaccFiles)'
1936 $(Echo) "LexFiles : " '$(LexFiles)'
1937 $(Echo) "Module : " '$(Module)'
1938 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1939 $(Echo) "SubDirs : " '$(SubDirs)'
1940 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1941 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1946 # General debugging rule, use 'make dbg-print-XXX' to print the
1947 # definition, value and origin of XXX.
1949 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))