25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 4.3KB

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