summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2008-11-16 21:55:46 (GMT)
committerYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2008-11-16 21:55:46 (GMT)
commit81f9d4d73eb40587d8c145d7d4e81396279b7247 (patch)
treedeb617c8fc8492313b05470641595ba181744092
parent9fdc3888c40a0f751a1f591b93ced62f86a907bd (diff)
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(-)
-rw-r--r--Makefile.in62
-rwxr-xr-xconfigure10
-rw-r--r--docs/overview.txt12
3 files changed, 58 insertions, 26 deletions
diff --git a/Makefile.in b/Makefile.in
index 410f032..1b19b2a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -5,11 +5,21 @@ MAKEFLAGS += --no-print-directory --no-builtin-rules
all: Makefile build
+###############################################################################
+# Sanity checks
+
# Check if Makefile is up to date:
Makefile: Makefile.in
@echo "$< did changed: you must re-run './configure'"
@false
+# If installing with DESTDIR, check it's an absolute path
+ifneq ($(strip $(DESTDIR)),)
+ ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
+ $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
+ endif
+endif
+
###############################################################################
# Configuration variables
@@ -100,46 +110,46 @@ local-test:
#--------------------------------------
# Install rules
-install-bin: $(BINDIR)
+install-bin: $(DESTDIR)$(BINDIR)
@echo " INST 'ct-ng'"
- @install -m 755 ct-ng "$(BINDIR)/ct-ng"
+ @install -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
# If one is hacking crosstool-NG, the patch set might change between any two
# installations of the same VERSION, thus the patches must be removed prior
# to being installed. It is simpler to remove the whole lib/ directory, as it
# is the goal of the install-lib rule to install the lib/ directory...
-install-lib: uninstall-lib $(LIBDIR) install-lib-main install-lib-samples
+install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
install-lib-main: $(LIBDIR)
- @for src_dir in config kconfig patches scripts tools; do \
- echo " INST '$${src_dir}/'"; \
- tar cf - --exclude=.svn $${src_dir} |(cd "$(LIBDIR)"; tar xf -); \
+ @for src_dir in config kconfig patches scripts tools; do \
+ echo " INST '$${src_dir}/'"; \
+ tar cf - --exclude=.svn $${src_dir} |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
done
- @rm -f "$(LIBDIR)/tools/addToolVersion.sh"
+ @rm -f "$(DESTDIR)$(LIBDIR)/tools/addToolVersion.sh"
@echo " INST 'steps.mk'"
- @install -m 644 steps.mk "$(LIBDIR)/steps.mk"
+ @install -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
# Samples need a little love:
# - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
-install-lib-samples: $(LIBDIR) install-lib-main
+install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
@echo " INST 'samples/'"
- @tar cf - --exclude=.svn samples |(cd "$(LIBDIR)"; tar xf -)
- @for samp_file in "$(LIBDIR)/samples/"*"/crosstool.config"; do \
+ @tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
+ @for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do \
sed -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file}; \
sed -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
done
-install-doc: $(DOCDIR)
- @for doc_file in docs/CREDITS docs/overview.txt; do \
- echo " INST '$${doc_file}'"; \
- install -m 644 "$${doc_file}" "$(DOCDIR)"; \
+install-doc: $(DESTDIR)$(DOCDIR)
+ @for doc_file in docs/CREDITS docs/overview.txt; do \
+ echo " INST '$${doc_file}'"; \
+ install -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
done
-install-man: $(MANDIR)
+install-man: $(DESTDIR)$(MANDIR)
@echo " INST 'ct-ng.1.gz'"
- @install -m 644 docs/ct-ng.1.gz "$(MANDIR)"
+ @install -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
-$(sort $(BINDIR) $(LIBDIR) $(DOCDIR) $(MANDIR)):
+$(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
@echo " MKDIR '$@'"
@install -m 755 -d "$@"
@@ -148,17 +158,17 @@ $(sort $(BINDIR) $(LIBDIR) $(DOCDIR) $(MANDIR)):
# Uninstall rules
uninstall-bin:
- @echo " RM '$(BINDIR)/ct-ng'"
- @rm -f "$(BINDIR)/ct-ng"
+ @echo " RM '$(DESTDIR)$(BINDIR)/ct-ng'"
+ @rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
uninstall-lib:
- @echo " RMDIR '$(LIBDIR)/'"
- @rm -rf "$(LIBDIR)"
+ @echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
+ @rm -rf "$(DESTDIR)$(LIBDIR)"
uninstall-doc:
- @echo " RMDIR '$(DOCDIR)/'"
- @rm -rf "$(DOCDIR)"
+ @echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
+ @rm -rf "$(DESTDIR)$(DOCDIR)"
uninstall-man:
- @echo " RM '$(MANDIR)/ct-ng.1.gz'"
- @rm -f "$(MANDIR)/ct-ng.1"{,.gz}
+ @echo " RM '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
+ @rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
diff --git a/configure b/configure
index 8b20f2c..ce32ac7 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,16 @@ echo "${VERSION}"
[ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
[ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
+# Check that install PATHs are absolute
+for p in BIN LIB DOC MAN; do
+ var="${p}DIR"
+ eval v="\${${var}}"
+ case "${v}" in
+ /*) ;;
+ *) do_error "'${var}' is not an absolute path: '${v}'"
+ esac
+done
+
# Check the existence of absolutely required tools
{ IFS='
';
diff --git a/docs/overview.txt b/docs/overview.txt
index cd476d8..8492959 100644
--- a/docs/overview.txt
+++ b/docs/overview.txt
@@ -16,6 +16,7 @@ Installing crosstool-NG
The hacker's way
Shell completion
Contributed code
+ Preparing for packaging
Configuring crosstool-NG
Interesting config options
Re-building an existing toolchain
@@ -191,6 +192,17 @@ There is no guarantee that a particuliar contribution applies to the current
version of crosstool-ng, or that it will work at all. Use contributions at
your own risk.
+Preparing for packaging |
+------------------------+
+
+If you plan on packaging crosstool-NG, you surely don't want to install it
+in your root file system. The install procedure of crosstool-NG honors the
+DESTDIR variable:
+
+ ./configure --prefix=/usr
+ make
+ make DESDTDIR=/packaging/place install
+
____________________________
/
Configuring crosstool-NG /