GNUmakefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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-2012 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. # Systems where /bin/sh is not the default shell need this. The $(shell)
  19. # command below won't work with e.g. stock DOS/Windows shells.
  20. ifeq ($(wildcard /bin/s[h]),/bin/sh)
  21. SHELL = /bin/sh
  22. else
  23. # will be used only with the next shell-test line, then overwritten
  24. # by a configured-in value
  25. SHELL = sh
  26. endif
  27. # If the user runs GNU make but has not yet run ./configure,
  28. # give them a diagnostic.
  29. _have-Makefile := $(shell test -f Makefile && echo yes)
  30. ifeq ($(_have-Makefile),yes)
  31. # Make tar archive easier to reproduce.
  32. export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
  33. # Allow the user to add to this in the Makefile.
  34. ALL_RECURSIVE_TARGETS =
  35. include Makefile
  36. # Some projects override e.g., _autoreconf here.
  37. -include $(srcdir)/cfg.mk
  38. # Allow cfg.mk to override these.
  39. _build-aux ?= build-aux
  40. _autoreconf ?= autoreconf -v
  41. include $(srcdir)/maint.mk
  42. # Ensure that $(VERSION) is up to date for dist-related targets, but not
  43. # for others: rerunning autoreconf and recompiling everything isn't cheap.
  44. _have-git-version-gen := \
  45. $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes)
  46. ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
  47. _is-dist-target ?= $(filter-out %clean, \
  48. $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS)))
  49. _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS)))
  50. ifneq (,$(_is-dist-target)$(_is-install-target))
  51. _curr-ver := $(shell cd $(srcdir) \
  52. && $(_build-aux)/git-version-gen \
  53. .tarball-version \
  54. $(git-version-gen-tag-sed-script))
  55. ifneq ($(_curr-ver),$(VERSION))
  56. ifeq ($(_curr-ver),UNKNOWN)
  57. $(info WARNING: unable to verify if $(VERSION) is the correct version)
  58. else
  59. ifneq (,$(_is-install-target))
  60. # GNU Coding Standards state that 'make install' should not cause
  61. # recompilation after 'make all'. But as long as changing the version
  62. # string alters config.h, the cost of having 'make all' always have an
  63. # up-to-date version is prohibitive. So, as a compromise, we merely
  64. # warn when installing a version string that is out of date; the user
  65. # should run 'autoreconf' (or something like 'make distcheck') to
  66. # fix the version, 'make all' to propagate it, then 'make install'.
  67. $(info WARNING: version string $(VERSION) is out of date;)
  68. $(info run '$(MAKE) _version' to fix it)
  69. else
  70. $(info INFO: running autoreconf for new version string: $(_curr-ver))
  71. GNUmakefile: _version
  72. touch GNUmakefile
  73. endif
  74. endif
  75. endif
  76. endif
  77. endif
  78. .PHONY: _version
  79. _version:
  80. cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf)
  81. $(MAKE) $(AM_MAKEFLAGS) Makefile
  82. else
  83. .DEFAULT_GOAL := abort-due-to-no-makefile
  84. srcdir = .
  85. # The package can override .DEFAULT_GOAL to run actions like autoreconf.
  86. -include ./cfg.mk
  87. # Allow cfg.mk to override these.
  88. _build-aux ?= build-aux
  89. _autoreconf ?= autoreconf -v
  90. include ./maint.mk
  91. ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
  92. $(MAKECMDGOALS): abort-due-to-no-makefile
  93. endif
  94. abort-due-to-no-makefile:
  95. @echo There seems to be no Makefile in this directory. 1>&2
  96. @echo "You must run ./configure before running 'make'." 1>&2
  97. @exit 1
  98. endif
  99. # Tell version 3.79 and up of GNU make to not build goals in this
  100. # directory in parallel, in case someone tries to build multiple
  101. # targets, and one of them can cause a recursive target to be invoked.
  102. # Only set this if Automake doesn't provide it.
  103. AM_RECURSIVE_TARGETS ?= $(RECURSIVE_TARGETS:-recursive=) \
  104. $(RECURSIVE_CLEAN_TARGETS:-recursive=) \
  105. dist distcheck tags ctags
  106. ALL_RECURSIVE_TARGETS += $(AM_RECURSIVE_TARGETS)
  107. ifneq ($(word 2, $(MAKECMDGOALS)), )
  108. ifneq ($(filter $(ALL_RECURSIVE_TARGETS), $(MAKECMDGOALS)), )
  109. .NOTPARALLEL:
  110. endif
  111. endif