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@
71 export gperf := @GPERF@
74 export CPPFLAGS := @CPPFLAGS@
75 export CFLAGS := @CFLAGS@
76 export LDFLAGS := @LDFLAGS@
78 export curses_hdr := @ac_ct_curses_hdr@
79 export gettext := @gettext@
81 # config options to push down to kconfig
82 KCONFIG:= @kconfig_options@
84 ###############################################################################
85 # Non-configure variables
87 MAN_SUBDIR := /man$(MAN_SECTION)
89 PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
91 ###############################################################################
94 # Check if Makefile is up to date:
96 @echo "$< did changed: you must re-run './configure'"
99 # If installing with DESTDIR, check it's an absolute path
100 ifneq ($(strip $(DESTDIR)),)
101 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
102 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
106 ###############################################################################
109 # If any extra MAKEFLAGS were added, re-run ourselves
110 # See top of file for an explanation of why this is needed...
111 ifneq ($(strip $(CT_MAKEFLAGS)),)
113 # Somehow, the new auto-completion for make in the recent distributions
114 # trigger a behavior where our Makefile calls itself recursively, in a
115 # never-ending loop (except on lack of ressources, swap, PIDs...)
116 # Avoid this situation by cutting the recursion short at the first
118 # This has the side effect of only showing the real targets, and hiding our
120 ifneq ($(MAKELEVEL),0)
121 $(error Recursion detected, bailing out...)
124 MAKEFLAGS += $(CT_MAKEFLAGS)
125 build install clean distclean mrproper uninstall:
129 # There were no additional MAKEFLAGS to add, do the job
131 TARGETS := bin lib lib-kconfig doc man
133 build: $(patsubst %,build-%,$(TARGETS))
135 install: build real-install
137 clean: $(patsubst %,clean-%,$(TARGETS))
140 @echo " RM 'Makefile'"
144 @echo " RM 'autostuff'"
145 @ rm -rf autom4te.cache config.log config.status configure
147 uninstall: real-uninstall
149 ###############################################################################
150 # Specific make rules
152 #--------------------------------------
155 build-bin: $(PROG_NAME) \
156 scripts/crosstool-NG.sh \
157 scripts/saveSample.sh \
161 build-lib: config/configure.in \
170 build-man: docs/$(PROG_NAME).1.gz
172 docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
178 @$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;' \
179 -e 's,@@CT_LIBDIR@@,$(libdir),g;' \
180 -e 's,@@CT_DOCDIR@@,$(docdir),g;' \
181 -e 's,@@CT_MANDIR@@,$(mandir),g;' \
182 -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \
183 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
184 -e 's,@@CT_DATE@@,$(DATE),g;' \
185 -e 's,@@CT_make@@,$(make),g;' \
186 -e 's,@@CT_bash@@,$(bash),g;' \
187 -e 's,@@CT_awk@@,$(awk),g;' \
191 docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
194 $(PROG_NAME): ct-ng.in Makefile
200 # We create a script fragment that is parseable from inside a Makefile,
201 # and one from inside a shell script
204 @(echo 'export install=$(install)'; \
205 echo 'export bash=$(bash)'; \
206 echo 'export awk=$(awk)'; \
207 echo 'export grep=$(grep)'; \
208 echo 'export make=$(make)'; \
209 echo 'export sed=$(sed)'; \
210 echo 'export libtool=$(libtool)'; \
211 echo 'export libtoolize=$(libtoolize)'; \
212 echo 'export objcopy=$(objcopy)'; \
213 echo 'export objdump=$(objdump)'; \
214 echo 'export readelf=$(readelf)'; \
215 echo 'export patch=$(patch)'; \
216 echo 'export gperf=$(gperf)'; \
221 @(echo 'export install="$(install)"'; \
222 echo 'export bash="$(bash)"'; \
223 echo 'export awk="$(awk)"'; \
224 echo 'export grep="$(grep)"'; \
225 echo 'export make="$(make)"'; \
226 echo 'export sed="$(sed)"'; \
227 echo 'export libtool="$(libtool)"'; \
228 echo 'export libtoolize="$(libtoolize)"'; \
229 echo 'export objcopy="$(objcopy)"'; \
230 echo 'export objdump="$(objdump)"'; \
231 echo 'export readelf="$(readelf)"'; \
232 echo 'export patch="$(patch)"'; \
233 echo 'export gperf="$(gperf)"'; \
236 config/configure.in: FORCE
238 @{ printf "# Generated file, do not edit\n"; \
239 printf "# Default values as found by ./configure\n"; \
240 for var in $(KCONFIG); do \
242 printf "config CONFIGURE_$${var%%=*}\n"; \
243 if [ "$${var#*=}" = "y" ]; then \
244 printf " def_bool y\n"; \
253 #--------------------------------------
257 @echo " RM '$(PROG_NAME)'"
259 @echo " RM 'scripts/crosstool-NG.sh'"
260 @rm -f scripts/crosstool-NG.sh
261 @echo " RM 'scripts/saveSample.sh'"
262 @rm -f scripts/saveSample.sh
263 @echo " RM 'scripts/showTuple.sh'"
264 @rm -f scripts/showTuple.sh
268 @rm -f paths.mk paths.sh
269 @echo " RM 'config/configure.in'"
270 @rm -f config/configure.in
273 @$(MAKE) -C kconfig clean
278 @echo " RM 'docs/$(PROG_NAME).1'"
279 @rm -f docs/$(PROG_NAME).1
280 @echo " RM 'docs/$(PROG_NAME).1.gz'"
281 @rm -f docs/$(PROG_NAME).1.gz
283 #--------------------------------------
284 # Check for --local setup
286 ifeq ($(strip $(LOCAL)),yes)
296 #--------------------------------------
299 real-install: $(patsubst %,install-%,$(TARGETS)) install-post
301 install-bin: $(DESTDIR)$(bindir)
302 @echo " INST '$(PROG_NAME)'"
303 @$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
305 # If one is hacking crosstool-NG, the patch set might change between any two
306 # installations of the same VERSION, thus the patches must be removed prior
307 # to being installed. It is the responsibility of the user to call uninstall
308 # first, if (s)he deems it necessary
309 install-lib: $(DESTDIR)$(libdir) \
313 LIB_SUB_DIR := config contrib patches scripts
314 $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
315 @echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
316 @tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
317 |(cd "$(DESTDIR)$(libdir)"; tar xf -)
319 # Huh? It seems we need at least one command to make this rule kick-in.
320 install-lib-%: install-lib-%-copy; @true
322 # Huh? that one does not inherit the -opy dependency, above...
323 install-lib-scripts: install-lib-scripts-copy
324 @chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
325 @chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
326 @rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
328 install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
329 @echo " INST 'steps.mk'"
330 @$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
331 @echo " INST 'paths'"
332 @$(install) -m 644 paths.mk paths.sh "$(DESTDIR)$(libdir)"
334 # Samples need a little love:
335 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
336 install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
337 @echo " INSTDIR 'samples/'"
338 @for samp_dir in samples/*/; do \
339 mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}"; \
340 $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
341 -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
342 $${samp_dir}/crosstool.config \
343 >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config"; \
344 $(install) -m 644 "$${samp_dir}/reported.by" \
345 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
346 for libc_cfg in "$${samp_dir}/"*libc*.config; do \
347 [ -f "$${libc_cfg}" ] || continue; \
348 $(install) -m 644 "$${libc_cfg}" \
349 "$(DESTDIR)$(libdir)/$${samp_dir}"; \
352 @$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
354 KCONFIG_FILES := conf mconf nconf kconfig.mk
355 install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main
356 @echo " INST 'kconfig/'"
357 @mkdir -p "$(DESTDIR)$(libdir)/kconfig"
358 @for f in $(KCONFIG_FILES); do \
359 install "kconfig/$${f}" "$(DESTDIR)$(libdir)/kconfig/$${f}"; \
362 install-doc: $(DESTDIR)$(docdir)
363 @echo " INST 'docs/*.txt'"
364 @for doc_file in docs/*.txt; do \
365 $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
368 install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
369 @echo " INST '$(PROG_NAME).1.gz'"
370 @$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
372 $(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
374 @$(install) -m 755 -d "$@"
378 @echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
379 @echo "your bash completion directory (usually /etc/bash_completion.d)"
381 #--------------------------------------
384 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
387 @echo " RM '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
388 @rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
391 @echo " RMDIR '$(DESTDIR)$(libdir)/'"
392 @rm -rf "$(DESTDIR)$(libdir)"
395 @echo " RMDIR '$(DESTDIR)$(docdir)/'"
396 @rm -rf "$(DESTDIR)$(docdir)"
399 @echo " RM '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
400 @rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
404 endif # No extra MAKEFLAGS were added
406 .PHONY: build $(patsubst %,build-%,$(TARGETS)) install