main.mk 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # This very makefile (main.mk) is the most recently loaded makefile (lastword MAKEFILE_LIST).
  2. # We use this information as the base directory for further include directives below.
  3. DIR_MAKEFILET := $(dir $(lastword $(MAKEFILE_LIST)))include
  4. RM ?= $(shell which rm) -f
  5. BUILD_ID = $(shell which git >/dev/null && git log -1 --pretty=format:%h || echo "unknown")
  6. DIR_BUILD ?= build
  7. DIR_DIST ?= dist
  8. # e.g. for "debian/rules install"
  9. DESTDIR ?= root
  10. MAKEFILET_CURRENT_VERSION = 0.14.4
  11. include $(DIR_MAKEFILET)/base.mk
  12. include $(DIR_MAKEFILET)/deprecations.mk
  13. include $(DIR_MAKEFILET)/generic.mk
  14. include $(DIR_MAKEFILET)/release.mk
  15. # 'deb-common' is used for simple deb packages and for pypi2deb packages
  16. include $(DIR_MAKEFILET)/deb-common.mk
  17. DISABLE_SHELL_CHECK ?= 0
  18. ifneq ($(DISABLE_SHELL_CHECK),1)
  19. include $(DIR_MAKEFILET)/shell.mk
  20. endif
  21. # Debian packaging
  22. DIR_DEBIAN_BUILD ?= $(DIR_BUILD)/debian
  23. ifneq ($(wildcard debian/changelog),)
  24. include $(DIR_MAKEFILET)/deb.mk
  25. endif
  26. # pypi2deb packaging
  27. DIR_PYPI2DEB_BUILD ?= $(DIR_BUILD)/pypi2deb
  28. PYPI2DEB_PACKAGES ?=
  29. ifneq ($(PYPI2DEB_PACKAGES),)
  30. include $(DIR_MAKEFILET)/pypi2deb.mk
  31. endif
  32. # pypi/python packaging
  33. # DIR_PYTHON_SETUP can be overwritten by the project
  34. DIR_PYTHON_SETUP ?= .
  35. PYTHON_SETUP_FILE = $(DIR_PYTHON_SETUP)/setup.py
  36. PYTHON_PYPROJECT_FILE = $(DIR_PYTHON_SETUP)/pyproject.toml
  37. ifneq ($(wildcard $(PYTHON_SETUP_FILE) $(PYTHON_PYPROJECT_FILE)),)
  38. include $(DIR_MAKEFILET)/python-common.mk
  39. else ifeq "$(MAKEFILET_ENABLE_PYTHON)" "1"
  40. # python suppert (e.g. for virtualenv) may be forced via MAKEFILET_ENABLE_PYTHON=1
  41. include $(DIR_MAKEFILET)/python-common.mk
  42. endif
  43. .PHONY: help
  44. .NOTPARALLEL:
  45. help: help-makefilet
  46. .PHONY: help-makefilet
  47. help-makefilet:
  48. @echo "Common makefilet targets:"
  49. @echo " dist"
  50. @echo " help"
  51. @echo " install"
  52. @echo " report"
  53. @echo " style"
  54. @echo " test"
  55. @echo " upload"
  56. @echo
  57. .PHONY: clean
  58. clean: clean-makefilet
  59. .PHONY: clean-makefilet
  60. clean-makefilet:
  61. $(RM) -r "$(DIR_BUILD)"
  62. # remove installation root directory (only if it is a subdirectory of the project)
  63. if echo "$(abspath $(DESTDIR))" | grep -q "^$(shell pwd)"; then $(RM) -r "$(DESTDIR)"; fi
  64. @# A changed DIR_BUILD could cause the makefilet download directory to survive the above
  65. @# clean operation. We detect the "automatic download" situation based on a non-empty
  66. @# DIR_MAKEFILET_DOWNLOAD variable.
  67. if [ -n "$(DIR_MAKEFILET_DOWNLOAD)" ]; then $(RM) -r "$(DIR_MAKEFILET_DOWNLOAD)"; fi
  68. .PHONY: dist-clean
  69. dist-clean: clean
  70. $(RM) -r "$(DIR_DIST)"
  71. # Reset the default goal. The next processed target (usually in the Makefile of the project) will
  72. # be the default target.
  73. .DEFAULT_GOAL :=