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
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 .y .l .lo .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 # VARIABLES: Set up various variables based on configuration data
196 ###############################################################################
198 # Variable for if this make is for a "cleaning" target
199 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
203 #--------------------------------------------------------------------
204 # Variables derived from configuration we are building
205 #--------------------------------------------------------------------
208 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
209 # this can be overridden on the make command line.
211 OPTIMIZE_OPTION := -O3
213 OPTIMIZE_OPTION := -O2
216 ifdef ENABLE_PROFILING
218 CXX.Flags += $(OPTIMIZE_OPTION) -pg -g
219 C.Flags += $(OPTIMIZE_OPTION) -pg -g
220 LD.Flags += $(OPTIMIZE_OPTION) -pg -g
223 ifeq ($(ENABLE_OPTIMIZED),1)
225 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
226 ifneq ($(OS),FreeBSD)
228 OmitFramePointer := -fomit-frame-pointer
232 # Darwin requires -fstrict-aliasing to be explicitly enabled.
234 EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
237 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
238 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
239 LD.Flags += $(OPTIMIZE_OPTION)
249 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
250 # CXX.Flags += -fvisibility-inlines-hidden
253 # IF REQUIRES_EH=1 is specified then don't disable exceptions
255 CXX.Flags += -fno-exceptions
258 # IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
260 # CXX.Flags += -fno-rtti
263 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
264 # then disable assertions by defining the appropriate preprocessor symbols.
265 ifdef DISABLE_ASSERTIONS
266 BuildMode := $(BuildMode)-Asserts
267 CPP.Defines += -DNDEBUG
269 CPP.Defines += -D_DEBUG
272 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
273 # configured), then enable expensive checks by defining the
274 # appropriate preprocessor symbols.
275 ifdef ENABLE_EXPENSIVE_CHECKS
276 BuildMode := $(BuildMode)+Checks
277 CPP.Defines += -D_GLIBCXX_DEBUG
280 ifeq ($(ENABLE_PIC),1)
285 CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
287 CPP.Defines += $(CPPFLAGS)
288 CPP.BaseFlags += $(CPP.Defines)
289 LD.Flags += $(LDFLAGS)
291 LibTool.Flags := --tag=CXX
293 # Make Floating point IEEE compliant on Alpha.
296 CPP.BaseFlags += -mieee
297 ifeq ($(ENABLE_PIC),0)
299 CPP.BaseFlags += -fPIC
304 LD.Flags += -Wl,--no-relax
307 #--------------------------------------------------------------------
308 # Directory locations
309 #--------------------------------------------------------------------
311 ifeq ($(LLVM_CROSS_COMPILING),1)
312 ifeq ($(BUILD_COMPONENT),1)
317 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/Build/bin
320 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
321 # It is very important that ObjDir not have an extra trailing
322 # slash. This ends up changing the rules so that dependency file (.d)
323 # information is not used at all!
324 ifeq ($(TargetMode),)
325 ObjDir := $(ObjRootDir)
327 ObjDir := $(ObjRootDir)/$(TargetMode)
329 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib
330 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin
331 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples
332 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib
333 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin
334 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples
335 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
337 #--------------------------------------------------------------------
338 # Full Paths To Compiled Tools and Utilities
339 #--------------------------------------------------------------------
340 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
343 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
346 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
349 ifeq ($(LLVM_CROSS_COMPILING),1)
350 TBLGEN := $(BuildLLVMToolDir)/tblgen$(EXEEXT)
352 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
355 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
357 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
360 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
363 LLI := $(LLVMToolDir)/lli$(EXEEXT)
366 LLC := $(LLVMToolDir)/llc$(EXEEXT)
369 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
372 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
375 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
377 ifeq ($(LLVMGCC_MAJVERS),3)
378 UPGRADE_MSG = $(Echo) "Upgrading $(1) assembly to latest."
379 UPGRADE_LL = $(Verb)$(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1)
380 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
381 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
385 LLVMGCCWITHPATH := $(LLVMGCC)
386 LLVMGXXWITHPATH := $(LLVMGXX)
389 #--------------------------------------------------------------------
390 # Adjust to user's request
391 #--------------------------------------------------------------------
393 # Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
394 # to be built. Note that if LOADABLE_MODULE is specified then the resulting
395 # shared library can be opened with dlopen. Also, LOADABLE_MODULE implies
396 # several other things so we force them to be defined/on.
397 ifdef LOADABLE_MODULE
399 DONT_BUILD_RELINKED := 1
400 LINK_LIBS_IN_SHARED := 1
405 LD.Flags += -rpath $(LibDir)
407 LibTool.Flags += --tag=disable-shared
417 # Adjust settings for verbose mode
420 LibTool.Flags += --silent
421 AR.Flags += >/dev/null 2>/dev/null
422 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
424 ConfigureScriptFLAGS :=
427 # By default, strip symbol information from executable
429 Strip := $(PLATFORMSTRIPOPTS)
430 StripWarnMsg := "(without symbols)"
431 Install.StripFlag += -s
434 # Adjust linker flags for building an executable
437 LD.Flags += -rpath $(ExmplDir) -export-dynamic
439 LD.Flags += -rpath $(ToolDir) -export-dynamic
443 #----------------------------------------------------------
444 # Options To Invoke Tools
445 #----------------------------------------------------------
447 CompileCommonOpts := -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
448 -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
451 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
454 # If we are building a universal binary on Mac OS/X, pass extra options. This
455 # is useful to people that want to link the LLVM libraries into their universal
458 # The following can be optionally specified:
459 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
460 # For Mac OS/X 10.4 Intel machines, the traditional one is:
461 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
462 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
463 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
466 ifndef UNIVERSAL_ARCH
467 UNIVERSAL_ARCH := i386 ppc
469 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
470 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
471 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
472 ifdef UNIVERSAL_SDK_PATH
473 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
474 Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
477 # Building universal cannot compute dependencies automatically.
478 DISABLE_AUTO_DEPENDENCIES=1
482 CPP.BaseFlags += -include llvm/System/Solaris.h
485 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
486 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
487 # All -I flags should go here, so that they don't confuse llvm-config.
488 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
489 $(patsubst %,-I%/include,\
490 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
491 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
494 ifeq ($(BUILD_COMPONENT), 1)
495 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
496 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
497 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
498 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
500 Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
503 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
504 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
505 Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
506 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
508 Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
512 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
513 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts)
514 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -E
516 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
517 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
520 LTLink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Link)
521 LTRelink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Relink)
522 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
524 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
525 ScriptInstall = $(INSTALL) -m 0755
526 DataInstall = $(INSTALL) -m 0644
528 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
529 # paths. In this case, the SYSPATH function (defined in
530 # Makefile.config) transforms Unix paths into Windows paths.
531 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
532 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
533 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
535 Archive = $(AR) $(AR.Flags)
536 LArchive = $(LLVMToolDir)/llvm-ar rcsf
543 #----------------------------------------------------------
544 # Get the list of source files and compute object file
546 #----------------------------------------------------------
549 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
550 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
551 $(PROJ_SRC_DIR)/*.l))
553 Sources := $(SOURCES)
557 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
560 BaseNameSources := $(sort $(basename $(Sources)))
562 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
563 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
564 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
566 ###############################################################################
567 # DIRECTORIES: Handle recursive descent of directory structure
568 ###############################################################################
570 #---------------------------------------------------------
571 # Provide rules to make install dirs. This must be early
572 # in the file so they get built before dependencies
573 #---------------------------------------------------------
575 $(PROJ_bindir): $(PROJ_bindir)/.dir
576 $(PROJ_libdir): $(PROJ_libdir)/.dir
577 $(PROJ_includedir): $(PROJ_includedir)/.dir
578 $(PROJ_etcdir): $(PROJ_etcdir)/.dir
580 # To create other directories, as needed, and timestamp their creation
582 $(Verb) $(MKDIR) $* > /dev/null
585 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
586 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
588 #---------------------------------------------------------
589 # Handle the DIRS options for sequential construction
590 #---------------------------------------------------------
596 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
597 ifdef BUILD_TARGET_DIRS
598 $(RecursiveTargets)::
599 $(Verb) for dir in $(BUILD_TARGET_DIRS); do \
600 if [ ! -f $$dir/Makefile ]; then \
602 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
604 ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \
607 $(RecursiveTargets)::
608 $(Verb) for dir in $(DIRS); do \
609 if [ ! -f $$dir/Makefile ]; then \
611 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
613 ($(MAKE) -C $$dir $@ ) || exit 1; \
616 ifdef BUILD_TARGET_DIRS
617 $(RecursiveTargets)::
618 $(Verb) for dir in $(BUILD_TARGET_DIRS); do \
619 ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \
622 $(RecursiveTargets)::
623 $(Verb) for dir in $(DIRS); do \
624 ($(MAKE) -C $$dir $@ ) || exit 1; \
630 #---------------------------------------------------------
631 # Handle the EXPERIMENTAL_DIRS options ensuring success
632 # after each directory is built.
633 #---------------------------------------------------------
634 ifdef EXPERIMENTAL_DIRS
635 $(RecursiveTargets)::
636 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
637 if [ ! -f $$dir/Makefile ]; then \
639 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
641 ($(MAKE) -C $$dir $@ ) || exit 0; \
645 #-----------------------------------------------------------
646 # Handle the PARALLEL_DIRS options for parallel construction
647 #-----------------------------------------------------------
650 SubDirs += $(PARALLEL_DIRS)
652 # Unfortunately, this list must be maintained if new recursive targets are added
653 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
654 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
655 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
656 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
657 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
658 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
660 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
663 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
665 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
667 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
670 #---------------------------------------------------------
671 # Handle the OPTIONAL_DIRS options for directores that may
673 #---------------------------------------------------------
676 SubDirs += $(OPTIONAL_DIRS)
678 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
679 $(RecursiveTargets)::
680 $(Verb) for dir in $(OPTIONAL_DIRS); do \
681 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
682 if [ ! -f $$dir/Makefile ]; then \
684 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
686 ($(MAKE) -C$$dir $@ ) || exit 1; \
690 $(RecursiveTargets)::
691 $(Verb) for dir in $(OPTIONAL_DIRS); do \
692 ($(MAKE) -C$$dir $@ ) || exit 1; \
697 #---------------------------------------------------------
698 # Handle the CONFIG_FILES options
699 #---------------------------------------------------------
704 $(Echo) Install circumvented with NO_INSTALL
706 $(Echo) UnInstall circumvented with NO_INSTALL
708 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
709 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
710 $(Verb)for file in $(CONFIG_FILES); do \
711 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
712 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
713 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
714 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
716 $(ECHO) Error: cannot find config file $${file}. ; \
721 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
722 $(Verb)for file in $(CONFIG_FILES); do \
723 $(RM) -f $(PROJ_etcdir)/$${file} ; \
729 ###############################################################################
730 # Set up variables for building libararies
731 ###############################################################################
733 #---------------------------------------------------------
734 # Define various command line options pertaining to the
735 # libraries needed when linking. There are "Proj" libs
736 # (defined by the user's project) and "LLVM" libs (defined
737 # by the LLVM project).
738 #---------------------------------------------------------
741 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
742 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
743 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
744 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
748 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
749 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
750 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
751 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
754 ifndef IS_CLEANING_TARGET
755 ifdef LINK_COMPONENTS
757 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
758 # clean in tools, then do a make in tools (instead of at the top level).
760 @echo "*** llvm-config doesn't exist - rebuilding it."
761 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
763 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
765 ProjLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
766 ProjLibsPaths += $(LLVM_CONFIG) \
767 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
771 ###############################################################################
772 # Library Build Rules: Four ways to build a library
773 ###############################################################################
775 #---------------------------------------------------------
776 # Bytecode Module Targets:
777 # If the user set MODULE_NAME then they want to build a
778 # bytecode module from the sources. We compile all the
779 # sources and link it together into a single bytecode
781 #---------------------------------------------------------
784 ifeq ($(strip $(LLVMGCC)),)
785 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
788 Module := $(LibDir)/$(MODULE_NAME).bc
789 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
792 ifdef EXPORTED_SYMBOL_FILE
793 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
796 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
797 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
798 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
800 all-local:: $(Module)
803 ifneq ($(strip $(Module)),)
804 -$(Verb) $(RM) -f $(Module)
807 ifdef BYTECODE_DESTINATION
808 ModuleDestDir := $(BYTECODE_DESTINATION)
810 ModuleDestDir := $(PROJ_libdir)
815 $(Echo) Install circumvented with NO_INSTALL
817 $(Echo) Uninstall circumvented with NO_INSTALL
819 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
821 install-module:: $(DestModule)
822 install-local:: $(DestModule)
824 $(DestModule): $(ModuleDestDir) $(Module)
825 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
826 $(Verb) $(DataInstall) $(Module) $(DestModule)
829 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
830 -$(Verb) $(RM) -f $(DestModule)
836 # if we're building a library ...
839 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
840 LIBRARYNAME := $(strip $(LIBRARYNAME))
841 ifdef LOADABLE_MODULE
842 LibName.LA := $(LibDir)/$(LIBRARYNAME).la
844 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
846 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
847 LibName.O := $(LibDir)/$(LIBRARYNAME).o
848 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
850 #---------------------------------------------------------
851 # Shared Library Targets:
852 # If the user asked for a shared library to be built
853 # with the SHARED_LIBRARY variable, then we provide
854 # targets for building them.
855 #---------------------------------------------------------
858 all-local:: $(LibName.LA)
860 ifdef LINK_LIBS_IN_SHARED
861 ifdef LOADABLE_MODULE
862 SharedLibKindMessage := "Loadable Module"
864 SharedLibKindMessage := "Shared Library"
866 $(LibName.LA): $(ObjectsLO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
867 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
868 $(LIBRARYNAME)$(SHLIBEXT)
869 $(Verb) $(LTLink) -o $@ $(ObjectsLO) $(ProjLibsOptions) \
871 $(Verb) $(LTInstall) $@ $(LibDir)
873 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
874 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
875 $(Verb) $(LTLink) -o $@ $(ObjectsLO)
876 $(Verb) $(LTInstall) $@ $(LibDir)
880 ifneq ($(strip $(LibName.LA)),)
881 -$(Verb) $(RM) -f $(LibName.LA)
886 $(Echo) Install circumvented with NO_INSTALL
888 $(Echo) Uninstall circumvented with NO_INSTALL
890 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
892 install-local:: $(DestSharedLib)
894 $(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
895 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
896 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
897 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
900 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
901 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
905 #---------------------------------------------------------
906 # Bytecode Library Targets:
907 # If the user asked for a bytecode library to be built
908 # with the BYTECODE_LIBRARY variable, then we provide
909 # targets for building them.
910 #---------------------------------------------------------
911 ifdef BYTECODE_LIBRARY
912 ifeq ($(strip $(LLVMGCC)),)
913 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
916 all-local:: $(LibName.BCA)
918 ifdef EXPORTED_SYMBOL_FILE
919 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
920 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
922 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
923 $(LLVMToolDir)/llvm-ar
924 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
926 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
928 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
930 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
931 $(LLVMToolDir)/llvm-ar
932 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
934 $(Verb) $(LArchive) $@ $(ObjectsBC)
939 ifneq ($(strip $(LibName.BCA)),)
940 -$(Verb) $(RM) -f $(LibName.BCA)
943 ifdef BYTECODE_DESTINATION
944 BytecodeDestDir := $(BYTECODE_DESTINATION)
946 BytecodeDestDir := $(PROJ_libdir)
949 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
951 install-bytecode-local:: $(DestBytecodeLib)
955 $(Echo) Install circumvented with NO_INSTALL
957 $(Echo) Uninstall circumvented with NO_INSTALL
959 install-local:: $(DestBytecodeLib)
961 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
962 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
963 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
966 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
967 -$(Verb) $(RM) -f $(DestBytecodeLib)
972 #---------------------------------------------------------
973 # ReLinked Library Targets:
974 # If the user explicitly requests a relinked library with
975 # BUILD_RELINKED, provide it. Otherwise, if they specify
976 # neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
978 #---------------------------------------------------------
980 ifndef DONT_BUILD_RELINKED
987 all-local:: $(LibName.O)
989 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
990 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
991 $(Verb) $(LTRelink) -o $@ $(ObjectsO)
994 ifneq ($(strip $(LibName.O)),)
995 -$(Verb) $(RM) -f $(LibName.O)
1000 $(Echo) Install circumvented with NO_INSTALL
1002 $(Echo) Uninstall circumvented with NO_INSTALL
1004 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
1006 install-local:: $(DestRelinkedLib)
1008 $(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
1009 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
1010 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
1013 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
1014 -$(Verb) $(RM) -f $(DestRelinkedLib)
1018 #---------------------------------------------------------
1019 # Archive Library Targets:
1020 # If the user wanted a regular archive library built,
1021 # then we provide targets for building them.
1022 #---------------------------------------------------------
1025 all-local:: $(LibName.A)
1027 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1028 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1029 -$(Verb) $(RM) -f $@
1030 $(Verb) $(Archive) $@ $(ObjectsO)
1031 $(Verb) $(Ranlib) $@
1034 ifneq ($(strip $(LibName.A)),)
1035 -$(Verb) $(RM) -f $(LibName.A)
1040 $(Echo) Install circumvented with NO_INSTALL
1042 $(Echo) Uninstall circumvented with NO_INSTALL
1044 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1046 install-local:: $(DestArchiveLib)
1048 $(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
1049 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1050 $(Verb) $(MKDIR) $(PROJ_libdir)
1051 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
1054 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1055 -$(Verb) $(RM) -f $(DestArchiveLib)
1062 ###############################################################################
1063 # Tool Build Rules: Build executable tool based on TOOLNAME option
1064 ###############################################################################
1068 #---------------------------------------------------------
1069 # Set up variables for building a tool.
1070 #---------------------------------------------------------
1072 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1074 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1077 #---------------------------------------------------------
1078 # Provide targets for building the tools
1079 #---------------------------------------------------------
1080 all-local:: $(ToolBuildPath)
1083 ifneq ($(strip $(ToolBuildPath)),)
1084 -$(Verb) $(RM) -f $(ToolBuildPath)
1088 $(ToolBuildPath): $(ExmplDir)/.dir
1090 $(ToolBuildPath): $(ToolDir)/.dir
1093 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1094 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1095 $(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1096 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1097 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1102 $(Echo) Install circumvented with NO_INSTALL
1104 $(Echo) Uninstall circumvented with NO_INSTALL
1106 DestTool = $(PROJ_bindir)/$(TOOLNAME)
1108 install-local:: $(DestTool)
1110 $(DestTool): $(PROJ_bindir) $(ToolBuildPath)
1111 $(Echo) Installing $(BuildMode) $(DestTool)
1112 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1115 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1116 -$(Verb) $(RM) -f $(DestTool)
1120 ###############################################################################
1121 # Object Build Rules: Build object files based on sources
1122 ###############################################################################
1124 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1126 DISABLE_AUTO_DEPENDENCIES=1
1129 ifdef SHARED_LIBRARY
1131 MAYBE_PIC_Compile.CXX = $(LTCompile.CXX)
1132 MAYBE_PIC_Compile.C = $(LTCompile.C)
1134 MAYBE_PIC_Compile.CXX = $(Compile.CXX)
1135 MAYBE_PIC_Compile.C = $(Compile.C)
1138 # Provide rule sets for when dependency generation is enabled
1139 ifndef DISABLE_AUTO_DEPENDENCIES
1141 #---------------------------------------------------------
1142 # Create .lo files in the ObjDir directory from the .cpp and .c files...
1143 #---------------------------------------------------------
1145 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1146 -MT "$(ObjDir)/$*.lo" -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1148 # If the build succeeded, move the dependency file over. If it failed, put an
1150 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1151 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1153 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1154 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1155 $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1158 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1159 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1160 $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1163 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1164 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1165 $(Verb) if $(MAYBE_PIC_Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1168 #---------------------------------------------------------
1169 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1170 #---------------------------------------------------------
1172 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1173 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1174 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1175 $< -o $@ -S -emit-llvm ; \
1176 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1177 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1178 $(call UPGRADE_MSG,$@)
1179 $(call UPGRADE_LL,$@)
1181 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1182 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1183 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1184 $< -o $@ -S -emit-llvm ; \
1185 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1186 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1187 $(call UPGRADE_MSG,$@)
1188 $(call UPGRADE_LL,$@)
1190 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1191 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1192 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1193 $< -o $@ -S -emit-llvm ; \
1194 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1195 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
1196 $(call UPGRADE_MSG,$@)
1197 $(call UPGRADE_LL,$@)
1199 # Provide alternate rule sets if dependencies are disabled
1202 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1203 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1204 $(MAYBE_PIC_Compile.CXX) $< -o $@
1206 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1207 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1208 $(MAYBE_PIC_Compile.CXX) $< -o $@
1210 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1211 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1212 $(MAYBE_PIC_Compile.C) $< -o $@
1214 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1215 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1216 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1217 $(call UPGRADE_MSG,$@)
1218 $(call UPGRADE_LL,$@)
1220 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1221 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1222 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1223 $(call UPGRADE_MSG,$@)
1224 $(call UPGRADE_LL,$@)
1226 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1227 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1228 $(BCCompile.C) $< -o $@ -S -emit-llvm
1229 $(call UPGRADE_MSG,@)
1230 $(call UPGRADE_LL,@)
1235 ## Rules for building preprocessed (.i/.ii) outputs.
1236 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1237 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1238 $(Verb) $(Preprocess.CXX) $< -o $@
1240 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1241 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1242 $(Verb) $(Preprocess.CXX) $< -o $@
1244 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1245 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1246 $(Verb) $(Preprocess.C) $< -o $@
1249 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1250 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1251 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1253 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1254 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1255 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1257 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1258 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1259 $(MAYBE_PIC_Compile.C) $< -o $@ -S
1262 # make the C and C++ compilers strip debug info out of bytecode libraries.
1264 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1265 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1266 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
1268 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1269 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1270 $(Verb) $(LLVMAS) $< -o - | \
1271 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
1275 #---------------------------------------------------------
1276 # Provide rule to build .bc files from .ll sources,
1277 # regardless of dependencies
1278 #---------------------------------------------------------
1279 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1280 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1281 $(Verb) $(LLVMAS) $< -f -o $@
1283 ###############################################################################
1284 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1285 ###############################################################################
1289 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1290 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
1291 $(LLVM_SRC_ROOT)/lib/Target/TargetCallingConv.td \
1292 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1293 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1294 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1295 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1296 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1297 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1299 # All of these files depend on tblgen and the .td files.
1300 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1302 # INCFiles rule: All of the tblgen generated files are emitted to
1303 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1304 # us to only "touch" the real file if the contents of it change. IOW, if
1305 # tblgen is modified, all of the .inc.tmp files are regereated, but no
1306 # dependencies of the .inc files are, unless the contents of the .inc file
1308 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1309 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1311 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1312 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1313 $(Echo) "Building $(<F) register names with tblgen"
1314 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1316 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1317 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1318 $(Echo) "Building $(<F) register information header with tblgen"
1319 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1321 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1322 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1323 $(Echo) "Building $(<F) register info implementation with tblgen"
1324 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1326 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1327 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1328 $(Echo) "Building $(<F) instruction names with tblgen"
1329 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1331 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1332 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1333 $(Echo) "Building $(<F) instruction information with tblgen"
1334 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1336 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1337 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1338 $(Echo) "Building $(<F) assembly writer with tblgen"
1339 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1341 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1342 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1343 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1344 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1346 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1347 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1348 $(Echo) "Building $(<F) code emitter with tblgen"
1349 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1351 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1352 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1353 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1354 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1356 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1357 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1358 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1359 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1361 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1362 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1363 $(Echo) "Building $(<F) subtarget information with tblgen"
1364 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1366 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1367 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1368 $(Echo) "Building $(<F) calling convention information with tblgen"
1369 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1372 -$(Verb) $(RM) -f $(INCFiles)
1376 ###############################################################################
1377 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1378 ###############################################################################
1380 #---------------------------------------------------------
1381 # Provide rules for generating a .cpp source file from
1382 # (f)lex input sources.
1383 #---------------------------------------------------------
1385 LexFiles := $(filter %.l,$(Sources))
1387 ifneq ($(LexFiles),)
1389 # Cancel built-in rules for lex
1393 all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1395 # Note the extra sed filtering here, used to cut down on the warnings emited
1396 # by GCC. The last line is a gross hack to work around flex aparently not
1397 # being able to resize the buffer on a large token input. Currently, for
1398 # uninitialized string buffers in LLVM we can generate very long tokens, so
1399 # this is a hack around it.
1400 # FIXME. (f.e. char Buffer[10000] )
1401 $(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
1402 $(Echo) Flexing $*.l
1403 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
1404 $(SED) 's/void yyunput/inline void yyunput/' | \
1405 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1406 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1407 > $(PROJ_SRC_DIR)/$*.cpp
1409 # IFF the .l file has changed since it was last checked into SVN, copy the .l
1410 # file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1411 # so that people without flex can build LLVM by copying the .cvs files to the
1412 # source location and building them.
1413 $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1414 $(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
1415 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
1416 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
1418 $(LexFiles:%.l=$(ObjDir)/%.o) : \
1419 $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1422 -$(Verb) $(RM) -f $(LexOutput)
1426 #---------------------------------------------------------
1427 # Provide rules for generating a .cpp and .h source files
1428 # from yacc (bison) input sources.
1429 #---------------------------------------------------------
1431 YaccFiles := $(filter %.y,$(Sources))
1432 ifneq ($(YaccFiles),)
1434 .PRECIOUS: $(YaccOutput)
1436 all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
1438 # Cancel built-in rules for yacc
1443 # Rule for building the bison based parsers...
1445 $(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
1446 $(Echo) "Bisoning $*.y"
1447 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1448 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1449 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
1451 # IFF the .y file has changed since it was last checked into SVN, copy the .y
1452 # file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1453 # mechanism so that people without flex can build LLVM by copying the .cvs files
1454 # to the source location and building them.
1455 $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1456 $(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
1457 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
1459 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
1460 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
1463 $(PROJ_SRC_DIR)/%.cpp : $(PROJ_SRC_DIR)/%.cpp.cvs
1464 $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .cpp.cvs"
1465 $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.cpp.cvs $(PROJ_SRC_DIR)/$*.cpp
1467 $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.h.cvs
1468 $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .h.cvs"
1469 $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.h.cvs $(PROJ_SRC_DIR)/$*.h
1473 $(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1475 YaccOutput := $(YaccFiles:%.y=%.output)
1478 -$(Verb) $(RM) -f $(YaccOutput)
1481 ###############################################################################
1482 # OTHER RULES: Other rules needed
1483 ###############################################################################
1485 # To create postscript files from dot files...
1486 ifneq ($(DOT),false)
1488 $(DOT) -Tps < $< > $@
1491 $(Echo) "Cannot build $@: The program dot is not installed"
1494 # This rules ensures that header files that are removed still have a rule for
1495 # which they can be "generated." This allows make to ignore them and
1496 # reproduce the dependency lists.
1500 # Define clean-local to clean the current directory. Note that this uses a
1501 # very conservative approach ensuring that empty variables do not cause
1502 # errors or disastrous removal.
1504 ifneq ($(strip $(ObjRootDir)),)
1505 -$(Verb) $(RM) -rf $(ObjRootDir)
1507 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1508 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1509 -$(Verb) $(RM) -f *$(SHLIBEXT)
1513 -$(Verb) $(RM) -rf Debug Release Profile
1516 ###############################################################################
1517 # DEPENDENCIES: Include the dependency files if we should
1518 ###############################################################################
1519 ifndef DISABLE_AUTO_DEPENDENCIES
1521 # If its not one of the cleaning targets
1522 ifndef IS_CLEANING_TARGET
1524 # Get the list of dependency files
1525 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1526 DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1528 -include $(DependFiles) ""
1534 ###############################################################################
1535 # CHECK: Running the test suite
1536 ###############################################################################
1539 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1540 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1541 $(EchoCmd) Running test suite ; \
1542 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1543 TESTSUITE=$(TESTSUITE) ; \
1545 $(EchoCmd) No Makefile in test directory ; \
1548 $(EchoCmd) No test directory ; \
1551 ###############################################################################
1552 # DISTRIBUTION: Handle construction of a distribution tarball
1553 ###############################################################################
1555 #------------------------------------------------------------------------
1556 # Define distribution related variables
1557 #------------------------------------------------------------------------
1558 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1559 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1560 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1561 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1562 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1563 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1564 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1565 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1566 Makefile.config.in configure autoconf
1567 DistOther := $(notdir $(wildcard \
1568 $(PROJ_SRC_DIR)/*.h \
1569 $(PROJ_SRC_DIR)/*.td \
1570 $(PROJ_SRC_DIR)/*.def \
1571 $(PROJ_SRC_DIR)/*.ll \
1572 $(PROJ_SRC_DIR)/*.in))
1573 DistSubDirs := $(SubDirs)
1574 DistSources = $(Sources) $(EXTRA_DIST)
1575 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1577 #------------------------------------------------------------------------
1578 # We MUST build distribution with OBJ_DIR != SRC_DIR
1579 #------------------------------------------------------------------------
1580 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1581 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1582 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1586 #------------------------------------------------------------------------
1587 # Prevent attempt to run dist targets from anywhere but the top level
1588 #------------------------------------------------------------------------
1590 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1591 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1594 #------------------------------------------------------------------------
1595 # Provide the top level targets
1596 #------------------------------------------------------------------------
1598 dist-gzip:: $(DistTarGZip)
1600 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1601 $(Echo) Packing gzipped distribution tar file.
1602 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1603 $(GZIP) -c > "$(DistTarGZip)"
1605 dist-bzip2:: $(DistTarBZ2)
1607 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1608 $(Echo) Packing bzipped distribution tar file.
1609 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1610 $(BZIP2) -c >$(DistTarBZ2)
1612 dist-zip:: $(DistZip)
1614 $(DistZip) : $(TopDistDir)/.makedistdir
1615 $(Echo) Packing zipped distribution file.
1616 $(Verb) rm -f $(DistZip)
1617 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1619 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1620 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1622 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1624 dist-check:: $(DistTarGZip)
1625 $(Echo) Checking distribution tar file.
1626 $(Verb) if test -d $(DistCheckDir) ; then \
1627 $(RM) -rf $(DistCheckDir) ; \
1629 $(Verb) $(MKDIR) $(DistCheckDir)
1630 $(Verb) cd $(DistCheckDir) && \
1631 $(MKDIR) $(DistCheckDir)/build && \
1632 $(MKDIR) $(DistCheckDir)/install && \
1633 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1635 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1636 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1639 $(MAKE) install && \
1640 $(MAKE) uninstall && \
1641 $(MAKE) dist-clean && \
1642 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1645 $(Echo) Cleaning distribution files
1646 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1651 #------------------------------------------------------------------------
1652 # Provide the recursive distdir target for building the distribution directory
1653 #------------------------------------------------------------------------
1654 distdir: $(DistDir)/.makedistdir
1655 $(DistDir)/.makedistdir: $(DistSources)
1656 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1657 if test -d "$(DistDir)" ; then \
1658 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1661 $(EchoCmd) Removing old $(DistDir) ; \
1662 $(RM) -rf $(DistDir); \
1663 $(EchoCmd) Making 'all' to verify build ; \
1664 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1666 $(Echo) Building Distribution Directory $(DistDir)
1667 $(Verb) $(MKDIR) $(DistDir)
1668 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1669 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1670 for file in $(DistFiles) ; do \
1672 $(PROJ_SRC_DIR)/*) \
1673 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1675 $(PROJ_SRC_ROOT)/*) \
1676 file=`echo "$$file" | \
1677 sed "s#^$$srcrootstrip/##"` \
1680 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1681 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1682 from_dir="$(PROJ_SRC_DIR)" ; \
1683 elif test -f "$$file" || test -d "$$file" ; then \
1686 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1687 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1688 to_dir="$(DistDir)/$$dir"; \
1689 $(MKDIR) "$$to_dir" ; \
1691 to_dir="$(DistDir)"; \
1693 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1694 if test -n "$$mid_dir" ; then \
1695 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1697 if test -d "$$from_dir/$$file"; then \
1698 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1699 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1700 cd $(PROJ_SRC_DIR) ; \
1701 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1702 ( cd $$to_dir ; $(TAR) xf - ) ; \
1703 cd $(PROJ_OBJ_DIR) ; \
1706 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1707 ( cd $$to_dir ; $(TAR) xf - ) ; \
1708 cd $(PROJ_OBJ_DIR) ; \
1710 elif test -f "$$from_dir/$$file" ; then \
1711 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1712 elif test -L "$$from_dir/$$file" ; then \
1713 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1714 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1715 $(EchoCmd) "===== WARNING: Distribution Source " \
1716 "$$from_dir/$$file Not Found!" ; \
1717 elif test "$(Verb)" != '@' ; then \
1718 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1721 $(Verb) for subdir in $(DistSubDirs) ; do \
1722 if test "$$subdir" \!= "." ; then \
1723 new_distdir="$(DistDir)/$$subdir" ; \
1724 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1725 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1726 DistDir="$$new_distdir" distdir ) || exit 1; \
1729 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1730 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1731 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1732 -name .svn \) -print` ;\
1733 $(MAKE) dist-hook ; \
1734 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1735 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1736 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1737 -o ! -type d ! -perm -444 -exec \
1738 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1739 || chmod -R a+r $(DistDir) ; \
1742 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1748 ###############################################################################
1749 # TOP LEVEL - targets only to apply at the top level directory
1750 ###############################################################################
1754 #------------------------------------------------------------------------
1755 # Install support for the project's include files:
1756 #------------------------------------------------------------------------
1759 $(Echo) Install circumvented with NO_INSTALL
1761 $(Echo) Uninstall circumvented with NO_INSTALL
1764 $(Echo) Installing include files
1765 $(Verb) $(MKDIR) $(PROJ_includedir)
1766 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1767 cd $(PROJ_SRC_ROOT)/include && \
1768 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1769 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1770 grep -v .svn` ; do \
1771 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1772 if test \! -d "$$instdir" ; then \
1773 $(EchoCmd) Making install directory $$instdir ; \
1774 $(MKDIR) $$instdir ;\
1776 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1779 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1780 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1781 cd $(PROJ_OBJ_ROOT)/include && \
1782 for hdr in `find . -type f -print | grep -v CVS` ; do \
1783 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1789 $(Echo) Uninstalling include files
1790 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1791 cd $(PROJ_SRC_ROOT)/include && \
1792 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1793 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1794 -o -name '*.in' ')' -print ')' | \
1795 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1796 cd $(PROJ_SRC_ROOT)/include && \
1797 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1798 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1804 @echo searching for overlength lines in files: $(Sources)
1807 egrep -n '.{81}' $(Sources) /dev/null
1810 @echo searching for tabs in files: $(Sources)
1813 egrep -n ' ' $(Sources) /dev/null
1816 @ls -l $(LibDir) | awk '\
1817 BEGIN { sum = 0; } \
1819 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1820 @ls -l $(ToolDir) | awk '\
1821 BEGIN { sum = 0; } \
1823 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1824 #------------------------------------------------------------------------
1825 # Print out the directories used for building
1826 #------------------------------------------------------------------------
1828 $(Echo) "BuildMode : " '$(BuildMode)'
1829 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1830 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1831 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1832 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1833 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1834 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1835 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1836 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1837 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1838 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1839 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1840 $(Echo) "UserTargets : " '$(UserTargets)'
1841 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1842 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1843 $(Echo) "ObjDir : " '$(ObjDir)'
1844 $(Echo) "LibDir : " '$(LibDir)'
1845 $(Echo) "ToolDir : " '$(ToolDir)'
1846 $(Echo) "ExmplDir : " '$(ExmplDir)'
1847 $(Echo) "Sources : " '$(Sources)'
1848 $(Echo) "TDFiles : " '$(TDFiles)'
1849 $(Echo) "INCFiles : " '$(INCFiles)'
1850 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1851 $(Echo) "PreConditions: " '$(PreConditions)'
1852 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1853 $(Echo) "Compile.C : " '$(Compile.C)'
1854 $(Echo) "Archive : " '$(Archive)'
1855 $(Echo) "YaccFiles : " '$(YaccFiles)'
1856 $(Echo) "LexFiles : " '$(LexFiles)'
1857 $(Echo) "Module : " '$(Module)'
1858 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1859 $(Echo) "SubDirs : " '$(SubDirs)'
1860 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1861 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'