main.mk 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.9.1
  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 " style"
  50. @echo " test"
  51. @echo " upload"
  52. @echo
  53. .PHONY: clean
  54. clean: clean-makefilet
  55. .PHONY: clean-makefilet
  56. clean-makefilet:
  57. $(RM) -r "$(DIR_BUILD)"
  58. # remove installation root directory (only if it is a subdirectory of the project)
  59. if echo "$(abspath $(DESTDIR))" | grep -q "^$(shell pwd)"; then $(RM) -r "$(DESTDIR)"; fi
  60. @# A changed DIR_BUILD could cause the makefilet download directory to survive the above
  61. @# clean operation. We detect the "automatic download" situation based on a non-empty
  62. @# DIR_MAKEFILET_DOWNLOAD variable.
  63. if [ -n "$(DIR_MAKEFILET_DOWNLOAD)" ]; then $(RM) -r "$(DIR_MAKEFILET_DOWNLOAD)"; fi
  64. .PHONY: dist-clean
  65. dist-clean: clean
  66. $(RM) -r "$(DIR_DIST)"
  67. # Reset the default goal. The next processed target (usually in the Makefile of the project) will
  68. # be the default target.
  69. .DEFAULT_GOAL :=