Makefile 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. PSYSH_SRC = bin src box.json.dist composer.json build/stub
  2. PSYSH_SRC_FILES = $(shell find src -type f -name "*.php")
  3. VERSION = $(shell git describe --tag --always --dirty=-dev)
  4. COMPOSER_OPTS = --no-interaction --no-progress --verbose
  5. COMPOSER_REQUIRE_OPTS = $(COMPOSER_OPTS) --no-update
  6. COMPOSER_UPDATE_OPTS = $(COMPOSER_OPTS) --prefer-stable --no-dev --classmap-authoritative --prefer-dist
  7. # Commands
  8. .PHONY: help clean build dist
  9. .DEFAULT_GOAL := help
  10. help:
  11. @echo "\033[33mUsage:\033[0m\n make TARGET\n\n\033[33mTargets:\033[0m"
  12. @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-7s\033[0m %s\n", $$1, $$2}'
  13. clean: ## Clean all created artifacts
  14. rm -rf build/*
  15. rm -rf dist/*
  16. rm -rf vendor-bin/*/vendor/
  17. build: ## Compile PHARs
  18. build: build/psysh/psysh build/psysh-compat/psysh build/psysh-php54/psysh build/psysh-php54-compat/psysh
  19. dist: ## Build tarballs for distribution
  20. dist: dist/psysh-$(VERSION).tar.gz dist/psysh-$(VERSION)-compat.tar.gz dist/psysh-$(VERSION)-php54.tar.gz dist/psysh-$(VERSION)-php54-compat.tar.gz
  21. # All the composer stuffs
  22. composer.lock: composer.json
  23. composer install
  24. touch $@
  25. vendor/autoload.php: composer.lock
  26. composer install
  27. touch $@
  28. vendor/bin/box: vendor/autoload.php
  29. composer bin box install
  30. touch $@
  31. # Lots of PHARs
  32. build/stub: bin/build-stub bin/psysh LICENSE
  33. bin/build-stub
  34. build/psysh: $(PSYSH_SRC) $(PSYSH_SRC_FILES)
  35. rm -rf $@ || true
  36. mkdir $@
  37. cp -R $(PSYSH_SRC) $@/
  38. composer config --working-dir $@ platform.php 7.0
  39. composer require --working-dir $@ $(COMPOSER_REQUIRE_OPTS) php:'>=7.0.0'
  40. composer update --working-dir $@ $(COMPOSER_UPDATE_OPTS)
  41. build/psysh-compat: $(PSYSH_SRC) $(PSYSH_SRC_FILES)
  42. rm -rf $@ || true
  43. mkdir $@
  44. cp -R $(PSYSH_SRC) $@/
  45. composer config --working-dir $@ platform.php 7.0
  46. composer require --working-dir $@ $(COMPOSER_REQUIRE_OPTS) php:'>=7.0.0'
  47. composer require --working-dir $@ $(COMPOSER_REQUIRE_OPTS) symfony/polyfill-iconv symfony/polyfill-mbstring hoa/console
  48. composer update --working-dir $@ $(COMPOSER_UPDATE_OPTS)
  49. build/psysh-php54: $(PSYSH_SRC) $(PSYSH_SRC_FILES)
  50. rm -rf $@ || true
  51. mkdir $@
  52. cp -R $(PSYSH_SRC) $@/
  53. composer config --working-dir $@ platform.php 5.4
  54. composer update --working-dir $@ $(COMPOSER_UPDATE_OPTS)
  55. build/psysh-php54-compat: $(PSYSH_SRC) $(PSYSH_SRC_FILES)
  56. rm -rf $@ || true
  57. mkdir $@
  58. cp -R $(PSYSH_SRC) $@/
  59. composer config --working-dir $@ platform.php 5.4
  60. composer require --working-dir $@ $(COMPOSER_REQUIRE_OPTS) symfony/polyfill-iconv symfony/polyfill-mbstring hoa/console:^2.15
  61. composer update --working-dir $@ $(COMPOSER_UPDATE_OPTS)
  62. build/%/psysh: vendor/bin/box build/%
  63. vendor/bin/box compile --working-dir $(dir $@)
  64. # Dist packages
  65. dist/psysh-$(VERSION).tar.gz: build/psysh/psysh
  66. @mkdir -p $(@D)
  67. tar -C $(dir $<) -czf $@ $(notdir $<)
  68. dist/psysh-$(VERSION)-%.tar.gz: build/psysh-%/psysh
  69. @mkdir -p $(@D)
  70. tar -C $(dir $<) -czf $@ $(notdir $<)