Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # -*- coding: utf-8; tab-width: 4 -*-
  2. # vim: ts=4 noet ai
  3. # Part of ScrollMeter
  4. # Copyright © 2016 Desktopd Project
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # Basic options
  19. addon_ext = .xpi
  20. git_command = git
  21. rsvg_command = rsvg-convert
  22. zopflipng_command = zopflipng
  23. net_access_delay = 5
  24. zopflipng_iterations = 1000
  25. # Silent rules resembling Automake
  26. default_verbosity = 0
  27. V_at = $(v_at_$(V))
  28. v_at_ = $(v_at_$(default_verbosity))
  29. v_at_0 = @
  30. v_at_1 =
  31. V_XPI = $(v_xpi_$(V))
  32. v_xpi_ = $(v_xpi_$(default_verbosity))
  33. v_xpi_0 = @echo ' XPI ' $@;
  34. v_xpi_1 =
  35. V_RSVG = $(v_rsvg_$(V))
  36. v_rsvg_ = $(v_rsvg_$(default_verbosity))
  37. v_rsvg_0 = @echo ' RSVG ' $@;
  38. v_rsvg_1 =
  39. # Important paths
  40. builds_dir = ./builds
  41. branding_src_dir = ./branding
  42. src_dir = ./src
  43. version_info_path = ./version_info
  44. git_submodule_jpm_sh = ./tools/jpm.sh
  45. addon_path = $(builds_dir)/latest
  46. all: addon
  47. .PHONY: all addon git-submodule git-submodule-check deps deps-check \
  48. $(addon_path) branding icon rsvg-check clean distclean
  49. addon: deps-check $(addon_path)
  50. $(addon_path):
  51. $(V_at)$(V_XPI)( \
  52. [ "$(V_at)" ] && export JPM_SILENT=1 ;\
  53. buildDir=$(builds_dir)/`date +%s` ;\
  54. rmdir $(builds_dir)/* >/dev/null 2>&1 ;\
  55. mkdir -p "$$buildDir" ;\
  56. addonName=`$(git_submodule_jpm_sh)/bin/jpm-build.sh printPkgName 3>&1 > "$$buildDir/build.zip"` ;\
  57. mv "$$buildDir/build.zip" "$$buildDir/$$addonName$(addon_ext)" ;\
  58. cd $(builds_dir)/ ;\
  59. rm -f ./latest ;\
  60. ln -fs "`basename "$$buildDir"`" ./latest ;\
  61. )
  62. deps: git-submodule
  63. deps-check: git-submodule-check
  64. git-submodule-check:
  65. @[ -d $(git_submodule_jpm_sh)/bin ] || { echo "Run 'make deps' first!" ; false ;}
  66. git-submodule:
  67. @echo "Git will access online repositories!!!"
  68. @echo "Interrupt within $(net_access_delay) seconds if you are not ready..."
  69. sleep $(net_access_delay)
  70. @echo "Now invoking Git!"
  71. $(git_command) submodule update --init --recursive
  72. branding: icon
  73. icon: rsvg-check $(src_dir)/icon.png $(src_dir)/icon64.png
  74. rsvg-check:
  75. $(V_at)which $(rsvg_command) >/dev/null
  76. $(src_dir)/icon.png:
  77. $(V_at)$(V_RSVG)( \
  78. set -e ;\
  79. $(rsvg_command) -w 96 -h 96 $(branding_src_dir)/icon.svg \
  80. > $(src_dir)/icon~tmp.png ;\
  81. which $(zopflipng_command) >/dev/null 2>&1 || { \
  82. echo 'Warning: zopflipng not available' ;\
  83. mv $(src_dir)/icon~tmp.png $(src_dir)/icon.png ;\
  84. exit ;} ;\
  85. $(zopflipng_command) --iterations=$(zopflipng_iterations) --splitting=3 --filters=01234mepb --lossy_8bit --lossy_transparent $(src_dir)/icon~tmp.png $(src_dir)/icon.png ;\
  86. rm -f $(src_dir)/icon~tmp.png ;\
  87. )
  88. $(src_dir)/icon64.png:
  89. $(V_at)$(V_RSVG)( \
  90. set -e ;\
  91. $(rsvg_command) -w 128 -h 128 $(branding_src_dir)/icon.svg \
  92. > $(src_dir)/icon64~tmp.png ;\
  93. which $(zopflipng_command) >/dev/null 2>&1 || { \
  94. echo 'Warning: zopflipng not available' ;\
  95. mv $(src_dir)/icon64~tmp.png $(src_dir)/icon64.png ;\
  96. exit ;} ;\
  97. $(zopflipng_command) --iterations=$(zopflipng_iterations) --splitting=3 --filters=01234mepb --lossy_8bit --lossy_transparent $(src_dir)/icon64~tmp.png $(src_dir)/icon64.png ;\
  98. rm -f $(src_dir)/icon64~tmp.png ;\
  99. )
  100. clean:
  101. distclean: clean
  102. rm -f $(src_dir)/icon~tmp.png $(src_dir)/icon64~tmp.png \
  103. $(src_dir)/icon.png $(src_dir)/icon64.png
  104. rm -f $(api_docs_path)