Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. PY?=python3
  2. PELICAN?=pelican
  3. PELICANOPTS=
  4. BASEDIR=$(CURDIR)
  5. INPUTDIR=$(BASEDIR)/content
  6. OUTPUTDIR=$(BASEDIR)/output
  7. CONFFILE=$(BASEDIR)/pelicanconf.py
  8. PUBLISHCONF=$(BASEDIR)/publishconf.py
  9. PHPPERSONAL=../php-personal
  10. FTP_HOST=********
  11. FTP_USER=********
  12. FTP_TARGET_DIR=********
  13. SSH_HOST=127.0.0.1
  14. SSH_PORT=22
  15. SSH_USER=user
  16. SSH_TARGET_DIR=path/to/personal-tube
  17. DEBUG ?= 0
  18. ifeq ($(DEBUG), 1)
  19. PELICANOPTS += -D
  20. endif
  21. RELATIVE ?= 0
  22. ifeq ($(RELATIVE), 1)
  23. PELICANOPTS += --relative-urls
  24. endif
  25. help:
  26. @echo 'Makefile for a pelican Web site '
  27. @echo ' '
  28. @echo 'Usage: '
  29. @echo ' make html (re)generate the web site '
  30. @echo ' make clean remove the generated files '
  31. @echo ' make regenerate regenerate files upon modification '
  32. @echo ' make hashover_backup backup of hashover '
  33. @echo ' make publish generate using production settings '
  34. @echo ' make serve [PORT=8000] serve site at http://localhost:8000 '
  35. @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 '
  36. @echo ' make devserver [PORT=8000] serve and regenerate together '
  37. @echo ' make ssh_upload upload the web site via SSH '
  38. @echo ' make rsync_upload upload the web site via rsync+ssh '
  39. @echo ' make ftp_upload upload the web site via FTP '
  40. @echo ' make validate validate the web site via html5validator'
  41. @echo ' '
  42. @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html '
  43. @echo 'Set the RELATIVE variable to 1 to enable relative urls '
  44. @echo ' '
  45. generate:
  46. $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
  47. phppersonal:
  48. mkdir -p $(OUTPUTDIR)/php-personal
  49. cp -rf $(PHPPERSONAL)/* $(OUTPUTDIR)/php-personal
  50. cleangit:
  51. \rm -rf $(OUTPUTDIR)/php-personal/.git
  52. html: clean generate vendor phppersonal cleangit
  53. clean:
  54. [ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
  55. regenerate:
  56. $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
  57. serve:
  58. ifdef PORT
  59. $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT)
  60. else
  61. $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
  62. endif
  63. serve-global:
  64. ifdef SERVER
  65. $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) -b $(SERVER)
  66. else
  67. $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) -b 0.0.0.0
  68. endif
  69. devserver:
  70. ifdef PORT
  71. $(PELICAN) -lr $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT)
  72. else
  73. $(PELICAN) -lr $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
  74. endif
  75. vendor:
  76. @bash $(BASEDIR)/scripts/vendor.sh
  77. publishconf:
  78. $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
  79. publish: publishconf vendor phppersonal cleangit
  80. ssh_upload: publish
  81. scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
  82. hashover_backup:
  83. rsync -rvzc $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)/hashover-next $(BASEDIR)/local.env/
  84. rsync_upload: publish
  85. rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)/
  86. ftp_upload: publish
  87. lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
  88. validate: publishconf
  89. html5validator --root $(OUTPUTDIR) || html5validator -l --root $(OUTPUTDIR)
  90. .PHONY: html help clean regenerate serve serve-global devserver publish ssh_upload rsync_upload ftp_upload