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 #--------------------------------------------------------------------
40 #--------------------------------------------------------------------
41 # Reset the list of suffixes we know how to build
42 #--------------------------------------------------------------------
44 .SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot
45 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
47 #--------------------------------------------------------------------
48 # Mark all of these targets as phony to avoid implicit rule search
49 #--------------------------------------------------------------------
50 .PHONY: $(UserTargets) $(InternalTargets)
52 #--------------------------------------------------------------------
53 # Make sure all the user-target rules are double colon rules and
54 # they are defined first.
55 #--------------------------------------------------------------------
59 ################################################################################
60 # PRECONDITIONS: that which must be built/checked first
61 ################################################################################
63 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
64 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66 ConfigureScript := $(PROJ_SRC_ROOT)/configure
67 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73 ifneq ($(MakefileCommonIn),)
74 PreConditions += $(MakefileCommon)
76 ifneq ($(MakefileConfigIn),)
77 PreConditions += $(MakefileConfig)
80 preconditions : $(PreConditions)
82 #------------------------------------------------------------------------
83 # Make sure the BUILT_SOURCES are built first
84 #------------------------------------------------------------------------
85 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
88 ifneq ($(strip $(BUILT_SOURCES)),)
89 -$(Verb) $(RM) -f $(BUILT_SOURCES)
92 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
94 $(Verb) if test -x config.status ; then \
95 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
96 $(MKDIR) .spotless.save ; \
97 $(MV) config.status .spotless.save ; \
98 $(MV) mklib .spotless.save ; \
99 $(MV) projects .spotless.save ; \
101 $(MV) .spotless.save/config.status . ; \
102 $(MV) .spotless.save/mklib . ; \
103 $(MV) .spotless.save/projects . ; \
104 $(RM) -rf .spotless.save ; \
105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
113 $(BUILT_SOURCES) : $(ObjMakefiles)
115 #------------------------------------------------------------------------
116 # Make sure we're not using a stale configuration
117 #------------------------------------------------------------------------
119 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
120 $(Verb) cd $(PROJ_OBJ_ROOT) && \
121 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
122 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
124 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
125 $(ConfigStatusScript)
127 .PRECIOUS: $(ConfigStatusScript)
128 $(ConfigStatusScript): $(ConfigureScript)
129 $(Echo) Reconfiguring with $<
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 #------------------------------------------------------------------------
138 # Make sure the configuration makefile is up to date
139 #------------------------------------------------------------------------
140 ifneq ($(MakefileConfigIn),)
141 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
142 $(Echo) Regenerating $@
143 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
146 ifneq ($(MakefileCommonIn),)
147 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
148 $(Echo) Regenerating $@
149 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
152 #------------------------------------------------------------------------
153 # If the Makefile in the source tree has been updated, copy it over into the
154 # build tree. But, only do this if the source and object makefiles differ
155 #------------------------------------------------------------------------
156 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
158 Makefile: $(PROJ_SRC_DIR)/Makefile
159 $(Echo) "Updating Makefile"
160 $(Verb) $(MKDIR) $(@D)
161 $(Verb) $(CP) -f $< $@
163 # Copy the Makefile.* files unless we're in the root directory which avoids
164 # the copying of Makefile.config.in or other things that should be explicitly
166 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
168 *Makefile.rules) ;; \
170 *) $(Echo) "Updating $(@F)" ; \
177 #------------------------------------------------------------------------
178 # Set up the basic dependencies
179 #------------------------------------------------------------------------
180 $(UserTargets):: $(PreConditions)
184 clean-all:: clean-local clean-all-local
185 install:: install-local
186 uninstall:: uninstall-local
187 install-local:: all-local
188 install-bytecode:: install-bytecode-local
190 ###############################################################################
191 # VARIABLES: Set up various variables based on configuration data
192 ###############################################################################
194 #--------------------------------------------------------------------
195 # Variables derived from configuration we are building
196 #--------------------------------------------------------------------
199 ifdef ENABLE_PROFILING
201 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
202 C.Flags := -O3 -DNDEBUG -pg
203 LD.Flags := -O3 -DNDEBUG -pg
205 ifdef ENABLE_OPTIMIZED
207 # Don't use -fomit-frame-pointer on FreeBSD
208 ifneq ($(OS),FreeBSD)
209 OmitFramePointer := -fomit-frame-pointer
211 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors \
213 C.Flags := -O3 -DNDEBUG $(OmitFramePointer)
214 LD.Flags := -O3 -DNDEBUG
217 CXX.Flags := -g -D_DEBUG
218 C.Flags := -g -D_DEBUG
219 LD.Flags := -g -D_DEBUG
224 CXX.Flags += $(CXXFLAGS)
226 CPP.Flags += $(CPPFLAGS)
227 LD.Flags += $(LDFLAGS)
229 LibTool.Flags := --tag=CXX
231 #Make Floating point ieee complient on alpha
237 #--------------------------------------------------------------------
238 # Directory locations
239 #--------------------------------------------------------------------
240 ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
241 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
242 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
243 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
244 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
245 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
246 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
247 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
249 #--------------------------------------------------------------------
250 # Full Paths To Compiled Tools and Utilities
251 #--------------------------------------------------------------------
252 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
255 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
258 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
261 BURG := $(LLVMToolDir)/burg$(EXEEXT)
264 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
267 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
270 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
273 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
276 LLI := $(LLVMToolDir)/lli$(EXEEXT)
279 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
282 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
285 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
286 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
288 #--------------------------------------------------------------------
289 # Adjust to user's request
290 #--------------------------------------------------------------------
292 # Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
293 # to be built. Note that if LOADABLE_MODULE is specified then the resulting
294 # shared library can be opened with dlopen
296 LD.Flags += -rpath $(LibDir)
297 ifdef LOADABLE_MODULE
301 LibTool.Flags += --tag=disable-shared
311 # Adjust settings for verbose mode
314 LibTool.Flags += --silent
315 AR.Flags += >/dev/null 2>/dev/null
316 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
318 ConfigureScriptFLAGS :=
321 # By default, strip symbol information from executable
323 Strip := $(PLATFORMSTRIPOPTS)
324 StripWarnMsg := "(without symbols)"
327 # Adjust linker flags for building an executable
330 LD.Flags += -rpath $(ExmplDir) -export-dynamic
332 LD.Flags += -rpath $(ToolDir) -export-dynamic
336 #----------------------------------------------------------
337 # Options To Invoke Tools
338 #----------------------------------------------------------
340 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
342 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
343 CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
344 -I$(PROJ_OBJ_ROOT)/include \
345 -I$(PROJ_SRC_ROOT)/include \
346 -I$(LLVM_OBJ_ROOT)/include \
347 -I$(LLVM_SRC_ROOT)/include \
348 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
350 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
351 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
352 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
354 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
355 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
356 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
358 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
359 $(CompileCommonOpts) $(LD.Flags) $(Strip)
360 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
362 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
363 Burg = $(BURG) -I $(PROJ_SRC_DIR)
364 TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR)
365 Archive = $(AR) $(AR.Flags)
366 LArchive = $(LLVMToolDir)/llvm-ar rcsf
373 #----------------------------------------------------------
374 # Get the list of source files and compute object file
376 #----------------------------------------------------------
379 FakeSources := $(FAKE_SOURCES)
381 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
383 BaseNameSources := $(sort $(basename $(FakeSources)))
384 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
385 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
386 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
389 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
390 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
391 $(PROJ_SRC_DIR)/*.l))
393 Sources := $(SOURCES)
397 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
400 BaseNameSources := $(sort $(basename $(Sources)))
401 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
402 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
403 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
406 ###############################################################################
407 # DIRECTORIES: Handle recursive descent of directory structure
408 ###############################################################################
410 #---------------------------------------------------------
411 # Provide rules to make install dirs. This must be early
412 # in the file so they get built before dependencies
413 #---------------------------------------------------------
416 $(Verb) $(MKDIR) $(PROJ_bindir)
419 $(Verb) $(MKDIR) $(PROJ_libdir)
422 $(Verb) $(MKDIR) $(PROJ_includedir)
425 $(Verb) $(MKDIR) $(PROJ_etcdir)
427 # To create other directories, as needed, and timestamp their creation
429 $(Verb) $(MKDIR) $* > /dev/null
432 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
433 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
435 #---------------------------------------------------------
436 # Handle the DIRS options for sequential construction
437 #---------------------------------------------------------
442 $(RecursiveTargets)::
443 $(Verb) for dir in $(DIRS); do \
444 if [ ! -f $$dir/Makefile ]; then \
446 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
448 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
449 ($(MAKE) -C $$dir $@ ) || exit 1; \
454 #---------------------------------------------------------
455 # Handle the EXPERIMENTAL_DIRS options ensuring success
456 # after each directory is built.
457 #---------------------------------------------------------
458 ifdef EXPERIMENTAL_DIRS
459 $(RecursiveTargets)::
460 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
461 if [ ! -f $$dir/Makefile ]; then \
463 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
465 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
466 ($(MAKE) -C $$dir $@ ) || exit 0; \
471 #---------------------------------------------------------
472 # Handle the PARALLEL_DIRS options for parallel construction
473 #---------------------------------------------------------
476 SubDirs += $(PARALLEL_DIRS)
478 # Unfortunately, this list must be maintained if new recursive targets are added
479 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
480 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
481 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
482 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
483 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
484 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
486 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
489 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
491 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
493 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
494 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
498 #---------------------------------------------------------
499 # Handle the OPTIONAL_DIRS options for directores that may
501 #---------------------------------------------------------
504 SubDirs += $(OPTIONAL_DIRS)
506 $(RecursiveTargets)::
507 $(Verb) for dir in $(OPTIONAL_DIRS); do \
508 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
509 if [ ! -f $$dir/Makefile ]; then \
511 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
513 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
514 ($(MAKE) -C$$dir $@ ) || exit 1; \
520 #---------------------------------------------------------
521 # Handle the CONFIG_FILES options
522 #---------------------------------------------------------
525 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
526 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
527 $(Verb)for file in $(CONFIG_FILES); do \
528 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
529 $(INSTALL) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
530 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
531 $(INSTALL) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
533 $(ECHO) Error: cannot find config file $${file}. ; \
538 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
539 $(Verb)for file in $(CONFIG_FILES); do \
540 $(RM) -f $(PROJ_etcdir)/$${file} ; \
545 ###############################################################################
546 # Library Build Rules: Four ways to build a library
547 ###############################################################################
549 #---------------------------------------------------------
550 # Bytecode Module Targets:
551 # If the user set MODULE_NAME then they want to build a
552 # bytecode module from the sources. We compile all the
553 # sources and link it together into a single bytecode
555 #---------------------------------------------------------
558 ifeq ($(strip $(LLVMGCC)),)
559 $(warning Modules require llvm-gcc but no llvm-gcc is available)
562 Module := $(LibDir)/$(MODULE_NAME).bc
563 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
565 ifdef EXPORTED_SYMBOL_FILE
566 LinkModule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
569 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
570 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
571 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
573 all-local:: $(Module)
576 ifneq ($(strip $(Module)),)
577 -$(Verb) $(RM) -f $(Module)
580 ifdef BYTECODE_DESTINATION
581 ModuleDestDir := $(BYTECODE_DESTINATION)
583 ModuleDestDir := $(PROJ_libdir)
586 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
588 install-module:: $(DestModule)
589 install-local:: $(DestModule)
591 $(DestModule): $(ModuleDestDir) $(Module)
592 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
593 $(Verb) $(INSTALL) $(Module) $@
596 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
597 -$(Verb) $(RM) -f $(DestModule)
602 # if we're building a library ...
605 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
606 LIBRARYNAME := $(strip $(LIBRARYNAME))
607 ifdef LOADABLE_MODULE
608 LibName.LA := $(LibDir)/$(LIBRARYNAME).la
610 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
612 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
613 LibName.O := $(LibDir)/$(LIBRARYNAME).o
614 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
616 #---------------------------------------------------------
617 # Shared Library Targets:
618 # If the user asked for a shared library to be built
619 # with the SHARED_LIBRARY variable, then we provide
620 # targets for building them.
621 #---------------------------------------------------------
624 all-local:: $(LibName.LA)
626 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
627 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
628 $(Verb) $(Link) -o $@ $(ObjectsLO)
629 $(Verb) $(LTInstall) $@ $(LibDir)
632 ifneq ($(strip $(LibName.LA)),)
633 -$(Verb) $(RM) -f $(LibName.LA)
636 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
638 install-local:: $(DestSharedLib)
640 $(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
641 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
642 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
643 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
646 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
647 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
651 #---------------------------------------------------------
652 # Bytecode Library Targets:
653 # If the user asked for a bytecode library to be built
654 # with the BYTECODE_LIBRARY variable, then we provide
655 # targets for building them.
656 #---------------------------------------------------------
657 ifdef BYTECODE_LIBRARY
658 ifeq ($(strip $(LLVMGCC)),)
659 $(warning Bytecode libraries require llvm-gcc which could not be found)
662 # make the C and C++ compilers strip debug info out of bytecode libraries.
663 BCCompile.C += -Wa,-strip-debug
664 BCCompile.CXX += -Wa,-strip-debug
666 all-local:: $(LibName.BCA)
668 ifdef EXPORTED_SYMBOL_FILE
669 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
670 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
672 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
673 $(LLVMToolDir)/llvm-ar
674 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
676 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
678 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
680 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
681 $(LLVMToolDir)/llvm-ar
682 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
684 $(Verb) $(LArchive) $@ $(ObjectsBC)
689 ifneq ($(strip $(LibName.BCA)),)
690 -$(Verb) $(RM) -f $(LibName.BCA)
693 ifdef BYTECODE_DESTINATION
694 BytecodeDestDir := $(BYTECODE_DESTINATION)
696 BytecodeDestDir := $(PROJ_libdir)
699 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
701 install-bytecode-local:: $(DestBytecodeLib)
703 install-local:: $(DestBytecodeLib)
705 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
706 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
707 $(Verb) $(INSTALL) $(LibName.BCA) $@
710 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
711 -$(Verb) $(RM) -f $(DestBytecodeLib)
716 #---------------------------------------------------------
717 # ReLinked Library Targets:
718 # If the user didn't explicitly forbid building a
719 # relinked then we provide targets for building them.
720 #---------------------------------------------------------
721 ifndef DONT_BUILD_RELINKED
723 all-local:: $(LibName.O)
725 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
726 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
727 $(Verb) $(Relink) -o $@ $(ObjectsO)
730 ifneq ($(strip $(LibName.O)),)
731 -$(Verb) $(RM) -f $(LibName.O)
734 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
736 install-local:: $(DestRelinkedLib)
738 $(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
739 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
740 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
743 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
744 -$(Verb) $(RM) -f $(DestRelinkedLib)
748 #---------------------------------------------------------
749 # Archive Library Targets:
750 # If the user wanted a regular archive library built,
751 # then we provide targets for building them.
752 #---------------------------------------------------------
755 all-local:: $(LibName.A)
757 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
758 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
760 $(Verb) $(Archive) $@ $(ObjectsO)
764 ifneq ($(strip $(LibName.A)),)
765 -$(Verb) $(RM) -f $(LibName.A)
768 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
770 install-local:: $(DestArchiveLib)
772 $(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
773 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
774 $(Verb) $(MKDIR) $(PROJ_libdir)
775 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
778 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
779 -$(Verb) $(RM) -f $(DestArchiveLib)
786 ###############################################################################
787 # Tool Build Rules: Build executable tool based on TOOLNAME option
788 ###############################################################################
792 #---------------------------------------------------------
793 # Handle the special "JIT" value for LLVM_LIBS which is a
794 # shorthand for a bunch of libraries that get the correct
795 # JIT support for a tool that runs JIT.
796 #---------------------------------------------------------
797 ifeq ($(LLVMLIBS),JIT)
799 # Make sure we can get our own symbols in the tool
802 # Generic JIT libraries
803 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
805 # You can enable the X86 JIT on a non-X86 host by setting the flag
806 # ENABLE_X86_JIT on the make command line. If not, it will still be
807 # enabled automagically on an X86 host.
812 # What the X86 JIT requires
814 JIT_LIBS += LLVMX86 LLVMSelectionDAG
817 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
818 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
819 # enabled automagically on an SparcV9 host.
820 ifeq ($(ARCH), Sparc)
821 ENABLE_SPARCV9_JIT = 1
824 # What the Sparc JIT requires
825 ifdef ENABLE_SPARCV9_JIT
826 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
827 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
828 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
829 LLVMDataStructure.a LLVMSparcV9RegAlloc
832 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
833 # ENABLE_PPC_JIT on the make command line. If not, it will still be
834 # enabled automagically on an PowerPC host.
835 ifeq ($(ARCH), PowerPC)
839 # What the PowerPC JIT requires
841 JIT_LIBS += LLVMPowerPC
844 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
845 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
846 LLVMSystem.a $(PLATFORMLIBDL)
849 #---------------------------------------------------------
850 # Set up variables for building a tool.
851 #---------------------------------------------------------
853 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
855 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
857 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
858 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
859 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
860 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
861 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
862 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
863 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
864 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
866 #---------------------------------------------------------
867 # Tell make that we need to rebuild subdirectories before
868 # we can link the tool. This affects things like LLI which
869 # has library subdirectories.
870 #---------------------------------------------------------
871 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
873 #---------------------------------------------------------
874 # Provide targets for building the tools
875 #---------------------------------------------------------
876 all-local:: $(ToolBuildPath)
879 ifneq ($(strip $(ToolBuildPath)),)
880 -$(Verb) $(RM) -f $(ToolBuildPath)
884 $(ToolBuildPath): $(ExmplDir)/.dir
886 $(ToolBuildPath): $(ToolDir)/.dir
889 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
890 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
891 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
892 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
893 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
895 DestTool = $(PROJ_bindir)/$(TOOLNAME)
897 install-local:: $(DestTool)
899 $(DestTool): $(PROJ_bindir) $(ToolBuildPath)
900 $(Echo) Installing $(BuildMode) $(DestTool)
901 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
904 $(Echo) Uninstalling $(BuildMode) $(DestTool)
905 -$(Verb) $(RM) -f $(DestTool)
909 ###############################################################################
910 # Object Build Rules: Build object files based on sources
911 ###############################################################################
913 # Provide rule sets for when dependency generation is enabled
914 ifndef DISABLE_AUTO_DEPENDENCIES
916 #---------------------------------------------------------
917 # Create .lo files in the ObjDir directory from the .cpp and .c files...
918 #---------------------------------------------------------
921 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
922 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
923 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
924 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
925 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
927 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
928 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
929 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
930 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
931 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
933 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
934 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
935 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
936 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
937 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
939 #---------------------------------------------------------
940 # Create .o files in the ObjDir directory from the .cpp and .c files...
941 #---------------------------------------------------------
944 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
945 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
946 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
947 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
948 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
950 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
951 $(Echo) "Compiling $*.cc for $(BuildMode) build"
952 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
953 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
954 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
956 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
957 $(Echo) "Compiling $*.c for $(BuildMode) build"
958 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
959 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
960 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
964 #---------------------------------------------------------
965 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
966 #---------------------------------------------------------
967 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
968 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
969 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
970 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
971 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
973 $(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
974 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
975 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
976 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
977 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
979 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
980 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
981 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
982 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
983 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
985 # Provide alternate rule sets if dependencies are disabled
990 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
991 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
992 $(LTCompile.CXX) $< -o $@
994 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
995 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
996 $(LTCompile.CXX) $< -o $@
998 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
999 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
1000 $(LTCompile.C) $< -o $@
1004 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1005 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
1006 $(Compile.CXX) $< -o $@
1008 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1009 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1010 $(Compile.CXX) $< -o $@
1012 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1013 $(Echo) "Compiling $*.c for $(BuildMode) build"
1014 $(Compile.C) $< -o $@
1017 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1018 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1019 $(BCCompile.CXX) $< -o $@
1021 $(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1022 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1023 $(BCCompile.CXX) $< -o $@
1025 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1026 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1027 $(BCCompile.C) $< -o $@
1031 #---------------------------------------------------------
1032 # Provide rule to build .bc files from .ll sources,
1033 # regardless of dependencies
1034 #---------------------------------------------------------
1035 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1036 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1037 $(Verb) $(LLVMAS) $< -f -o $@
1039 ###############################################################################
1040 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1041 ###############################################################################
1045 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
1046 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1047 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1048 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1050 # All of these files depend on tblgen and the .td files.
1051 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1053 # INCFiles rule: All of the tblgen generated files are emitted to
1054 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1055 # us to only "touch" the real file if the contents of it change. IOW, if
1056 # tblgen is modified, all of the .inc.tmp files are regereated, but no
1057 # dependencies of the .inc files are, unless the contents of the .inc file
1059 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1060 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1062 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1063 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1064 $(Echo) "Building $(<F) register names with tblgen"
1065 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
1067 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1068 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1069 $(Echo) "Building $(<F) register information header with tblgen"
1070 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
1072 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1073 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1074 $(Echo) "Building $(<F) register info implementation with tblgen"
1075 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
1077 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1078 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1079 $(Echo) "Building $(<F) instruction names with tblgen"
1080 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
1082 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1083 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1084 $(Echo) "Building $(<F) instruction information with tblgen"
1085 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1087 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1088 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1089 $(Echo) "Building $(<F) assembly writer with tblgen"
1090 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1092 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1093 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1094 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1095 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1097 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1098 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1099 $(Echo) "Building $(<F) code emitter with tblgen"
1100 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1103 -$(Verb) $(RM) -f $(INCFiles)
1107 ###############################################################################
1108 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1109 ###############################################################################
1111 #---------------------------------------------------------
1112 # Provide rules for generating a .cpp source file from
1113 # (f)lex input sources.
1114 #---------------------------------------------------------
1116 LexFiles := $(filter %.l,$(Sources))
1118 ifneq ($(LexFiles),)
1120 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1122 .PRECIOUS: $(LexOutput)
1124 # Note the extra sed filtering here, used to cut down on the warnings emited
1125 # by GCC. The last line is a gross hack to work around flex aparently not
1126 # being able to resize the buffer on a large token input. Currently, for
1127 # uninitialized string buffers in LLVM we can generate very long tokens, so
1128 # this is a hack around it.
1129 # FIXME. (f.e. char Buffer[10000] )
1131 $(Echo) Flexing $*.l
1132 $(Verb) $(FLEX) -t $< | \
1133 $(SED) 's/void yyunput/inline void yyunput/' | \
1134 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1135 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1139 -$(Verb) $(RM) -f $(LexOutput)
1140 $(Verb) $(RM) -f $(LexOutput)
1144 #---------------------------------------------------------
1145 # Provide rules for generating a .cpp and .h source files
1146 # from yacc (bison) input sources.
1147 #---------------------------------------------------------
1149 YaccFiles := $(filter %.y,$(Sources))
1150 ifneq ($(YaccFiles),)
1151 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1153 .PRECIOUS: $(YaccOutput)
1155 # Cancel built-in rules for yacc
1160 # Rule for building the bison parsers...
1162 $(Echo) "Bisoning $*.y"
1163 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1164 $(Verb) $(MV) -f $*.tab.c $*.cpp
1165 $(Verb) $(MV) -f $*.tab.h $*.h
1168 -$(Verb) $(RM) -f $(YaccOutput)
1169 $(Verb) $(RM) -f $(YaccOutput)
1172 ###############################################################################
1173 # OTHER RULES: Other rules needed
1174 ###############################################################################
1176 # To create postscript files from dot files...
1177 ifneq ($(DOT),false)
1179 $(DOT) -Tps < $< > $@
1182 $(Echo) "Cannot build $@: The program dot is not installed"
1185 # This rules ensures that header files that are removed still have a rule for
1186 # which they can be "generated." This allows make to ignore them and
1187 # reproduce the dependency lists.
1191 # Define clean-local to clean the current directory. Note that this uses a
1192 # very conservative approach ensuring that empty variables do not cause
1193 # errors or disastrous removal.
1195 ifneq ($(strip $(ObjDir)),)
1196 -$(Verb) $(RM) -rf $(ObjDir)
1198 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1199 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1200 -$(Verb) $(RM) -f *$(SHLIBEXT)
1204 -$(Verb) $(RM) -rf Debug Release Profile
1206 # Build tags database for Emacs/Xemacs:
1210 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1211 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1212 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1213 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1214 -name '*.cpp' -o -name '*.h' | \
1215 $(ETAGS) $(ETAGSFLAGS) -
1218 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1219 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1220 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1221 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1222 \( -name '*.cpp' -o -name '*.h' \) -print | \
1223 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
1226 ###############################################################################
1227 # DEPENDENCIES: Include the dependency files if we should
1228 ###############################################################################
1229 ifndef DISABLE_AUTO_DEPENDENCIES
1231 # If its not one of the cleaning targets
1232 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1234 # Get the list of dependency files
1235 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1236 DependFiles := $(patsubst %,$(PROJ_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1238 -include /dev/null $(DependFiles)
1244 ###############################################################################
1245 # CHECK: Running the test suite
1246 ###############################################################################
1249 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1250 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1251 $(EchoCmd) Running test suite ; \
1252 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1253 TESTSUITE=$(TESTSUITE) ; \
1255 $(EchoCmd) No Makefile in test directory ; \
1258 $(EchoCmd) No test directory ; \
1261 ###############################################################################
1262 # DISTRIBUTION: Handle construction of a distribution tarball
1263 ###############################################################################
1265 #------------------------------------------------------------------------
1266 # Define distribution related variables
1267 #------------------------------------------------------------------------
1268 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1269 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1270 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1271 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1272 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1273 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1274 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1275 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1276 Makefile.config.in configure autoconf
1277 DistOther := $(notdir $(wildcard \
1278 $(PROJ_SRC_DIR)/*.h \
1279 $(PROJ_SRC_DIR)/*.td \
1280 $(PROJ_SRC_DIR)/*.def \
1281 $(PROJ_SRC_DIR)/*.ll \
1282 $(PROJ_SRC_DIR)/*.in))
1283 DistSubDirs := $(SubDirs)
1284 DistSources = $(Sources) $(EXTRA_DIST)
1285 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1287 #------------------------------------------------------------------------
1288 # We MUST build distribution with OBJ_DIR != SRC_DIR
1289 #------------------------------------------------------------------------
1290 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1291 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1292 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1296 #------------------------------------------------------------------------
1297 # Prevent attempt to run dist targets from anywhere but the top level
1298 #------------------------------------------------------------------------
1300 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1301 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1304 #------------------------------------------------------------------------
1305 # Provide the top level targets
1306 #------------------------------------------------------------------------
1308 dist-gzip:: $(DistTarGZip)
1310 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1311 $(Echo) Packing gzipped distribution tar file.
1312 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1313 $(GZIP) -c > "$(DistTarGZip)"
1315 dist-bzip2:: $(DistTarBZ2)
1317 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1318 $(Echo) Packing bzipped distribution tar file.
1319 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1320 $(BZIP2) -c >$(DistTarBZ2)
1322 dist-zip:: $(DistZip)
1324 $(DistZip) : $(TopDistDir)/.makedistdir
1325 $(Echo) Packing zipped distribution file.
1326 $(Verb) rm -f $(DistZip)
1327 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1329 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1330 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1332 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1334 dist-check:: $(DistTarGZip)
1335 $(Echo) Checking distribution tar file.
1336 $(Verb) if test -d $(DistCheckDir) ; then \
1337 $(RM) -rf $(DistCheckDir) ; \
1339 $(Verb) $(MKDIR) $(DistCheckDir)
1340 $(Verb) cd $(DistCheckDir) && \
1341 $(MKDIR) $(DistCheckDir)/build && \
1342 $(MKDIR) $(DistCheckDir)/install && \
1343 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1345 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1346 --srcdir=../$(DistName) && \
1349 $(MAKE) install && \
1350 $(MAKE) uninstall && \
1353 $(MAKE) dist-clean && \
1354 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1357 $(Echo) Cleaning distribution files
1358 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1363 #------------------------------------------------------------------------
1364 # Provide the recursive distdir target for building the distribution directory
1365 #------------------------------------------------------------------------
1366 distdir: $(DistDir)/.makedistdir
1367 $(DistDir)/.makedistdir: $(DistSources)
1368 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1369 if test -d "$(DistDir)" ; then \
1370 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1373 $(EchoCmd) Removing old $(DistDir) ; \
1374 $(RM) -rf $(DistDir); \
1375 $(EchoCmd) Making 'all' to verify build ; \
1378 $(Echo) Building Distribution Directory $(DistDir)
1379 $(Verb) $(MKDIR) $(DistDir)
1380 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1381 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1382 for file in $(DistFiles) ; do \
1384 $(PROJ_SRC_DIR)/*) \
1385 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1387 $(PROJ_SRC_ROOT)/*) \
1388 file=`echo "$$file" | \
1389 sed "s#^$$srcrootstrip/##"` \
1392 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1393 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1394 from_dir="$(PROJ_SRC_DIR)" ; \
1395 elif test -f "$$file" || test -d "$$file" ; then \
1398 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1399 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1400 to_dir="$(DistDir)/$$dir"; \
1401 $(MKDIR) "$$to_dir" ; \
1403 to_dir="$(DistDir)"; \
1405 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1406 if test -n "$$mid_dir" ; then \
1407 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1409 if test -d "$$from_dir/$$file"; then \
1410 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1411 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1412 $(CP) -pR "$(PROJ_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1414 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1415 elif test -f "$$from_dir/$$file" ; then \
1416 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1417 elif test -L "$$from_dir/$$file" ; then \
1418 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1419 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1420 $(EchoCmd) "===== WARNING: Distribution Source " \
1421 "$$from_dir/$$file Not Found!" ; \
1422 elif test "$(Verb)" != '@' ; then \
1423 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1426 $(Verb) for subdir in $(DistSubDirs) ; do \
1427 if test "$$subdir" \!= "." ; then \
1428 new_distdir="$(DistDir)/$$subdir" ; \
1429 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1430 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1434 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1435 $(EchoCmd) Eliminating CVS directories from distribution ; \
1436 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1437 $(MAKE) dist-hook ; \
1438 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1439 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1440 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1441 -o ! -type d ! -perm -444 -exec \
1442 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1443 || chmod -R a+r $(DistDir) ; \
1446 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1452 ###############################################################################
1453 # TOP LEVEL - targets only to apply at the top level directory
1454 ###############################################################################
1458 #------------------------------------------------------------------------
1459 # Install support for the project's include files:
1460 #------------------------------------------------------------------------
1462 $(Echo) Installing include files
1463 $(Verb) $(MKDIR) $(PROJ_includedir)
1464 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1465 cd $(PROJ_SRC_ROOT)/include && \
1466 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1467 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
1468 $(INSTALL) $$hdr $(PROJ_includedir) ; \
1471 $(Verb) if [ -d "$(PROJ_OBJ_ROOT)/include" ] ; then \
1472 cd $(PROJ_OBJ_ROOT)/include && \
1473 for hdr in `find . -type f -print` ; do \
1474 $(INSTALL) $$hdr $(PROJ_includedir) ; \
1479 $(Echo) Uninstalling include files
1480 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1481 cd $(PROJ_SRC_ROOT)/include && \
1482 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1483 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \
1484 -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1485 cd $(PROJ_SRC_ROOT)/include && \
1486 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' \
1487 | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1492 #------------------------------------------------------------------------
1493 # Print out the directories used for building
1494 #------------------------------------------------------------------------
1496 $(Echo) "BuildMode : " '$(BuildMode)'
1497 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1498 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1499 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1500 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1501 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1502 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1503 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1504 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1505 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1506 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1507 $(Echo) "UserTargets : " '$(UserTargets)'
1508 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1509 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1510 $(Echo) "ObjDir : " '$(ObjDir)'
1511 $(Echo) "LibDir : " '$(LibDir)'
1512 $(Echo) "ToolDir : " '$(ToolDir)'
1513 $(Echo) "ExmplDir : " '$(ExmplDir)'
1514 $(Echo) "Sources : " '$(Sources)'
1515 $(Echo) "TDFiles : " '$(TDFiles)'
1516 $(Echo) "INCFiles : " '$(INCFiles)'
1517 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1518 $(Echo) "Preconditions: " '$(Preconditions)'
1519 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1520 $(Echo) "Compile.C : " '$(Compile.C)'
1521 $(Echo) "Archive : " '$(Archive)'
1522 $(Echo) "YaccFiles : " '$(YaccFiles)'
1523 $(Echo) "LexFiles : " '$(LexFiles)'
1524 $(Echo) "Module : " '$(Module)'