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
41 # Stuff found by ./configure
43 export LOCAL := @enable_local@
44 export PROG_SED := @program_transform_name@
45 export PACKAGE_TARNAME := @PACKAGE_TARNAME@
46 export VERSION := @PACKAGE_VERSION@
47 export prefix := @prefix@
48 export exec_prefix := @exec_prefix@
49 export bindir := @bindir@
50 export libdir := @libdir@@sublibdir@
51 export docdir := @docdir@@subdocdir@
52 export mandir := @mandir@
53 export datarootdir := @datarootdir@
54 export install := @INSTALL@
55 export bash := @_BASH@
60 export libtool := @LIBTOOL@
61 export libtoolize := @LIBTOOLIZE@
62 export objcopy := @OBJCOPY@
63 export objdump := @OBJDUMP@
64 export readelf := @READELF@
65 export patch := @PATCH@
68 export CPPFLAGS := @CPPFLAGS@
69 export CFLAGS := @CFLAGS@
70 export LDFLAGS := @LDFLAGS@
72 export curses_hdr := @ac_ct_curses_hdr@
73 export gettext := @gettext@
75 # config options to push down to kconfig
76 KCONFIG:= @kconfig_options@
78 ###############################################################################
79 # Non-configure variables
81 MAN_SUBDIR := /man$(MAN_SECTION)
83 PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
85 ###############################################################################
88 # Check if Makefile is up to date:
90 @echo "$< did changed: you must re-run './configure'"
93 # If installing with DESTDIR, check it's an absolute path
94 ifneq ($(strip $(DESTDIR)),)
95 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
96 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
100 ###############################################################################
103 # If any extra MAKEFLAGS were added, re-run ourselves
104 # See top of file for an explanation of why this is needed...
105 ifneq ($(strip $(CT_MAKEFLAGS)),)
107 # Somehow, the new auto-completion for make in the recent distributions
108 # trigger a behavior where our Makefile calls itself recursively, in a
109 # never-ending loop (except on lack of ressources, swap, PIDs...)
110 # Avoid this situation by cutting the recursion short at the first
112 # This has the side effect of only showing the real targets, and hiding our
114 ifneq ($(MAKELEVEL),0)
115 $(error Recursion detected, bailing out...)
118 MAKEFLAGS += $(CT_MAKEFLAGS)
119 build install clean distclean mrproper uninstall:
123 # There were no additional MAKEFLAGS to add, do the job
125 TARGETS := bin lib lib-kconfig doc man
127 build: $(patsubst %,build-%,$(TARGETS))
129 install: build real-install
131 clean: $(patsubst %,clean-%,$(TARGETS))
134 @echo " RM 'Makefile'"
138 @echo " RM 'autostuff'"
139 @ rm -rf autom4te.cache config.log config.status configure
141 uninstall: real-uninstall
143 ###############################################################################
144 # Specific make rules
146 #--------------------------------------
149 build-bin: $(PROG_NAME) \
150 scripts/crosstool-NG.sh \
151 scripts/saveSample.sh \
155 build-lib: config/configure.in \
164 build-man: docs/$(PROG_NAME).1.gz
166 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
172 @$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;' \
173 -e 's,@@CT_LIBDIR@@,$(libdir),g;' \
174 -e 's,@@CT_DOCDIR@@,$(docdir),g;' \
175 -e 's,@@CT_MANDIR@@,$(mandir),g;' \
176 -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \
177 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
178 -e 's,@@CT_DATE@@,$(DATE),g;' \
179 -e 's,@@CT_make@@,$(make),g;' \
180 -e 's,@@CT_bash@@,$(bash),g;' \
181 -e 's,@@CT_awk@@,$(awk),g;' \
185 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
188 $(PROG_NAME): ct-ng.in Makefile
194 # We create a script fragment that is parseable from inside a Makefile,
195 # and one from inside a shell script
198 @(echo 'export install=$(install)'; \
199 echo 'export bash=$(bash)'; \
200 echo 'export awk=$(awk)'; \
201 echo 'export grep=$(grep)'; \
202 echo 'export make=$(make)'; \
203 echo 'export sed=$(sed)'; \
204 echo 'export libtool=$(libtool)'; \
205 echo 'export libtoolize=$(libtoolize)'; \
206 echo 'export objcopy=$(objcopy)'; \
207 echo 'export objdump=$(objdump)'; \
208 echo 'export readelf=$(readelf)'; \
209 echo 'export patch=$(patch)'; \
214 @(echo 'export install="$(install)"'; \
215 echo 'export bash="$(bash)"'; \
216 echo 'export awk="$(awk)"'; \
217 echo 'export grep="$(grep)"'; \
218 echo 'export make="$(make)"'; \
219 echo 'export sed="$(sed)"'; \
220 echo 'export libtool="$(libtool)"'; \
221 echo 'export libtoolize="$(libtoolize)"'; \
222 echo 'export objcopy="$(objcopy)"'; \
223 echo 'export objdump="$(objdump)"'; \
224 echo 'export readelf="$(readelf)"'; \
225 echo 'export patch="$(patch)"'; \
228 config/configure.in: FORCE
230 @{ printf "# Generated file, do not edit\n"; \
231 printf "# Default values as found by ./configure\n"; \
232 for var in $(KCONFIG); do \
234 printf "config CONFIGURE_$${var%%=*}\n"; \
235 if [ "$${var#*=}" = "y" ]; then \
236 printf " def_bool y\n"; \
245 #--------------------------------------
249 @echo " RM '$(PROG_NAME)'"
251 @echo " RM 'scripts/crosstool-NG.sh'"
252 @rm -f scripts/crosstool-NG.sh
253 @echo " RM 'scripts/saveSample.sh'"
254 @rm -f scripts/saveSample.sh
255 @echo " RM 'scripts/showTuple.sh'"
256 @rm -f scripts/showTuple.sh
260 @rm -f paths.mk paths.sh
261 @echo " RM 'config/configure.in'"
262 @rm -f config/configure.in
265 @$(MAKE) -C kconfig clean
270 @echo " RM 'docs/$(PROG_NAME).1'"
271 @rm -f docs/$(PROG_NAME).1
272 @echo " RM 'docs/$(PROG_NAME).1.gz'"
273 @rm -f docs/$(PROG_NAME).1.gz
275 #--------------------------------------
276 # Check for --local setup
278 ifeq ($(strip $(LOCAL)),yes)
288 #--------------------------------------
291 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
293 install-bin: $(DESTDIR)$(bindir)
294 @echo " INST '$(PROG_NAME)'"
295 @$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
297 # If one is hacking crosstool-NG, the patch set might change between any two
298 # installations of the same VERSION, thus the patches must be removed prior
299 # to being installed. It is simpler to remove the whole lib/ directory, as it
300 # is the goal of the install-lib rule to install the lib/ directory...
301 install-lib: uninstall-lib \
302 $(DESTDIR)$(libdir) \
306 LIB_SUB_DIR := config contrib patches scripts
307 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
308 @echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
309 @tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
310 |(cd "$(DESTDIR)$(libdir)"; tar xf -)
312 # Huh? It seems we need at least one command to make this rule kick-in.
313 install-lib-%: install-lib-%-copy; @true
315 # Huh? that one does not inherit the -opy dependency, above...
316 install-lib-scripts: install-lib-scripts-copy
317 @chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
318 @chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
319 @rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
321 install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
322 @echo " INST 'steps.mk'"
323 @$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
324 @echo " INST 'paths'"
325 @$(install) -m 644 paths.mk paths.sh "$(DESTDIR)$(libdir)"
327 # Samples need a little love:
328 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
329 install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
330 @echo " INSTDIR 'samples/'"
331 @for samp_dir in samples/*/; do \
332 mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}"; \
333 $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
334 -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
335 $${samp_dir}/crosstool.config \
336 >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config"; \
337 $(install) -m 644 "$${samp_dir}/reported.by" \
338 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
339 for libc_cfg in "$${samp_dir}/"*libc*.config; do \
340 [ -f "$${libc_cfg}" ] || continue; \
341 $(install) -m 644 "$${libc_cfg}" \
342 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
345 @$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
347 KCONFIG_FILES := conf mconf nconf kconfig.mk
348 install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main
349 @echo " INST 'kconfig/'"
350 @for f in $(KCONFIG_FILES); do \
351 install -D "kconfig/$${f}" "$(DESTDIR)$(libdir)/kconfig/$${f}"; \
354 install-doc: $(DESTDIR)$(docdir)
355 @echo " INST 'docs/*.txt'"
356 @for doc_file in docs/*.txt; do \
357 $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
360 install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
361 @echo " INST '$(PROG_NAME).1.gz'"
362 @$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
364 $(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
366 @$(install) -m 755 -d "$@"
370 @echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
371 @echo "your bash completion directory (usually /etc/bash_completion.d)"
373 #--------------------------------------
376 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
379 @echo " RM '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
380 @rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
383 @echo " RMDIR '$(DESTDIR)$(libdir)/'"
384 @rm -rf "$(DESTDIR)$(libdir)"
387 @echo " RMDIR '$(DESTDIR)$(docdir)/'"
388 @rm -rf "$(DESTDIR)$(docdir)"
391 @echo " RM '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
392 @rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
396 endif # No extra MAKEFLAGS were added
398 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install