Makefile.example 4.1 KB

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