GNUmakefile 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Maintainer makefile for Automake. Requires GNU make.
  2. # Copyright (C) 2012-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ifeq ($(filter bootstrap,$(MAKECMDGOALS)),)
  17. ifeq ($(wildcard Makefile),)
  18. # Any target but 'bootstrap' specified in an unconfigured tree
  19. # is an error, even when the user is running GNU make.
  20. $(warning There seems to be no Makefile in this directory.)
  21. $(warning You must run ./configure before running 'make'.)
  22. $(error Fatal Error)
  23. endif
  24. include ./Makefile
  25. include $(srcdir)/maintainer/maint.mk
  26. include $(srcdir)/maintainer/syntax-checks.mk
  27. else # ! bootstrap in $(MAKECMDGOALS)
  28. other-targets := $(filter-out bootstrap,$(MAKECMDGOALS))
  29. config-status := $(wildcard ./config.status)
  30. BOOTSTRAP_SHELL ?= /bin/sh
  31. export BOOTSTRAP_SHELL
  32. # Allow the user (or more likely the developer) to ask for a bootstrap
  33. # of the package.
  34. #
  35. # Two issues that must be kept in mind in the implementation below:
  36. #
  37. # [1] "make bootstrap" can be invoked before 'configure' is run (and in
  38. # fact, even before it is created, if we are bootstrapping from a
  39. # freshly-cloned checkout).
  40. #
  41. # [2] When re-bootstrapping an already configured tree, we must ensure
  42. # that the automatic remake rules for Makefile and company do not
  43. # kick in, because the tree might be in an inconsistent state (e.g.,
  44. # we have just switched from 'maint' to 'master', and have the built
  45. # 'automake' script left from 'maint', but the files 'lib/am/*.am'
  46. # are from 'master': if 'automake' gets run and uses those files --
  47. # boom!).
  48. ifdef config-status # Bootstrap from an already-configured tree.
  49. # We need the definition of $(srcdir) in the 'bootstrap' rule
  50. # below.
  51. srcdir := $(shell echo @srcdir@ | $(config-status) --file=-)
  52. ifndef srcdir
  53. $(error Could not obtain $$(srcdir) from $(config-status))
  54. endif
  55. # Also, if we are re-bootstrapping an already-configured tree, we
  56. # want to re-configure it with the same pre-existing configuration.
  57. old-configure-flags := $(shell $(config-status) --config)
  58. else # Assume we are bootstrapping from an unconfigured srcdir.
  59. srcdir := .
  60. old-configure-flags :=
  61. endif
  62. configure-flags := $(old-configure-flags) $(BOOTSTRAP_CONFIGURE_FLAGS)
  63. .PHONY: bootstrap
  64. bootstrap:
  65. cd $(srcdir) && $(SHELL) ./bootstrap
  66. $(srcdir)/configure $(configure-flags)
  67. $(MAKE) clean
  68. $(MAKE) check TESTS=t/get-sysconf
  69. # Ensure that all the specified targets but 'bootstrap' (if any) are
  70. # run with a properly re-bootstrapped tree.
  71. ifdef other-targets
  72. $(other-targets): restart
  73. .PHONY: $(other-targets) restart
  74. restart: bootstrap; $(MAKE) $(AM_MAKEFLAGS) $(other-targets)
  75. endif
  76. endif # ! bootstrap in $(MAKECMDGOALS)