Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. PY?=python3
  2. PELICAN?=pelican
  3. PELICANOPTS=
  4. BASEDIR=$(CURDIR)
  5. INPUTDIR=$(BASEDIR)/content
  6. BUILDDIR=$(BASEDIR)/build
  7. OUTPUTDIR=$(BASEDIR)/output
  8. CONFFILE=$(BASEDIR)/pelicanconf.py
  9. PUBLISHCONF=$(BASEDIR)/publishconf.py
  10. FTP_HOST=localhost
  11. FTP_USER=anonymous
  12. FTP_TARGET_DIR=/
  13. SSH_HOST=fangmeier.tech
  14. SSH_PORT=22
  15. SSH_USER=caleb
  16. SSH_TARGET_DIR=/var/www/thesis
  17. S3_BUCKET=my_s3_bucket
  18. CLOUDFILES_USERNAME=my_rackspace_username
  19. CLOUDFILES_API_KEY=my_rackspace_api_key
  20. CLOUDFILES_CONTAINER=my_cloudfiles_container
  21. DROPBOX_DIR=~/Dropbox/Public/
  22. GITHUB_PAGES_BRANCH=gh-pages
  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 pdf (re)generate the pdf '
  37. @echo ' make clean remove the generated files '
  38. @echo ' make regenerate regenerate files upon modification '
  39. @echo ' make publish generate using production settings '
  40. @echo ' make serve [PORT=8000] serve site at http://localhost:8000'
  41. @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 '
  42. @echo ' make devserver [PORT=8000] start/restart develop_server.sh '
  43. @echo ' make stopserver stop local server '
  44. @echo ' make ssh_upload upload the web site via SSH '
  45. @echo ' make rsync_upload upload the web site via rsync+ssh '
  46. @echo ' make dropbox_upload upload the web site via Dropbox '
  47. @echo ' make ftp_upload upload the web site via FTP '
  48. @echo ' make s3_upload upload the web site via S3 '
  49. @echo ' make cf_upload upload the web site via Cloud Files'
  50. @echo ' make github upload the web site via gh-pages '
  51. @echo ' '
  52. @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html '
  53. @echo 'Set the RELATIVE variable to 1 to enable relative urls '
  54. @echo ' '
  55. html:
  56. ./convert.py html
  57. $(PELICAN) $(BUILDDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
  58. pdf:
  59. ./convert.py tex
  60. cd $(BUILDDIR); rubber thesis
  61. clean:
  62. [ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
  63. cd $(BUILDDIR); rubber --clean thesis; rm -f *_*.tex; rm -f *_*.html; rm -f *_*.aux
  64. regenerate:
  65. $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
  66. serve:
  67. ifdef PORT
  68. cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)
  69. else
  70. cd $(OUTPUTDIR) && $(PY) -m pelican.server
  71. endif
  72. serve-global:
  73. ifdef SERVER
  74. cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 $(SERVER)
  75. else
  76. cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 0.0.0.0
  77. endif
  78. devserver:
  79. ifdef PORT
  80. $(BASEDIR)/develop_server.sh restart $(PORT)
  81. else
  82. $(BASEDIR)/develop_server.sh restart
  83. endif
  84. stopserver:
  85. $(BASEDIR)/develop_server.sh stop
  86. @echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
  87. publish:
  88. $(PELICAN) $(BUILDDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
  89. [ -f content/thesis.pdf ] && cp $(BUILDDIR)/thesis.pdf $(OUTPUTDIR)
  90. ssh_upload: publish
  91. scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
  92. rsync_upload: publish
  93. rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
  94. dropbox_upload: publish
  95. cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR)
  96. ftp_upload: publish
  97. lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
  98. s3_upload: publish
  99. s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed --guess-mime-type --no-mime-magic --no-preserve
  100. cf_upload: publish
  101. cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) .
  102. github: publish
  103. ghp-import -m "Generate Pelican site" -b $(GITHUB_PAGES_BRANCH) $(OUTPUTDIR)
  104. git push origin $(GITHUB_PAGES_BRANCH)
  105. .PHONY: html pdf help clean regenerate serve serve-global devserver stopserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload cf_upload github