blob: daa6b60c5d8b80481d79b6f8d9ce9946ab8b6c5b [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 Santivetti8c549192020-10-05 23:19:50 +010010OUTPUTDIR_VIDEOS=$(OUTPUTDIR)/videos
Luigi Santivettif72f6572020-02-17 23:11:56 +000011CONFFILE=$(BASEDIR)/pelicanconf.py
12PUBLISHCONF=$(BASEDIR)/publishconf.py
13
14FTP_HOST=localhost
15FTP_USER=anonymous
16FTP_TARGET_DIR=/
17
18SSH_HOST=localhost
19SSH_PORT=22
20SSH_USER=root
21SSH_TARGET_DIR=/var/www
22
23S3_BUCKET=my_s3_bucket
24
25CLOUDFILES_USERNAME=my_rackspace_username
26CLOUDFILES_API_KEY=my_rackspace_api_key
27CLOUDFILES_CONTAINER=my_cloudfiles_container
28
29DROPBOX_DIR=~/Dropbox/Public/
30
31GITHUB_PAGES_BRANCH=gh-pages
32
luigi38e29362020-04-04 22:42:06 +010033INSTALLSUDO ?= 0
34ifeq ($(INSTALLSUDO),1)
35 SUDO := sudo -E
36endif
37INSTALLFLAGS := $(INSTALLFLAGS) -rXaA
38INSTALLDIR ?=
Luigi Santivetti8c549192020-10-05 23:19:50 +010039# Copy the whole directory theme
luigi38e29362020-04-04 22:42:06 +010040INSTALLDIR_THEME ?=
Luigi Santivetti8c549192020-10-05 23:19:50 +010041# Copy contents only
luigi38e29362020-04-04 22:42:06 +010042INSTALLDIR_PHOTOS ?=
Luigi Santivetti8c549192020-10-05 23:19:50 +010043INSTALLDIR_VIDEOS ?=
Luigi Santivettif72f6572020-02-17 23:11:56 +000044
45DEBUG ?= 0
46ifeq ($(DEBUG), 1)
47 PELICANOPTS += -D
48endif
49
50RELATIVE ?= 0
51ifeq ($(RELATIVE), 1)
52 PELICANOPTS += --relative-urls
53endif
54
55help:
56 @echo 'Makefile for a pelican Web site '
57 @echo ' '
58 @echo 'Usage: '
59 @echo ' make html (re)generate the web site '
luigi38e29362020-04-04 22:42:06 +010060 @echo ' make clean-html remove all html files and folders '
61 @echo ' make clean-theme remove output/theme '
62 @echo ' make clean-photos remove output/photos '
Luigi Santivetti8c549192020-10-05 23:19:50 +010063 @echo ' make clean-videos remove output/videos '
64 @echo ' make distclean remove output and __pycache__ '
luigi38e29362020-04-04 22:42:06 +010065 @echo ' make clean remove output folder '
Luigi Santivettif72f6572020-02-17 23:11:56 +000066 @echo ' make regenerate regenerate files upon modification '
67 @echo ' make publish generate using production settings '
68 @echo ' make serve [PORT=8000] serve site at http://localhost:8000'
69 @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 '
70 @echo ' make devserver [PORT=8000] start/restart develop_server.sh '
71 @echo ' make stopserver stop local server '
72 @echo ' make ssh_upload upload the web site via SSH '
73 @echo ' make rsync_upload upload the web site via rsync+ssh '
74 @echo ' make dropbox_upload upload the web site via Dropbox '
75 @echo ' make ftp_upload upload the web site via FTP '
76 @echo ' make s3_upload upload the web site via S3 '
77 @echo ' make cf_upload upload the web site via Cloud Files'
78 @echo ' make github upload the web site via gh-pages '
luigi38e29362020-04-04 22:42:06 +010079 @echo ' make install-html copy *.html, html folders locally '
80 @echo ' make install-theme copy output/theme locally '
81 @echo ' make install-photos copy output/photos locally '
Luigi Santivetti8c549192020-10-05 23:19:50 +010082 @echo ' make install-videos copy output/videos locally '
luigi38e29362020-04-04 22:42:06 +010083 @echo ' make install copy output/* locally '
Luigi Santivettif72f6572020-02-17 23:11:56 +000084 @echo ' '
85 @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html '
86 @echo 'Set the RELATIVE variable to 1 to enable relative urls '
87 @echo ' '
88
89html:
90 $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
91
luigi38e29362020-04-04 22:42:06 +010092clean-html:
93 find "$(OUTPUTDIR)" -type f -name *.html -delete
94 find "$(OUTPUTDIR)" -type d -empty -delete
95
96clean-theme:
97 [ ! -d "$(OUTPUTDIR_THEME)" ] || rm -rf $(OUTPUTDIR_THEME)
98
99clean-photos:
100 [ ! -d "$(OUTPUTDIR_PHOTOS)" ] || rm -rf $(OUTPUTDIR_PHOTOS)
101
Luigi Santivetti8c549192020-10-05 23:19:50 +0100102clean-videos:
103 [ ! -d "$(OUTPUTDIR_VIDEOS)" ] || rm -rf $(OUTPUTDIR_VIDEOS)
104
Luigi Santivettif72f6572020-02-17 23:11:56 +0000105clean:
luigi38e29362020-04-04 22:42:06 +0100106 [ ! -d "$(OUTPUTDIR)" ] || rm -rf $(OUTPUTDIR)
Luigi Santivettif72f6572020-02-17 23:11:56 +0000107
Luigi Santivetti8c549192020-10-05 23:19:50 +0100108distclean: clean
109 find $(BASEDIR) -type d -name "__pycache__" -exec rm -rf '{}' '+'
110
Luigi Santivettif72f6572020-02-17 23:11:56 +0000111regenerate:
112 $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
113
114serve:
115ifdef PORT
116 cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)
117else
118 cd $(OUTPUTDIR) && $(PY) -m pelican.server
119endif
120
121serve-global:
122ifdef SERVER
123 cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 $(SERVER)
124else
125 cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 0.0.0.0
126endif
127
128
129devserver:
130ifdef PORT
131 $(BASEDIR)/develop_server.sh restart $(PORT)
132else
133 $(BASEDIR)/develop_server.sh restart
134endif
135
136stopserver:
137 $(BASEDIR)/develop_server.sh stop
138 @echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
139
140publish:
141 $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
142
143ssh_upload: publish
144 scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
145
146rsync_upload: publish
147 rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
148
149dropbox_upload: publish
150 cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR)
151
152ftp_upload: publish
153 lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
154
155s3_upload: publish
156 s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed --guess-mime-type --no-mime-magic --no-preserve
157
158cf_upload: publish
159 cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) .
160
161github: publish
162 ghp-import -m "Generate Pelican site" -b $(GITHUB_PAGES_BRANCH) $(OUTPUTDIR)
163 git push origin $(GITHUB_PAGES_BRANCH)
164
luigi38e29362020-04-04 22:42:06 +0100165install-html:
166 [ -d "$(OUTPUTDIR)" ] && [ -d "$(INSTALLDIR)" ] && \
Luigi Santivetti8c549192020-10-05 23:19:50 +0100167 $(SUDO) rsync $(INSTALLFLAGS) \
168 --exclude=$(notdir $(OUTPUTDIR_THEME)) \
169 --exclude=$(notdir $(OUTPUTDIR_PHOTOS)) \
170 --exclude=$(notdir $(OUTPUTDIR_VIDEOS)) \
171 $(OUTPUTDIR)/* $(INSTALLDIR)
luigi38e29362020-04-04 22:42:06 +0100172
173install-theme:
174 [ -d "$(OUTPUTDIR_THEME)" ] && [ -d "$(INSTALLDIR_THEME)" ] && \
175 $(SUDO) rsync $(INSTALLFLAGS) $(OUTPUTDIR_THEME) $(INSTALLDIR_THEME)/
176
177install-photos:
Luigi Santivetti8c549192020-10-05 23:19:50 +0100178 [ ! -d "$(OUTPUTDIR_PHOTOS)" ] && { echo "Nothing to do for: install-photos"; \
179 exit 0; } || [ -d "$(INSTALLDIR_PHOTOS)" ] && \
180 $(SUDO) rsync $(INSTALLFLAGS) $(OUTPUTDIR_PHOTOS)/ $(INSTALLDIR_PHOTOS)
luigi38e29362020-04-04 22:42:06 +0100181
Luigi Santivetti8c549192020-10-05 23:19:50 +0100182install-videos:
183 [ ! -d "$(OUTPUTDIR_VIDEOS)" ] && { echo "Nothing to do for: install-videos"; \
184 exit 0; } || [ -d "$(INSTALLDIR_VIDEOS)" ] && \
185 $(SUDO) rsync $(INSTALLFLAGS) $(OUTPUTDIR_VIDEOS)/ $(INSTALLDIR_VIDEOS)
186
187install: install-html install-theme install-photos install-videos
Luigi Santivettif72f6572020-02-17 23:11:56 +0000188
189
luigi38e29362020-04-04 22:42:06 +0100190.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