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 # Further: quad test because the flags 'rR' and '-rR' can be reordered.
28 ifeq ($(filter Rr,$(MAKEFLAGS)),)
29 ifeq ($(filter -Rr,$(MAKEFLAGS)),)
30 ifeq ($(filter rR,$(MAKEFLAGS)),)
31 ifeq ($(filter -rR,$(MAKEFLAGS)),)
38 # Remove any suffix rules
43 ###############################################################################
44 # Configuration variables
46 # Stuff found by ./configure
48 export LOCAL := @enable_local@
49 export PROG_SED := @program_transform_name@
50 export PACKAGE_TARNAME := @PACKAGE_TARNAME@
51 export VERSION := @PACKAGE_VERSION@
52 export prefix := @prefix@
53 export exec_prefix := @exec_prefix@
54 export bindir := @bindir@
55 export libdir := @libdir@@sublibdir@
56 export docdir := @docdir@@subdocdir@
57 export mandir := @mandir@
58 export datarootdir := @datarootdir@
59 export install := @INSTALL@
60 export bash := @_BASH@
65 export libtool := @LIBTOOL@
66 export libtoolize := @LIBTOOLIZE@
67 export objcopy := @OBJCOPY@
68 export objdump := @OBJDUMP@
69 export readelf := @READELF@
70 export patch := @PATCH@
73 export CPPFLAGS := @CPPFLAGS@
74 export CFLAGS := @CFLAGS@
75 export LDFLAGS := @LDFLAGS@
77 export curses_hdr := @ac_ct_curses_hdr@
78 export gettext := @gettext@
80 # config options to push down to kconfig
81 KCONFIG:= @kconfig_options@
83 ###############################################################################
84 # Non-configure variables
86 MAN_SUBDIR := /man$(MAN_SECTION)
88 PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
90 ###############################################################################
93 # Check if Makefile is up to date:
95 @echo "$< did changed: you must re-run './configure'"
98 # If installing with DESTDIR, check it's an absolute path
99 ifneq ($(strip $(DESTDIR)),)
100 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
101 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
105 ###############################################################################
108 # If any extra MAKEFLAGS were added, re-run ourselves
109 # See top of file for an explanation of why this is needed...
110 ifneq ($(strip $(CT_MAKEFLAGS)),)
112 # Somehow, the new auto-completion for make in the recent distributions
113 # trigger a behavior where our Makefile calls itself recursively, in a
114 # never-ending loop (except on lack of ressources, swap, PIDs...)
115 # Avoid this situation by cutting the recursion short at the first
117 # This has the side effect of only showing the real targets, and hiding our
119 ifneq ($(MAKELEVEL),0)
120 $(error Recursion detected, bailing out...)
123 MAKEFLAGS += $(CT_MAKEFLAGS)
124 build install clean distclean mrproper uninstall:
128 # There were no additional MAKEFLAGS to add, do the job
130 TARGETS := bin lib lib-kconfig doc man
132 build: $(patsubst %,build-%,$(TARGETS))
134 install: build real-install
136 clean: $(patsubst %,clean-%,$(TARGETS))
139 @echo " RM 'Makefile'"
143 @echo " RM 'autostuff'"
144 @ rm -rf autom4te.cache config.log config.status configure
146 uninstall: real-uninstall
148 ###############################################################################
149 # Specific make rules
151 #--------------------------------------
154 build-bin: $(PROG_NAME) \
155 scripts/crosstool-NG.sh \
156 scripts/saveSample.sh \
160 build-lib: config/configure.in \
169 build-man: docs/$(PROG_NAME).1.gz
171 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
177 @$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;' \
178 -e 's,@@CT_LIBDIR@@,$(libdir),g;' \
179 -e 's,@@CT_DOCDIR@@,$(docdir),g;' \
180 -e 's,@@CT_MANDIR@@,$(mandir),g;' \
181 -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \
182 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
183 -e 's,@@CT_DATE@@,$(DATE),g;' \
184 -e 's,@@CT_make@@,$(make),g;' \
185 -e 's,@@CT_bash@@,$(bash),g;' \
186 -e 's,@@CT_awk@@,$(awk),g;' \
190 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
193 $(PROG_NAME): ct-ng.in Makefile
199 # We create a script fragment that is parseable from inside a Makefile,
200 # and one from inside a shell script
203 @(echo 'export install=$(install)'; \
204 echo 'export bash=$(bash)'; \
205 echo 'export awk=$(awk)'; \
206 echo 'export grep=$(grep)'; \
207 echo 'export make=$(make)'; \
208 echo 'export sed=$(sed)'; \
209 echo 'export libtool=$(libtool)'; \
210 echo 'export libtoolize=$(libtoolize)'; \
211 echo 'export objcopy=$(objcopy)'; \
212 echo 'export objdump=$(objdump)'; \
213 echo 'export readelf=$(readelf)'; \
214 echo 'export patch=$(patch)'; \
219 @(echo 'export install="$(install)"'; \
220 echo 'export bash="$(bash)"'; \
221 echo 'export awk="$(awk)"'; \
222 echo 'export grep="$(grep)"'; \
223 echo 'export make="$(make)"'; \
224 echo 'export sed="$(sed)"'; \
225 echo 'export libtool="$(libtool)"'; \
226 echo 'export libtoolize="$(libtoolize)"'; \
227 echo 'export objcopy="$(objcopy)"'; \
228 echo 'export objdump="$(objdump)"'; \
229 echo 'export readelf="$(readelf)"'; \
230 echo 'export patch="$(patch)"'; \
233 config/configure.in: FORCE
235 @{ printf "# Generated file, do not edit\n"; \
236 printf "# Default values as found by ./configure\n"; \
237 for var in $(KCONFIG); do \
239 printf "config CONFIGURE_$${var%%=*}\n"; \
240 if [ "$${var#*=}" = "y" ]; then \
241 printf " def_bool y\n"; \
250 #--------------------------------------
254 @echo " RM '$(PROG_NAME)'"
256 @echo " RM 'scripts/crosstool-NG.sh'"
257 @rm -f scripts/crosstool-NG.sh
258 @echo " RM 'scripts/saveSample.sh'"
259 @rm -f scripts/saveSample.sh
260 @echo " RM 'scripts/showTuple.sh'"
261 @rm -f scripts/showTuple.sh
265 @rm -f paths.mk paths.sh
266 @echo " RM 'config/configure.in'"
267 @rm -f config/configure.in
270 @$(MAKE) -C kconfig clean
275 @echo " RM 'docs/$(PROG_NAME).1'"
276 @rm -f docs/$(PROG_NAME).1
277 @echo " RM 'docs/$(PROG_NAME).1.gz'"
278 @rm -f docs/$(PROG_NAME).1.gz
280 #--------------------------------------
281 # Check for --local setup
283 ifeq ($(strip $(LOCAL)),yes)
293 #--------------------------------------
296 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
298 install-bin: $(DESTDIR)$(bindir)
299 @echo " INST '$(PROG_NAME)'"
300 @$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
302 # If one is hacking crosstool-NG, the patch set might change between any two
303 # installations of the same VERSION, thus the patches must be removed prior
304 # to being installed. It is the responsibility of the user to call uninstall
305 # first, if (s)he deems it necessary
306 install-lib: $(DESTDIR)$(libdir) \
310 LIB_SUB_DIR := config contrib patches scripts
311 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
312 @echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
313 @tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
314 |(cd "$(DESTDIR)$(libdir)"; tar xf -)
316 # Huh? It seems we need at least one command to make this rule kick-in.
317 install-lib-%: install-lib-%-copy; @true
319 # Huh? that one does not inherit the -opy dependency, above...
320 install-lib-scripts: install-lib-scripts-copy
321 @chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
322 @chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
323 @rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
325 install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
326 @echo " INST 'steps.mk'"
327 @$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
328 @echo " INST 'paths'"
329 @$(install) -m 644 paths.mk paths.sh "$(DESTDIR)$(libdir)"
331 # Samples need a little love:
332 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
333 install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
334 @echo " INSTDIR 'samples/'"
335 @for samp_dir in samples/*/; do \
336 mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}"; \
337 $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
338 -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
339 $${samp_dir}/crosstool.config \
340 >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config"; \
341 $(install) -m 644 "$${samp_dir}/reported.by" \
342 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
343 for libc_cfg in "$${samp_dir}/"*libc*.config; do \
344 [ -f "$${libc_cfg}" ] || continue; \
345 $(install) -m 644 "$${libc_cfg}" \
346 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
349 @$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
351 KCONFIG_FILES := conf mconf nconf kconfig.mk
352 install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main
353 @echo " INST 'kconfig/'"
354 @mkdir -p "$(DESTDIR)$(libdir)/kconfig"
355 @for f in $(KCONFIG_FILES); do \
356 install "kconfig/$${f}" "$(DESTDIR)$(libdir)/kconfig/$${f}"; \
359 install-doc: $(DESTDIR)$(docdir)
360 @echo " INST 'docs/*.txt'"
361 @for doc_file in docs/*.txt; do \
362 $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
365 install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
366 @echo " INST '$(PROG_NAME).1.gz'"
367 @$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
369 $(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
371 @$(install) -m 755 -d "$@"
375 @echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
376 @echo "your bash completion directory (usually /etc/bash_completion.d)"
378 #--------------------------------------
381 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
384 @echo " RM '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
385 @rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
388 @echo " RMDIR '$(DESTDIR)$(libdir)/'"
389 @rm -rf "$(DESTDIR)$(libdir)"
392 @echo " RMDIR '$(DESTDIR)$(docdir)/'"
393 @rm -rf "$(DESTDIR)$(docdir)"
396 @echo " RM '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
397 @rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
401 endif # No extra MAKEFLAGS were added
403 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install