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
32 include/llvm/Config/config.h \
33 include/llvm/Support/DataTypes.h \
34 include/llvm/ADT/hash_map \
35 include/llvm/ADT/hash_set \
36 include/llvm/ADT/iterator
38 ################################################################################
39 # INITIALIZATION: Basic things the makefile needs
40 ################################################################################
42 #--------------------------------------------------------------------
43 # Set the VPATH so that we can find source files.
44 #--------------------------------------------------------------------
47 #--------------------------------------------------------------------
48 # Reset the list of suffixes we know how to build
49 #--------------------------------------------------------------------
51 .SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot
52 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
54 #--------------------------------------------------------------------
55 # Mark all of these targets as phony to avoid implicit rule search
56 #--------------------------------------------------------------------
57 .PHONY: $(UserTargets) $(InternalTargets)
59 #--------------------------------------------------------------------
60 # Make sure all the user-target rules are double colon rules and
61 # they are defined first.
62 #--------------------------------------------------------------------
66 ################################################################################
67 # PRECONDITIONS: that which must be built/checked first
68 ################################################################################
70 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
71 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
72 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
73 ConfigureScript := $(PROJ_SRC_ROOT)/configure
74 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
75 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
76 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
77 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
78 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
79 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
80 ifneq ($(MakefileCommonIn),)
81 PreConditions += $(MakefileCommon)
83 ifneq ($(MakefileConfigIn),)
84 PreConditions += $(MakefileConfig)
87 FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
88 PreConditions += $(FilesToConfigPATH)
90 preconditions : $(PreConditions)
92 #------------------------------------------------------------------------
93 # Make sure the BUILT_SOURCES are built first
94 #------------------------------------------------------------------------
95 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
98 ifneq ($(strip $(BUILT_SOURCES)),)
99 -$(Verb) $(RM) -f $(BUILT_SOURCES)
102 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
104 $(Verb) if test -x config.status ; then \
105 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
106 $(MKDIR) .spotless.save ; \
107 $(MV) config.status .spotless.save ; \
108 $(MV) mklib .spotless.save ; \
109 $(MV) projects .spotless.save ; \
111 $(MV) .spotless.save/config.status . ; \
112 $(MV) .spotless.save/mklib . ; \
113 $(MV) .spotless.save/projects . ; \
114 $(RM) -rf .spotless.save ; \
115 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
116 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
117 $(ConfigStatusScript) ; \
119 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
123 $(BUILT_SOURCES) : $(ObjMakefiles)
125 #------------------------------------------------------------------------
126 # Make sure we're not using a stale configuration
127 #------------------------------------------------------------------------
129 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
130 $(Verb) cd $(PROJ_OBJ_ROOT) && \
131 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
132 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
134 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
135 $(ConfigStatusScript)
137 .PRECIOUS: $(ConfigStatusScript)
138 $(ConfigStatusScript): $(ConfigureScript)
139 $(Echo) Reconfiguring with $<
140 $(Verb) cd $(PROJ_OBJ_ROOT) && \
141 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
142 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
144 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
145 $(ConfigStatusScript)
147 #------------------------------------------------------------------------
148 # If we're buildilng LLVM, then make sure the generated headers are Up2Dt
149 #------------------------------------------------------------------------
150 ifeq ($(LLVM_OBJ_ROOT),$(PROJ_OBJ_ROOT))
151 .PRECIOUS: $(FilesToConfigPATH)
152 $(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
153 $(Echo) Regenerating $*
154 $(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
157 #------------------------------------------------------------------------
158 # Make sure the configuration makefile is up to date
159 #------------------------------------------------------------------------
160 ifneq ($(MakefileConfigIn),)
161 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
162 $(Echo) Regenerating $@
163 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
166 ifneq ($(MakefileCommonIn),)
167 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
168 $(Echo) Regenerating $@
169 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
172 #------------------------------------------------------------------------
173 # If the Makefile in the source tree has been updated, copy it over into the
174 # build tree. But, only do this if the source and object makefiles differ
175 #------------------------------------------------------------------------
176 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
178 Makefile: $(PROJ_SRC_DIR)/Makefile
179 $(Echo) "Updating Makefile"
180 $(Verb) $(MKDIR) $(@D)
181 $(Verb) $(CP) -f $< $@
183 # Copy the Makefile.* files unless we're in the root directory which avoids
184 # the copying of Makefile.config.in or other things that should be explicitly
186 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
188 *Makefile.rules) ;; \
190 *) $(Echo) "Updating $(@F)" ; \
197 #------------------------------------------------------------------------
198 # Set up the basic dependencies
199 #------------------------------------------------------------------------
200 $(UserTargets):: $(PreConditions)
204 clean-all:: clean-local clean-all-local
205 install:: install-local
206 uninstall:: uninstall-local
207 install-local:: all-local
208 install-bytecode:: install-bytecode-local
210 ###############################################################################
211 # VARIABLES: Set up various variables based on configuration data
212 ###############################################################################
214 #--------------------------------------------------------------------
215 # Variables derived from configuration we are building
216 #--------------------------------------------------------------------
219 ifdef ENABLE_PROFILING
221 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
222 C.Flags := -O3 -DNDEBUG -pg
223 LD.Flags := -O3 -DNDEBUG -pg
225 ifdef ENABLE_OPTIMIZED
227 # Don't use -fomit-frame-pointer on FreeBSD
228 ifneq ($(OS),FreeBSD)
229 OmitFramePointer := -fomit-frame-pointer
231 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors \
233 C.Flags := -O3 -DNDEBUG $(OmitFramePointer)
234 LD.Flags := -O3 -DNDEBUG
237 CXX.Flags := -g -D_DEBUG
238 C.Flags := -g -D_DEBUG
239 LD.Flags := -g -D_DEBUG
244 CXX.Flags += $(CXXFLAGS)
246 CPP.Flags += $(CPPFLAGS)
247 LD.Flags += $(LDFLAGS)
249 LibTool.Flags := --tag=CXX
251 #Make Floating point ieee complient on alpha
257 #--------------------------------------------------------------------
258 # Directory locations
259 #--------------------------------------------------------------------
260 ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
261 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
262 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
263 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
264 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
265 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
266 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
267 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
269 #--------------------------------------------------------------------
270 # Full Paths To Compiled Tools and Utilities
271 #--------------------------------------------------------------------
272 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
275 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
278 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
281 BURG := $(LLVMToolDir)/burg$(EXEEXT)
284 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
287 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
290 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
293 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
296 LLI := $(LLVMToolDir)/lli$(EXEEXT)
299 LLC := $(LLVMToolDir)/llc$(EXEEXT)
302 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
305 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
308 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
309 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
311 #--------------------------------------------------------------------
312 # Adjust to user's request
313 #--------------------------------------------------------------------
315 # Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
316 # to be built. Note that if LOADABLE_MODULE is specified then the resulting
317 # shared library can be opened with dlopen
319 LD.Flags += -rpath $(LibDir)
320 ifdef LOADABLE_MODULE
324 LibTool.Flags += --tag=disable-shared
334 # Adjust settings for verbose mode
337 LibTool.Flags += --silent
338 AR.Flags += >/dev/null 2>/dev/null
339 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
341 ConfigureScriptFLAGS :=
344 # By default, strip symbol information from executable
346 Strip := $(PLATFORMSTRIPOPTS)
347 StripWarnMsg := "(without symbols)"
348 Install.StripFlag += -s
351 # Adjust linker flags for building an executable
354 LD.Flags += -rpath $(ExmplDir) -export-dynamic
356 LD.Flags += -rpath $(ToolDir) -export-dynamic
360 #----------------------------------------------------------
361 # Options To Invoke Tools
362 #----------------------------------------------------------
364 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
367 CompileCommonOpts += -D_REENTRANT -D_HPUX_SOURCE
370 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
371 CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
372 -I$(PROJ_OBJ_ROOT)/include \
373 -I$(PROJ_SRC_ROOT)/include \
374 -I$(LLVM_OBJ_ROOT)/include \
375 -I$(LLVM_SRC_ROOT)/include \
376 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
378 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
379 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
380 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
382 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
383 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
384 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
386 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
387 $(CompileCommonOpts) $(LD.Flags) $(Strip)
388 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
390 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
392 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
393 DataInstall = $(INSTALL) -m 0644
394 Burg = $(BURG) -I $(PROJ_SRC_DIR)
395 TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR)
396 Archive = $(AR) $(AR.Flags)
397 LArchive = $(LLVMToolDir)/llvm-ar rcsf
404 #----------------------------------------------------------
405 # Get the list of source files and compute object file
407 #----------------------------------------------------------
410 FakeSources := $(FAKE_SOURCES)
412 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
414 BaseNameSources := $(sort $(basename $(FakeSources)))
415 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
416 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
417 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
420 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
421 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
422 $(PROJ_SRC_DIR)/*.l))
424 Sources := $(SOURCES)
428 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
431 BaseNameSources := $(sort $(basename $(Sources)))
432 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
433 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
434 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
437 ###############################################################################
438 # DIRECTORIES: Handle recursive descent of directory structure
439 ###############################################################################
441 #---------------------------------------------------------
442 # Provide rules to make install dirs. This must be early
443 # in the file so they get built before dependencies
444 #---------------------------------------------------------
446 $(PROJ_bindir): $(PROJ_bindir)/.dir
447 $(PROJ_libdir): $(PROJ_libdir)/.dir
448 $(PROJ_includedir): $(PROJ_includedir)/.dir
449 $(PROJ_etcdir): $(PROJ_etcdir)/.dir
451 # To create other directories, as needed, and timestamp their creation
453 $(Verb) $(MKDIR) $* > /dev/null
456 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
457 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
459 #---------------------------------------------------------
460 # Handle the DIRS options for sequential construction
461 #---------------------------------------------------------
466 $(RecursiveTargets)::
467 $(Verb) for dir in $(DIRS); do \
468 if [ ! -f $$dir/Makefile ]; then \
470 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
472 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
473 ($(MAKE) -C $$dir $@ ) || exit 1; \
478 #---------------------------------------------------------
479 # Handle the EXPERIMENTAL_DIRS options ensuring success
480 # after each directory is built.
481 #---------------------------------------------------------
482 ifdef EXPERIMENTAL_DIRS
483 $(RecursiveTargets)::
484 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
485 if [ ! -f $$dir/Makefile ]; then \
487 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
489 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
490 ($(MAKE) -C $$dir $@ ) || exit 0; \
495 #---------------------------------------------------------
496 # Handle the PARALLEL_DIRS options for parallel construction
497 #---------------------------------------------------------
500 SubDirs += $(PARALLEL_DIRS)
502 # Unfortunately, this list must be maintained if new recursive targets are added
503 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
504 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
505 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
506 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
507 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
508 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
510 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
513 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
515 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
517 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
518 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
522 #---------------------------------------------------------
523 # Handle the OPTIONAL_DIRS options for directores that may
525 #---------------------------------------------------------
528 SubDirs += $(OPTIONAL_DIRS)
530 $(RecursiveTargets)::
531 $(Verb) for dir in $(OPTIONAL_DIRS); do \
532 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
533 if [ ! -f $$dir/Makefile ]; then \
535 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
537 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
538 ($(MAKE) -C$$dir $@ ) || exit 1; \
544 #---------------------------------------------------------
545 # Handle the CONFIG_FILES options
546 #---------------------------------------------------------
549 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
550 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
551 $(Verb)for file in $(CONFIG_FILES); do \
552 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
553 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
554 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
555 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
557 $(ECHO) Error: cannot find config file $${file}. ; \
562 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
563 $(Verb)for file in $(CONFIG_FILES); do \
564 $(RM) -f $(PROJ_etcdir)/$${file} ; \
569 ###############################################################################
570 # Set up variables for building libararies
571 ###############################################################################
573 #---------------------------------------------------------
574 # Handle the special "JIT" value for LLVM_LIBS which is a
575 # shorthand for a bunch of libraries that get the correct
576 # JIT support for a library or a tool that runs JIT.
577 #---------------------------------------------------------
578 ifeq ($(LLVMLIBS),JIT)
580 # Make sure we can get our own symbols in the tool
583 # Generic JIT libraries
584 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
586 # You can enable the X86 JIT on a non-X86 host by setting the flag
587 # ENABLE_X86_JIT on the make command line. If not, it will still be
588 # enabled automagically on an X86 host.
593 # What the X86 JIT requires
595 JIT_LIBS += LLVMX86 LLVMSelectionDAG
598 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
599 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
600 # enabled automagically on an SparcV9 host.
601 ifeq ($(ARCH), Sparc)
602 ENABLE_SPARCV9_JIT = 1
605 # What the Sparc JIT requires
606 ifdef ENABLE_SPARCV9_JIT
607 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
608 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
609 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
610 LLVMDataStructure.a LLVMSparcV9RegAlloc
613 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
614 # ENABLE_PPC_JIT on the make command line. If not, it will still be
615 # enabled automagically on an PowerPC host.
616 ifeq ($(ARCH), PowerPC)
620 # What the PowerPC JIT requires
622 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
625 # You can enable the Alpha JIT on a non-Alpha host by setting the flag
626 # ENABLE_ALPHA_JIT on the make command line. If not, it will still be
627 # enabled automagically on an Alpha host.
628 ifeq ($(ARCH), Alpha)
632 # What the Alpha JIT requires
633 ifdef ENABLE_ALPHA_JIT
634 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
637 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
638 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
639 LLVMSystem.a $(PLATFORMLIBDL)
642 #---------------------------------------------------------
643 # Define various command line options pertaining to the
644 # libraries needed when linking. There are "Proj" libs
645 # (defined by the user's project) and "LLVM" libs (defined
646 # by the # LLVM project).
647 #---------------------------------------------------------
648 # Some versions of gcc on Alpha produce too many symbols, so use a .a file
650 USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
651 LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
654 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
655 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
656 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
657 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
658 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
659 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
660 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
661 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
663 ###############################################################################
664 # Library Build Rules: Four ways to build a library
665 ###############################################################################
667 #---------------------------------------------------------
668 # Bytecode Module Targets:
669 # If the user set MODULE_NAME then they want to build a
670 # bytecode module from the sources. We compile all the
671 # sources and link it together into a single bytecode
673 #---------------------------------------------------------
676 ifeq ($(strip $(LLVMGCC)),)
677 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
680 Module := $(LibDir)/$(MODULE_NAME).bc
681 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
683 ifdef EXPORTED_SYMBOL_FILE
684 LinkModule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
687 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
688 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
689 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
691 all-local:: $(Module)
694 ifneq ($(strip $(Module)),)
695 -$(Verb) $(RM) -f $(Module)
698 ifdef BYTECODE_DESTINATION
699 ModuleDestDir := $(BYTECODE_DESTINATION)
701 ModuleDestDir := $(PROJ_libdir)
704 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
706 install-module:: $(DestModule)
707 install-local:: $(DestModule)
709 $(DestModule): $(ModuleDestDir) $(Module)
710 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
711 $(Verb) $(DataInstall) $(Module) $(DestModule)
714 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
715 -$(Verb) $(RM) -f $(DestModule)
720 # if we're building a library ...
723 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
724 LIBRARYNAME := $(strip $(LIBRARYNAME))
725 ifdef LOADABLE_MODULE
726 LibName.LA := $(LibDir)/$(LIBRARYNAME).la
728 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
730 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
731 LibName.O := $(LibDir)/$(LIBRARYNAME).o
732 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
734 #---------------------------------------------------------
735 # Shared Library Targets:
736 # If the user asked for a shared library to be built
737 # with the SHARED_LIBRARY variable, then we provide
738 # targets for building them.
739 #---------------------------------------------------------
742 all-local:: $(LibName.LA)
744 ifdef LINK_LIBS_IN_SHARED
745 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
746 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
747 $(Verb) $(Link) -o $@ $(ObjectsLO) \
748 $(ProjLibsOptions) $(LLVMLibsOptions)
749 $(Verb) $(LTInstall) $@ $(LibDir)
751 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
752 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
753 $(Verb) $(Link) -o $@ $(ObjectsLO)
754 $(Verb) $(LTInstall) $@ $(LibDir)
758 ifneq ($(strip $(LibName.LA)),)
759 -$(Verb) $(RM) -f $(LibName.LA)
762 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
764 install-local:: $(DestSharedLib)
766 $(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
767 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
768 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
769 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
772 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
773 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
777 #---------------------------------------------------------
778 # Bytecode Library Targets:
779 # If the user asked for a bytecode library to be built
780 # with the BYTECODE_LIBRARY variable, then we provide
781 # targets for building them.
782 #---------------------------------------------------------
783 ifdef BYTECODE_LIBRARY
784 ifeq ($(strip $(LLVMGCC)),)
785 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
788 # make the C and C++ compilers strip debug info out of bytecode libraries.
789 BCCompile.C += -Wa,-strip-debug
790 BCCompile.CXX += -Wa,-strip-debug
792 all-local:: $(LibName.BCA)
794 ifdef EXPORTED_SYMBOL_FILE
795 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
796 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
798 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
799 $(LLVMToolDir)/llvm-ar
800 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
802 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
804 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
806 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
807 $(LLVMToolDir)/llvm-ar
808 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
810 $(Verb) $(LArchive) $@ $(ObjectsBC)
815 ifneq ($(strip $(LibName.BCA)),)
816 -$(Verb) $(RM) -f $(LibName.BCA)
819 ifdef BYTECODE_DESTINATION
820 BytecodeDestDir := $(BYTECODE_DESTINATION)
822 BytecodeDestDir := $(PROJ_libdir)
825 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
827 install-bytecode-local:: $(DestBytecodeLib)
829 install-local:: $(DestBytecodeLib)
831 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
832 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
833 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
836 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
837 -$(Verb) $(RM) -f $(DestBytecodeLib)
842 #---------------------------------------------------------
843 # ReLinked Library Targets:
844 # If the user didn't explicitly forbid building a
845 # relinked then we provide targets for building them.
846 #---------------------------------------------------------
847 ifndef DONT_BUILD_RELINKED
849 all-local:: $(LibName.O)
851 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
852 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
853 $(Verb) $(Relink) -o $@ $(ObjectsO)
856 ifneq ($(strip $(LibName.O)),)
857 -$(Verb) $(RM) -f $(LibName.O)
860 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
862 install-local:: $(DestRelinkedLib)
864 $(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
865 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
866 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
869 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
870 -$(Verb) $(RM) -f $(DestRelinkedLib)
874 #---------------------------------------------------------
875 # Archive Library Targets:
876 # If the user wanted a regular archive library built,
877 # then we provide targets for building them.
878 #---------------------------------------------------------
881 all-local:: $(LibName.A)
883 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
884 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
886 $(Verb) $(Archive) $@ $(ObjectsO)
890 ifneq ($(strip $(LibName.A)),)
891 -$(Verb) $(RM) -f $(LibName.A)
894 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
896 install-local:: $(DestArchiveLib)
898 $(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
899 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
900 $(Verb) $(MKDIR) $(PROJ_libdir)
901 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
904 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
905 -$(Verb) $(RM) -f $(DestArchiveLib)
912 ###############################################################################
913 # Tool Build Rules: Build executable tool based on TOOLNAME option
914 ###############################################################################
918 #---------------------------------------------------------
919 # Set up variables for building a tool.
920 #---------------------------------------------------------
922 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
924 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
927 #---------------------------------------------------------
928 # Tell make that we need to rebuild subdirectories before
929 # we can link the tool. This affects things like LLI which
930 # has library subdirectories.
931 #---------------------------------------------------------
932 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
934 #---------------------------------------------------------
935 # Provide targets for building the tools
936 #---------------------------------------------------------
937 all-local:: $(ToolBuildPath)
940 ifneq ($(strip $(ToolBuildPath)),)
941 -$(Verb) $(RM) -f $(ToolBuildPath)
945 $(ToolBuildPath): $(ExmplDir)/.dir
947 $(ToolBuildPath): $(ToolDir)/.dir
950 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
951 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
952 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
953 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
954 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
956 DestTool = $(PROJ_bindir)/$(TOOLNAME)
958 install-local:: $(DestTool)
960 $(DestTool): $(PROJ_bindir) $(ToolBuildPath)
961 $(Echo) Installing $(BuildMode) $(DestTool)
962 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
965 $(Echo) Uninstalling $(BuildMode) $(DestTool)
966 -$(Verb) $(RM) -f $(DestTool)
970 ###############################################################################
971 # Object Build Rules: Build object files based on sources
972 ###############################################################################
974 # Provide rule sets for when dependency generation is enabled
975 ifndef DISABLE_AUTO_DEPENDENCIES
977 #---------------------------------------------------------
978 # Create .lo files in the ObjDir directory from the .cpp and .c files...
979 #---------------------------------------------------------
982 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
983 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
984 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
985 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
986 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
988 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
989 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
990 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
991 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
992 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
994 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
995 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
996 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
997 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
998 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
1000 #---------------------------------------------------------
1001 # Create .o files in the ObjDir directory from the .cpp and .c files...
1002 #---------------------------------------------------------
1005 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1006 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
1007 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1008 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1009 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1011 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1012 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1013 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1014 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1015 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1017 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1018 $(Echo) "Compiling $*.c for $(BuildMode) build"
1019 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1020 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1021 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
1025 #---------------------------------------------------------
1026 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1027 #---------------------------------------------------------
1028 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1029 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1030 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1031 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1032 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1034 $(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1035 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1036 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1037 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1038 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1040 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1041 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1042 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
1043 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1044 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
1046 # Provide alternate rule sets if dependencies are disabled
1049 ifdef SHARED_LIBRARY
1051 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1052 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
1053 $(LTCompile.CXX) $< -o $@
1055 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1056 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1057 $(LTCompile.CXX) $< -o $@
1059 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1060 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
1061 $(LTCompile.C) $< -o $@
1065 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1066 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
1067 $(Compile.CXX) $< -o $@
1069 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1070 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1071 $(Compile.CXX) $< -o $@
1073 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1074 $(Echo) "Compiling $*.c for $(BuildMode) build"
1075 $(Compile.C) $< -o $@
1078 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1079 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1080 $(BCCompile.CXX) $< -o $@
1082 $(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1083 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1084 $(BCCompile.CXX) $< -o $@
1086 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1087 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1088 $(BCCompile.C) $< -o $@
1092 #---------------------------------------------------------
1093 # Provide rule to build .bc files from .ll sources,
1094 # regardless of dependencies
1095 #---------------------------------------------------------
1096 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1097 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1098 $(Verb) $(LLVMAS) $< -f -o $@
1100 ###############################################################################
1101 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1102 ###############################################################################
1106 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
1107 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1108 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1109 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1111 # All of these files depend on tblgen and the .td files.
1112 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1114 # INCFiles rule: All of the tblgen generated files are emitted to
1115 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1116 # us to only "touch" the real file if the contents of it change. IOW, if
1117 # tblgen is modified, all of the .inc.tmp files are regereated, but no
1118 # dependencies of the .inc files are, unless the contents of the .inc file
1120 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1121 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1123 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1124 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1125 $(Echo) "Building $(<F) register names with tblgen"
1126 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
1128 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1129 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1130 $(Echo) "Building $(<F) register information header with tblgen"
1131 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
1133 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1134 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1135 $(Echo) "Building $(<F) register info implementation with tblgen"
1136 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
1138 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1139 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1140 $(Echo) "Building $(<F) instruction names with tblgen"
1141 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
1143 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1144 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1145 $(Echo) "Building $(<F) instruction information with tblgen"
1146 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1148 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1149 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1150 $(Echo) "Building $(<F) assembly writer with tblgen"
1151 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1153 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1154 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1155 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1156 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1158 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1159 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1160 $(Echo) "Building $(<F) code emitter with tblgen"
1161 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1164 -$(Verb) $(RM) -f $(INCFiles)
1168 ###############################################################################
1169 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1170 ###############################################################################
1172 #---------------------------------------------------------
1173 # Provide rules for generating a .cpp source file from
1174 # (f)lex input sources.
1175 #---------------------------------------------------------
1177 LexFiles := $(filter %.l,$(Sources))
1179 ifneq ($(LexFiles),)
1181 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1183 .PRECIOUS: $(LexOutput)
1185 # Note the extra sed filtering here, used to cut down on the warnings emited
1186 # by GCC. The last line is a gross hack to work around flex aparently not
1187 # being able to resize the buffer on a large token input. Currently, for
1188 # uninitialized string buffers in LLVM we can generate very long tokens, so
1189 # this is a hack around it.
1190 # FIXME. (f.e. char Buffer[10000] )
1192 $(Echo) Flexing $*.l
1193 $(Verb) $(FLEX) -t $< | \
1194 $(SED) 's/void yyunput/inline void yyunput/' | \
1195 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1196 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1200 -$(Verb) $(RM) -f $(LexOutput)
1201 $(Verb) $(RM) -f $(LexOutput)
1205 #---------------------------------------------------------
1206 # Provide rules for generating a .cpp and .h source files
1207 # from yacc (bison) input sources.
1208 #---------------------------------------------------------
1210 YaccFiles := $(filter %.y,$(Sources))
1211 ifneq ($(YaccFiles),)
1212 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1214 .PRECIOUS: $(YaccOutput)
1216 # Cancel built-in rules for yacc
1221 # Rule for building the bison parsers...
1223 $(Echo) "Bisoning $*.y"
1224 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1225 $(Verb) $(MV) -f $*.tab.c $*.cpp
1226 $(Verb) $(MV) -f $*.tab.h $*.h
1229 -$(Verb) $(RM) -f $(YaccOutput)
1230 $(Verb) $(RM) -f $(YaccOutput)
1233 ###############################################################################
1234 # OTHER RULES: Other rules needed
1235 ###############################################################################
1237 # To create postscript files from dot files...
1238 ifneq ($(DOT),false)
1240 $(DOT) -Tps < $< > $@
1243 $(Echo) "Cannot build $@: The program dot is not installed"
1246 # This rules ensures that header files that are removed still have a rule for
1247 # which they can be "generated." This allows make to ignore them and
1248 # reproduce the dependency lists.
1252 # Define clean-local to clean the current directory. Note that this uses a
1253 # very conservative approach ensuring that empty variables do not cause
1254 # errors or disastrous removal.
1256 ifneq ($(strip $(ObjDir)),)
1257 -$(Verb) $(RM) -rf $(ObjDir)
1259 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1260 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1261 -$(Verb) $(RM) -f *$(SHLIBEXT)
1265 -$(Verb) $(RM) -rf Debug Release Profile
1267 # Build tags database for Emacs/Xemacs:
1271 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1272 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1273 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1274 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1275 -name '*.cpp' -o -name '*.h' | \
1276 $(ETAGS) $(ETAGSFLAGS) -
1279 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1280 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1281 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1282 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1283 \( -name '*.cpp' -o -name '*.h' \) -print | \
1284 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
1287 ###############################################################################
1288 # DEPENDENCIES: Include the dependency files if we should
1289 ###############################################################################
1290 ifndef DISABLE_AUTO_DEPENDENCIES
1292 # If its not one of the cleaning targets
1293 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1295 # Get the list of dependency files
1296 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1297 DependFiles := $(patsubst %,$(PROJ_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1299 -include /dev/null $(DependFiles)
1305 ###############################################################################
1306 # CHECK: Running the test suite
1307 ###############################################################################
1310 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1311 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1312 $(EchoCmd) Running test suite ; \
1313 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1314 TESTSUITE=$(TESTSUITE) ; \
1316 $(EchoCmd) No Makefile in test directory ; \
1319 $(EchoCmd) No test directory ; \
1322 ###############################################################################
1323 # DISTRIBUTION: Handle construction of a distribution tarball
1324 ###############################################################################
1326 #------------------------------------------------------------------------
1327 # Define distribution related variables
1328 #------------------------------------------------------------------------
1329 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1330 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1331 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1332 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1333 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1334 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1335 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1336 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1337 Makefile.config.in configure autoconf
1338 DistOther := $(notdir $(wildcard \
1339 $(PROJ_SRC_DIR)/*.h \
1340 $(PROJ_SRC_DIR)/*.td \
1341 $(PROJ_SRC_DIR)/*.def \
1342 $(PROJ_SRC_DIR)/*.ll \
1343 $(PROJ_SRC_DIR)/*.in))
1344 DistSubDirs := $(SubDirs)
1345 DistSources = $(Sources) $(EXTRA_DIST)
1346 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1348 #------------------------------------------------------------------------
1349 # We MUST build distribution with OBJ_DIR != SRC_DIR
1350 #------------------------------------------------------------------------
1351 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1352 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1353 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1357 #------------------------------------------------------------------------
1358 # Prevent attempt to run dist targets from anywhere but the top level
1359 #------------------------------------------------------------------------
1361 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1362 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1365 #------------------------------------------------------------------------
1366 # Provide the top level targets
1367 #------------------------------------------------------------------------
1369 dist-gzip:: $(DistTarGZip)
1371 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1372 $(Echo) Packing gzipped distribution tar file.
1373 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1374 $(GZIP) -c > "$(DistTarGZip)"
1376 dist-bzip2:: $(DistTarBZ2)
1378 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1379 $(Echo) Packing bzipped distribution tar file.
1380 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1381 $(BZIP2) -c >$(DistTarBZ2)
1383 dist-zip:: $(DistZip)
1385 $(DistZip) : $(TopDistDir)/.makedistdir
1386 $(Echo) Packing zipped distribution file.
1387 $(Verb) rm -f $(DistZip)
1388 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1390 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1391 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1393 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1395 dist-check:: $(DistTarGZip)
1396 $(Echo) Checking distribution tar file.
1397 $(Verb) if test -d $(DistCheckDir) ; then \
1398 $(RM) -rf $(DistCheckDir) ; \
1400 $(Verb) $(MKDIR) $(DistCheckDir)
1401 $(Verb) cd $(DistCheckDir) && \
1402 $(MKDIR) $(DistCheckDir)/build && \
1403 $(MKDIR) $(DistCheckDir)/install && \
1404 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1406 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1407 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1410 $(MAKE) install && \
1411 $(MAKE) uninstall && \
1414 $(MAKE) dist-clean && \
1415 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1418 $(Echo) Cleaning distribution files
1419 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1424 #------------------------------------------------------------------------
1425 # Provide the recursive distdir target for building the distribution directory
1426 #------------------------------------------------------------------------
1427 distdir: $(DistDir)/.makedistdir
1428 $(DistDir)/.makedistdir: $(DistSources)
1429 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1430 if test -d "$(DistDir)" ; then \
1431 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1434 $(EchoCmd) Removing old $(DistDir) ; \
1435 $(RM) -rf $(DistDir); \
1436 $(EchoCmd) Making 'all' to verify build ; \
1439 $(Echo) Building Distribution Directory $(DistDir)
1440 $(Verb) $(MKDIR) $(DistDir)
1441 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1442 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1443 for file in $(DistFiles) ; do \
1445 $(PROJ_SRC_DIR)/*) \
1446 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1448 $(PROJ_SRC_ROOT)/*) \
1449 file=`echo "$$file" | \
1450 sed "s#^$$srcrootstrip/##"` \
1453 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1454 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1455 from_dir="$(PROJ_SRC_DIR)" ; \
1456 elif test -f "$$file" || test -d "$$file" ; then \
1459 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1460 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1461 to_dir="$(DistDir)/$$dir"; \
1462 $(MKDIR) "$$to_dir" ; \
1464 to_dir="$(DistDir)"; \
1466 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1467 if test -n "$$mid_dir" ; then \
1468 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1470 if test -d "$$from_dir/$$file"; then \
1471 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1472 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1473 cd $(PROJ_SRC_DIR) ; \
1474 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1475 ( cd $$to_dir ; $(TAR) xf - ) ; \
1476 cd $(PROJ_OBJ_DIR) ; \
1479 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1480 ( cd $$to_dir ; $(TAR) xf - ) ; \
1481 cd $(PROJ_OBJ_DIR) ; \
1483 elif test -f "$$from_dir/$$file" ; then \
1484 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1485 elif test -L "$$from_dir/$$file" ; then \
1486 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1487 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1488 $(EchoCmd) "===== WARNING: Distribution Source " \
1489 "$$from_dir/$$file Not Found!" ; \
1490 elif test "$(Verb)" != '@' ; then \
1491 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1494 $(Verb) for subdir in $(DistSubDirs) ; do \
1495 if test "$$subdir" \!= "." ; then \
1496 new_distdir="$(DistDir)/$$subdir" ; \
1497 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1498 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1502 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1503 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1504 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o -name .svn \) -print` ;\
1505 $(MAKE) dist-hook ; \
1506 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1507 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1508 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1509 -o ! -type d ! -perm -444 -exec \
1510 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1511 || chmod -R a+r $(DistDir) ; \
1514 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1520 ###############################################################################
1521 # TOP LEVEL - targets only to apply at the top level directory
1522 ###############################################################################
1526 #------------------------------------------------------------------------
1527 # Install support for the project's include files:
1528 #------------------------------------------------------------------------
1530 $(Echo) Installing include files
1531 $(Verb) $(MKDIR) $(PROJ_includedir)
1532 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1533 cd $(PROJ_SRC_ROOT)/include && \
1534 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1535 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
1536 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1537 if test \! -d "$$instdir" ; then \
1538 $(EchoCmd) Making install directory $$instdir ; \
1539 $(MKDIR) $$instdir ;\
1541 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1544 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1545 cd $(PROJ_OBJ_ROOT)/include && \
1546 for hdr in `find . -type f -print` ; do \
1547 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1552 $(Echo) Uninstalling include files
1553 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1554 cd $(PROJ_SRC_ROOT)/include && \
1555 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1556 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \
1557 -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1558 cd $(PROJ_SRC_ROOT)/include && \
1559 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' \
1560 | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1565 #------------------------------------------------------------------------
1566 # Print out the directories used for building
1567 #------------------------------------------------------------------------
1569 $(Echo) "BuildMode : " '$(BuildMode)'
1570 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1571 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1572 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1573 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1574 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1575 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1576 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1577 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1578 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1579 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1580 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1581 $(Echo) "UserTargets : " '$(UserTargets)'
1582 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1583 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1584 $(Echo) "ObjDir : " '$(ObjDir)'
1585 $(Echo) "LibDir : " '$(LibDir)'
1586 $(Echo) "ToolDir : " '$(ToolDir)'
1587 $(Echo) "ExmplDir : " '$(ExmplDir)'
1588 $(Echo) "Sources : " '$(Sources)'
1589 $(Echo) "TDFiles : " '$(TDFiles)'
1590 $(Echo) "INCFiles : " '$(INCFiles)'
1591 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1592 $(Echo) "PreConditions: " '$(PreConditions)'
1593 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1594 $(Echo) "Compile.C : " '$(Compile.C)'
1595 $(Echo) "Archive : " '$(Archive)'
1596 $(Echo) "YaccFiles : " '$(YaccFiles)'
1597 $(Echo) "LexFiles : " '$(LexFiles)'
1598 $(Echo) "Module : " '$(Module)'
1599 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'