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@
59 export libtool := @LIBTOOL@
60 export libtoolize := @LIBTOOLIZE@
61 export objcopy := @OBJCOPY@
62 export objdump := @OBJDUMP@
63 export readelf := @READELF@
64 export patch := @PATCH@
67 export CPPFLAGS := @CPPFLAGS@
68 export CFLAGS := @CFLAGS@
69 export LDFLAGS := @LDFLAGS@
71 export curses_hdr := @ac_ct_curses_hdr@
72 export gettext := @gettext@
74 # config options to push down to kconfig
75 KCONFIG:= @kconfig_options@
77 ###############################################################################
78 # Non-configure variables
80 MAN_SUBDIR := /man$(MAN_SECTION)
82 PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
84 ###############################################################################
87 # Check if Makefile is up to date:
89 @echo "$< did changed: you must re-run './configure'"
92 # If installing with DESTDIR, check it's an absolute path
93 ifneq ($(strip $(DESTDIR)),)
94 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
95 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
99 ###############################################################################
102 # If any extra MAKEFLAGS were added, re-run ourselves
103 # See top of file for an explanation of why this is needed...
104 ifneq ($(strip $(CT_MAKEFLAGS)),)
106 # Somehow, the new auto-completion for make in the recent distributions
107 # trigger a behavior where our Makefile calls itself recursively, in a
108 # never-ending loop (except on lack of ressources, swap, PIDs...)
109 # Avoid this situation by cutting the recursion short at the first
111 # This has the side effect of only showing the real targets, and hiding our
113 ifneq ($(MAKELEVEL),0)
114 $(error Recursion detected, bailing out...)
117 MAKEFLAGS += $(CT_MAKEFLAGS)
118 build install clean distclean mrproper uninstall:
122 # There were no additional MAKEFLAGS to add, do the job
124 TARGETS := bin lib lib-kconfig doc man
126 build: $(patsubst %,build-%,$(TARGETS))
128 install: build real-install
130 clean: $(patsubst %,clean-%,$(TARGETS))
133 @echo " RM 'Makefile'"
137 @echo " RM 'autostuff'"
138 @ rm -rf autom4te.cache config.log config.status configure
140 uninstall: real-uninstall
142 ###############################################################################
143 # Specific make rules
145 #--------------------------------------
148 build-bin: $(PROG_NAME) \
149 scripts/crosstool-NG.sh \
150 scripts/saveSample.sh \
154 build-lib: config/configure.in \
163 build-man: docs/$(PROG_NAME).1.gz
165 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
171 @$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;' \
172 -e 's,@@CT_LIBDIR@@,$(libdir),g;' \
173 -e 's,@@CT_DOCDIR@@,$(docdir),g;' \
174 -e 's,@@CT_MANDIR@@,$(mandir),g;' \
175 -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \
176 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
177 -e 's,@@CT_DATE@@,$(DATE),g;' \
178 -e 's,@@CT_make@@,$(make),g;' \
179 -e 's,@@CT_bash@@,$(bash),g;' \
183 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
186 $(PROG_NAME): ct-ng.in Makefile
192 # We create a script fragment that is parseable from inside a Makefile,
193 # and one from inside a shell script
196 @(echo 'export install=$(install)'; \
197 echo 'export bash=$(bash)'; \
198 echo 'export grep=$(grep)'; \
199 echo 'export make=$(make)'; \
200 echo 'export sed=$(sed)'; \
201 echo 'export libtool=$(libtool)'; \
202 echo 'export libtoolize=$(libtoolize)'; \
203 echo 'export objcopy=$(objcopy)'; \
204 echo 'export objdump=$(objdump)'; \
205 echo 'export readelf=$(readelf)'; \
206 echo 'export patch=$(patch)'; \
211 @(echo 'export install="$(install)"'; \
212 echo 'export bash="$(bash)"'; \
213 echo 'export grep="$(grep)"'; \
214 echo 'export make="$(make)"'; \
215 echo 'export sed="$(sed)"'; \
216 echo 'export libtool="$(libtool)"'; \
217 echo 'export libtoolize="$(libtoolize)"'; \
218 echo 'export objcopy="$(objcopy)"'; \
219 echo 'export objdump="$(objdump)"'; \
220 echo 'export readelf="$(readelf)"'; \
221 echo 'export patch="$(patch)"'; \
224 config/configure.in: FORCE
226 @{ printf "# Generated file, do not edit\n"; \
227 printf "# Default values as found by ./configure\n"; \
228 for var in $(KCONFIG); do \
230 printf "config CONFIGURE_$${var%%=*}\n"; \
231 if [ "$${var#*=}" = "y" ]; then \
232 printf " def_bool y\n"; \
241 #--------------------------------------
245 @echo " RM '$(PROG_NAME)'"
247 @echo " RM 'scripts/crosstool-NG.sh'"
248 @rm -f scripts/crosstool-NG.sh
249 @echo " RM 'scripts/saveSample.sh'"
250 @rm -f scripts/saveSample.sh
251 @echo " RM 'scripts/showTuple.sh'"
252 @rm -f scripts/showTuple.sh
256 @rm -f paths.mk paths.sh
257 @echo " RM 'config/configure.in'"
258 @rm -f config/configure.in
261 @$(MAKE) -C kconfig clean
266 @echo " RM 'docs/$(PROG_NAME).1'"
267 @rm -f docs/$(PROG_NAME).1
268 @echo " RM 'docs/$(PROG_NAME).1.gz'"
269 @rm -f docs/$(PROG_NAME).1.gz
271 #--------------------------------------
272 # Check for --local setup
274 ifeq ($(strip $(LOCAL)),yes)
284 #--------------------------------------
287 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
289 install-bin: $(DESTDIR)$(bindir)
290 @echo " INST '$(PROG_NAME)'"
291 @$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
293 # If one is hacking crosstool-NG, the patch set might change between any two
294 # installations of the same VERSION, thus the patches must be removed prior
295 # to being installed. It is simpler to remove the whole lib/ directory, as it
296 # is the goal of the install-lib rule to install the lib/ directory...
297 install-lib: uninstall-lib \
298 $(DESTDIR)$(libdir) \
302 LIB_SUB_DIR := config contrib patches scripts
303 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
304 @echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
305 @tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
306 |(cd "$(DESTDIR)$(libdir)"; tar xf -)
308 # Huh? It seems we need at least one command to make this rule kick-in.
309 install-lib-%: install-lib-%-copy; @true
311 # Huh? that one does not inherit the -opy dependency, above...
312 install-lib-scripts: install-lib-scripts-copy
313 @chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
314 @chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
315 @rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
317 install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
318 @echo " INST 'steps.mk'"
319 @$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
320 @echo " INST 'paths'"
321 @$(install) -m 644 paths.mk paths.sh "$(DESTDIR)$(libdir)"
323 # Samples need a little love:
324 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
325 install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
326 @echo " INSTDIR 'samples/'"
327 @for samp_dir in samples/*/; do \
328 mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}"; \
329 $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
330 -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
331 $${samp_dir}/crosstool.config \
332 >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config"; \
333 $(install) -m 644 "$${samp_dir}/reported.by" \
334 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
335 for libc_cfg in "$${samp_dir}/"*libc*.config; do \
336 [ -f "$${libc_cfg}" ] || continue; \
337 $(install) -m 644 "$${libc_cfg}" \
338 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
341 @$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
343 KCONFIG_FILES := conf mconf nconf kconfig.mk
344 install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main
345 @echo " INST 'kconfig/'"
346 @for f in $(KCONFIG_FILES); do \
347 install -D "kconfig/$${f}" "$(DESTDIR)$(libdir)/kconfig/$${f}"; \
350 install-doc: $(DESTDIR)$(docdir)
351 @echo " INST 'docs/*.txt'"
352 @for doc_file in docs/*.txt; do \
353 $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
356 install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
357 @echo " INST '$(PROG_NAME).1.gz'"
358 @$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
360 $(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
362 @$(install) -m 755 -d "$@"
366 @echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
367 @echo "your bash completion directory (usually /etc/bash_completion.d)"
369 #--------------------------------------
372 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
375 @echo " RM '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
376 @rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
379 @echo " RMDIR '$(DESTDIR)$(libdir)/'"
380 @rm -rf "$(DESTDIR)$(libdir)"
383 @echo " RMDIR '$(DESTDIR)$(docdir)/'"
384 @rm -rf "$(DESTDIR)$(docdir)"
387 @echo " RM '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
388 @rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
392 endif # No extra MAKEFLAGS were added
394 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install