main.mk 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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)/generic.mk
  11. include $(DIR_MAKEFILET)/release.mk
  12. # 'deb-common' is used for simple deb packages and for pypi2deb packages
  13. include $(DIR_MAKEFILET)/deb-common.mk
  14. # TODO: remove this global flag and move it to individual (failing) projects
  15. DISABLE_SHELL_CHECK ?= 1
  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.mk
  36. # by default a project-related virtual environment is used
  37. DISABLE_CUSTOM_VIRTUALENV ?=
  38. ifneq ($(DISABLE_CUSTOM_VIRTUALENV),1)
  39. VIRTUALENV_REQUIREMENTS_FILE ?= requirements.txt
  40. ifneq ($(wildcard $(VIRTUALENV_REQUIREMENTS_FILE)),)
  41. include $(DIR_MAKEFILET)/python-virtualenv.mk
  42. endif
  43. endif
  44. ifneq ($(wildcard manage.py),)
  45. include $(DIR_MAKEFILET)/python-django.mk
  46. endif
  47. # set the test arguments if they were not overridden by another component (e.g. Django)
  48. PYTHON_TEST_ARGS ?= -m unittest discover
  49. endif
  50. .PHONY: help
  51. help: help-makefilet
  52. .PHONY: help-makefilet
  53. help-makefilet:
  54. @echo "Common makefilet targets:"
  55. @echo " dist"
  56. @echo " help"
  57. @echo " install"
  58. @echo " report"
  59. @echo " test"
  60. @echo " upload"
  61. @echo
  62. .PHONY: clean
  63. clean: clean-makefilet
  64. .PHONY: clean-makefilet
  65. clean-makefilet:
  66. $(RM) -r "$(DIR_BUILD)"
  67. # remove installation root directory (only if it is a subdirectory of the project)
  68. if echo "$(abspath $(DESTDIR))" | grep -q "^$(shell pwd)"; then $(RM) -r "$(DESTDIR)"; fi
  69. @# A changed DIR_BUILD could cause the makefilet download directory to survive the above
  70. @# clean operation. We detect the "automatic download" situation based on a non-empty
  71. @# DIR_MAKEFILET_DOWNLOAD variable.
  72. if [ -n "$(DIR_MAKEFILET_DOWNLOAD)" ]; then $(RM) -r "$(DIR_MAKEFILET_DOWNLOAD)"; fi
  73. .PHONY: dist-clean
  74. dist-clean: clean
  75. $(RM) -r "$(DIR_DIST)"
  76. # Reset the default goal. The next processed target (usually in the Makefile of the project) will
  77. # be the default target.
  78. .DEFAULT_GOAL :=