main.mk 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. include $(DIR_MAKEFILET)/release.mk
  11. # 'deb-common' is used for simple deb packages and for pypi2deb packages
  12. include $(DIR_MAKEFILET)/deb-common.mk
  13. # TODO: remove this global flag and move it to individual (failing) projects
  14. DISABLE_SHELL_CHECK ?= 1
  15. ifeq ($(DISABLE_SHELL_CHECK),)
  16. include $(DIR_MAKEFILET)/shell.mk
  17. endif
  18. # Debian packaging
  19. DIR_DEBIAN_BUILD ?= $(DIR_BUILD)/debian
  20. ifneq ($(wildcard debian/changelog),)
  21. include $(DIR_MAKEFILET)/deb.mk
  22. endif
  23. # pypi2deb packaging
  24. DIR_PYPI2DEB_BUILD ?= $(DIR_BUILD)/pypi2deb
  25. ifneq ($(PYPI2DEB_PACKAGES),)
  26. include $(DIR_MAKEFILET)/pypi2deb.mk
  27. endif
  28. # pypi/python packaging
  29. # DIR_PYTHON_SETUP can be overwritten by the project
  30. DIR_PYTHON_SETUP ?= .
  31. PYTHON_SETUP_FILE = $(DIR_PYTHON_SETUP)/setup.py
  32. ifneq ($(wildcard $(PYTHON_SETUP_FILE)),)
  33. include $(DIR_MAKEFILET)/python.mk
  34. endif
  35. .PHONY: help
  36. help: help-makefilet
  37. .PHONY: help-makefilet
  38. help-makefilet:
  39. @echo "Common makefilet targets:"
  40. @echo " dist"
  41. @echo " help"
  42. @echo " install"
  43. @echo " report"
  44. @echo " test"
  45. @echo " upload"
  46. @echo
  47. .PHONY: clean
  48. clean: clean-makefilet
  49. .PHONY: clean-makefilet
  50. clean-makefilet:
  51. $(RM) -r "$(DIR_BUILD)"
  52. # remove installation root directory (only if it is a subdirectory of the project)
  53. if echo "$(realpath $(DESTDIR))" | grep -q "^$(shell pwd)"; then $(RM) -r "$(DESTDIR)"; fi
  54. .PHONY: dist-clean
  55. dist-clean: clean
  56. $(RM) -r "$(DIR_DIST)"
  57. # Reset the default goal. The next processed target (usually in the Makefile of the project) will
  58. # be the default target.
  59. .DEFAULT_GOAL :=