1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file was developed by the LLVM research group and is distributed under
6 # the University of Illinois Open Source 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 tags 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 #--------------------------------------------------------------------
38 VPATH=$(BUILD_SRC_DIR)
40 #--------------------------------------------------------------------
41 # Reset the list of suffixes we know how to build
42 #--------------------------------------------------------------------
44 .SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
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 $(BUILD_SRC_DIR)/Makefile*))
65 ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
66 ConfigureScript := $(LLVM_SRC_ROOT)/configure
67 ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
68 MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
69 MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
70 PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
72 preconditions : $(PreConditions)
74 #------------------------------------------------------------------------
75 # Make sure the BUILT_SOURCES are built first
76 #------------------------------------------------------------------------
77 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
80 ifneq ($(strip $(BUILT_SOURCES)),)
81 -$(Verb) $(RM) -f $(BUILT_SOURCES)
84 ifneq ($(BUILD_OBJ_ROOT),$(BUILD_SRC_ROOT))
86 $(Verb) if test -x config.status ; then \
87 $(EchoCmd) Wiping out $(BUILD_OBJ_ROOT) ; \
88 $(MKDIR) .spotless.save ; \
89 $(MV) config.status .spotless.save ; \
90 $(MV) mklib .spotless.save ; \
91 $(MV) projects .spotless.save ; \
93 $(MV) .spotless.save/config.status . ; \
94 $(MV) .spotless.save/mklib . ; \
95 $(MV) .spotless.save/projects . ; \
96 $(RM) -rf .spotless.save ; \
97 $(EchoCmd) Rebuilding configuration of $(BUILD_OBJ_ROOT) ; \
98 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
99 $(ConfigStatusScript) ; \
101 $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \
105 $(BUILT_SOURCES) : $(ObjMakefiles)
107 #------------------------------------------------------------------------
108 # Make sure we're not using a stale configuration
109 #------------------------------------------------------------------------
111 $(Echo) Reconfiguring $(BUILD_OBJ_ROOT)
112 $(Verb) cd $(BUILD_OBJ_ROOT) && \
113 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
114 $(ConfigStatusScript)
116 .PRECIOUS: $(ConfigStatusScript)
117 $(ConfigStatusScript): $(ConfigureScript)
118 $(Echo) Reconfiguring with $<
119 $(Verb) cd $(BUILD_OBJ_ROOT) && \
120 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
121 $(ConfigStatusScript)
123 #------------------------------------------------------------------------
124 # Make sure the configuration makefile is up to date
125 #------------------------------------------------------------------------
126 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
127 $(Echo) Regenerating $@
128 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
130 #------------------------------------------------------------------------
131 # If the Makefile in the source tree has been updated, copy it over into the
132 # build tree. But, only do this if the source and object makefiles differ
133 #------------------------------------------------------------------------
134 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
136 Makefile: $(BUILD_SRC_DIR)/Makefile
137 $(Echo) "Updating Makefile"
138 $(Verb) $(MKDIR) $(@D)
139 $(Verb) $(CP) -f $< $@
141 # Copy the Makefile.* files unless we're in the root directory which avoids
142 # the copying of Makefile.config.in or other things that should be explicitly
144 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
146 *Makefile.rules) ;; \
148 *) $(Echo) "Updating $(@F)" ; \
155 #------------------------------------------------------------------------
156 # Set up the basic dependencies
157 #------------------------------------------------------------------------
158 $(UserTargets):: $(PreConditions)
162 clean-all:: clean-local clean-all-local
163 install:: install-local
164 uninstall:: uninstall-local
165 install-local:: all-local
166 install-bytecode:: install-bytecode-local
168 ###############################################################################
169 # VARIABLES: Set up various variables based on configuration data
170 ###############################################################################
172 #--------------------------------------------------------------------
173 # Variables derived from configuration we are building
174 #--------------------------------------------------------------------
176 ifdef ENABLE_PROFILING
178 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
179 C.Flags := -O3 -DNDEBUG -pg
180 LD.Flags := -O3 -DNDEBUG -pg
182 ifdef ENABLE_OPTIMIZED
184 CXX.Flags := -O3 -DNDEBUG -finline-functions \
185 -felide-constructors -fomit-frame-pointer
186 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
187 LD.Flags := -O3 -DNDEBUG
190 CXX.Flags := -g -D_DEBUG
191 C.Flags := -g -D_DEBUG
192 LD.Flags := -g -D_DEBUG
197 CXX.Flags += $(CXXFLAGS)
199 CPP.Flags += $(CPPFLAGS)
200 LD.Flags += $(LDFLAGS)
202 LibTool.Flags := --tag=CXX
204 #--------------------------------------------------------------------
205 # Directory locations
206 #--------------------------------------------------------------------
207 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
208 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
209 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
210 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
211 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
212 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
213 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
214 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
216 #--------------------------------------------------------------------
217 # Full Paths To Compiled Tools and Utilities
218 #--------------------------------------------------------------------
219 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
222 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
225 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
228 BURG := $(LLVMToolDir)/burg$(EXEEXT)
231 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
234 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
237 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
240 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
243 LLI := $(LLVMToolDir)/lli$(EXEEXT)
246 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
248 LLVMGCCWITHPATH := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCC)
249 LLVMGXXWITHPATH := PATH=$(LLVMToolDir):$(PATH) $(LLVMGXX)
251 #--------------------------------------------------------------------
252 # Adjust to user's request
253 #--------------------------------------------------------------------
255 # Adjust LIBTOOL flags for shared libraries, or not.
256 ifndef SHARED_LIBRARY
257 LibTool.Flags += --tag=disable-shared
259 LD.Flags += -rpath $(LibDir)
269 # Adjust settings for verbose mode
272 LibTool.Flags += --silent
273 AR.Flags += >/dev/null 2>/dev/null
274 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
276 ConfigureScriptFLAGS :=
279 # By default, strip symbol information from executable
281 Strip := $(PLATFORMSTRIPOPTS)
282 StripWarnMsg := "(without symbols)"
285 # Adjust linker flags for building an executable
288 LD.Flags += -rpath $(ExmplDir) -export-dynamic
290 LD.Flags += -rpath $(ToolDir) -export-dynamic
294 #----------------------------------------------------------
295 # Options To Invoke Tools
296 #----------------------------------------------------------
298 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
300 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
301 CPP.Flags += -I$(BUILD_OBJ_DIR) \
303 -I$(BUILD_SRC_ROOT)/include \
304 -I$(BUILD_OBJ_ROOT)/include \
305 -I$(LLVM_OBJ_ROOT)/include \
306 -I$(LLVM_SRC_ROOT)/include \
307 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
309 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
310 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
311 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
313 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
314 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
315 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
316 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
317 $(CompileCommonOpts) $(LD.Flags) $(Strip)
318 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
320 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
321 Burg = $(BURG) -I $(BUILD_SRC_DIR)
322 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
323 Archive = $(AR) $(AR.Flags)
324 LArchive = $(LLVMToolDir)/llvm-ar rcsf
331 #----------------------------------------------------------
332 # Get the list of source files and compute object file
334 #----------------------------------------------------------
337 FakeSources := $(FAKE_SOURCES)
339 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
341 BaseNameSources := $(sort $(basename $(FakeSources)))
342 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
343 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
344 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
347 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
348 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
349 $(BUILD_SRC_DIR)/*.l))
351 Sources := $(SOURCES)
355 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
358 BaseNameSources := $(sort $(basename $(Sources)))
359 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
360 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
361 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
364 ###############################################################################
365 # DIRECTORIES: Handle recursive descent of directory structure
366 ###############################################################################
368 #---------------------------------------------------------
369 # Provide rules to make install dirs. This must be early
370 # in the file so they get built before dependencies
371 #---------------------------------------------------------
374 $(Verb) $(MKDIR) $(bindir)
377 $(Verb) $(MKDIR) $(libdir)
380 $(Verb) $(MKDIR) $(includedir)
383 $(Verb) $(MKDIR) $(sysconfdir)
385 # To create other directories, as needed, and timestamp their creation
387 $(Verb) $(MKDIR) $* > /dev/null
390 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
391 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
393 #---------------------------------------------------------
394 # Handle the DIRS options for sequential construction
395 #---------------------------------------------------------
400 $(RecursiveTargets)::
401 $(Verb) for dir in $(DIRS); do \
402 if [ ! -f $$dir/Makefile ]; then \
404 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
406 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
407 ($(MAKE) -C $$dir $@ ) || exit 1; \
412 #---------------------------------------------------------
413 # Handle the EXPERIMENTAL_DIRS options ensuring success
414 # after each directory is built.
415 #---------------------------------------------------------
416 ifdef EXPERIMENTAL_DIRS
417 $(RecursiveTargets)::
418 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
419 if [ ! -f $$dir/Makefile ]; then \
421 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
423 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
424 ($(MAKE) -C $$dir $@ ) || exit 0; \
429 #---------------------------------------------------------
430 # Handle the PARALLEL_DIRS options for parallel construction
431 #---------------------------------------------------------
434 SubDirs += $(PARALLEL_DIRS)
436 # Unfortunately, this list must be maintained if new recursive targets are added
437 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
438 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
439 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
440 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
441 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
442 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
444 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
447 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
449 $(CP) $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
451 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
452 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
456 #---------------------------------------------------------
457 # Handle the OPTIONAL_DIRS options for directores that may
459 #---------------------------------------------------------
462 SubDirs += $(OPTIONAL_DIRS)
464 $(RecursiveTargets)::
465 $(Verb) for dir in $(OPTIONAL_DIRS); do \
466 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
467 if [ ! -f $$dir/Makefile ]; then \
469 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
471 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
472 ($(MAKE) -C$$dir $@ ) || exit 1; \
478 #---------------------------------------------------------
479 # Handle the CONFIG_FILES options
480 #---------------------------------------------------------
483 install-local:: $(sysconfdir) $(CONFIG_FILES)
484 $(Echo) Installing Configuration Files To $(sysconfdir)
485 $(Verb)for file in $(CONFIG_FILES); do \
486 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
487 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
488 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
489 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
491 $(ECHO) Error: cannot find config file $${file}. ; \
496 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
497 $(Verb)for file in $(CONFIG_FILES); do \
498 $(RM) -f $(sysconfdir)/$${file} ; \
503 ###############################################################################
504 # Library Build Rules: Four ways to build a library
505 ###############################################################################
507 #---------------------------------------------------------
508 # Bytecode Module Targets:
509 # If the user set MODULE_NAME then they want to build a
510 # bytecode module from the sources. We compile all the
511 # sources and link it together into a single bytecode
513 #---------------------------------------------------------
517 Module := $(LibDir)/$(MODULE_NAME).bc
518 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
520 ifdef EXPORTED_SYMBOL_FILE
521 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
524 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
525 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
526 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
528 all-local:: $(Module)
531 ifneq ($(strip $(Module)),)
532 -$(Verb) $(RM) -f $(Module)
535 ifdef BYTECODE_DESTINATION
536 ModuleDestDir := $(BYTECODE_DESTINATION)
538 ModuleDestDir := $(libdir)
541 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
543 install-module:: $(DestModule)
544 install-local:: $(DestModule)
546 $(DestModule): $(ModuleDestDir) $(Module)
547 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
548 $(Verb) $(INSTALL) $(Module) $@
551 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
552 -$(Verb) $(RM) -f $(DestModule)
556 # if we're building a library ...
559 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
560 LIBRARYNAME := $(strip $(LIBRARYNAME))
561 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
562 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
563 LibName.O := $(LibDir)/$(LIBRARYNAME).o
564 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
566 #---------------------------------------------------------
567 # Shared Library Targets:
568 # If the user asked for a shared library to be built
569 # with the SHARED_LIBRARY variable, then we provide
570 # targets for building them.
571 #---------------------------------------------------------
574 all-local:: $(LibName.LA)
576 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
577 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
578 $(Verb) $(Link) -o $@ $(ObjectsLO)
579 $(Verb) $(LTInstall) $@ $(LibDir)
582 ifneq ($(strip $(LibName.LA)),)
583 -$(Verb) $(RM) -f $(LibName.LA)
586 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
588 install-local:: $(DestSharedLib)
590 $(DestSharedLib): $(libdir) $(LibName.LA)
591 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
592 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
593 $(Verb) $(LIBTOOL) --finish $(libdir)
596 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
597 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
601 #---------------------------------------------------------
602 # Bytecode Library Targets:
603 # If the user asked for a bytecode library to be built
604 # with the BYTECODE_LIBRARY variable, then we provide
605 # targets for building them.
606 #---------------------------------------------------------
607 ifdef BYTECODE_LIBRARY
609 # make the C and C++ compilers strip debug info out of bytecode libraries.
610 BCCompile.C += -Wa,-strip-debug
611 BCCompile.CXX += -Wa,-strip-debug
613 all-local:: $(LibName.BCA)
615 ifdef EXPORTED_SYMBOL_FILE
616 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
617 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
619 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
620 $(LLVMToolDir)/llvm-ar
621 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
623 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
625 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
627 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
628 $(LLVMToolDir)/llvm-ar
629 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
631 $(Verb) $(LArchive) $@ $(ObjectsBC)
636 ifneq ($(strip $(LibName.BCA)),)
637 -$(Verb) $(RM) -f $(LibName.BCA)
640 ifdef BYTECODE_DESTINATION
641 BytecodeDestDir := $(BYTECODE_DESTINATION)
643 BytecodeDestDir := $(libdir)
646 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
648 install-bytecode-local:: $(DestBytecodeLib)
650 install-local:: $(DestBytecodeLib)
652 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
653 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
654 $(Verb) $(INSTALL) $(LibName.BCA) $@
657 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
658 -$(Verb) $(RM) -f $(DestBytecodeLib)
662 #---------------------------------------------------------
663 # ReLinked Library Targets:
664 # If the user didn't explicitly forbid building a
665 # relinked then we provide targets for building them.
666 #---------------------------------------------------------
667 ifndef DONT_BUILD_RELINKED
669 all-local:: $(LibName.O)
671 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
672 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
673 $(Verb) $(Relink) -o $@ $(ObjectsO)
676 ifneq ($(strip $(LibName.O)),)
677 -$(Verb) $(RM) -f $(LibName.O)
680 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
682 install-local:: $(DestRelinkedLib)
684 $(DestRelinkedLib): $(libdir) $(LibName.O)
685 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
686 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
689 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
690 -$(Verb) $(RM) -f $(DestRelinkedLib)
694 #---------------------------------------------------------
695 # Archive Library Targets:
696 # If the user wanted a regular archive library built,
697 # then we provide targets for building them.
698 #---------------------------------------------------------
701 all-local:: $(LibName.A)
703 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
704 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
706 $(Verb) $(Archive) $@ $(ObjectsO)
710 ifneq ($(strip $(LibName.A)),)
711 -$(Verb) $(RM) -f $(LibName.A)
714 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
716 install-local:: $(DestArchiveLib)
718 $(DestArchiveLib): $(libdir) $(LibName.A)
719 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
720 $(Verb) $(MKDIR) $(libdir)
721 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
724 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
725 -$(Verb) $(RM) -f $(DestArchiveLib)
732 ###############################################################################
733 # Tool Build Rules: Build executable tool based on TOOLNAME option
734 ###############################################################################
738 #---------------------------------------------------------
739 # Handle the special "JIT" value for LLVM_LIBS which is a
740 # shorthand for a bunch of libraries that get the correct
741 # JIT support for a tool that runs JIT.
742 #---------------------------------------------------------
743 ifeq ($(LLVMLIBS),JIT)
745 # Make sure we can get our own symbols in the tool
748 # Generic JIT libraries
749 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
751 # You can enable the X86 JIT on a non-X86 host by setting the flag
752 # ENABLE_X86_JIT on the make command line. If not, it will still be
753 # enabled automagically on an X86 host.
758 # What the X86 JIT requires
763 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
764 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
765 # enabled automagically on an SparcV9 host.
766 ifeq ($(ARCH), Sparc)
767 ENABLE_SPARCV9_JIT = 1
770 # What the Sparc JIT requires
771 ifdef ENABLE_SPARCV9_JIT
772 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
773 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
774 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
775 LLVMDataStructure.a LLVMSparcV9RegAlloc
778 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
779 # ENABLE_PPC_JIT on the make command line. If not, it will still be
780 # enabled automagically on an PowerPC host.
781 ifeq ($(ARCH), PowerPC)
785 # What the PowerPC JIT requires
787 JIT_LIBS += LLVMPowerPC
790 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
791 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
792 LLVMSystem.a $(PLATFORMLIBDL)
795 #---------------------------------------------------------
796 # Set up variables for building a tool.
797 #---------------------------------------------------------
799 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
801 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
803 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
804 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
805 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
806 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
807 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
808 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
809 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
810 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
812 #---------------------------------------------------------
813 # Tell make that we need to rebuild subdirectories before
814 # we can link the tool. This affects things like LLI which
815 # has library subdirectories.
816 #---------------------------------------------------------
817 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
819 #---------------------------------------------------------
820 # Provide targets for building the tools
821 #---------------------------------------------------------
822 all-local:: $(ToolBuildPath)
825 ifneq ($(strip $(ToolBuildPath)),)
826 -$(Verb) $(RM) -f $(ToolBuildPath)
830 $(ToolBuildPath): $(ExmplDir)/.dir
832 $(ToolBuildPath): $(ToolDir)/.dir
835 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
836 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
837 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
838 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
839 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
841 DestTool = $(bindir)/$(TOOLNAME)
843 install-local:: $(DestTool)
845 $(DestTool): $(bindir) $(ToolBuildPath)
846 $(Echo) Installing $(BuildMode) $(DestTool)
847 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
850 $(Echo) Uninstalling $(BuildMode) $(DestTool)
851 -$(Verb) $(RM) -f $(DestTool)
855 ###############################################################################
856 # Object Build Rules: Build object files based on sources
857 ###############################################################################
859 # Provide rule sets for when dependency generation is enabled
860 ifndef DISABLE_AUTO_DEPENDENCIES
862 #---------------------------------------------------------
863 # Create .lo files in the ObjDir directory from the .cpp and .c files...
864 #---------------------------------------------------------
867 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
868 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
869 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
870 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
871 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
873 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
874 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
875 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
876 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
877 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
879 #---------------------------------------------------------
880 # Create .o files in the ObjDir directory from the .cpp and .c files...
881 #---------------------------------------------------------
884 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
885 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
886 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
887 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
888 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
890 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
891 $(Echo) "Compiling $*.c for $(BuildMode) build"
892 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
893 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
894 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
898 #---------------------------------------------------------
899 # Create .bc files in the ObjDir directory from .cpp and .c files...
900 #---------------------------------------------------------
901 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
902 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
903 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
904 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
905 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
907 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
908 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
909 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
910 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
911 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
913 # Provide alternate rule sets if dependencies are disabled
918 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
919 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
920 $(LTCompile.CXX) $< -o $@
922 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
923 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
924 $(LTCompile.C) $< -o $@
928 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
929 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
930 $(Compile.CXX) $< -o $@
932 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
933 $(Echo) "Compiling $*.c for $(BuildMode) build"
934 $(Compile.C) $< -o $@
937 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
938 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
939 $(BCCompile.CXX) $< -o $@
941 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
942 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
943 $(BCCompile.C) $< -o $@
947 #---------------------------------------------------------
948 # Provide rule to build .bc files from .ll sources,
949 # regardless of dependencies
950 #---------------------------------------------------------
951 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
952 $(Echo) "Compiling $*.ll for $(BuildMode) build"
953 $(Verb) $(LLVMAS) $< -f -o $@
955 ###############################################################################
956 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
957 ###############################################################################
961 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
962 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
963 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
964 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
966 # All of these files depend on tblgen and the .td files.
967 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
969 # INCFiles rule: All of the tblgen generated files are emitted to
970 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
971 # us to only "touch" the real file if the contents of it change. IOW, if
972 # tblgen is modified, all of the .inc.tmp files are regereated, but no
973 # dependencies of the .inc files are, unless the contents of the .inc file
975 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
976 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
978 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
979 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
980 $(Echo) "Building $(<F) register names with tblgen"
981 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
983 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
984 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
985 $(Echo) "Building $(<F) register information header with tblgen"
986 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
988 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
989 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
990 $(Echo) "Building $(<F) register info implementation with tblgen"
991 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
993 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
994 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
995 $(Echo) "Building $(<F) instruction names with tblgen"
996 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
998 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
999 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1000 $(Echo) "Building $(<F) instruction information with tblgen"
1001 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1003 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1004 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1005 $(Echo) "Building $(<F) assembly writer with tblgen"
1006 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1008 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1009 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1010 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1011 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1013 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1014 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1015 $(Echo) "Building $(<F) code emitter with tblgen"
1016 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1019 -$(Verb) $(RM) -f $(INCFiles)
1023 ###############################################################################
1024 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1025 ###############################################################################
1027 #---------------------------------------------------------
1028 # Provide rules for generating a .cpp source file from
1029 # (f)lex input sources.
1030 #---------------------------------------------------------
1032 LexFiles := $(filter %.l,$(Sources))
1034 ifneq ($(LexFiles),)
1036 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1038 .PRECIOUS: $(LexOutput)
1040 # Note the extra sed filtering here, used to cut down on the warnings emited
1041 # by GCC. The last line is a gross hack to work around flex aparently not
1042 # being able to resize the buffer on a large token input. Currently, for
1043 # uninitialized string buffers in LLVM we can generate very long tokens, so
1044 # this is a hack around it.
1045 # FIXME. (f.e. char Buffer[10000] )
1047 $(Echo) Flexing $*.l
1048 $(Verb) $(FLEX) -t $< | \
1049 $(SED) 's/void yyunput/inline void yyunput/' | \
1050 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1051 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1055 -$(Verb) $(RM) -f $(LexOutput)
1056 $(Verb) $(RM) -f $(LexOutput)
1060 #---------------------------------------------------------
1061 # Provide rules for generating a .cpp and .h source files
1062 # from yacc (bison) input sources.
1063 #---------------------------------------------------------
1065 YaccFiles := $(filter %.y,$(Sources))
1066 ifneq ($(YaccFiles),)
1067 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1069 .PRECIOUS: $(YaccOutput)
1071 # Cancel built-in rules for yacc
1076 # Rule for building the bison parsers...
1078 $(Echo) "Bisoning $*.y"
1079 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1080 $(Verb) $(MV) -f $*.tab.c $*.cpp
1081 $(Verb) $(MV) -f $*.tab.h $*.h
1084 -$(Verb) $(RM) -f $(YaccOutput)
1085 $(Verb) $(RM) -f $(YaccOutput)
1088 ###############################################################################
1089 # OTHER RULES: Other rules needed
1090 ###############################################################################
1092 # To create postscript files from dot files...
1093 ifneq ($(DOT),false)
1095 $(DOT) -Tps < $< > $@
1098 $(Echo) "Cannot build $@: The program dot is not installed"
1101 # This rules ensures that header files that are removed still have a rule for
1102 # which they can be "generated." This allows make to ignore them and
1103 # reproduce the dependency lists.
1106 # Define clean-local to clean the current directory. Note that this uses a
1107 # very conservative approach ensuring that empty variables do not cause
1108 # errors or disastrous removal.
1110 ifneq ($(strip $(ObjDir)),)
1111 -$(Verb) $(RM) -rf $(ObjDir)
1113 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1114 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1115 -$(Verb) $(RM) -f *$(SHLIBEXT)
1119 -$(Verb) $(RM) -rf Debug Release Profile
1121 # Build tags database for Emacs/Xemacs:
1125 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1126 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1127 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1128 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1129 -name '*.cpp' -o -name '*.h' | \
1130 $(ETAGS) $(ETAGSFLAGS) -
1133 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1134 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1135 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1136 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1137 \( -name '*.cpp' -o -name '*.h' \) -print | \
1138 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1141 ###############################################################################
1142 # DEPENDENCIES: Include the dependency files if we should
1143 ###############################################################################
1144 ifndef DISABLE_AUTO_DEPENDENCIES
1146 # If its not one of the cleaning targets
1147 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1149 # Get the list of dependency files
1150 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1151 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1153 -include /dev/null $(DependFiles)
1159 ###############################################################################
1160 # CHECK: Running the test suite
1161 ###############################################################################
1164 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1165 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1166 $(EchoCmd) Running test suite ; \
1167 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1168 TESTSUITE=$(TESTSUITE) ; \
1170 $(EchoCmd) No Makefile in test directory ; \
1173 $(EchoCmd) No test directory ; \
1176 ###############################################################################
1177 # DISTRIBUTION: Handle construction of a distribution tarball
1178 ###############################################################################
1180 #------------------------------------------------------------------------
1181 # Define distribution related variables
1182 #------------------------------------------------------------------------
1183 DistName := $(LLVM_TARBALL_NAME)
1184 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1185 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1186 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1187 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1188 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1189 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1190 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1191 Makefile.config.in configure autoconf
1192 DistOther := $(notdir $(wildcard \
1193 $(BUILD_SRC_DIR)/*.h \
1194 $(BUILD_SRC_DIR)/*.td \
1195 $(BUILD_SRC_DIR)/*.def \
1196 $(BUILD_SRC_DIR)/*.ll \
1197 $(BUILD_SRC_DIR)/*.in))
1198 DistSubDirs := $(SubDirs)
1199 DistSources = $(Sources) $(EXTRA_DIST)
1200 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1202 #------------------------------------------------------------------------
1203 # We MUST build distribution with OBJ_DIR != SRC_DIR
1204 #------------------------------------------------------------------------
1205 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1206 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1207 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1211 #------------------------------------------------------------------------
1212 # Prevent catastrophic remove
1213 #------------------------------------------------------------------------
1214 ifeq ($(LLVM_TARBALL_NAME),)
1215 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1218 #------------------------------------------------------------------------
1219 # Prevent attempt to run dist targets from anywhere but the top level
1220 #------------------------------------------------------------------------
1223 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1224 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1228 #------------------------------------------------------------------------
1229 # Provide the top level targets
1230 #------------------------------------------------------------------------
1232 dist-gzip:: $(DistTarGZip)
1234 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1235 $(Echo) Packing gzipped distribution tar file.
1236 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1237 $(GZIP) -c > "$(DistTarGZip)"
1239 dist-bzip2:: $(DistTarBZ2)
1241 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1242 $(Echo) Packing bzipped distribution tar file.
1243 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1244 $(BZIP2) -c >$(DistTarBZ2)
1246 dist-zip:: $(DistZip)
1248 $(DistZip) : $(TopDistDir)/.makedistdir
1249 $(Echo) Packing zipped distribution file.
1250 $(Verb) rm -f $(DistZip)
1251 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1253 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1254 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1256 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1258 dist-check:: $(DistTarGZip)
1259 $(Echo) Checking distribution tar file.
1260 $(Verb) if test -d $(DistCheckDir) ; then \
1261 $(RM) -rf $(DistCheckDir) ; \
1263 $(Verb) $(MKDIR) $(DistCheckDir)
1264 $(Verb) cd $(DistCheckDir) && \
1265 $(MKDIR) $(DistCheckDir)/build && \
1266 $(MKDIR) $(DistCheckDir)/install && \
1267 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1269 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1270 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1273 $(MAKE) install && \
1274 $(MAKE) uninstall && \
1277 $(MAKE) dist-clean && \
1278 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1281 $(Echo) Cleaning distribution files
1282 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1287 #------------------------------------------------------------------------
1288 # Provide the recursive distdir target for building the distribution directory
1289 #------------------------------------------------------------------------
1290 distdir: $(DistDir)/.makedistdir
1291 $(DistDir)/.makedistdir: $(DistSources)
1292 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1293 if test -d "$(DistDir)" ; then \
1294 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1297 $(EchoCmd) Removing old $(DistDir) ; \
1298 $(RM) -rf $(DistDir); \
1299 $(EchoCmd) Making 'all' to verify build ; \
1302 $(Echo) Building Distribution Directory $(DistDir)
1303 $(Verb) $(MKDIR) $(DistDir)
1304 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1305 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1306 for file in $(DistFiles) ; do \
1308 $(BUILD_SRC_DIR)/*) \
1309 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1311 $(BUILD_SRC_ROOT)/*) \
1312 file=`echo "$$file" | \
1313 sed "s#^$$srcrootstrip/##"` \
1316 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1317 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1318 from_dir="$(BUILD_SRC_DIR)" ; \
1319 elif test -f "$$file" || test -d "$$file" ; then \
1322 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1323 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1324 to_dir="$(DistDir)/$$dir"; \
1325 $(MKDIR) "$$to_dir" ; \
1327 to_dir="$(DistDir)"; \
1329 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1330 if test -n "$$mid_dir" ; then \
1331 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1333 if test -d "$$from_dir/$$file"; then \
1334 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1335 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1336 $(CP) -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1338 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1339 elif test -f "$$from_dir/$$file" ; then \
1340 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1341 elif test -L "$$from_dir/$$file" ; then \
1342 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1343 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1344 $(EchoCmd) "===== WARNING: Distribution Source " \
1345 "$$from_dir/$$file Not Found!" ; \
1346 elif test "$(Verb)" != '@' ; then \
1347 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1350 $(Verb) for subdir in $(DistSubDirs) ; do \
1351 if test "$$subdir" \!= "." ; then \
1352 new_distdir="$(DistDir)/$$subdir" ; \
1353 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1354 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1358 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1359 $(EchoCmd) Eliminating CVS directories from distribution ; \
1360 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1361 $(MAKE) dist-hook ; \
1362 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1363 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1364 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1365 -o ! -type d ! -perm -444 -exec \
1366 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1367 || chmod -R a+r $(DistDir) ; \
1370 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1376 ###############################################################################
1377 # TOP LEVEL - targets only to apply at the top level directory
1378 ###############################################################################
1382 #------------------------------------------------------------------------
1383 # Install support for the project's include files:
1384 #------------------------------------------------------------------------
1386 $(Echo) Installing include files
1387 $(Verb) $(MKDIR) $(includedir)
1388 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1389 cd $(BUILD_SRC_ROOT)/include && \
1390 find . -path '*/Internal' -prune -o '(' -type f \
1391 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1392 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1396 $(Echo) Uninstalling include files
1397 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1398 cd $(BUILD_SRC_ROOT)/include && \
1399 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1400 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1401 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1406 #------------------------------------------------------------------------
1407 # Print out the directories used for building
1408 #------------------------------------------------------------------------
1410 $(Echo) "BuildMode : " '$(BuildMode)'
1411 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1412 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1413 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1414 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1415 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1416 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1417 $(Echo) "libdir : " '$(libdir)'
1418 $(Echo) "bindir : " '$(bindir)'
1419 $(Echo) "sysconfdir : " '$(sysconfdir)'
1420 $(Echo) "UserTargets : " '$(UserTargets)'
1421 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1422 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1423 $(Echo) "ObjDir : " '$(ObjDir)'
1424 $(Echo) "LibDir : " '$(LibDir)'
1425 $(Echo) "ToolDir : " '$(ToolDir)'
1426 $(Echo) "ExmplDir : " '$(ExmplDir)'
1427 $(Echo) "Sources : " '$(Sources)'
1428 $(Echo) "TDFiles : " '$(TDFiles)'
1429 $(Echo) "INCFiles : " '$(INCFiles)'
1430 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1431 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1432 $(Echo) "Compile.C : " '$(Compile.C)'
1433 $(Echo) "Archive : " '$(Archive)'
1434 $(Echo) "YaccFiles : " '$(YaccFiles)'
1435 $(Echo) "LexFiles : " '$(LexFiles)'
1436 $(Echo) "Module : " '$(Module)'