blob: cc1ec0bf1b49a8674baf3c36de14ea3f6ad9c274 [file] [log] [blame]
Luigi Santivettid93cb0f2020-02-17 22:21:28 +00001PY?=python3
2PELICAN?=pelican
3PELICANOPTS=
4
5BASEDIR=$(CURDIR)
6INPUTDIR=$(BASEDIR)/content
7OUTPUTDIR=$(BASEDIR)/output
8CONFFILE=$(BASEDIR)/pelicanconf.py
9PUBLISHCONF=$(BASEDIR)/publishconf.py
10
11FTP_HOST=localhost
12FTP_USER=anonymous
13FTP_TARGET_DIR=/
14
15SSH_HOST=localhost
16SSH_PORT=22
17SSH_USER=root
18SSH_TARGET_DIR=/var/www
19
20S3_BUCKET=my_s3_bucket
21
22CLOUDFILES_USERNAME=my_rackspace_username
23CLOUDFILES_API_KEY=my_rackspace_api_key
24CLOUDFILES_CONTAINER=my_cloudfiles_container
25
26DROPBOX_DIR=~/Dropbox/Public/
27
28GITHUB_PAGES_BRANCH=gh-pages
29
30INSTALLDIR=
31UID="www-data"
32GID="www-data"
33MOD="664"
34
35DEBUG ?= 0
36ifeq ($(DEBUG), 1)
37 PELICANOPTS += -D
38endif
39
40RELATIVE ?= 0
41ifeq ($(RELATIVE), 1)
42 PELICANOPTS += --relative-urls
43endif
44
45help:
46 @echo 'Makefile for a pelican Web site '
47 @echo ' '
48 @echo 'Usage: '
49 @echo ' make html (re)generate the web site '
50 @echo ' make clean remove the generated files '
51 @echo ' make regenerate regenerate files upon modification '
52 @echo ' make publish generate using production settings '
53 @echo ' make serve [PORT=8000] serve site at http://localhost:8000'
54 @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 '
55 @echo ' make devserver [PORT=8000] start/restart develop_server.sh '
56 @echo ' make stopserver stop local server '
57 @echo ' make ssh_upload upload the web site via SSH '
58 @echo ' make rsync_upload upload the web site via rsync+ssh '
59 @echo ' make dropbox_upload upload the web site via Dropbox '
60 @echo ' make ftp_upload upload the web site via FTP '
61 @echo ' make s3_upload upload the web site via S3 '
62 @echo ' make cf_upload upload the web site via Cloud Files'
63 @echo ' make github upload the web site via gh-pages '
64 @echo ' '
65 @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html '
66 @echo 'Set the RELATIVE variable to 1 to enable relative urls '
67 @echo ' '
68
69html:
70 $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
71
72clean:
73 [ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
74
75regenerate:
76 $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
77
78serve:
79ifdef PORT
80 cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)
81else
82 cd $(OUTPUTDIR) && $(PY) -m pelican.server
83endif
84
85serve-global:
86ifdef SERVER
87 cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 $(SERVER)
88else
89 cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 0.0.0.0
90endif
91
92
93devserver:
94ifdef PORT
95 $(BASEDIR)/develop_server.sh restart $(PORT)
96else
97 $(BASEDIR)/develop_server.sh restart
98endif
99
100stopserver:
101 $(BASEDIR)/develop_server.sh stop
102 @echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
103
104publish:
105 $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
106
107ssh_upload: publish
108 scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
109
110rsync_upload: publish
111 rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
112
113dropbox_upload: publish
114 cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR)
115
116ftp_upload: publish
117 lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
118
119s3_upload: publish
120 s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed --guess-mime-type --no-mime-magic --no-preserve
121
122cf_upload: publish
123 cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) .
124
125github: publish
126 ghp-import -m "Generate Pelican site" -b $(GITHUB_PAGES_BRANCH) $(OUTPUTDIR)
127 git push origin $(GITHUB_PAGES_BRANCH)
128
129install:
130 @command [ -z "$(INSTALLDIR)" ] && echo "INSTALLDIR unset. i.e. make install INSTALLDIR=\"/path/to/dir\"" && exit 1 ||:
131 @command [ ! -d $(OUTPUTDIR) ] && echo "OUTPUTDIR unset. i.e. make html" && exit 1 ||:
132 @echo "Copying $(OUTPUTDIR) to $(INSTALLDIR)"
133 @command sudo cp -ra $(OUTPUTDIR)/* $(INSTALLDIR) ||:
134 @echo "Setting chown to $(UID):$(GID)"
135 @command sudo chown -R $(UID):$(GID) $(INSTALLDIR) ||:
136 @echo "Setting chmod $(MOD) to files"
137 @command find $(INSTALLDIR) -type f | sudo xargs -i{} chmod $(MOD) {} ||:
138 @echo "Installed files:"
139 @command find $(INSTALLDIR) -type f ||:
140 @echo "Done."
141
142
143.PHONY: html help clean regenerate serve serve-global devserver stopserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload cf_upload github install