Newer
Older
endif
endif
#---------------------------------------------------------
# ReLinked Library Targets:
Chris Lattner
committed
# If the user explicitly requests a relinked library with
# BUILD_RELINKED, provide it. Otherwise, if they specify
# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
# them one.
#---------------------------------------------------------
Chris Lattner
committed
ifndef BUILD_ARCHIVE
ifndef DONT_BUILD_RELINKED
Chris Lattner
committed
BUILD_RELINKED = 1
endif
endif
ifdef BUILD_RELINKED
all-local:: $(LibName.O)
$(LibName.O): $(ObjectsO) $(LibDir)/.dir
$(Echo) Linking $(BuildMode) Object Library $(notdir $@)
$(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO)
Vikram S. Adve
committed
ifneq ($(strip $(LibName.O)),)
-$(Verb) $(RM) -f $(LibName.O)
ifdef NO_INSTALL
install-local::
$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
$(Echo) Uninstall circumvented with NO_INSTALL
else
install-local:: $(DestRelinkedLib)
$(DestRelinkedLib): $(LibName.O) $(PROJ_libdir)
$(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
uninstall-local::
$(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
-$(Verb) $(RM) -f $(DestRelinkedLib)
endif
endif
#---------------------------------------------------------
# Archive Library Targets:
# If the user wanted a regular archive library built,
# then we provide targets for building them.
#---------------------------------------------------------
ifdef BUILD_ARCHIVE
all-local:: $(LibName.A)
$(LibName.A): $(ObjectsO) $(LibDir)/.dir
$(Echo) Building $(BuildMode) Archive Library $(notdir $@)
-$(Verb) $(RM) -f $@
$(Verb) $(Archive) $@ $(ObjectsO)
$(Verb) $(Ranlib) $@
ifneq ($(strip $(LibName.A)),)
-$(Verb) $(RM) -f $(LibName.A)
ifdef NO_INSTALL
install-local::
$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
$(Echo) Uninstall circumvented with NO_INSTALL
else
install-local:: $(DestArchiveLib)
$(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
$(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
uninstall-local::
$(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
-$(Verb) $(RM) -f $(DestArchiveLib)
endif
###############################################################################
# Tool Build Rules: Build executable tool based on TOOLNAME option
###############################################################################
ifdef TOOLNAME
#---------------------------------------------------------
# Set up variables for building a tool.
#---------------------------------------------------------
ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
#---------------------------------------------------------
# Prune Exports
#---------------------------------------------------------
# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
# not exporting all of the weak symbols from the binary. This reduces dyld
# startup time by 4x on darwin in some cases.
ifdef TOOL_NO_EXPORTS
ifeq ($(OS),Darwin)
# Tiger tools don't support this.
ifneq ($(DARWIN_MAJVERS),4)
LD.Flags += -Wl,-exported_symbol -Wl,_main
endif
endif
ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
endif
endif
#---------------------------------------------------------
# Provide targets for building the tools
#---------------------------------------------------------
all-local:: $(ToolBuildPath)
John Criswell
committed
ifneq ($(strip $(ToolBuildPath)),)
-$(Verb) $(RM) -f $(ToolBuildPath)
ifdef EXAMPLE_TOOL
$(ToolBuildPath): $(ExmplDir)/.dir
else
$(ToolBuildPath): $(ToolDir)/.dir
endif
$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
$(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
$(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
$(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
ifdef NO_INSTALL
install-local::
$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
$(Echo) Uninstall circumvented with NO_INSTALL
else
install-local:: $(DestTool)
$(DestTool): $(ToolBuildPath) $(PROJ_bindir)
$(Echo) Installing $(BuildMode) $(DestTool)
uninstall-local::
$(Echo) Uninstalling $(BuildMode) $(DestTool)
-$(Verb) $(RM) -f $(DestTool)
endif
endif
###############################################################################
# Object Build Rules: Build object files based on sources
###############################################################################
# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
ifeq ($(OS),HP-UX)
DISABLE_AUTO_DEPENDENCIES=1
endif
# Provide rule sets for when dependency generation is enabled
ifndef DISABLE_AUTO_DEPENDENCIES
#---------------------------------------------------------
# Create .o files in the ObjDir directory from the .cpp and .c files...
#---------------------------------------------------------
DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
# If the build succeeded, move the dependency file over. If it failed, put an
# empty file there.
DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
$(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattner
committed
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
#---------------------------------------------------------
Chris Lattner
committed
# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
#---------------------------------------------------------
$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
$(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
$(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
$< -o $@ -S -emit-llvm ; \
then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattner
committed
$(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
$(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
$< -o $@ -S -emit-llvm ; \
Chris Lattner
committed
then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Chris Lattner
committed
$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
$(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
$(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
$< -o $@ -S -emit-llvm ; \
then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
# Provide alternate rule sets if dependencies are disabled
else
$(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Chris Lattner
committed
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
$(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattner
committed
$(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner
committed
$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
$(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
## Rules for building preprocessed (.i/.ii) outputs.
$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
$(Verb) $(Preprocess.CXX) $< -o $@
$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
$(Verb) $(Preprocess.CXX) $< -o $@
$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
$(Verb) $(Preprocess.C) $< -o $@
$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
# make the C and C++ compilers strip debug info out of bytecode libraries.
ifdef DEBUG_RUNTIME
$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
$(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
$(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
else
$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
$(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
$(LOPT) -std-compile-opts -strip-debug -o $@ -f
endif
#---------------------------------------------------------
# Provide rule to build .bc files from .ll sources,
# regardless of dependencies
#---------------------------------------------------------
$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
$(Echo) "Compiling $*.ll for $(BuildMode) build"
$(Verb) $(LLVMAS) $< -f -o $@
###############################################################################
# TABLEGEN: Provide rules for running tblgen to produce *.inc files
###############################################################################
ifdef TARGET
TABLEGEN_INC_FILES_COMMON = 1
endif
ifdef LLVMC_BUILD_AUTOGENERATED_INC
TABLEGEN_INC_FILES_COMMON = 1
endif
ifdef TABLEGEN_INC_FILES_COMMON
INCFiles := $(filter %.inc,$(BUILT_SOURCES))
INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
.PRECIOUS: $(INCTMPFiles) $(INCFiles)
# INCFiles rule: All of the tblgen generated files are emitted to
# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
# us to only "touch" the real file if the contents of it change. IOW, if
# tblgen is modified, all of the .inc.tmp files are regenerated, but no
# dependencies of the .inc files are, unless the contents of the .inc file
# changes.
$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
$(Verb) $(CMP) -s $@ $< || $(CP) $< $@
endif # TABLEGEN_INC_FILES_COMMON
ifdef TARGET
$(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
$(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
$(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
$(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
$(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
$(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
Rafael Espindola
committed
# All of these files depend on tblgen and the .td files.
$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) register names with tblgen"
$(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) register information header with tblgen"
$(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
Vikram S. Adve
committed
$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) register info implementation with tblgen"
$(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) instruction names with tblgen"
$(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) instruction information with tblgen"
$(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) assembly writer with tblgen"
$(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) assembly writer #1 with tblgen"
$(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) code emitter with tblgen"
$(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
$(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
$(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) subtarget information with tblgen"
$(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) calling convention information with tblgen"
$(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
$(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
$(Echo) "Building $(<F) calling convention information with tblgen"
$(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
-$(Verb) $(RM) -f $(INCFiles)
endif # TARGET
ifdef LLVMC_BUILD_AUTOGENERATED_INC
LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
TDFiles := $(LLVMCPluginSrc) \
$(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
$(TBLGEN) $(TD_COMMON)
$(Echo) "Building LLVMC configuration library with tblgen"
$(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
endif # LLVMC_BUILD_AUTOGENERATED_INC
###############################################################################
# OTHER RULES: Other rules needed
###############################################################################
ifneq ($(DOT),false)
%.ps: %.dot
$(DOT) -Tps < $< > $@
else
$(Echo) "Cannot build $@: The program dot is not installed"
endif
# This rules ensures that header files that are removed still have a rule for
# which they can be "generated." This allows make to ignore them and
# reproduce the dependency lists.
John Criswell
committed
%.h:: ;
Chris Lattner
committed
%.hpp:: ;
# Define clean-local to clean the current directory. Note that this uses a
# very conservative approach ensuring that empty variables do not cause
# errors or disastrous removal.
ifneq ($(strip $(ObjRootDir)),)
-$(Verb) $(RM) -rf $(ObjRootDir)
-$(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)
endif
-$(Verb) $(RM) -rf Debug Release Profile
###############################################################################
# DEPENDENCIES: Include the dependency files if we should
###############################################################################
ifndef DISABLE_AUTO_DEPENDENCIES
DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukman
committed
endif
###############################################################################
# CHECK: Running the test suite
###############################################################################
check::
$(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
$(EchoCmd) Running test suite ; \
TESTSUITE=$(TESTSUITE) ; \
else \
$(EchoCmd) No Makefile in test directory ; \
fi ; \
else \
$(EchoCmd) No test directory ; \
fi
Bill Wendling
committed
###############################################################################
# UNITTESTS: Running the unittests test suite
###############################################################################
unittests::
$(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
$(EchoCmd) Running unittests test suite ; \
$(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
else \
$(EchoCmd) No Makefile in unittests directory ; \
fi ; \
else \
$(EchoCmd) No unittests directory ; \
fi
###############################################################################
# DISTRIBUTION: Handle construction of a distribution tarball
###############################################################################
#------------------------------------------------------------------------
# Define distribution related variables
#------------------------------------------------------------------------
DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Makefile.config.in configure autoconf
DistOther := $(notdir $(wildcard \
$(PROJ_SRC_DIR)/*.h \
$(PROJ_SRC_DIR)/*.td \
$(PROJ_SRC_DIR)/*.def \
$(PROJ_SRC_DIR)/*.ll \
$(PROJ_SRC_DIR)/*.in))
DistSubDirs := $(SubDirs)
DistSources = $(Sources) $(EXTRA_DIST)
DistFiles = $(DistAlways) $(DistSources) $(DistOther)
#------------------------------------------------------------------------
# We MUST build distribution with OBJ_DIR != SRC_DIR
#------------------------------------------------------------------------
dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
$(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
#------------------------------------------------------------------------
# Prevent attempt to run dist targets from anywhere but the top level
#------------------------------------------------------------------------
ifneq ($(LEVEL),.)
dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
#------------------------------------------------------------------------
# Provide the top level targets
#------------------------------------------------------------------------
dist-gzip:: $(DistTarGZip)
$(DistTarGZip) : $(TopDistDir)/.makedistdir
$(Echo) Packing gzipped distribution tar file.
$(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
$(GZIP) -c > "$(DistTarGZip)"
dist-bzip2:: $(DistTarBZ2)
$(Echo) Packing bzipped distribution tar file.
$(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
$(BZIP2) -c >$(DistTarBZ2)
dist-zip:: $(DistZip)
$(Echo) Packing zipped distribution file.
$(Verb) rm -f $(DistZip)
$(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
$(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
$(Echo) Checking distribution tar file.
$(Verb) if test -d $(DistCheckDir) ; then \
$(RM) -rf $(DistCheckDir) ; \
fi
$(Verb) $(MKDIR) $(DistCheckDir)
$(Verb) cd $(DistCheckDir) && \
$(MKDIR) $(DistCheckDir)/build && \
$(MKDIR) $(DistCheckDir)/install && \
gunzip -c $(DistTarGZip) | $(TAR) xf - && \
cd build && \
../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
--srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
$(MAKE) check && \
Bill Wendling
committed
$(MAKE) unittests && \
$(MAKE) install && \
$(MAKE) uninstall && \
$(MAKE) dist-clean && \
$(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
$(Echo) Cleaning distribution files
-$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
$(DistCheckDir)
#------------------------------------------------------------------------
# Provide the recursive distdir target for building the distribution directory
#------------------------------------------------------------------------
distdir: $(DistDir)/.makedistdir
$(DistDir)/.makedistdir: $(DistSources)
$(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
if test -d "$(DistDir)" ; then \
find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
exit 1 ; \
fi ; \
$(RM) -rf $(DistDir); \
$(EchoCmd) Making 'all' to verify build ; \
$(MAKE) ENABLE_OPTIMIZED=1 all ; \
fi
$(Echo) Building Distribution Directory $(DistDir)
$(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
for file in $(DistFiles) ; do \
case "$$file" in \
file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
;; \
file=`echo "$$file" | \
sed "s#^$$srcrootstrip/##"` \
;; \
if test -f "$(PROJ_SRC_DIR)/$$file" || \
test -d "$(PROJ_SRC_DIR)/$$file" ; then \
from_dir="$(PROJ_SRC_DIR)" ; \
elif test -f "$$file" || test -d "$$file" ; then \
fi ; \
to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
to_dir="$(DistDir)/$$dir"; \
$(MKDIR) "$$to_dir" ; \
else \
to_dir="$(DistDir)"; \
fi; \
mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
if test -n "$$mid_dir" ; then \
$(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
fi ; \
if test -d "$$from_dir/$$file"; then \
if test -d "$(PROJ_SRC_DIR)/$$file" && \
test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
cd $(PROJ_SRC_DIR) ; \
$(TAR) cf - $$file --exclude .svn --exclude CVS | \
( cd $$to_dir ; $(TAR) xf - ) ; \
cd $(PROJ_OBJ_DIR) ; \
else \
cd $$from_dir ; \
$(TAR) cf - $$file --exclude .svn --exclude CVS | \
( cd $$to_dir ; $(TAR) xf - ) ; \
cd $(PROJ_OBJ_DIR) ; \
fi; \
elif test -f "$$from_dir/$$file" ; then \
$(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
$(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
$(EchoCmd) "===== WARNING: Distribution Source " \
"$$from_dir/$$file Not Found!" ; \
elif test "$(Verb)" != '@' ; then \
$(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
$(Verb) for subdir in $(DistSubDirs) ; do \
if test "$$subdir" \!= "." ; then \
new_distdir="$(DistDir)/$$subdir" ; \
test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
$(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
$(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
$(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
-name .svn \) -print` ;\
$(MAKE) dist-hook ; \
$(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
-o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
-o ! -type d ! -perm -400 -exec chmod a+r {} \; \
-o ! -type d ! -perm -444 -exec \
$(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
|| chmod -R a+r $(DistDir) ; \
fi
# This is invoked by distdir target, define it as a no-op to avoid errors if not
# defined by user.
dist-hook::
endif
###############################################################################
# TOP LEVEL - targets only to apply at the top level directory
###############################################################################
ifeq ($(LEVEL),.)
#------------------------------------------------------------------------
# Install support for the project's include files:
#------------------------------------------------------------------------
ifdef NO_INSTALL
install-local::
$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
$(Echo) Uninstall circumvented with NO_INSTALL
else
$(Echo) Installing include files
for hdr in `find . -type f '!' '(' -name '*~' \
-o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
grep -v .svn` ; do \
instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
if test \! -d "$$instdir" ; then \
$(EchoCmd) Making install directory $$instdir ; \
$(MKDIR) $$instdir ;\
fi ; \
$(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
done ; \
cd $(PROJ_OBJ_ROOT)/include && \
done ; \
$(Echo) Uninstalling include files
$(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
cd $(PROJ_SRC_ROOT)/include && \
$(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
'!' '(' -name '*~' -o -name '.#*' \
-o -name '*.in' ')' -print ')' | \
grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
cd $(PROJ_SRC_ROOT)/include && \
$(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
-print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
endif
Gabor Greif
committed
@echo searching for overlength lines in files: $(Sources)
@echo
@echo
egrep -n '.{81}' $(Sources) /dev/null
Anton Korobeynikov
committed
check-for-tabs:
Gabor Greif
committed
@echo searching for tabs in files: $(Sources)
@echo
@echo
egrep -n ' ' $(Sources) /dev/null
Gabor Greif
committed
check-footprint:
@ls -l $(LibDir) | awk '\
BEGIN { sum = 0; } \
{ sum += $$5; } \
END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
@ls -l $(ToolDir) | awk '\
BEGIN { sum = 0; } \
{ sum += $$5; } \
END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
#------------------------------------------------------------------------
# Print out the directories used for building
#------------------------------------------------------------------------
$(Echo) "BuildMode : " '$(BuildMode)'
$(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
$(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
$(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
$(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
$(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
$(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
$(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
$(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
$(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
$(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
$(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
$(Echo) "UserTargets : " '$(UserTargets)'
$(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
$(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
$(Echo) "ObjDir : " '$(ObjDir)'
$(Echo) "LibDir : " '$(LibDir)'
$(Echo) "ToolDir : " '$(ToolDir)'
$(Echo) "ExmplDir : " '$(ExmplDir)'
$(Echo) "Sources : " '$(Sources)'
$(Echo) "TDFiles : " '$(TDFiles)'
$(Echo) "INCFiles : " '$(INCFiles)'
$(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
$(Echo) "PreConditions: " '$(PreConditions)'
$(Echo) "Compile.CXX : " '$(Compile.CXX)'
$(Echo) "Compile.C : " '$(Compile.C)'
$(Echo) "Archive : " '$(Archive)'
$(Echo) "YaccFiles : " '$(YaccFiles)'
$(Echo) "LexFiles : " '$(LexFiles)'
$(Echo) "Module : " '$(Module)'
$(Echo) "SubDirs : " '$(SubDirs)'
$(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
$(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
###
# Debugging
# General debugging rule, use 'make dbg-print-XXX' to print the
# definition, value and origin of XXX.
make-print-%:
$(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))