Honor the DESTDIR variable to install out-of-place (Eg. for packaging).
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Nov 16 21:55:46 2008 +0000 (2008-11-16)
changeset 10470c450efc5e3f
parent 1046 f07b7b9619c6
child 1048 06521debb8ed
Honor the DESTDIR variable to install out-of-place (Eg. for packaging).

/trunk/configure | 10 10 0 0 +++++++++
/trunk/Makefile.in | 62 36 26 0 +++++++++++++++++++++++++++++++-----------------------
/trunk/docs/overview.txt | 12 12 0 0 ++++++++++
3 files changed, 58 insertions(+), 26 deletions(-)
Makefile.in
configure
docs/overview.txt
     1.1 --- a/Makefile.in	Sun Nov 16 20:38:07 2008 +0000
     1.2 +++ b/Makefile.in	Sun Nov 16 21:55:46 2008 +0000
     1.3 @@ -5,11 +5,21 @@
     1.4  
     1.5  all: Makefile build
     1.6  
     1.7 +###############################################################################
     1.8 +# Sanity checks
     1.9 +
    1.10  # Check if Makefile is up to date:
    1.11  Makefile: Makefile.in
    1.12  	@echo "$< did changed: you must re-run './configure'"
    1.13  	@false
    1.14  
    1.15 +# If installing with DESTDIR, check it's an absolute path
    1.16 +ifneq ($(strip $(DESTDIR)),)
    1.17 +  ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
    1.18 +    $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
    1.19 +  endif
    1.20 +endif
    1.21 +
    1.22  ###############################################################################
    1.23  # Configuration variables
    1.24  
    1.25 @@ -100,46 +110,46 @@
    1.26  #--------------------------------------
    1.27  # Install rules
    1.28  
    1.29 -install-bin: $(BINDIR)
    1.30 +install-bin: $(DESTDIR)$(BINDIR)
    1.31  	@echo "  INST   'ct-ng'"
    1.32 -	@install -m 755 ct-ng "$(BINDIR)/ct-ng"
    1.33 +	@install -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
    1.34  
    1.35  # If one is hacking crosstool-NG, the patch set might change between any two
    1.36  # installations of the same VERSION, thus the patches must be removed prior
    1.37  # to being installed. It is simpler to remove the whole lib/ directory, as it
    1.38  # is the goal of the install-lib rule to install the lib/ directory...
    1.39 -install-lib: uninstall-lib $(LIBDIR) install-lib-main install-lib-samples
    1.40 +install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
    1.41  
    1.42  install-lib-main: $(LIBDIR)
    1.43 -	@for src_dir in config kconfig patches scripts tools; do                \
    1.44 -	     echo "  INST   '$${src_dir}/'";                                    \
    1.45 -	     tar cf - --exclude=.svn $${src_dir} |(cd "$(LIBDIR)"; tar xf -);   \
    1.46 +	@for src_dir in config kconfig patches scripts tools; do                        \
    1.47 +	     echo "  INST   '$${src_dir}/'";                                            \
    1.48 +	     tar cf - --exclude=.svn $${src_dir} |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
    1.49  	 done
    1.50 -	@rm -f "$(LIBDIR)/tools/addToolVersion.sh"
    1.51 +	@rm -f "$(DESTDIR)$(LIBDIR)/tools/addToolVersion.sh"
    1.52  	@echo "  INST   'steps.mk'"
    1.53 -	@install -m 644 steps.mk "$(LIBDIR)/steps.mk"
    1.54 +	@install -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
    1.55  
    1.56  # Samples need a little love:
    1.57  #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
    1.58 -install-lib-samples: $(LIBDIR) install-lib-main
    1.59 +install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
    1.60  	@echo "  INST   'samples/'"
    1.61 -	@tar cf - --exclude=.svn samples |(cd "$(LIBDIR)"; tar xf -)
    1.62 -	@for samp_file in "$(LIBDIR)/samples/"*"/crosstool.config"; do                          \
    1.63 +	@tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
    1.64 +	@for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do                \
    1.65  	     sed -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file};             \
    1.66  	     sed -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file};   \
    1.67  	 done
    1.68  
    1.69 -install-doc: $(DOCDIR)
    1.70 -	@for doc_file in docs/CREDITS docs/overview.txt; do \
    1.71 -	     echo "  INST   '$${doc_file}'";                \
    1.72 -	     install -m 644 "$${doc_file}" "$(DOCDIR)";     \
    1.73 +install-doc: $(DESTDIR)$(DOCDIR)
    1.74 +	@for doc_file in docs/CREDITS docs/overview.txt; do         \
    1.75 +	     echo "  INST   '$${doc_file}'";                        \
    1.76 +	     install -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)";   \
    1.77  	 done
    1.78  
    1.79 -install-man: $(MANDIR)
    1.80 +install-man: $(DESTDIR)$(MANDIR)
    1.81  	@echo "  INST   'ct-ng.1.gz'"
    1.82 -	@install -m 644 docs/ct-ng.1.gz "$(MANDIR)"
    1.83 +	@install -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
    1.84  
    1.85 -$(sort $(BINDIR) $(LIBDIR) $(DOCDIR) $(MANDIR)):
    1.86 +$(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
    1.87  	@echo "  MKDIR  '$@'"
    1.88  	@install -m 755 -d "$@"
    1.89  
    1.90 @@ -148,17 +158,17 @@
    1.91  # Uninstall rules
    1.92  
    1.93  uninstall-bin:
    1.94 -	@echo "  RM     '$(BINDIR)/ct-ng'"
    1.95 -	@rm -f "$(BINDIR)/ct-ng"
    1.96 +	@echo "  RM     '$(DESTDIR)$(BINDIR)/ct-ng'"
    1.97 +	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
    1.98  
    1.99  uninstall-lib:
   1.100 -	@echo "  RMDIR  '$(LIBDIR)/'"
   1.101 -	@rm -rf "$(LIBDIR)"
   1.102 +	@echo "  RMDIR  '$(DESTDIR)$(LIBDIR)/'"
   1.103 +	@rm -rf "$(DESTDIR)$(LIBDIR)"
   1.104  
   1.105  uninstall-doc:
   1.106 -	@echo "  RMDIR  '$(DOCDIR)/'"
   1.107 -	@rm -rf "$(DOCDIR)"
   1.108 +	@echo "  RMDIR  '$(DESTDIR)$(DOCDIR)/'"
   1.109 +	@rm -rf "$(DESTDIR)$(DOCDIR)"
   1.110  
   1.111  uninstall-man:
   1.112 -	@echo "  RM     '$(MANDIR)/ct-ng.1.gz'"
   1.113 -	@rm -f "$(MANDIR)/ct-ng.1"{,.gz}
   1.114 +	@echo "  RM     '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
   1.115 +	@rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
     2.1 --- a/configure	Sun Nov 16 20:38:07 2008 +0000
     2.2 +++ b/configure	Sun Nov 16 21:55:46 2008 +0000
     2.3 @@ -277,6 +277,16 @@
     2.4  [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
     2.5  [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
     2.6  
     2.7 +# Check that install PATHs are absolute
     2.8 +for p in BIN LIB DOC MAN; do
     2.9 +  var="${p}DIR"
    2.10 +  eval v="\${${var}}"
    2.11 +  case "${v}" in
    2.12 +    /*) ;;
    2.13 +    *)  do_error "'${var}' is not an absolute path: '${v}'"
    2.14 +  esac
    2.15 +done
    2.16 +
    2.17  # Check the existence of absolutely required tools
    2.18  { IFS='
    2.19  ';
     3.1 --- a/docs/overview.txt	Sun Nov 16 20:38:07 2008 +0000
     3.2 +++ b/docs/overview.txt	Sun Nov 16 21:55:46 2008 +0000
     3.3 @@ -16,6 +16,7 @@
     3.4    The hacker's way
     3.5    Shell completion
     3.6    Contributed code
     3.7 +  Preparing for packaging
     3.8  Configuring crosstool-NG
     3.9    Interesting config options
    3.10    Re-building an existing toolchain
    3.11 @@ -191,6 +192,17 @@
    3.12  version of crosstool-ng, or that it will work at all. Use contributions at
    3.13  your own risk.
    3.14  
    3.15 +Preparing for packaging |
    3.16 +------------------------+
    3.17 +
    3.18 +If you plan on packaging crosstool-NG, you surely don't want to install it
    3.19 +in your root file system. The install procedure of crosstool-NG honors the
    3.20 +DESTDIR variable:
    3.21 +
    3.22 +  ./configure --prefix=/usr
    3.23 +  make
    3.24 +  make DESDTDIR=/packaging/place install
    3.25 +
    3.26  ____________________________
    3.27                             /
    3.28  Configuring crosstool-NG  /