You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
3.6 KiB

  1. PYTHON ?= python3
  2. PYTHON_VERSION_MINOR := $(shell ${PYTHON} -c "import sys; print(sys.version_info.minor)")
  3. PYRCC5 ?= pyrcc5
  4. REQ_MINOR_VERSION = 6
  5. PREFIX ?= /usr/local
  6. # Window compatability via Msys2
  7. # - venv creates Scripts instead of bin
  8. # - compile generates .pyd instead of .so
  9. # - venv with --sytem-site-packages has issues on windows as well...
  10. ifeq ($(shell ${PYTHON} -c "import platform; print(platform.system())"), Windows)
  11. BIN = Scripts
  12. SO = *.pyd
  13. VENV_OPTIONS =
  14. else
  15. BIN = bin
  16. SO = *.so
  17. VENV_OPTIONS = --system-site-packages
  18. endif
  19. # Set this variable if all dependencies are already met on the system. We will then avoid the
  20. # whole vitualenv creation and pip install dance.
  21. NO_VENV ?=
  22. ifdef NO_VENV
  23. VENV_PYTHON = $(PYTHON)
  24. else
  25. VENV_PYTHON = ./env/$(BIN)/python
  26. endif
  27. # If you're installing into a path that is not going to be the final path prefix (such as a
  28. # sandbox), set DESTDIR to that path.
  29. # Our build scripts are not very "make like" yet and perform their task in a bundle. For now, we
  30. # use one of each file to act as a representative, a target, of these groups.
  31. packages = hscommon qtlib core qt
  32. localedirs = $(wildcard locale/*/LC_MESSAGES)
  33. pofiles = $(wildcard locale/*/LC_MESSAGES/*.po)
  34. mofiles = $(patsubst %.po,%.mo,$(pofiles))
  35. vpath %.po $(localedirs)
  36. vpath %.mo $(localedirs)
  37. all: | env i18n modules qt/dg_rc.py
  38. @echo "Build complete! You can run dupeGuru with 'make run'"
  39. run:
  40. $(VENV_PYTHON) run.py
  41. pyc: | env
  42. ${VENV_PYTHON} -m compileall ${packages}
  43. reqs:
  44. ifneq ($(shell test $(PYTHON_VERSION_MINOR) -gt $(REQ_MINOR_VERSION); echo $$?),0)
  45. $(error "Python 3.${REQ_MINOR_VERSION}+ required. Aborting.")
  46. endif
  47. ifndef NO_VENV
  48. @${PYTHON} -m venv -h > /dev/null || \
  49. echo "Creation of our virtualenv failed. If you're on Ubuntu, you probably need python3-venv."
  50. endif
  51. @${PYTHON} -c 'import PyQt5' >/dev/null 2>&1 || \
  52. { echo "PyQt 5.4+ required. Install it and try again. Aborting"; exit 1; }
  53. env: | reqs
  54. ifndef NO_VENV
  55. @echo "Creating our virtualenv"
  56. ${PYTHON} -m venv env
  57. $(VENV_PYTHON) -m pip install -r requirements.txt
  58. # We can't use the "--system-site-packages" flag on creation because otherwise we end up with
  59. # the system's pip and that messes up things in some cases (notably in Gentoo).
  60. ${PYTHON} -m venv --upgrade ${VENV_OPTIONS} env
  61. endif
  62. build/help: | env
  63. $(VENV_PYTHON) build.py --doc
  64. qt/dg_rc.py: qt/dg.qrc
  65. $(PYRCC5) qt/dg.qrc > qt/dg_rc.py
  66. i18n: $(mofiles)
  67. %.mo: %.po
  68. msgfmt -o [email protected] $<
  69. modules: | env
  70. $(VENV_PYTHON) build.py --modules
  71. mergepot: | env
  72. $(VENV_PYTHON) build.py --mergepot
  73. normpo: | env
  74. $(VENV_PYTHON) build.py --normpo
  75. install: all pyc
  76. mkdir -p ${DESTDIR}${PREFIX}/share/dupeguru
  77. cp -rf ${packages} locale ${DESTDIR}${PREFIX}/share/dupeguru
  78. cp -f run.py ${DESTDIR}${PREFIX}/share/dupeguru/run.py
  79. chmod 755 ${DESTDIR}${PREFIX}/share/dupeguru/run.py
  80. mkdir -p ${DESTDIR}${PREFIX}/bin
  81. ln -sf ${PREFIX}/share/dupeguru/run.py ${DESTDIR}${PREFIX}/bin/dupeguru
  82. mkdir -p ${DESTDIR}${PREFIX}/share/applications
  83. cp -f pkg/dupeguru.desktop ${DESTDIR}${PREFIX}/share/applications
  84. mkdir -p ${DESTDIR}${PREFIX}/share/pixmaps
  85. cp -f images/dgse_logo_128.png ${DESTDIR}${PREFIX}/share/pixmaps/dupeguru.png
  86. installdocs: build/help
  87. mkdir -p ${DESTDIR}${PREFIX}/share/dupeguru
  88. cp -rf build/help ${DESTDIR}${PREFIX}/share/dupeguru
  89. uninstall:
  90. rm -rf "${DESTDIR}${PREFIX}/share/dupeguru"
  91. rm -f "${DESTDIR}${PREFIX}/bin/dupeguru"
  92. rm -f "${DESTDIR}${PREFIX}/share/applications/dupeguru.desktop"
  93. rm -f "${DESTDIR}${PREFIX}/share/pixmaps/dupeguru.png"
  94. clean:
  95. -rm -rf build
  96. -rm locale/*/LC_MESSAGES/*.mo
  97. -rm core/pe/*.$(SO) qt/pe/*.$(SO)
  98. .PHONY: clean normpo mergepot modules i18n reqs run pyc install uninstall all