Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. .DEFAULT_GOAL := help
  2. ifndef TAG
  3. TAG=alpine
  4. endif
  5. PORT ?= 8080
  6. PHP := $(shell sh -c 'which php')
  7. ifdef NO_DOCKER
  8. PHP = php
  9. else
  10. PHP = docker run \
  11. --rm \
  12. --volume $(shell pwd):/var/www/FreshRSS:z \
  13. --env FRESHRSS_ENV=development \
  14. --name freshrss-php-cli \
  15. freshrss/freshrss:$(TAG) \
  16. php
  17. endif
  18. ifeq ($(findstring alpine,$(TAG)),alpine)
  19. DOCKERFILE=Dockerfile-Alpine
  20. else ifeq ($(findstring arm,$(TAG)),arm)
  21. DOCKERFILE=Dockerfile-QEMU-ARM
  22. else
  23. DOCKERFILE=Dockerfile
  24. endif
  25. ############
  26. ## Docker ##
  27. ############
  28. .PHONY: build
  29. build: ## Build a Docker image
  30. docker build \
  31. --pull \
  32. --tag freshrss/freshrss:$(TAG) \
  33. --file Docker/$(DOCKERFILE) .
  34. .PHONY: start
  35. start: ## Start the development environment (use Docker)
  36. docker run \
  37. --rm \
  38. --volume $(shell pwd):/var/www/FreshRSS:z \
  39. --publish $(PORT):80 \
  40. --env FRESHRSS_ENV=development \
  41. --name freshrss-dev \
  42. freshrss/freshrss:$(TAG)
  43. .PHONY: stop
  44. stop: ## Stop FreshRSS container if any
  45. docker stop freshrss-dev
  46. ###########
  47. ## Tests ##
  48. ###########
  49. bin/phpunit: ## Install PHPUnit for test purposes
  50. mkdir -p bin/
  51. wget -O bin/phpunit https://phar.phpunit.de/phpunit-7.5.9.phar
  52. echo '5404288061420c3921e53dd3a756bf044be546c825c5e3556dea4c51aa330f69 bin/phpunit' | sha256sum -c - || rm bin/phpunit
  53. .PHONY: test
  54. test: bin/phpunit ## Run the test suite
  55. $(PHP) ./bin/phpunit --bootstrap ./tests/bootstrap.php ./tests
  56. ##########
  57. ## I18N ##
  58. ##########
  59. .PHONY: i18n-format
  60. i18n-format: ## Format I18N files
  61. @$(PHP) ./cli/manipulate.translation.php -a format
  62. @echo Files formatted.
  63. .PHONY: i18n-add-language
  64. i18n-add-language: ## Add a new supported language
  65. ifndef lang
  66. @echo To add a new language, you need to provide one in the "lang" variable.
  67. @exit 10
  68. endif
  69. @$(PHP) ./cli/manipulate.translation.php -a add -l $(lang)
  70. @echo Language added.
  71. .PHONY: i18n-add-key
  72. i18n-add-key: ## Add a translation key to all supported languages
  73. ifndef key
  74. @echo To add a key, you need to provide one in the "key" variable.
  75. @exit 10
  76. endif
  77. ifndef value
  78. @echo To add a key, you need to provide its value in the "value" variable.
  79. @exit 10
  80. endif
  81. @$(PHP) ./cli/manipulate.translation.php -a add -k $(key) -v "$(value)"
  82. @echo Key added.
  83. .PHONY: i18n-remove-key
  84. i18n-remove-key: ## Remove a translation key from all supported languages
  85. ifndef key
  86. @echo To remove a key, you need to provide one in the "key" variable.
  87. @exit 10
  88. endif
  89. @$(PHP) ./cli/manipulate.translation.php -a delete -k $(key)
  90. @echo Key removed.
  91. .PHONY: i18n-ignore-key
  92. i18n-ignore-key: ## Ignore a translation key for the selected language
  93. ifndef lang
  94. @echo To ignore a key, you need to provide a language in the "lang" variable.
  95. @exit 10
  96. endif
  97. ifndef key
  98. @echo To ignore a key, you need to provide one in the "key" variable.
  99. @exit 10
  100. endif
  101. @$(PHP) ./cli/manipulate.translation.php -a ignore -k $(key) -l $(lang)
  102. @echo Key ignored.
  103. ##########
  104. ## HELP ##
  105. ##########
  106. .PHONY: help
  107. help:
  108. @grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'