1 # Makefile.in for building crosstool-NG
2 # This file serves as source for the ./configure operation
4 # This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS
5 # to set additional flags in the current Makfile ( see:
6 # http://savannah.gnu.org/bugs/?20501 ), although the make manual says it
7 # should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion )
8 # so we have to work it around by calling ourselves back if needed
10 # So why do we need not to use the built rules and variables? Because we
11 # need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in
12 # and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite
13 # nor a command associated, and that built-in implicit rule takes precedence
14 # over our non-built-in implicit rule '%: %.in', below.
16 # CT_MAKEFLAGS will be used later, below...
18 # Do not print directories as we descend into them
19 ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),)
20 CT_MAKEFLAGS += --no-print-directory
23 # Use neither builtin rules, nor builtin variables
24 # Note: dual test, because if -R and -r are given on the command line
25 # (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding
26 # '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' )
27 ifeq ($(filter Rr,$(MAKEFLAGS)),)
28 ifeq ($(filter -Rr,$(MAKEFLAGS)),)
33 # Remove any suffix rules
38 ###############################################################################
39 # Configuration variables
49 # Paths found by ./configure
56 ###############################################################################
57 # Non-configure variables
59 MAN_SUBDIR := /man$(MAN_SECTION)
61 ###############################################################################
64 # Check if Makefile is up to date:
66 @echo "$< did changed: you must re-run './configure'"
69 # If installing with DESTDIR, check it's an absolute path
70 ifneq ($(strip $(DESTDIR)),)
71 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
72 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
76 ###############################################################################
79 # If any extra MAKEFLAGS were added, re-run ourselves
80 # See top of file for an explanation of why this is needed...
81 ifneq ($(strip $(CT_MAKEFLAGS)),)
83 MAKEFLAGS += $(CT_MAKEFLAGS)
84 build install clean distclean uninstall:
88 # There were no additional MAKEFLAGS to add, do the job
90 TARGETS := bin lib doc man
92 build: $(patsubst %,build-%,$(TARGETS))
94 install: build real-install
96 clean: $(patsubst %,clean-%,$(TARGETS))
99 @echo " RM 'Makefile'"
102 uninstall: real-uninstall
104 ###############################################################################
105 # Specific make rules
107 #--------------------------------------
110 build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
117 build-man: docs/ct-ng.1.gz
119 docs/ct-ng.1.gz: docs/ct-ng.1
125 @$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \
126 -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \
127 -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \
128 -e 's,@@CT_MANDIR@@,$(MANDIR),g;' \
129 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
130 -e 's,@@CT_DATE@@,$(DATE),g;' \
131 -e 's,@@CT_make@@,$(make),g;' \
132 -e 's,@@CT_bash@@,$(bash),g;' \
135 # We create a script fragment that is parseable from inside a Makefile,
136 # but also from inside a shell script, hence the reason why we don't
137 # use := to set variables, although that will incur a (very small)
138 # penalty from the Makefile that includes it (due to re-evaluation at
142 @(echo "export install=$(install)"; \
143 echo "export bash=$(bash)"; \
144 echo "export grep=$(grep)"; \
145 echo "export make=$(make)"; \
146 echo "export sed=$(sed)"; \
149 #--------------------------------------
155 @echo " RM 'scripts/crosstool-NG.sh'"
156 @rm -f scripts/crosstool-NG.sh
157 @echo " RM 'scripts/saveSample.sh'"
158 @rm -f scripts/saveSample.sh
159 @echo " RM 'scripts/showTuple.sh'"
160 @rm -f scripts/showTuple.sh
163 @echo " RM 'paths.mk'"
169 @echo " RM 'docs/ct-ng.1'"
171 @echo " RM 'docs/ct-ng.1.gz'"
172 @rm -f docs/ct-ng.1.gz
174 #--------------------------------------
175 # Check for --local setup
177 ifeq ($(strip $(LOCAL)),y)
187 #--------------------------------------
190 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
192 install-bin: $(DESTDIR)$(BINDIR)
193 @echo " INST 'ct-ng'"
194 @$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
196 # If one is hacking crosstool-NG, the patch set might change between any two
197 # installations of the same VERSION, thus the patches must be removed prior
198 # to being installed. It is simpler to remove the whole lib/ directory, as it
199 # is the goal of the install-lib rule to install the lib/ directory...
200 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
202 install-lib-main: $(DESTDIR)$(LIBDIR)
203 @for src_dir in config kconfig patches scripts; do \
204 echo " INST '$${src_dir}/'"; \
205 tar cf - --exclude='*.sh.in' $${src_dir} \
206 |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
208 @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
209 @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
210 @rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
211 @echo " INST 'steps.mk'"
212 @$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
213 @echo " INST 'paths.mk'"
214 @$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
216 # Samples need a little love:
217 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
218 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
219 @echo " INST 'samples/'"
220 @tar cf - samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
221 @for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do \
222 $(sed) -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file}; \
223 $(sed) -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
226 install-doc: $(DESTDIR)$(DOCDIR)
227 @for doc_file in docs/CREDITS docs/overview.txt; do \
228 echo " INST '$${doc_file}'"; \
229 $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
232 install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
233 @echo " INST 'ct-ng.1.gz'"
234 @$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
236 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
238 @$(install) -m 755 -d "$@"
242 @echo "For auto-completion, do not forget to install 'ct-ng.comp'"
243 @echo "into you 'bash_completion.d'"
245 #--------------------------------------
248 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
251 @echo " RM '$(DESTDIR)$(BINDIR)/ct-ng'"
252 @rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
255 @echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
256 @rm -rf "$(DESTDIR)$(LIBDIR)"
259 @echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
260 @rm -rf "$(DESTDIR)$(DOCDIR)"
263 @echo " RM '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
264 @rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
268 endif # No extra MAKEFLAGS were added