Makefile.example 3.7 KB

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