#--------------------------------------------------------------------
# Define the various target sets
#--------------------------------------------------------------------
-RecursiveTargets := all clean check install uninstall
-LocalTargets := all-local clean-local check-local install-local printvars \
- uninstall-local
+RecursiveTargets := all clean clean-all check install uninstall
+LocalTargets := all-local clean-local clean-all-local check-local \
+ install-local printvars uninstall-local
TopLevelTargets := dist dist-check dist-clean tags dist-gzip dist-bzip2 \
dist-zip
UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
# PRECONDITIONS: that which must be built/checked first
################################################################################
-SrcMakefiles := $(filter %Makefile %Makefile.rules %Makefile.tests \
- %Makefile.JIT,$(wildcard $(BUILD_SRC_DIR)/Makefile*))
+SrcMakefiles := $(filter %Makefile %Makefile.tests %Makefile.JIT,\
+ $(wildcard $(BUILD_SRC_DIR)/Makefile*))
ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
ConfigureScript := $(LLVM_SRC_ROOT)/configure
ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
clean-local::
ifneq ($(strip $(BUILT_SOURCES)),)
- $(Verb) $(RM) -f $(BUILT_SOURCES)
+ -$(Verb) $(RM) -f $(BUILT_SOURCES)
endif
$(BUILT_SOURCES) : $(ObjMakefiles)
#------------------------------------------------------------------------
ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
-$(BUILD_OBJ_DIR)/Makefile : $(BUILD_SRC_DIR)/Makefile
+Makefile: $(BUILD_SRC_DIR)/Makefile
$(Echo) "Updating Makefile"
$(Verb) $(MKDIR) $(@D)
$(Verb) cp -f $< $@
all:: all-local
check:: check-local
clean:: clean-local
+clean-all:: clean-local clean-all-local
install:: install-local
uninstall:: uninstall-local
check-local:: all-local
# Directory locations
#--------------------------------------------------------------------
ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
-LibDir := $(BUILD_OBJ_ROOT)/lib/$(BuildMode)
-ToolDir := $(BUILD_OBJ_ROOT)/tools/$(BuildMode)
-LLVMLibDir := $(LLVM_OBJ_ROOT)/lib/$(BuildMode)
-LLVMToolDir := $(LLVM_OBJ_ROOT)/tools/$(BuildMode)
+LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
+ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
+ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
+LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
+LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
+LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
#--------------------------------------------------------------------
# Full Paths To Compiled Tools and Utilities
LD.Flags += -rpath $(LibDir)
endif
+ifdef TOOL_VERBOSE
+ C.Flags += -v
+ CXX.Flags += -v
+ LD.Flags += -v
+ BCLinkLib.Flags += -v
+ VERBOSE := 1
+endif
+
# Adjust settings for verbose mode
ifndef VERBOSE
Verb := @
# Adjust linker flags for building an executable
ifdef TOOLNAME
+ifdef EXAMPLE_TOOL
+ LD.Flags += -rpath $(ExmplDir) -export-dynamic
+else
LD.Flags += -rpath $(ToolDir) -export-dynamic
endif
+endif
#----------------------------------------------------------
# Options To Invoke Tools
$(CompileCommonOpts) $(LD.Flags) $(Strip)
Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
$(CompileCommonOpts)
-BCLinkLib = $(LLVMGCC) -shared -nostdlib
+BCLinkLib = $(LLVMGCC) -shared -nostdlib $(BCLinkLib.Flags)
LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Burg = $(BURG) -I $(BUILD_SRC_DIR)
TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Archive = $(AR) $(AR.Flags)
+LArchive = $(ToolDir)/llvm-ar rcsf
ifdef RANLIB
Ranlib = $(RANLIB)
else
$(Verb) $(MKDIR) $* > /dev/null
@$(DATE) > $@
-.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(LLVMLibDir)/.dir
-.PRECIOUS: $(LLVMToolDir)/.dir
+.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
+.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
#---------------------------------------------------------
# Handle the DIRS options for sequential construction
# recursive targets are added.
all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
+clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
check :: $(addsuffix /.makecheck ,$(PARALLEL_DIRS))
install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
install-local:: $(sysconfdir) $(CONFIG_FILES)
$(Echo) Installing Configuration Files To $(sysconfdir)
$(Verb)for file in $(CONFIG_FILES); do \
- $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
+ if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
+ $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
+ elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
+ $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
+ else \
+ $(ECHO) Error: cannot find config file $${file}. ; \
+ fi \
done
uninstall-local::
clean-local::
ifneq ($(strip $(LibName.LA)),)
- $(Verb) $(RM) -f $(LibName.LA)
+ -$(Verb) $(RM) -f $(LibName.LA)
endif
DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
uninstall-local::
$(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
- $(Verb) $(RM) -f $(DestSharedLib)
+ -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
endif
clean-local::
ifneq ($(strip $(LibName.BC)),)
- $(Verb) $(RM) -f $(LibName.BC)
+ -$(Verb) $(RM) -f $(LibName.BC)
endif
DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
uninstall-local::
$(Echo) Uninstalling $(BuildMode) Bytecode Library $(DestBytecodeLib)
- $(Verb) $(RM) -f $(DestBytecodeLib)
+ -$(Verb) $(RM) -f $(DestBytecodeLib)
endif
clean-local::
ifneq ($(strip $(LibName.O)),)
- $(Verb) $(RM) -f $(LibName.O)
+ -$(Verb) $(RM) -f $(LibName.O)
endif
DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
uninstall-local::
$(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
- $(Verb) $(RM) -f $(DestRelinkedLib)
+ -$(Verb) $(RM) -f $(DestRelinkedLib)
endif
$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
$(Echo) Building $(BuildMode) Archive Library $(notdir $@)
- $(Verb)$(RM) -f $@
+ -$(Verb) $(RM) -f $@
$(Verb) $(Archive) $@ $(ObjectsO)
$(Verb) $(Ranlib) $@
clean-local::
ifneq ($(strip $(LibName.A)),)
- $(Verb) $(RM) -f $(LibName.A)
+ -$(Verb) $(RM) -f $(LibName.A)
endif
DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
uninstall-local::
$(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
- $(Verb) $(RM) -f $(DestArchiveLib)
+ -$(Verb) $(RM) -f $(DestArchiveLib)
endif
#---------------------------------------------------------
# Set up variables for building a tool.
#---------------------------------------------------------
+ifdef EXAMPLE_TOOL
+ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
+else
ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
+endif
ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
clean-local::
ifneq ($(strip $(ToolBuildPath)),)
- $(Verb) $(RM) -f $(ToolBuildPath)
+ -$(Verb) $(RM) -f $(ToolBuildPath)
endif
-$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)\
- $(ToolDir)/.dir
+ifdef EXAMPLE_TOOL
+$(ToolBuildPath): $(ExmplDir)/.dir
+else
+$(ToolBuildPath): $(ToolDir)/.dir
+endif
+
+$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
$(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
$(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
uninstall-local::
$(Echo) Uninstalling $(BuildMode) $(DestTool)
- $(Verb) $(RM) -f $(DestTool)
+ -$(Verb) $(RM) -f $(DestTool)
endif
$(Verb) $(TableGen) -gen-emitter -o $@ $<
clean-local::
- $(Verb) $(RM) -f $(INCFiles)
+ -$(Verb) $(RM) -f $(INCFiles)
endif
# (f)lex input sources.
#---------------------------------------------------------
-LexOutput := $(strip $(subst %.l,%.cpp,$(filter %.l,$(Sources))))
+LexFiles := $(filter %.l,$(Sources))
+
+ifneq ($(LexFiles),)
-ifneq ($(LexOutput),)
+LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
.PRECIOUS: $(LexOutput)
> $@
clean-local::
- $(RM) -f $(LexOutput)
+ -$(Verb) $(RM) -f $(LexOutput)
+ $(Verb) $(RM) -f $(LexOutput)
endif
# from yacc (bison) input sources.
#---------------------------------------------------------
-YaccOutput := $(strip $(addprefix $(subst %.y,%,$(filter %.y,$(Sources))),\
- .h .cpp .output))
-
-ifneq ($(YaccOutput),)
+YaccFiles := $(filter %.y,$(Sources))
+ifneq ($(YaccFiles),)
+YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
.PRECIOUS: $(YaccOutput)
$(Verb) $(MV) -f $*.tab.h $*.h
clean-local::
- $(RM) -f $(YaccOutput)
+ -$(Verb) $(RM) -f $(YaccOutput)
+ $(Verb) $(RM) -f $(YaccOutput)
endif
###############################################################################
# errors or disastrous removal.
clean-local::
ifneq ($(strip $(ObjDir)),)
- $(Verb) $(RM) -rf $(ObjDir)
+ -$(Verb) $(RM) -rf $(ObjDir)
endif
- $(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
+ -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
- $(Verb) $(RM) -f *$(SHLIBEXT)
+ -$(Verb) $(RM) -f *$(SHLIBEXT)
endif
+clean-all-local::
+ -$(Verb) $(RM) -rf Debug Release Profile
+
# Build tags database for Emacs/Xemacs:
-tags:: TAGS
+tags:: TAGS CTAGS
+
TAGS:
- find include lib tools examples -name '*.cpp' -o -name '*.h' | \
+ find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
+ $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
+ $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
+ $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
+ -name '*.cpp' -o -name '*.h' | \
$(ETAGS) $(ETAGSFLAGS) -
+CTAGS:
+ find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
+ $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
+ $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
+ $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
+ \( -name '*.cpp' -o -name '*.h' \) -print | \
+ ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
+
+
###############################################################################
# DEPENDENCIES: Include the dependency files if we should
###############################################################################
dist-clean::
$(Echo) Cleaning distribution files
- $(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
+ -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
endif
$(Echo) "ObjDir : " '$(ObjDir)'
$(Echo) "LibDir : " '$(LibDir)'
$(Echo) "ToolDir : " '$(ToolDir)'
+ $(Echo) "ExmplDir : " '$(ExmplDir)'
$(Echo) "TDFiles : " '$(TDFiles)'
$(Echo) "INCFiles : " '$(INCFiles)'
$(Echo) "Compile.CXX : " '$(Compile.CXX)'
$(Echo) "Compile.C : " '$(Compile.C)'
$(Echo) "Archive : " '$(Archive)'
+ $(Echo) "YaccFiles : " '$(YaccFiles)'
+ $(Echo) "LexFiles : " '$(LexFiles)'