Makefile.example 4.1 KB

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