yann@197: # Makefile.in for building crosstool-NG yann@182: # This file serves as source for the ./configure operation yann@182: yann@1156: # This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS yann@1156: # to set additional flags in the current Makfile ( see: yann@1156: # http://savannah.gnu.org/bugs/?20501 ), although the make manual says it yann@1156: # should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion ) yann@1156: # so we have to work it around by calling ourselves back if needed yann@1156: yann@1156: # So why do we need not to use the built rules and variables? Because we yann@1156: # need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in yann@1156: # and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite yann@1156: # nor a command associated, and that built-in implicit rule takes precedence yann@1156: # over our non-built-in implicit rule '%: %.in', below. yann@1156: yann@1156: # CT_MAKEFLAGS will be used later, below... yann@1156: yann@1156: # Do not print directories as we descend into them yann@1156: ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),) yann@1156: CT_MAKEFLAGS += --no-print-directory yann@1156: endif yann@1156: yann@1156: # Use neither builtin rules, nor builtin variables yann@1156: # Note: dual test, because if -R and -r are given on the command line yann@1156: # (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding yann@1156: # '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' ) yann@1156: ifeq ($(filter Rr,$(MAKEFLAGS)),) yann@1156: ifeq ($(filter -Rr,$(MAKEFLAGS)),) yann@1156: CT_MAKEFLAGS += -Rr yann@1156: endif # No -Rr yann@1156: endif # No Rr yann@1156: yann@1156: # Remove any suffix rules yann@1156: .SUFFIXES: yann@554: yann@382: all: Makefile build yann@382: yann@1047: ############################################################################### yann@182: # Configuration variables yann@182: yann@182: VERSION:= @@VERSION@@ yann@182: BINDIR := @@BINDIR@@ yann@185: LIBDIR := @@LIBDIR@@ yann@185: DOCDIR := @@DOCDIR@@ yann@185: MANDIR := @@MANDIR@@ yann@182: DATE := @@DATE@@ yann@285: LOCAL := @@LOCAL@@ yann@1141: yann@1141: # Paths found by ./configure yann@1153: install:= @@install@@ yann@1153: bash := @@bash@@ yann@1153: grep := @@grep@@ yann@1153: make := @@make@@ yann@1153: sed := @@sed@@ titus@1962: libtool:= @@libtool@@ titus@1962: objcopy:= @@objcopy@@ titus@1962: objdump:= @@objdump@@ titus@1962: readelf:= @@readelf@@ titus@1962: patch := @@patch@@ yann@1109: yann@2481: # config options to push down to kconfig yann@2481: KCONFIG:= @@KCONFIG@@ yann@2481: yann@1109: ############################################################################### yann@2026: # Non-configure variables yann@2026: MAN_SECTION := 1 yann@2026: MAN_SUBDIR := /man$(MAN_SECTION) yann@2026: yann@2026: ############################################################################### yann@1109: # Sanity checks yann@1109: yann@1109: # Check if Makefile is up to date: yann@1109: Makefile: Makefile.in yann@1109: @echo "$< did changed: you must re-run './configure'" yann@1109: @false yann@1109: yann@1109: # If installing with DESTDIR, check it's an absolute path yann@1109: ifneq ($(strip $(DESTDIR)),) yann@1109: ifneq ($(DESTDIR),$(abspath /$(DESTDIR))) yann@1109: $(error DESTDIR is not an absolute PATH: '$(DESTDIR)') yann@1109: endif yann@1109: endif yann@182: yann@182: ############################################################################### yann@182: # Global make rules yann@182: yann@1156: # If any extra MAKEFLAGS were added, re-run ourselves yann@1156: # See top of file for an explanation of why this is needed... yann@1156: ifneq ($(strip $(CT_MAKEFLAGS)),) yann@1156: yann@2505: # Somehow, the new auto-completion for make in the recent distributions yann@2505: # trigger a behavior where our Makefile calls itself recursively, in a yann@2505: # never-ending loop (except on lack of ressources, swap, PIDs...) yann@2505: # Avoid this situation by cutting the recursion short at the first yann@2505: # level. yann@2505: # This has the side effect of only showing the real targets, and hiding our yann@2505: # internal ones. :-) yann@2505: ifneq ($(MAKELEVEL),0) yann@2505: $(error Recursion detected, bailing out...) yann@2505: endif yann@2505: yann@1156: MAKEFLAGS += $(CT_MAKEFLAGS) yann@1156: build install clean distclean uninstall: yann@1156: @$(MAKE) $@ yann@1156: yann@1156: else yann@1156: # There were no additional MAKEFLAGS to add, do the job yann@1156: yann@555: TARGETS := bin lib doc man yann@182: yann@555: build: $(patsubst %,build-%,$(TARGETS)) yann@182: yann@1101: install: build real-install yann@555: yann@555: clean: $(patsubst %,clean-%,$(TARGETS)) yann@182: yann@182: distclean: clean yann@554: @echo " RM 'Makefile'" yann@182: @rm -f Makefile yann@182: yann@1048: uninstall: real-uninstall yann@182: yann@182: ############################################################################### yann@182: # Specific make rules yann@182: yann@182: #-------------------------------------- yann@182: # Build rules yann@182: yann@1336: build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh yann@1297: @chmod 755 $^ yann@182: yann@2481: build-lib: paths.mk config/configure.in yann@182: yann@555: build-doc: yann@555: yann@309: build-man: docs/ct-ng.1.gz yann@309: yann@309: docs/ct-ng.1.gz: docs/ct-ng.1 yann@554: @echo " GZIP '$@'" yann@317: @gzip -c9 $< >$@ yann@182: yann@470: %: %.in Makefile yann@554: @echo " SED '$@'" yann@1153: @$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \ yann@1153: -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \ yann@1153: -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \ yann@1153: -e 's,@@CT_MANDIR@@,$(MANDIR),g;' \ yann@1153: -e 's,@@CT_VERSION@@,$(VERSION),g;' \ yann@1153: -e 's,@@CT_DATE@@,$(DATE),g;' \ yann@1153: -e 's,@@CT_make@@,$(make),g;' \ yann@1156: -e 's,@@CT_bash@@,$(bash),g;' \ yann@1153: $@.in >$@ yann@1153: yann@1153: # We create a script fragment that is parseable from inside a Makefile, yann@1153: # but also from inside a shell script, hence the reason why we don't fr@1643: # use := to set variables, although that will incur a (very small) yann@1153: # penalty from the Makefile that includes it (due to re-evaluation at yann@1153: # each call). yann@2481: paths.mk: FORCE yann@1153: @echo " GEN '$@'" yann@1153: @(echo "export install=$(install)"; \ yann@1153: echo "export bash=$(bash)"; \ yann@1153: echo "export grep=$(grep)"; \ yann@1153: echo "export make=$(make)"; \ yann@1153: echo "export sed=$(sed)"; \ titus@1962: echo "export libtool=$(libtool)"; \ titus@1962: echo "export objcopy=$(objcopy)"; \ titus@1962: echo "export objdump=$(objdump)"; \ titus@1962: echo "export readelf=$(readelf)"; \ titus@1962: echo "export patch=$(patch)"; \ yann@1153: ) >paths.mk yann@182: yann@2481: config/configure.in: FORCE yann@2481: @echo " GEN '$@'" yann@2481: @{ printf "# Generated file, do not edit\n"; \ yann@2481: printf "# Default values as found by ./configure\n"; \ yann@2481: for var in $(KCONFIG); do \ yann@2481: printf "\n"; \ yann@2481: printf "config CONFIGURE_$${var%%=*}\n"; \ yann@2481: printf " bool\n"; \ yann@2481: if [ "$${var#*=}" = "y" ]; then \ yann@2481: printf " default y\n"; \ yann@2481: fi; \ yann@2481: done; \ yann@2481: } >$@ yann@2481: yann@2481: FORCE: yann@2481: yann@182: #-------------------------------------- yann@182: # Clean rules yann@182: yann@182: clean-bin: yann@554: @echo " RM 'ct-ng'" yann@182: @rm -f ct-ng yann@1339: @echo " RM 'scripts/crosstool-NG.sh'" yann@1158: @rm -f scripts/crosstool-NG.sh yann@1339: @echo " RM 'scripts/saveSample.sh'" yann@1186: @rm -f scripts/saveSample.sh yann@1339: @echo " RM 'scripts/showTuple.sh'" yann@1336: @rm -f scripts/showTuple.sh yann@182: yann@182: clean-lib: yann@1154: @echo " RM 'paths.mk'" yann@1154: @rm -f paths.mk yann@2481: @echo " RM 'config/configure.in'" yann@2481: @rm -f config/configure.in yann@182: yann@182: clean-doc: yann@555: yann@555: clean-man: yann@554: @echo " RM 'docs/ct-ng.1'" yann@318: @rm -f docs/ct-ng.1 yann@554: @echo " RM 'docs/ct-ng.1.gz'" yann@318: @rm -f docs/ct-ng.1.gz yann@182: yann@182: #-------------------------------------- yann@554: # Check for --local setup yann@182: yann@1297: ifeq ($(strip $(LOCAL)),y) yann@1048: yann@1101: real-install: yann@1297: @true yann@1048: yann@1048: real-uninstall: yann@1048: @true yann@1048: yann@1048: else yann@285: yann@554: #-------------------------------------- yann@554: # Install rules yann@554: yann@1876: real-install: $(patsubst %,install-%,$(TARGETS)) install-post yann@1048: yann@1047: install-bin: $(DESTDIR)$(BINDIR) yann@1994: @echo " INST 'ct-ng'" yann@1153: @$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng" yann@182: yann@555: # If one is hacking crosstool-NG, the patch set might change between any two yann@555: # installations of the same VERSION, thus the patches must be removed prior yann@555: # to being installed. It is simpler to remove the whole lib/ directory, as it yann@555: # is the goal of the install-lib rule to install the lib/ directory... yann@1047: install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples yann@182: yann@1994: LIB_SUB_DIR := config contrib kconfig patches scripts yann@1994: $(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR) yann@1994: @echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'" yann@1994: @tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \ yann@1994: |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -) yann@1994: yann@1994: # Huh? It seems we need at least one command to make this rule kick-in. yann@1994: install-lib-%: install-lib-%-copy; @true yann@1994: yann@1994: # Huh? that one does not inherit the -opy dependency, above... yann@1994: install-lib-scripts: install-lib-scripts-copy yann@1184: @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh yann@1186: @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh yann@1101: @rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh" yann@1994: yann@1994: install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR)) yann@1994: @echo " INST 'steps.mk'" yann@1153: @$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk" yann@1994: @echo " INST 'paths.mk'" yann@1153: @$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk" yann@182: yann@182: # Samples need a little love: yann@425: # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR yann@1047: install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main yann@1994: @echo " INSTDIR 'samples/'" yann@2577: @for samp_dir in samples/*/; do \ yann@2577: mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \ yann@2422: $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \ yann@2422: -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \ yann@2577: $${samp_dir}/crosstool.config \ yann@2577: >"$(DESTDIR)$(LIBDIR)/$${samp_dir}/crosstool.config"; \ yann@2577: $(install) -m 644 "$${samp_dir}/reported.by" \ yann@2577: "$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \ yann@2577: for libc_cfg in "$${samp_dir}/"*libc*.config; do \ yann@2577: [ -f "$${libc_cfg}" ] || continue; \ yann@2577: $(install) -m 644 "$${libc_cfg}" \ yann@2577: "$(DESTDIR)$(LIBDIR)/$${samp_dir}"; \ yann@2577: done; \ yann@182: done yann@2424: @$(install) -m 644 samples/samples.mk "$(DESTDIR)$(LIBDIR)/samples/samples.mk" yann@182: yann@1047: install-doc: $(DESTDIR)$(DOCDIR) yann@2076: @echo " INST 'docs/*.txt'" yann@2076: @for doc_file in docs/*.txt; do \ yann@1153: $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \ yann@182: done yann@249: yann@2026: install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR) yann@1994: @echo " INST 'ct-ng.1.gz'" yann@2026: @$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)" yann@182: yann@2026: $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)): yann@1994: @echo " MKDIR '$@/'" yann@1153: @$(install) -m 755 -d "$@" yann@182: yann@1876: install-post: yann@1876: @echo yann@1994: @echo "For auto-completion, do not forget to install 'ct-ng.comp' into" yann@1994: @echo "your bash completion directory (usually /etc/bash_completion.d)" yann@182: yann@182: #-------------------------------------- yann@182: # Uninstall rules yann@182: yann@1048: real-uninstall: $(patsubst %,uninstall-%,$(TARGETS)) yann@1048: yann@554: uninstall-bin: yann@1994: @echo " RM '$(DESTDIR)$(BINDIR)/ct-ng'" yann@1047: @rm -f "$(DESTDIR)$(BINDIR)/ct-ng" yann@182: yann@554: uninstall-lib: yann@1994: @echo " RMDIR '$(DESTDIR)$(LIBDIR)/'" yann@1047: @rm -rf "$(DESTDIR)$(LIBDIR)" yann@298: yann@554: uninstall-doc: yann@1994: @echo " RMDIR '$(DESTDIR)$(DOCDIR)/'" yann@1047: @rm -rf "$(DESTDIR)$(DOCDIR)" yann@554: yann@554: uninstall-man: yann@2423: @echo " RM '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1.gz'" yann@2423: @rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1"{,.gz} yann@1048: yann@1048: endif # Not --local yann@1156: yann@1156: endif # No extra MAKEFLAGS were added