crosstool-ng/Makefile.in
Yann E. MORIN" 26da02fdaa docs: uninstall the man page
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
2011-04-29 00:05:41 +02:00

288 lines
8.7 KiB
Makefile

# Makefile.in for building crosstool-NG
# This file serves as source for the ./configure operation
# This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS
# to set additional flags in the current Makfile ( see:
# http://savannah.gnu.org/bugs/?20501 ), although the make manual says it
# should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion )
# so we have to work it around by calling ourselves back if needed
# So why do we need not to use the built rules and variables? Because we
# need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in
# and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite
# nor a command associated, and that built-in implicit rule takes precedence
# over our non-built-in implicit rule '%: %.in', below.
# CT_MAKEFLAGS will be used later, below...
# Do not print directories as we descend into them
ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),)
CT_MAKEFLAGS += --no-print-directory
endif
# Use neither builtin rules, nor builtin variables
# Note: dual test, because if -R and -r are given on the command line
# (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding
# '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' )
ifeq ($(filter Rr,$(MAKEFLAGS)),)
ifeq ($(filter -Rr,$(MAKEFLAGS)),)
CT_MAKEFLAGS += -Rr
endif # No -Rr
endif # No Rr
# Remove any suffix rules
.SUFFIXES:
all: Makefile build
###############################################################################
# Configuration variables
VERSION:= @@VERSION@@
BINDIR := @@BINDIR@@
LIBDIR := @@LIBDIR@@
DOCDIR := @@DOCDIR@@
MANDIR := @@MANDIR@@
DATE := @@DATE@@
LOCAL := @@LOCAL@@
# Paths found by ./configure
install:= @@install@@
bash := @@bash@@
grep := @@grep@@
make := @@make@@
sed := @@sed@@
libtool:= @@libtool@@
objcopy:= @@objcopy@@
objdump:= @@objdump@@
readelf:= @@readelf@@
patch := @@patch@@
###############################################################################
# Non-configure variables
MAN_SECTION := 1
MAN_SUBDIR := /man$(MAN_SECTION)
###############################################################################
# Sanity checks
# Check if Makefile is up to date:
Makefile: Makefile.in
@echo "$< did changed: you must re-run './configure'"
@false
# If installing with DESTDIR, check it's an absolute path
ifneq ($(strip $(DESTDIR)),)
ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
$(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
endif
endif
###############################################################################
# Global make rules
# If any extra MAKEFLAGS were added, re-run ourselves
# See top of file for an explanation of why this is needed...
ifneq ($(strip $(CT_MAKEFLAGS)),)
MAKEFLAGS += $(CT_MAKEFLAGS)
build install clean distclean uninstall:
@$(MAKE) $@
else
# There were no additional MAKEFLAGS to add, do the job
TARGETS := bin lib doc man
build: $(patsubst %,build-%,$(TARGETS))
install: build real-install
clean: $(patsubst %,clean-%,$(TARGETS))
distclean: clean
@echo " RM 'Makefile'"
@rm -f Makefile
uninstall: real-uninstall
###############################################################################
# Specific make rules
#--------------------------------------
# Build rules
build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh
@chmod 755 $^
build-lib: paths.mk
build-doc:
build-man: docs/ct-ng.1.gz
docs/ct-ng.1.gz: docs/ct-ng.1
@echo " GZIP '$@'"
@gzip -c9 $< >$@
%: %.in Makefile
@echo " SED '$@'"
@$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \
-e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \
-e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \
-e 's,@@CT_MANDIR@@,$(MANDIR),g;' \
-e 's,@@CT_VERSION@@,$(VERSION),g;' \
-e 's,@@CT_DATE@@,$(DATE),g;' \
-e 's,@@CT_make@@,$(make),g;' \
-e 's,@@CT_bash@@,$(bash),g;' \
$@.in >$@
# We create a script fragment that is parseable from inside a Makefile,
# but also from inside a shell script, hence the reason why we don't
# use := to set variables, although that will incur a (very small)
# penalty from the Makefile that includes it (due to re-evaluation at
# each call).
paths.mk:
@echo " GEN '$@'"
@(echo "export install=$(install)"; \
echo "export bash=$(bash)"; \
echo "export grep=$(grep)"; \
echo "export make=$(make)"; \
echo "export sed=$(sed)"; \
echo "export libtool=$(libtool)"; \
echo "export objcopy=$(objcopy)"; \
echo "export objdump=$(objdump)"; \
echo "export readelf=$(readelf)"; \
echo "export patch=$(patch)"; \
) >paths.mk
#--------------------------------------
# Clean rules
clean-bin:
@echo " RM 'ct-ng'"
@rm -f ct-ng
@echo " RM 'scripts/crosstool-NG.sh'"
@rm -f scripts/crosstool-NG.sh
@echo " RM 'scripts/saveSample.sh'"
@rm -f scripts/saveSample.sh
@echo " RM 'scripts/showTuple.sh'"
@rm -f scripts/showTuple.sh
clean-lib:
@echo " RM 'paths.mk'"
@rm -f paths.mk
clean-doc:
clean-man:
@echo " RM 'docs/ct-ng.1'"
@rm -f docs/ct-ng.1
@echo " RM 'docs/ct-ng.1.gz'"
@rm -f docs/ct-ng.1.gz
#--------------------------------------
# Check for --local setup
ifeq ($(strip $(LOCAL)),y)
real-install:
@true
real-uninstall:
@true
else
#--------------------------------------
# Install rules
real-install: $(patsubst %,install-%,$(TARGETS)) install-post
install-bin: $(DESTDIR)$(BINDIR)
@echo " INST 'ct-ng'"
@$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
# If one is hacking crosstool-NG, the patch set might change between any two
# installations of the same VERSION, thus the patches must be removed prior
# to being installed. It is simpler to remove the whole lib/ directory, as it
# is the goal of the install-lib rule to install the lib/ directory...
install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
LIB_SUB_DIR := config contrib kconfig patches scripts
$(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(LIBDIR)
@echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
|(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
# Huh? It seems we need at least one command to make this rule kick-in.
install-lib-%: install-lib-%-copy; @true
# Huh? that one does not inherit the -opy dependency, above...
install-lib-scripts: install-lib-scripts-copy
@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
install-lib-main: $(DESTDIR)$(LIBDIR) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
@echo " INST 'steps.mk'"
@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
@echo " INST 'paths.mk'"
@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
# Samples need a little love:
# - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
@echo " INSTDIR 'samples/'"
@for samp_file in samples/*/crosstool.config; do \
mkdir -p "$(DESTDIR)$(LIBDIR)/$${samp_file%/*}"; \
$(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
-e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
$${samp_file} \
>"$(DESTDIR)$(LIBDIR)/$${samp_file}"; \
done
install-doc: $(DESTDIR)$(DOCDIR)
@echo " INST 'docs/*.txt'"
@for doc_file in docs/*.txt; do \
$(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
done
install-man: $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)
@echo " INST 'ct-ng.1.gz'"
@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)"
$(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)$(MAN_SUBDIR)):
@echo " MKDIR '$@/'"
@$(install) -m 755 -d "$@"
install-post:
@echo
@echo "For auto-completion, do not forget to install 'ct-ng.comp' into"
@echo "your bash completion directory (usually /etc/bash_completion.d)"
#--------------------------------------
# Uninstall rules
real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
uninstall-bin:
@echo " RM '$(DESTDIR)$(BINDIR)/ct-ng'"
@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
uninstall-lib:
@echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
@rm -rf "$(DESTDIR)$(LIBDIR)"
uninstall-doc:
@echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
@rm -rf "$(DESTDIR)$(DOCDIR)"
uninstall-man:
@echo " RM '$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1.gz'"
@rm -f "$(DESTDIR)$(MANDIR)$(MAN_SUBDIR)/ct-ng.1"{,.gz}
endif # Not --local
endif # No extra MAKEFLAGS were added