main.mk 2.4 KB

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