Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # -*- coding: utf-8; tab-width: 4 -*-
  2. # vim: ts=4 noet ai
  3. # Part of No Resource URI Leak
  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. # Silent rules resembling Automake
  25. default_verbosity = 0
  26. V_at = $(v_at_$(V))
  27. v_at_ = $(v_at_$(default_verbosity))
  28. v_at_0 = @
  29. v_at_1 =
  30. V_XPI = $(v_xpi_$(V))
  31. v_xpi_ = $(v_xpi_$(default_verbosity))
  32. v_xpi_0 = @echo ' XPI ' $@;
  33. v_xpi_1 =
  34. V_RSVG = $(v_rsvg_$(V))
  35. v_rsvg_ = $(v_rsvg_$(default_verbosity))
  36. v_rsvg_0 = @echo ' RSVG ' $@;
  37. v_rsvg_1 =
  38. # Important paths
  39. builds_dir = ./builds
  40. branding_src_dir = ./branding
  41. src_dir = ./src
  42. version_info_path = ./version_info
  43. git_submodule_jpm_sh = ./tools/jpm.sh
  44. addon_path = $(builds_dir)/latest
  45. all: addon
  46. .PHONY: all addon git-submodule git-submodule-check deps deps-check \
  47. $(addon_path) branding icon rsvg-check clean distclean
  48. addon: deps-check $(addon_path)
  49. $(addon_path):
  50. $(V_at)$(V_XPI)( \
  51. [ "$(V_at)" ] && export JPM_SILENT=1 ;\
  52. buildDir=$(builds_dir)/`date +%s` ;\
  53. rmdir $(builds_dir)/* >/dev/null 2>&1 ;\
  54. mkdir -p "$$buildDir" ;\
  55. addonName=`$(git_submodule_jpm_sh)/bin/jpm-build.sh printPkgName 3>&1 > "$$buildDir/build.zip"` ;\
  56. mv "$$buildDir/build.zip" "$$buildDir/$$addonName$(addon_ext)" ;\
  57. cd $(builds_dir)/ ;\
  58. rm -f ./latest ;\
  59. ln -fs "`basename "$$buildDir"`" ./latest ;\
  60. )
  61. deps: git-submodule
  62. deps-check: git-submodule-check
  63. git-submodule-check:
  64. @[ -d $(git_submodule_jpm_sh)/bin ] || { echo "Run 'make deps' first!" ; false ;}
  65. git-submodule:
  66. @echo "Git will access online repositories!!!"
  67. @echo "Interrupt within $(net_access_delay) seconds if you are not ready..."
  68. sleep $(net_access_delay)
  69. @echo "Now invoking Git!"
  70. $(git_command) submodule update --init --recursive
  71. branding: icon
  72. icon: rsvg-check $(src_dir)/icon.png $(src_dir)/icon64.png
  73. rsvg-check:
  74. $(V_at)which $(rsvg_command) >/dev/null
  75. $(src_dir)/icon.png:
  76. $(V_at)$(V_RSVG)( \
  77. set -e ;\
  78. $(rsvg_command) -w 96 -h 96 $(branding_src_dir)/icon.svg \
  79. > $(src_dir)/icon~tmp.png ;\
  80. which $(zopflipng_command) >/dev/null 2>&1 || { \
  81. echo 'Warning: zopflipng not available' ;\
  82. mv $(src_dir)/icon~tmp.png $(src_dir)/icon.png ;\
  83. exit ;} ;\
  84. $(zopflipng_command) --iterations=200 --splitting=3 --filters=01234mepb --lossy_8bit --lossy_transparent $(src_dir)/icon~tmp.png $(src_dir)/icon.png ;\
  85. rm -f $(src_dir)/icon~tmp.png ;\
  86. )
  87. $(src_dir)/icon64.png:
  88. $(V_at)$(V_RSVG)( \
  89. set -e ;\
  90. $(rsvg_command) -w 128 -h 128 $(branding_src_dir)/icon.svg \
  91. > $(src_dir)/icon64~tmp.png ;\
  92. which $(zopflipng_command) >/dev/null 2>&1 || { \
  93. echo 'Warning: zopflipng not available' ;\
  94. mv $(src_dir)/icon64~tmp.png $(src_dir)/icon64.png ;\
  95. exit ;} ;\
  96. $(zopflipng_command) --iterations=200 --splitting=3 --filters=01234mepb --lossy_8bit --lossy_transparent $(src_dir)/icon64~tmp.png $(src_dir)/icon64.png ;\
  97. rm -f $(src_dir)/icon64~tmp.png ;\
  98. )
  99. clean:
  100. distclean: clean
  101. rm -f $(src_dir)/icon~tmp.png $(src_dir)/icon64~tmp.png \
  102. $(src_dir)/icon.png $(src_dir)/icon64.png
  103. rm -f $(api_docs_path)
  104. install: debian-install
  105. debian-install: $(addon_path)
  106. @echo "The 'install' target is only for Debian packaging!"
  107. install-xpi $(addon_path)/*.xpi