Skip to content
Makefile.rules 69.7 KiB
Newer Older
Reid Spencer's avatar
Reid Spencer committed
###############################################################################
# Library Build Rules: Four ways to build a library
###############################################################################
Chris Lattner's avatar
Chris Lattner committed

#---------------------------------------------------------
# Bytecode Module Targets:
#   If the user set MODULE_NAME then they want to build a
#   bytecode module from the sources. We compile all the
#   sources and link it together into a single bytecode
#   module.
#---------------------------------------------------------

ifdef MODULE_NAME
ifeq ($(strip $(LLVMCC)),)
$(warning Modules require LLVM capable compiler but none is available ****)
Reid Spencer's avatar
Reid Spencer committed
else

Module     := $(LibDir)/$(MODULE_NAME).bc
Chris Lattner's avatar
Chris Lattner committed
LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer's avatar
Reid Spencer committed
$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
	$(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
	$(Verb) $(LinkModule) -o $@ $(ObjectsBC)

all-local:: $(Module)

clean-local::
ifneq ($(strip $(Module)),)
	-$(Verb) $(RM) -f $(Module)
endif

ifdef BYTECODE_DESTINATION
ModuleDestDir := $(BYTECODE_DESTINATION)
else
ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
ifdef NO_INSTALL
install-local::
	$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
	$(Echo) Uninstall circumvented with NO_INSTALL
else
DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
install-local:: $(DestModule)

$(DestModule): $(ModuleDestDir) $(Module)
	$(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
	$(Verb) $(DataInstall) $(Module) $(DestModule)

uninstall-local::
	$(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
	-$(Verb) $(RM) -f $(DestModule)
Reid Spencer's avatar
Reid Spencer committed
endif
Reid Spencer's avatar
Reid Spencer committed
# if we're building a library ...
Chris Lattner's avatar
Chris Lattner committed
ifdef LIBRARYNAME
# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
LIBRARYNAME := $(strip $(LIBRARYNAME))
Nick Lewycky's avatar
Nick Lewycky committed
LibName.A  := $(LibDir)/$(LIBRARYNAME).a
LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
LibName.A  := $(LibDir)/lib$(LIBRARYNAME).a
Nick Lewycky's avatar
Nick Lewycky committed
LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
endif
LibName.O  := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer's avatar
Reid Spencer committed
LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Reid Spencer's avatar
Reid Spencer committed
#---------------------------------------------------------
# Shared Library Targets:
#   If the user asked for a shared library to be built
#   with the SHARED_LIBRARY variable, then we provide
#   targets for building them.
#---------------------------------------------------------
Nick Lewycky's avatar
Nick Lewycky committed
all-local:: $(LibName.SO)
ifdef EXPORTED_SYMBOL_FILE
$(LibName.SO): $(NativeExportsFile)
endif

Reid Spencer's avatar
Reid Spencer committed
ifdef LOADABLE_MODULE
SharedLibKindMessage := "Loadable Module"
Reid Spencer's avatar
Reid Spencer committed
else
SharedLibKindMessage := "Shared Library"
endif
Nick Lewycky's avatar
Nick Lewycky committed
$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
	  $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
	  $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
Nick Lewycky's avatar
Nick Lewycky committed
$(LibName.SO): $(ObjectsO) $(LibDir)/.dir
	$(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
Reid Spencer's avatar
Reid Spencer committed

clean-local::
Nick Lewycky's avatar
Nick Lewycky committed
ifneq ($(strip $(LibName.SO)),)
	-$(Verb) $(RM) -f $(LibName.SO)
ifdef NO_INSTALL
install-local::
	$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
	$(Echo) Uninstall circumvented with NO_INSTALL
else
DestSharedLib = $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
install-local:: $(DestSharedLib)
$(DestSharedLib): $(LibName.SO) $(DESTDIR)$(PROJ_libdir)
	$(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
uninstall-local::
	$(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
	-$(Verb) $(RM) -f $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).*
Chris Lattner's avatar
Chris Lattner committed

Reid Spencer's avatar
Reid Spencer committed
#---------------------------------------------------------
# Bytecode Library Targets:
#   If the user asked for a bytecode library to be built
#   with the BYTECODE_LIBRARY variable, then we provide
Reid Spencer's avatar
Reid Spencer committed
#   targets for building them.
#---------------------------------------------------------
ifeq ($(strip $(LLVMCC)),)
$(warning Bytecode libraries require LLVM capable compiler but none is available ****)
Reid Spencer's avatar
Reid Spencer committed
else
Reid Spencer's avatar
Reid Spencer committed
all-local:: $(LibName.BCA)
Reid Spencer's avatar
Reid Spencer committed
ifdef EXPORTED_SYMBOL_FILE
BCLinkLib = $(LLVMLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer's avatar
Reid Spencer committed
$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
                $(LLVMToolDir)/llvm-ar
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
	  "(internalize)"
	$(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
	$(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
Reid Spencer's avatar
Reid Spencer committed
else
$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
                $(LLVMToolDir)/llvm-ar
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) $(LArchive) $@ $(ObjectsBC)

endif
Chris Lattner's avatar
Chris Lattner committed

Reid Spencer's avatar
Reid Spencer committed
clean-local::
Reid Spencer's avatar
Reid Spencer committed
ifneq ($(strip $(LibName.BCA)),)
	-$(Verb) $(RM) -f $(LibName.BCA)
ifdef BYTECODE_DESTINATION
BytecodeDestDir := $(BYTECODE_DESTINATION)
else
BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
Reid Spencer's avatar
Reid Spencer committed

install-bytecode-local:: $(DestBytecodeLib)
ifdef NO_INSTALL
install-local::
	$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
	$(Echo) Uninstall circumvented with NO_INSTALL
else
install-local:: $(DestBytecodeLib)
$(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
	$(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Chris Lattner's avatar
Chris Lattner committed

Reid Spencer's avatar
Reid Spencer committed
	$(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer's avatar
Reid Spencer committed
endif
#---------------------------------------------------------
# Library Targets:
#   If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
#   building an archive.
#---------------------------------------------------------
ifndef LOADABLE_MODULE
BUILD_ARCHIVE = 1
#---------------------------------------------------------
# Archive Library Targets:
#   If the user wanted a regular archive library built,
#   then we provide targets for building them.
#---------------------------------------------------------
$(LibName.A): $(ObjectsO) $(LibDir)/.dir
	$(Echo) Building $(BuildMode) Archive Library $(notdir $@)
	$(Verb) $(Archive) $@ $(ObjectsO)
	$(Verb) $(Ranlib) $@
Reid Spencer's avatar
Reid Spencer committed
clean-local::
ifdef NO_INSTALL
install-local::
	$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
	$(Echo) Uninstall circumvented with NO_INSTALL
else
DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
install-local:: $(DestArchiveLib)
$(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
	$(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
	$(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
	$(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Chris Lattner's avatar
Chris Lattner committed
endif

Reid Spencer's avatar
Reid Spencer committed
# endif LIBRARYNAME
###############################################################################
# Tool Build Rules: Build executable tool based on TOOLNAME option
###############################################################################

#---------------------------------------------------------
# Set up variables for building a tool.
#---------------------------------------------------------
TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer's avatar
Reid Spencer committed
ifdef EXAMPLE_TOOL
ToolBuildPath   := $(ExmplDir)/$(TOOLEXENAME)
Reid Spencer's avatar
Reid Spencer committed
else
ToolBuildPath   := $(ToolDir)/$(TOOLEXENAME)
endif

# TOOLALIAS is a name to symlink (or copy) the tool to.
ifdef TOOLALIAS
ifdef EXAMPLE_TOOL
ToolAliasBuildPath   := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
else
ToolAliasBuildPath   := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
endif
Reid Spencer's avatar
Reid Spencer committed
endif
#---------------------------------------------------------
# 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

# Tiger tools don't support this.
ifneq ($(DARWIN_MAJVERS),4)
LD.Flags += -Wl,-exported_symbol -Wl,_main
endif
ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
Nick Lewycky's avatar
Nick Lewycky committed
  LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
#---------------------------------------------------------
# Provide targets for building the tools
#---------------------------------------------------------
all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
Reid Spencer's avatar
Reid Spencer committed
clean-local::
Reid Spencer's avatar
Reid Spencer committed
endif
ifneq ($(strip $(ToolAliasBuildPath)),)
	-$(Verb) $(RM) -f $(ToolAliasBuildPath)
endif
Reid Spencer's avatar
Reid Spencer committed
ifdef EXAMPLE_TOOL
$(ToolBuildPath): $(ExmplDir)/.dir
else
$(ToolBuildPath): $(ToolDir)/.dir
endif

Chris Lattner's avatar
Chris Lattner committed
$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
	$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
	$(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattner's avatar
Chris Lattner committed
	$(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
          $(StripWarnMsg)
ifneq ($(strip $(ToolAliasBuildPath)),)
$(ToolAliasBuildPath): $(ToolBuildPath)
	$(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
	$(Verb) $(RM) -f $(ToolAliasBuildPath)
	$(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
	$(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLNAME) \
          $(StripWarnMsg)
endif

ifdef NO_INSTALL
install-local::
	$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
	$(Echo) Uninstall circumvented with NO_INSTALL
else
DestTool = $(DESTDIR)$(PROJ_bindir)/$(TOOLEXENAME)
$(DestTool): $(ToolBuildPath) $(DESTDIR)$(PROJ_bindir)
	$(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
	$(Echo) Uninstalling $(BuildMode) $(DestTool)
DestToolAlias = $(DESTDIR)$(PROJ_bindir)/$(TOOLALIAS)$(EXEEXT)

install-local:: $(DestToolAlias)

$(DestToolAlias): $(DestTool) $(PROJ_bindir)
	$(Echo) Installing $(BuildMode) $(DestToolAlias)
	$(Verb) $(RM) -f $(DestToolAlias)
	$(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)

uninstall-local::
	$(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
	-$(Verb) $(RM) -f $(DestToolAlias)
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"
# Provide rule sets for when dependency generation is enabled
#---------------------------------------------------------
Nick Lewycky's avatar
Nick Lewycky committed
# Create .o files in the ObjDir directory from the .cpp and .c files...
#---------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed

DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
Nick Lewycky's avatar
Nick Lewycky committed
         -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
# If the build succeeded, move the dependency file over, otherwise
# remove it.
DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
                  else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi

$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
	$(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Reid Spencer's avatar
Reid Spencer committed

$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
	$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
	$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Reid Spencer's avatar
Reid Spencer committed

#---------------------------------------------------------
# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
#---------------------------------------------------------
BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
	-MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"

# If the build succeeded, move the dependency file over, otherwise
# remove it.
BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
                     else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi

$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
	$(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
	$(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
                              $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
	        $(BC_DEPEND_MOVEFILE)
$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
	$(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
	$(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
                              $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
	        $(BC_DEPEND_MOVEFILE)
$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
	$(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
	$(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
                              $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
	        $(BC_DEPEND_MOVEFILE)

# Provide alternate rule sets if dependencies are disabled
Nick Lewycky's avatar
Nick Lewycky committed
$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
	$(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Compile.CXX) $< -o $@
Reid Spencer's avatar
Reid Spencer committed

Nick Lewycky's avatar
Nick Lewycky committed
$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
	$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Compile.CXX) $< -o $@
Nick Lewycky's avatar
Nick Lewycky committed
$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
	$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Compile.C) $< -o $@
$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
	$(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattner's avatar
Chris Lattner committed
	$(BCCompile.CXX) $< -o $@ -S -emit-llvm
$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
	$(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner's avatar
Chris Lattner committed
	$(BCCompile.CXX) $< -o $@ -S -emit-llvm
$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
	$(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattner's avatar
Chris Lattner committed
	$(BCCompile.C) $< -o $@ -S -emit-llvm

endif

## 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)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Compile.CXX) $< -o $@ -S

$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
	$(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Compile.CXX) $< -o $@ -S

$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
	$(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky's avatar
Nick Lewycky committed
	$(Compile.C) $< -o $@ -S
Chris Lattner's avatar
Chris Lattner committed
# make the C and C++ compilers strip debug info out of bytecode libraries.
$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
	$(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
	$(Verb) $(LOPT) $< -std-compile-opts -o $@
$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Chris Lattner's avatar
Chris Lattner committed
	$(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
	$(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
#---------------------------------------------------------
# Provide rule to build .bc files from .ll sources,
# regardless of dependencies
#---------------------------------------------------------
$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
	$(Echo) "Compiling $*.ll for $(BuildMode) build"
###############################################################################
# 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
Chris Lattner's avatar
Chris Lattner committed

Chris Lattner's avatar
Chris Lattner committed
TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
           $(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)
# 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, $@) $<
$(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, $@) $<
Chris Lattner's avatar
Chris Lattner committed

$(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)/%GenAsmMatcher.inc.tmp): \
$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
	$(Echo) "Building $(<F) assembly matcher with tblgen"
	$(Verb) $(TableGen) -gen-asm-matcher -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)/%GenDisassemblerTables.inc.tmp): \
$(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir
	$(Echo) "Building $(<F) disassembly tables with tblgen"
	$(Verb) $(TableGen) -gen-disassembler -o $(call SYSPATH, $@) $<

$(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
$(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir
	$(Echo) "Building $(<F) enhanced disassembly information with tblgen"
	$(Verb) $(TableGen) -gen-enhanced-disassembly-info -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 : %.td $(ObjDir)/.dir
	$(Echo) "Building $(<F) intrinsics information with tblgen"
	$(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<

$(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir
	$(Echo) "Building $(<F) decoder tables with tblgen"
	$(Verb) $(TableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<


Reid Spencer's avatar
Reid Spencer committed
clean-local::
endif # TARGET

ifdef LLVMC_BUILD_AUTOGENERATED_INC

LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
	$(strip $(wildcard $(PROJ_OBJ_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
###############################################################################
Chris Lattner's avatar
Chris Lattner committed
# To create postscript files from dot files...
Chris Lattner's avatar
Chris Lattner committed
%.ps: %.dot
	$(Echo) "Cannot build $@: The program dot is not installed"
Chris Lattner's avatar
Chris Lattner committed

# 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.
# Define clean-local to clean the current directory. Note that this uses a
# very conservative approach ensuring that empty variables do not cause
Reid Spencer's avatar
Reid Spencer committed
clean-local::
ifneq ($(strip $(ObjRootDir)),)
	-$(Verb) $(RM) -rf $(ObjRootDir)
Reid Spencer's avatar
Reid Spencer committed
endif
	-$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
clean-all-local::
	-$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer's avatar
Reid Spencer committed
###############################################################################
# DEPENDENCIES: Include the dependency files if we should
###############################################################################
ifndef DISABLE_AUTO_DEPENDENCIES

Reid Spencer's avatar
Reid Spencer committed
# If its not one of the cleaning targets
ifndef IS_CLEANING_TARGET
Reid Spencer's avatar
Reid Spencer committed
# Get the list of dependency files
DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)

# Include bitcode dependency files if using bitcode libraries
ifdef BYTECODE_LIBRARY
DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
endif
Reid Spencer's avatar
Reid Spencer committed

-include $(DependFiles) ""
###############################################################################
# CHECK: Running the test suite
###############################################################################

Reid Spencer's avatar
Reid Spencer committed
	$(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
	  if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
	    $(EchoCmd) Running test suite ; \
Reid Spencer's avatar
Reid Spencer committed
	    $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
	      TESTSUITE=$(TESTSUITE) ; \
	  else \
	    $(EchoCmd) No Makefile in test directory ; \
	  fi ; \
	else \
	  $(EchoCmd) No test directory ; \
	fi

check-lit::
	$(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
	  if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
	    $(EchoCmd) Running test suite ; \
	    $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
	  else \
	    $(EchoCmd) No Makefile in test directory ; \
	  fi ; \
	else \
	  $(EchoCmd) No test directory ; \
	fi

check-all::
	$(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
	  if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
	    $(EchoCmd) Running test suite ; \
	    $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
	  else \
	    $(EchoCmd) No Makefile in test directory ; \
	  fi ; \
	else \
	  $(EchoCmd) No test directory ; \
	fi

###############################################################################
# UNITTESTS: Running the unittests test suite
###############################################################################

	$(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 unitcheck; \
	  else \
	    $(EchoCmd) No Makefile in unittests directory ; \
	  fi ; \
	else \
	  $(EchoCmd) No unittests directory ; \
	fi

Reid Spencer's avatar
Reid Spencer committed
###############################################################################
# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer's avatar
Reid Spencer committed
###############################################################################

#------------------------------------------------------------------------
# Define distribution related variables
#------------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed
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 \
Reid Spencer's avatar
Reid Spencer committed
               $(PROJ_SRC_DIR)/*.h \
               $(PROJ_SRC_DIR)/*.td \
               $(PROJ_SRC_DIR)/*.def \
               $(PROJ_SRC_DIR)/*.ll \
               $(PROJ_SRC_DIR)/*.in))
DistSources  = $(Sources) $(EXTRA_DIST)
DistFiles    = $(DistAlways) $(DistSources) $(DistOther)
#------------------------------------------------------------------------
# We MUST build distribution with OBJ_DIR != SRC_DIR
#------------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed
ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer's avatar
Reid Spencer committed
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
#------------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed
ifneq ($(LEVEL),.)
dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
#------------------------------------------------------------------------
# Provide the top level targets
#------------------------------------------------------------------------

$(DistTarGZip) : $(TopDistDir)/.makedistdir
	$(Echo) Packing gzipped distribution tar file.
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
	  $(GZIP) -c > "$(DistTarGZip)"
$(DistTarBZ2) : $(TopDistDir)/.makedistdir
	$(Echo) Packing bzipped distribution tar file.
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
	  $(BZIP2) -c >$(DistTarBZ2)
$(DistZip) : $(TopDistDir)/.makedistdir
	$(Echo) Packing zipped distribution file.
	$(Verb) rm -f $(DistZip)
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
	$(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
dist-check:: $(DistTarGZip)
	$(Echo) Checking distribution tar file.
	$(Verb) if test -d $(DistCheckDir) ; then \
	$(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) all && \
	  $(MAKE) install && \
	  $(MAKE) uninstall && \
	  $(MAKE) dist-clean && \
	  $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer's avatar
Reid Spencer committed

dist-clean::
	$(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 ; \
	  $(EchoCmd) Removing old $(DistDir) ; \
	  $(EchoCmd) Making 'all' to verify build ; \
	  $(MAKE) ENABLE_OPTIMIZED=1 all ; \
	$(Echo) Building Distribution Directory $(DistDir)
	$(Verb) $(MKDIR) $(DistDir)
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
	srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer's avatar
Reid Spencer committed
	for file in $(DistFiles) ; do \
	  case "$$file" in \
Reid Spencer's avatar
Reid Spencer committed
	    $(PROJ_SRC_DIR)/*) \
	      file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
	      ;; \
Reid Spencer's avatar
Reid Spencer committed
	    $(PROJ_SRC_ROOT)/*) \
	      file=`echo "$$file" | \
		sed "s#^$$srcrootstrip/##"` \
	      ;; \
Reid Spencer's avatar
Reid Spencer committed
	  esac; \
Reid Spencer's avatar
Reid Spencer committed
	  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 \
Reid Spencer's avatar
Reid Spencer committed
	    from_dir=. ; \
	  fi ; \
	  to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer's avatar
Reid Spencer committed
	  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; \
Reid Spencer's avatar
Reid Spencer committed
          fi ; \
	  if test -d "$$from_dir/$$file"; then \
Reid Spencer's avatar
Reid Spencer committed
	    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) ; \
Reid Spencer's avatar
Reid Spencer committed
	    fi; \
	  elif test -f "$$from_dir/$$file" ; then \
Reid Spencer's avatar
Reid Spencer committed
	    $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer's avatar
Reid Spencer committed
	  elif test -L "$$from_dir/$$file" ; then \
Reid Spencer's avatar
Reid Spencer committed
	    $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer's avatar
Reid Spencer committed
	  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" ; \
Reid Spencer's avatar
Reid Spencer committed
	  fi; \
	done
	$(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer's avatar
Reid Spencer committed
	  if test "$$subdir" \!= "." ; then \
	    new_distdir="$(DistDir)/$$subdir" ; \
	    test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
	    ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencer's avatar
Reid Spencer committed
	      DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer's avatar
Reid Spencer committed
	  fi; \
	done
	$(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.
Reid Spencer's avatar
Reid Spencer committed
dist-hook::

endif

###############################################################################
# TOP LEVEL - targets only to apply at the top level directory
###############################################################################

ifeq ($(LEVEL),.)
Reid Spencer's avatar
Reid Spencer committed

#------------------------------------------------------------------------
# Install support for the project's include files:
Reid Spencer's avatar
Reid Spencer committed
#------------------------------------------------------------------------
ifdef NO_INSTALL
install-local::
	$(Echo) Install circumvented with NO_INSTALL
uninstall-local::