main.mk 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.12.0
  11. include $(DIR_MAKEFILET)/base.mk
  12. include $(DIR_MAKEFILET)/generic.mk
  13. include $(DIR_MAKEFILET)/release.mk
  14. # 'deb-common' is used for simple deb packages and for pypi2deb packages
  15. include $(DIR_MAKEFILET)/deb-common.mk
  16. DISABLE_SHELL_CHECK ?= 0
  17. ifneq ($(DISABLE_SHELL_CHECK),1)
  18. include $(DIR_MAKEFILET)/shell.mk
  19. endif
  20. # Debian packaging
  21. DIR_DEBIAN_BUILD ?= $(DIR_BUILD)/debian
  22. ifneq ($(wildcard debian/changelog),)
  23. include $(DIR_MAKEFILET)/deb.mk
  24. endif
  25. # pypi2deb packaging
  26. DIR_PYPI2DEB_BUILD ?= $(DIR_BUILD)/pypi2deb
  27. PYPI2DEB_PACKAGES ?=
  28. ifneq ($(PYPI2DEB_PACKAGES),)
  29. include $(DIR_MAKEFILET)/pypi2deb.mk
  30. endif
  31. # pypi/python packaging
  32. # DIR_PYTHON_SETUP can be overwritten by the project
  33. DIR_PYTHON_SETUP ?= .
  34. PYTHON_SETUP_FILE = $(DIR_PYTHON_SETUP)/setup.py
  35. ifneq ($(wildcard $(PYTHON_SETUP_FILE)),)
  36. include $(DIR_MAKEFILET)/python-common.mk
  37. else ifeq "$(MAKEFILET_ENABLE_PYTHON)" "1"
  38. # python suppert (e.g. for virtualenv) may be forced via MAKEFILET_ENABLE_PYTHON=1
  39. include $(DIR_MAKEFILET)/python-common.mk
  40. endif
  41. .PHONY: help
  42. .NOTPARALLEL:
  43. help: help-makefilet
  44. .PHONY: help-makefilet
  45. help-makefilet:
  46. @echo "Common makefilet targets:"
  47. @echo " dist"
  48. @echo " help"
  49. @echo " install"
  50. @echo " report"
  51. @echo " style"
  52. @echo " test"
  53. @echo " upload"
  54. @echo
  55. .PHONY: clean
  56. clean: clean-makefilet
  57. .PHONY: clean-makefilet
  58. clean-makefilet:
  59. $(RM) -r "$(DIR_BUILD)"
  60. # remove installation root directory (only if it is a subdirectory of the project)
  61. if echo "$(abspath $(DESTDIR))" | grep -q "^$(shell pwd)"; then $(RM) -r "$(DESTDIR)"; fi
  62. @# A changed DIR_BUILD could cause the makefilet download directory to survive the above
  63. @# clean operation. We detect the "automatic download" situation based on a non-empty
  64. @# DIR_MAKEFILET_DOWNLOAD variable.
  65. if [ -n "$(DIR_MAKEFILET_DOWNLOAD)" ]; then $(RM) -r "$(DIR_MAKEFILET_DOWNLOAD)"; fi
  66. .PHONY: dist-clean
  67. dist-clean: clean
  68. $(RM) -r "$(DIR_DIST)"
  69. # Reset the default goal. The next processed target (usually in the Makefile of the project) will
  70. # be the default target.
  71. .DEFAULT_GOAL :=