Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # vim: set sw=2 ts=2 sts=2 et tw=80 fmr={{{,}}} fdl=0 fdm=marker:
  2. # pgs-cli build.
  3. .PHONY: help dist
  4. # Auto-Documenting Section. Displays a target list with `##` descriptions.
  5. help:
  6. @grep -E '^[a-zA-Z_-]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "%-15s %s\n", $$1, $$2}'
  7. dist: ## Create a distribution for live usage
  8. # --- Create Folders ---
  9. @rm -r dist/*
  10. @mkdir -p dist/css dist/js dist/tags
  11. # --- Combine CSS ---
  12. @for file in $$(cat css/app.css | sed "$(CSS_FILES)"); do \
  13. cat css/$$file >> dist/css/app.css; \
  14. done
  15. # --- Combine Javascript ---
  16. @for file in $$(grep "$(JS_TAGS)" index.html | sed "$(JS_FILES)"); do \
  17. cat $$file >> dist/js/app.js; \
  18. done
  19. # --- Combine Riot Tags ---
  20. @for file in $$(grep "$(RIOT_TAGS)" index.html | sed "$(RIOT_FILES)"); do \
  21. cat $$file >> dist/tags/app.tag; \
  22. done
  23. # --- Modify Index Page ---
  24. @# Output is piped/redirected as BSD and GNU `sed -i` differ.
  25. @cp index.html dist/temp.html
  26. @sed "/$(JS_TAGS)/D" dist/temp.html | sed "s|$(APPJS_PH)|$(APPJS_TAG)|" > dist/index.html
  27. @cp dist/index.html dist/temp.html
  28. @sed "/$(RIOT_TAGS)/D" dist/temp.html | sed "s|$(APPTAG_PH)|$(APPTAG_TAG)|" > dist/index.html
  29. @rm dist/temp.html
  30. @echo "All Done!"
  31. CSS_FILES = s|@import.*[\'\"]\(.*\)[\'\"].*|\1|
  32. JS_TAGS = <script .*src=[\'\"].*\.js[\'\"]
  33. JS_FILES = s|.*src=[\'\"]\(.*\.js\)[\'\"].*|\1|
  34. RIOT_TAGS = <script .*src=[\'\"].*\.tag[\'\"]
  35. RIOT_FILES = s|.*src=[\'\"]\(.*\.tag\)[\'\"].*|\1|
  36. APPJS_PH = <!-- appjsplaceholder -->
  37. APPJS_TAG = <script type='text/javascript' src='js/app.js'></script>
  38. APPTAG_PH = <!-- apptagplaceholder -->
  39. APPTAG_TAG = <script type='riot/tag' src='tags/app.tag'></script>