Skip to content
Makefile.rules 73.6 KiB
Newer Older
	$(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::
	$(Echo) Uninstall circumvented with NO_INSTALL
else
Reid Spencer's avatar
Reid Spencer committed
install-local::
	$(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer's avatar
Reid Spencer committed
	  cd $(PROJ_SRC_ROOT)/include && \
	  for  hdr in `find . -type f '!' '(' -name '*~' \
	      -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
	      grep -v .svn` ; do \
	    instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
Reid Spencer's avatar
Reid Spencer committed
	    if test \! -d "$$instdir" ; then \
	      $(EchoCmd) Making install directory $$instdir ; \
	      $(MKDIR) $$instdir ;\
	    fi ; \
	    $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
Reid Spencer's avatar
Reid Spencer committed
ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer's avatar
Reid Spencer committed
	  for hdr in `find . -type f -print | grep -v CVS` ; do \
	    $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
Reid Spencer's avatar
Reid Spencer committed
endif
Reid Spencer's avatar
Reid Spencer committed

uninstall-local::
Reid Spencer's avatar
Reid Spencer committed
	$(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
	  cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer's avatar
Reid Spencer committed
	    $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
	      '!' '(' -name '*~' -o -name '.#*' \
Chris Lattner's avatar
Chris Lattner committed
        -o -name '*.in' ')' -print ')' | \
        grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
	  cd $(PROJ_SRC_ROOT)/include && \
Chris Lattner's avatar
Chris Lattner committed
	    $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
      -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
	@echo searching for overlength lines in files: $(Sources)
	@echo
	@echo
	egrep -n '.{81}' $(Sources) /dev/null
	@echo searching for tabs in files: $(Sources)
	@echo
	@echo
	egrep -n '	' $(Sources) /dev/null
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
#------------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed
printvars::
Reid Spencer's avatar
Reid Spencer committed
	$(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)'
Reid Spencer's avatar
Reid Spencer committed
	$(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)'
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) "Compile.CXX  : " '$(Compile.CXX)'
	$(Echo) "Compile.C    : " '$(Compile.C)'
	$(Echo) "Archive      : " '$(Archive)'
	$(Echo) "YaccFiles    : " '$(YaccFiles)'
	$(Echo) "LexFiles     : " '$(LexFiles)'
	$(Echo) "Module       : " '$(Module)'
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
	$(Echo) "SubDirs      : " '$(SubDirs)'
Reid Spencer's avatar
Reid Spencer committed
	$(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
	$(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
# General debugging rule, use 'make dbg-print-XXX' to print the
# definition, value and origin of XXX.
	$(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))