main.mk 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.15.0
  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. # load optional external modules (see `MAKEFILET_MODULES`)
  44. include $(DIR_MAKEFILET)/makefilet-download-modules.mk
  45. .PHONY: help
  46. .NOTPARALLEL:
  47. help: help-makefilet
  48. .PHONY: help-makefilet
  49. help-makefilet:
  50. @echo "Common makefilet targets:"
  51. @echo " dist"
  52. @echo " help"
  53. @echo " install"
  54. @echo " report"
  55. @echo " style"
  56. @echo " test"
  57. @echo " upload"
  58. @echo
  59. .PHONY: clean
  60. clean: clean-makefilet
  61. .PHONY: clean-makefilet
  62. clean-makefilet:
  63. $(RM) -r "$(DIR_BUILD)"
  64. # remove installation root directory (only if it is a subdirectory of the project)
  65. if echo "$(abspath $(DESTDIR))" | grep -q "^$(shell pwd)"; then $(RM) -r "$(DESTDIR)"; fi
  66. @# A changed DIR_BUILD could cause the makefilet download directory to survive the above
  67. @# clean operation. We detect the "automatic download" situation based on a non-empty
  68. @# DIR_MAKEFILET_DOWNLOAD variable.
  69. if [ -n "$(DIR_MAKEFILET_DOWNLOAD)" ]; then $(RM) -r "$(DIR_MAKEFILET_DOWNLOAD)"; fi
  70. .PHONY: dist-clean
  71. dist-clean: clean
  72. $(RM) -r "$(DIR_DIST)"
  73. # Reset the default goal. The next processed target (usually in the Makefile of the project) will
  74. # be the default target.
  75. .DEFAULT_GOAL :=