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(-)
1 # Makefile.in for building crosstool-NG
2 # This file serves as source for the ./configure operation
4 MAKEFLAGS += --no-print-directory --no-builtin-rules
8 ###############################################################################
11 # Check if Makefile is up to date:
13 @echo "$< did changed: you must re-run './configure'"
16 # If installing with DESTDIR, check it's an absolute path
17 ifneq ($(strip $(DESTDIR)),)
18 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
19 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
23 ###############################################################################
24 # Configuration variables
33 MAKE := $(shell which $(MAKE) || type -p $(MAKE) || echo /usr/bin/make)
35 ###############################################################################
38 TARGETS := bin lib doc man
40 build: $(patsubst %,build-%,$(TARGETS))
42 install: local-test build $(patsubst %,install-%,$(TARGETS))
44 clean: $(patsubst %,clean-%,$(TARGETS))
47 @echo " RM 'Makefile'"
50 uninstall: local-test $(patsubst %,uninstall-%,$(TARGETS))
52 ###############################################################################
55 #--------------------------------------
66 build-man: docs/ct-ng.1.gz
68 docs/ct-ng.1.gz: docs/ct-ng.1
74 @sed -r -e 's,@@CT_MAKE@@,$(MAKE),g;' \
75 -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \
76 -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \
77 -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \
78 -e 's,@@CT_MANDIR@@,$(MANDIR),g;' \
79 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
80 -e 's,@@CT_DATE@@,$(DATE),g;' \
83 #--------------------------------------
95 @echo " RM 'docs/ct-ng.1'"
97 @echo " RM 'docs/ct-ng.1.gz'"
98 @rm -f docs/ct-ng.1.gz
100 #--------------------------------------
101 # Check for --local setup
103 # If using locally, don't install
105 @if [ "$(LOCAL)" = "1" ]; then \
106 echo "You're using local copy as runtime. You can't (un)install."; \
110 #--------------------------------------
113 install-bin: $(DESTDIR)$(BINDIR)
114 @echo " INST 'ct-ng'"
115 @install -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
117 # If one is hacking crosstool-NG, the patch set might change between any two
118 # installations of the same VERSION, thus the patches must be removed prior
119 # to being installed. It is simpler to remove the whole lib/ directory, as it
120 # is the goal of the install-lib rule to install the lib/ directory...
121 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
123 install-lib-main: $(LIBDIR)
124 @for src_dir in config kconfig patches scripts tools; do \
125 echo " INST '$${src_dir}/'"; \
126 tar cf - --exclude=.svn $${src_dir} |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
128 @rm -f "$(DESTDIR)$(LIBDIR)/tools/addToolVersion.sh"
129 @echo " INST 'steps.mk'"
130 @install -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
132 # Samples need a little love:
133 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
134 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
135 @echo " INST 'samples/'"
136 @tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
137 @for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do \
138 sed -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file}; \
139 sed -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
142 install-doc: $(DESTDIR)$(DOCDIR)
143 @for doc_file in docs/CREDITS docs/overview.txt; do \
144 echo " INST '$${doc_file}'"; \
145 install -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
148 install-man: $(DESTDIR)$(MANDIR)
149 @echo " INST 'ct-ng.1.gz'"
150 @install -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
152 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
154 @install -m 755 -d "$@"
157 #--------------------------------------
161 @echo " RM '$(DESTDIR)$(BINDIR)/ct-ng'"
162 @rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
165 @echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
166 @rm -rf "$(DESTDIR)$(LIBDIR)"
169 @echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
170 @rm -rf "$(DESTDIR)$(DOCDIR)"
173 @echo " RM '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
174 @rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}