blob: ead59174dba93f3fed32c4238c1efa2c219d7dd2 [file] [log] [blame]
Luigi Santivettif72f6572020-02-17 23:11:56 +00001PY?=python3
2PELICAN?=pelican
3PELICANOPTS=
4
5BASEDIR=$(CURDIR)
6INPUTDIR=$(BASEDIR)/content
7OUTPUTDIR=$(BASEDIR)/output
luigi38e29362020-04-04 22:42:06 +01008OUTPUTDIR_THEME=$(OUTPUTDIR)/theme
9OUTPUTDIR_PHOTOS=$(OUTPUTDIR)/photos
Luigi Santivettif72f6572020-02-17 23:11:56 +000010CONFFILE=$(BASEDIR)/pelicanconf.py
11PUBLISHCONF=$(BASEDIR)/publishconf.py
12
13FTP_HOST=localhost
14FTP_USER=anonymous
15FTP_TARGET_DIR=/
16
17SSH_HOST=localhost
18SSH_PORT=22
19SSH_USER=root
20SSH_TARGET_DIR=/var/www
21
22S3_BUCKET=my_s3_bucket
23
24CLOUDFILES_USERNAME=my_rackspace_username
25CLOUDFILES_API_KEY=my_rackspace_api_key
26CLOUDFILES_CONTAINER=my_cloudfiles_container
27
28DROPBOX_DIR=~/Dropbox/Public/
29
30GITHUB_PAGES_BRANCH=gh-pages
31
luigi38e29362020-04-04 22:42:06 +010032INSTALLSUDO ?= 0
33ifeq ($(INSTALLSUDO),1)
34 SUDO := sudo -E
35endif
36INSTALLFLAGS := $(INSTALLFLAGS) -rXaA
37INSTALLDIR ?=
38INSTALLDIR_THEME ?=
39INSTALLDIR_PHOTOS ?=
Luigi Santivettif72f6572020-02-17 23:11:56 +000040
41DEBUG ?= 0
42ifeq ($(DEBUG), 1)
43 PELICANOPTS += -D
44endif
45
46RELATIVE ?= 0
47ifeq ($(RELATIVE), 1)
48 PELICANOPTS += --relative-urls
49endif
50
51help:
52 @echo 'Makefile for a pelican Web site '
53 @echo ' '
54 @echo 'Usage: '
55 @echo ' make html (re)generate the web site '
luigi38e29362020-04-04 22:42:06 +010056 @echo ' make clean-html remove all html files and folders '
57 @echo ' make clean-theme remove output/theme '
58 @echo ' make clean-photos remove output/photos '
59 @echo ' make clean remove output folder '
Luigi Santivettif72f6572020-02-17 23:11:56 +000060 @echo ' make regenerate regenerate files upon modification '
61 @echo ' make publish generate using production settings '
62 @echo ' make serve [PORT=8000] serve site at http://localhost:8000'
63 @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 '
64 @echo ' make devserver [PORT=8000] start/restart develop_server.sh '
65 @echo ' make stopserver stop local server '
66 @echo ' make ssh_upload upload the web site via SSH '
67 @echo ' make rsync_upload upload the web site via rsync+ssh '
68 @echo ' make dropbox_upload upload the web site via Dropbox '
69 @echo ' make ftp_upload upload the web site via FTP '
70 @echo ' make s3_upload upload the web site via S3 '
71 @echo ' make cf_upload upload the web site via Cloud Files'
72 @echo ' make github upload the web site via gh-pages '
luigi38e29362020-04-04 22:42:06 +010073 @echo ' make install-html copy *.html, html folders locally '
74 @echo ' make install-theme copy output/theme locally '
75 @echo ' make install-photos copy output/photos locally '
76 @echo ' make install copy output/* locally '
Luigi Santivettif72f6572020-02-17 23:11:56 +000077 @echo ' '
78 @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html '
79 @echo 'Set the RELATIVE variable to 1 to enable relative urls '
80 @echo ' '
81
82html:
83 $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
84
luigi38e29362020-04-04 22:42:06 +010085clean-html:
86 find "$(OUTPUTDIR)" -type f -name *.html -delete
87 find "$(OUTPUTDIR)" -type d -empty -delete
88
89clean-theme:
90 [ ! -d "$(OUTPUTDIR_THEME)" ] || rm -rf $(OUTPUTDIR_THEME)
91
92clean-photos:
93 [ ! -d "$(OUTPUTDIR_PHOTOS)" ] || rm -rf $(OUTPUTDIR_PHOTOS)
94
Luigi Santivettif72f6572020-02-17 23:11:56 +000095clean:
luigi38e29362020-04-04 22:42:06 +010096 [ ! -d "$(OUTPUTDIR)" ] || rm -rf $(OUTPUTDIR)
Luigi Santivettif72f6572020-02-17 23:11:56 +000097
98regenerate:
99 $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
100
101serve:
102ifdef PORT
103 cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)
104else
105 cd $(OUTPUTDIR) && $(PY) -m pelican.server
106endif
107
108serve-global:
109ifdef SERVER
110 cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 $(SERVER)
111else
112 cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 0.0.0.0
113endif
114
115
116devserver:
117ifdef PORT
118 $(BASEDIR)/develop_server.sh restart $(PORT)
119else
120 $(BASEDIR)/develop_server.sh restart
121endif
122
123stopserver:
124 $(BASEDIR)/develop_server.sh stop
125 @echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
126
127publish:
128 $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
129
130ssh_upload: publish
131 scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
132
133rsync_upload: publish
134 rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
135
136dropbox_upload: publish
137 cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR)
138
139ftp_upload: publish
140 lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
141
142s3_upload: publish
143 s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed --guess-mime-type --no-mime-magic --no-preserve
144
145cf_upload: publish
146 cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) .
147
148github: publish
149 ghp-import -m "Generate Pelican site" -b $(GITHUB_PAGES_BRANCH) $(OUTPUTDIR)
150 git push origin $(GITHUB_PAGES_BRANCH)
151
luigi38e29362020-04-04 22:42:06 +0100152install-html:
153 [ -d "$(OUTPUTDIR)" ] && [ -d "$(INSTALLDIR)" ] && \
154 $(SUDO) rsync $(INSTALLFLAGS) --exclude=$(notdir $(OUTPUTDIR_THEME)) \
155 --exclude=$(notdir $(OUTPUTDIR_PHOTOS)) $(OUTPUTDIR)/* $(INSTALLDIR)
156
157install-theme:
158 [ -d "$(OUTPUTDIR_THEME)" ] && [ -d "$(INSTALLDIR_THEME)" ] && \
159 $(SUDO) rsync $(INSTALLFLAGS) $(OUTPUTDIR_THEME) $(INSTALLDIR_THEME)/
160
161install-photos:
162 [ -d "$(OUTPUTDIR_PHOTOS)" ] && [ -d "$(INSTALLDIR_PHOTOS)" ] && \
163 $(SUDO) rsync $(INSTALLFLAGS) $(OUTPUTDIR_PHOTOS) $(INSTALLDIR_PHOTOS)/
164
165install: install-html install-theme install-photos
Luigi Santivettif72f6572020-02-17 23:11:56 +0000166
167
luigi38e29362020-04-04 22:42:06 +0100168.PHONY: html help clean clean-html clean-theme clean-photos regenerate serve serve-global devserver stopserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload cf_upload github install install-html install-theme install-photos