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
46 PROG_PFX:=@@PROG_PFX@@
47 PROG_SFX:=@@PROG_SFX@@
48 PROG_SED:=@@PROG_SED@@
52 # Paths found by ./configure
53 install := @@install@@
58 libtool := @@libtool@@
59 libtoolize:= @@libtoolize@@
60 objcopy := @@objcopy@@
61 objdump := @@objdump@@
62 readelf := @@readelf@@
65 # config options to push down to kconfig
68 ###############################################################################
69 # Non-configure variables
71 MAN_SUBDIR := /man$(MAN_SECTION)
73 PROG_NAME := $(shell echo '$(PROG_PFX)ct-ng$(PROG_SFX)' |sed -e '$(PROG_SED)' )
75 ###############################################################################
78 # Check if Makefile is up to date:
80 @echo "$< did changed: you must re-run './configure'"
83 # If installing with DESTDIR, check it's an absolute path
84 ifneq ($(strip $(DESTDIR)),)
85 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
86 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
90 ###############################################################################
93 # If any extra MAKEFLAGS were added, re-run ourselves
94 # See top of file for an explanation of why this is needed...
95 ifneq ($(strip $(CT_MAKEFLAGS)),)
97 # Somehow, the new auto-completion for make in the recent distributions
98 # trigger a behavior where our Makefile calls itself recursively, in a
99 # never-ending loop (except on lack of ressources, swap, PIDs...)
100 # Avoid this situation by cutting the recursion short at the first
102 # This has the side effect of only showing the real targets, and hiding our
104 ifneq ($(MAKELEVEL),0)
105 $(error Recursion detected, bailing out...)
108 MAKEFLAGS += $(CT_MAKEFLAGS)
109 build install clean distclean uninstall:
113 # There were no additional MAKEFLAGS to add, do the job
115 TARGETS := bin lib doc man
117 build: $(patsubst %,build-%,$(TARGETS))
119 install: build real-install
121 clean: $(patsubst %,clean-%,$(TARGETS))
124 @echo " RM 'Makefile'"
127 uninstall: real-uninstall
129 ###############################################################################
130 # Specific make rules
132 #--------------------------------------
135 build-bin: $(PROG_NAME) scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
138 build-lib: paths.mk config/configure.in
142 build-man: docs/$(PROG_NAME).1.gz
144 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
150 @$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \
151 -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \
152 -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \
153 -e 's,@@CT_MANDIR@@,$(MANDIR),g;' \
154 -e 's,@@CT_PROG_PFX@@,$(PROG_PFX),g;' \
155 -e 's,@@CT_PROG_SFX@@,$(PROG_SFX),g;' \
156 -e 's,@@CT_PROG_SED@@,$(PROG_SED),g;' \
157 -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \
158 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
159 -e 's,@@CT_DATE@@,$(DATE),g;' \
160 -e 's,@@CT_make@@,$(make),g;' \
161 -e 's,@@CT_bash@@,$(bash),g;' \
165 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
168 $(PROG_NAME): ct-ng.in Makefile
174 # We create a script fragment that is parseable from inside a Makefile,
175 # but also from inside a shell script, hence the reason why we don't
176 # use := to set variables, although that will incur a (very small)
177 # penalty from the Makefile that includes it (due to re-evaluation at
181 @(echo "export install=$(install)"; \
182 echo "export bash=$(bash)"; \
183 echo "export grep=$(grep)"; \
184 echo "export make=$(make)"; \
185 echo "export sed=$(sed)"; \
186 echo "export libtool=$(libtool)"; \
187 echo "export libtoolize=$(libtoolize)"; \
188 echo "export objcopy=$(objcopy)"; \
189 echo "export objdump=$(objdump)"; \
190 echo "export readelf=$(readelf)"; \
191 echo "export patch=$(patch)"; \
194 config/configure.in: FORCE
196 @{ printf "# Generated file, do not edit\n"; \
197 printf "# Default values as found by ./configure\n"; \
198 for var in $(KCONFIG); do \
200 printf "config CONFIGURE_$${var%%=*}\n"; \
202 if [ "$${var#*=}" = "y" ]; then \
203 printf " default y\n"; \
210 #--------------------------------------
214 @echo " RM '$(PROG_NAME)'"
216 @echo " RM 'scripts/crosstool-NG.sh'"
217 @rm -f scripts/crosstool-NG.sh
218 @echo " RM 'scripts/saveSample.sh'"
219 @rm -f scripts/saveSample.sh
220 @echo " RM 'scripts/showTuple.sh'"
221 @rm -f scripts/showTuple.sh
224 @echo " RM 'paths.mk'"
226 @echo " RM 'config/configure.in'"
227 @rm -f config/configure.in
232 @echo " RM 'docs/$(PROG_NAME).1'"
233 @rm -f docs/$(PROG_NAME).1
234 @echo " RM 'docs/$(PROG_NAME).1.gz'"
235 @rm -f docs/$(PROG_NAME).1.gz
237 #--------------------------------------
238 # Check for --local setup
240 ifeq ($(strip $(LOCAL)),y)
250 #--------------------------------------
253 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
255 install-bin: $(DESTDIR)$(BINDIR)
256 @echo " INST '$(PROG_NAME)'"
257 @$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(BINDIR)/$(PROG_NAME)"
259 # If one is hacking crosstool-NG, the patch set might change between any two
260 # installations of the same VERSION, thus the patches must be removed prior
261 # to being installed. It is simpler to remove the whole lib/ directory, as it
262 # is the goal of the install-lib rule to install the lib/ directory...
263 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
265 LIB_SUB_DIR := config contrib kconfig patches scripts
266 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR)
267 @echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
268 @tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
269 |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
271 # Huh? It seems we need at least one command to make this rule kick-in.
272 install-lib-%: install-lib-%-copy; @true
274 # Huh? that one does not inherit the -opy dependency, above...
275 install-lib-scripts: install-lib-scripts-copy
276 @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
277 @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
278 @rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
280 install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
281 @echo " INST 'steps.mk'"
282 @$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
283 @echo " INST 'paths.mk'"
284 @$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
286 # Samples need a little love:
287 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
288 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
289 @echo " INSTDIR 'samples/'"
290 @for samp_dir in samples/*/; do \
291 mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \
292 $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
293 -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
294 $${samp_dir}/crosstool.config \
295 >"$(DESTDIR)$(LIBDIR)/$${samp_dir}/crosstool.config"; \
296 $(install) -m 644 "$${samp_dir}/reported.by" \
297 "$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \
298 for libc_cfg in "$${samp_dir}/"*libc*.config; do \
299 [ -f "$${libc_cfg}" ] || continue; \
300 $(install) -m 644 "$${libc_cfg}" \
301 "$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \
304 @$(install) -m 644 samples/samples.mk "$(DESTDIR)$(LIBDIR)/samples/samples.mk"
306 install-doc: $(DESTDIR)$(DOCDIR)
307 @echo " INST 'docs/*.txt'"
308 @for doc_file in docs/*.txt; do \
309 $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
312 install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
313 @echo " INST '$(PROG_NAME).1.gz'"
314 @$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
316 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
318 @$(install) -m 755 -d "$@"
322 @echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
323 @echo "your bash completion directory (usually /etc/bash_completion.d)"
325 #--------------------------------------
328 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
331 @echo " RM '$(DESTDIR)$(BINDIR)/$(PROG_NAME)'"
332 @rm -f "$(DESTDIR)$(BINDIR)/$(PROG_NAME)"
335 @echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
336 @rm -rf "$(DESTDIR)$(LIBDIR)"
339 @echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
340 @rm -rf "$(DESTDIR)$(DOCDIR)"
343 @echo " RM '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
344 @rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
348 endif # No extra MAKEFLAGS were added