GNUmakefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Having a separate GNUmakefile lets me 'include' the dynamically
  2. # generated rules created via cfg.mk (package-local configuration)
  3. # as well as maint.mk (generic maintainer rules).
  4. # This makefile is used only if you run GNU Make.
  5. # It is necessary if you want to build targets usually of interest
  6. # only to the maintainer.
  7. # Copyright (C) 2001, 2003, 2006-2014 Free Software Foundation, Inc.
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # If the user runs GNU make but has not yet run ./configure,
  19. # give them a diagnostic.
  20. _gl-Makefile := $(wildcard [M]akefile)
  21. ifneq ($(_gl-Makefile),)
  22. # Make tar archive easier to reproduce.
  23. export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
  24. # Allow the user to add to this in the Makefile.
  25. ALL_RECURSIVE_TARGETS =
  26. include Makefile
  27. # Some projects override e.g., _autoreconf here.
  28. -include $(srcdir)/cfg.mk
  29. # Allow cfg.mk to override these.
  30. _build-aux ?= build-aux
  31. _autoreconf ?= autoreconf -v
  32. include $(srcdir)/maint.mk
  33. # Ensure that $(VERSION) is up to date for dist-related targets, but not
  34. # for others: rerunning autoreconf and recompiling everything isn't cheap.
  35. _have-git-version-gen := \
  36. $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes)
  37. ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
  38. _is-dist-target ?= $(filter-out %clean, \
  39. $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS)))
  40. _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS)))
  41. ifneq (,$(_is-dist-target)$(_is-install-target))
  42. _curr-ver := $(shell cd $(srcdir) \
  43. && $(_build-aux)/git-version-gen \
  44. .tarball-version \
  45. $(git-version-gen-tag-sed-script))
  46. ifneq ($(_curr-ver),$(VERSION))
  47. ifeq ($(_curr-ver),UNKNOWN)
  48. $(info WARNING: unable to verify if $(VERSION) is the correct version)
  49. else
  50. ifneq (,$(_is-install-target))
  51. # GNU Coding Standards state that 'make install' should not cause
  52. # recompilation after 'make all'. But as long as changing the version
  53. # string alters config.h, the cost of having 'make all' always have an
  54. # up-to-date version is prohibitive. So, as a compromise, we merely
  55. # warn when installing a version string that is out of date; the user
  56. # should run 'autoreconf' (or something like 'make distcheck') to
  57. # fix the version, 'make all' to propagate it, then 'make install'.
  58. $(info WARNING: version string $(VERSION) is out of date;)
  59. $(info run '$(MAKE) _version' to fix it)
  60. else
  61. $(info INFO: running autoreconf for new version string: $(_curr-ver))
  62. GNUmakefile: _version
  63. touch GNUmakefile
  64. endif
  65. endif
  66. endif
  67. endif
  68. endif
  69. .PHONY: _version
  70. _version:
  71. cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf)
  72. $(MAKE) $(AM_MAKEFLAGS) Makefile
  73. else
  74. .DEFAULT_GOAL := abort-due-to-no-makefile
  75. srcdir = .
  76. # The package can override .DEFAULT_GOAL to run actions like autoreconf.
  77. -include ./cfg.mk
  78. # Allow cfg.mk to override these.
  79. _build-aux ?= build-aux
  80. _autoreconf ?= autoreconf -v
  81. include ./maint.mk
  82. ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
  83. $(MAKECMDGOALS): abort-due-to-no-makefile
  84. endif
  85. abort-due-to-no-makefile:
  86. @echo There seems to be no Makefile in this directory. 1>&2
  87. @echo "You must run ./configure before running 'make'." 1>&2
  88. @exit 1
  89. endif
  90. # Tell version 3.79 and up of GNU make to not build goals in this
  91. # directory in parallel, in case someone tries to build multiple
  92. # targets, and one of them can cause a recursive target to be invoked.
  93. # Only set this if Automake doesn't provide it.
  94. AM_RECURSIVE_TARGETS ?= $(RECURSIVE_TARGETS:-recursive=) \
  95. $(RECURSIVE_CLEAN_TARGETS:-recursive=) \
  96. dist distcheck tags ctags
  97. ALL_RECURSIVE_TARGETS += $(AM_RECURSIVE_TARGETS)
  98. ifneq ($(word 2, $(MAKECMDGOALS)), )
  99. ifneq ($(filter $(ALL_RECURSIVE_TARGETS), $(MAKECMDGOALS)), )
  100. .NOTPARALLEL:
  101. endif
  102. endif