Makefile

Tue, 15 Mar 2016 16:23:22 +0100

author
David Douard <david.douard@logilab.fr>
date
Tue, 15 Mar 2016 16:23:22 +0100
changeset 38
71e96f955e7a
parent 0
e7f601f9db69
permissions
-rw-r--r--

[10MHz] typos

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

mercurial