Merge fail (bis).
[platal.git] / Makefile
1
2 # $Id: Makefile,v 1.5 2004/11/25 20:18:39 x99laine Exp $
3 ################################################################################
4 # definitions
5
6 VERSNUM := $(shell grep VERSION ChangeLog | head -1 | sed -e "s/VERSION //;s/ .*//")
7 VERSTAG := $(shell grep VERSION ChangeLog | head -1 | grep 'XX' > /dev/null 2> /dev/null && echo 'beta')
8
9 VERSION = $(VERSNUM)$(VERSTAG)
10
11 PKG_NAME = platal
12 PKG_DIST = $(PKG_NAME)-$(VERSION)
13 PKG_FILES = AUTHORS ChangeLog COPYING README Makefile
14 PKG_DIRS = configs htdocs include install.d plugins po scripts templates upgrade
15
16 VCS_FILTER = ! -name .arch-ids ! -name CVS
17
18 define download
19 @echo "Downloading $@ from $(DOWNLOAD_SRC)"
20 wget $(DOWNLOAD_SRC) -O $@ -q || ($(RM) $@; exit 1)
21 endef
22
23 ################################################################################
24 # global targets
25
26 all: build
27
28 build: core conf static banana wiki openid medals jquery
29
30 check:
31 @!(find . -name '*.php' -exec php -l {} ";" | grep -v 'No syntax errors detected')
32
33 test:
34 make -C core test
35
36 q:
37 @echo -e "Code statistics\n"
38 @sloccount $(filter-out wiki/ spool/, $(wildcard */)) 2> /dev/null | egrep '^[a-z]*:'
39
40 %: %.in Makefile ChangeLog
41 sed -e 's,@VERSION@,$(VERSION),g' $< > $@
42
43 up: update
44 update:
45 @git fetch && git rebase `git symbolic-ref HEAD | sed -e 's~refs/heads/~origin/~'` && git submodule update
46
47 ################################################################################
48 # targets
49
50 ##
51 ## core
52 ##
53
54 core:
55 [ -d core/.git ] || ( git submodule init && git submodule update )
56 make -C core all
57
58 ##
59 ## conf
60 ##
61
62 conf: spool/templates_c spool/mails_c classes/platalglobals.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp spool/banana
63
64 spool/templates_c spool/mails_c spool/uploads spool/conf spool/tmp spool/run spool/banana:
65 mkdir -p $@
66 chmod o+w $@
67
68 htdocs/.htaccess: htdocs/.htaccess.in Makefile
69 @REWRITE_BASE="/~$$(id -un)"; \
70 test "$$REWRITE_BASE" = "/~web" && REWRITE_BASE="/"; \
71 sed -e "s,@REWRITE_BASE@,$$REWRITE_BASE,g" $< > $@
72
73 ##
74 ## static content
75 ##
76 static: htdocs/javascript/core.js htdocs/javascript@VERSION
77
78 htdocs/javascript/core.js:
79 cd htdocs/javascript/ && ln -s ../../core/htdocs/javascript/core.js
80
81 %@VERSION: % Makefile ChangeLog
82 cd $< && rm -f $(VERSION) && ln -sf . $(VERSION)
83
84 ##
85 ## wiki
86 ##
87
88 WIKI_NEEDS = \
89 wiki/local/farmconfig.php \
90 wiki/pub/skins/empty \
91 wiki/cookbook/e-protect.php \
92 spool/wiki.d \
93 htdocs/uploads \
94 htdocs/wiki \
95
96 wiki: get-wiki build-wiki
97
98 build-wiki: $(WIKI_NEEDS) | get-wiki
99
100 htdocs/uploads:
101 cd htdocs && ln -sf ../spool/uploads
102
103 htdocs/wiki:
104 cd htdocs && ln -sf ../wiki/pub wiki
105
106
107 spool/wiki.d:
108 mkdir -p $@
109 chmod o+w $@
110 cd $@ && ln -sf ../../include/wiki/wiki.d/* .
111
112
113 wiki/cookbook/e-protect.php:
114 cd wiki/cookbook && ln -sf ../../include/wiki/e-protect.php
115
116 wiki/local/farmconfig.php:
117 cd wiki/local/ && ln -sf ../../include/wiki/farmconfig.php
118
119 wiki/pub/skins/empty:
120 cd wiki/pub/skins/ && ln -sf ../../../include/wiki/empty
121
122
123 get-wiki:
124 @if ! test -d wiki; then \
125 wget http://www.pmwiki.org/pub/pmwiki/pmwiki-latest.tgz; \
126 tar -xzvf pmwiki-latest.tgz; \
127 rm pmwiki-latest.tgz; \
128 mv pmwiki-* wiki; \
129 fi
130
131 ##
132 ## openid
133 ##
134
135 openid: get-openid spool/openid/store
136
137 # There is no obvious way to automatically use the latest version
138 OPENID_VERSION = 2.2.2
139 OPENID_COMMIT = 782224d
140 get-openid:
141 @if ! test -d include/Auth; then \
142 wget --no-check-certificate \
143 https://github.com/openid/php-openid/tarball/$(OPENID_VERSION) \
144 -O php-openid-$(OPENID_VERSION).tar.gz; \
145 tar -xzf php-openid-$(OPENID_VERSION).tar.gz; \
146 mv openid-php-openid-$(OPENID_COMMIT)/Auth include/; \
147 rm php-openid-$(OPENID_VERSION).tar.gz; \
148 rm -r openid-php-openid-$(OPENID_COMMIT); \
149 fi
150
151 spool/openid/store:
152 mkdir -p $@
153 chmod o+w $@
154
155 ##
156 ## banana
157 ##
158 banana: htdocs/images/banana htdocs/css/banana.css
159 htdocs/images/banana: banana-sub
160 cd $(@D) && ln -snf ../../banana/img $(@F)
161
162 htdocs/css/banana.css: banana-sub
163 cd $(@D) && ln -snf ../../banana/css/style.css $(@F)
164
165 banana-sub:
166 make -C banana
167
168 ##
169 ## Medal thumbnails
170 ##
171 MEDAL_PICTURES=$(wildcard htdocs/images/medals/*.jpg)
172 MEDAL_THUMBNAILS=$(subst /medals/,/medals/thumb/,$(MEDAL_PICTURES))
173
174 medals: $(MEDAL_THUMBNAILS)
175
176 $(MEDAL_THUMBNAILS): $(subst /medals/thumb/,/medals/,$(@F))
177 convert -resize x50 $(subst /medals/thumb/,/medals/,$@) $@
178
179 ##
180 ## jquery
181 ##
182 JQUERY_VERSION=1.4.4
183 JQUERY_PLUGINS=color form
184 JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQUERY_PLUGINS)))
185
186 JQUERY_UI_VERSION=1.8.7
187 JQUERY_UI=core widget tabs datepicker
188 JQUERY_UI_PATHES=$(addprefix htdocs/javascript/jquery.ui.,$(addsuffix .js,$(JQUERY_UI)))
189
190 JQUERY_TMPL_VERSION=vBeta1.0.0
191 JQUERY_TMPL_PATH=htdocs/javascript/jquery.tmpl.js
192
193 JSTREE_VERSION=1.0rc2
194 JSTREE_PATH=htdocs/javascript/jquery.jstree.js
195
196 # TODO: jquery.autocomplete.js should rather be downloaded from an official source. The issue
197 # is that the version we use is not available anymore on the Internet, and the latest version
198 # we could use is not backward compatible with our current code.
199 jquery: htdocs/javascript/jquery.xorg.js htdocs/javascript/jquery.ui.xorg.js $(JSTREE_PATH)
200
201 htdocs/javascript/jquery.xorg.js: htdocs/javascript/jquery.js $(JQUERY_PLUGINS_PATHES) $(JQUERY_TMPL_PATH) htdocs/javascript/jquery.autocomplete.js
202 cat $^ > $@
203
204 htdocs/javascript/jquery.ui.xorg.js: $(JQUERY_UI_PATHES) htdocs/javascript/jquery.ui.datepicker-fr.js
205 cat $^ > $@
206
207 htdocs/javascript/jquery-$(JQUERY_VERSION).min.js: DOWNLOAD_SRC = http://jquery.com/src/$(@F)
208 htdocs/javascript/jquery-$(JQUERY_VERSION).min.js:
209 @-rm htdocs/javascript/jquery-*.min.js
210 @$(download)
211
212 htdocs/javascript/jquery.js: htdocs/javascript/jquery-$(JQUERY_VERSION).min.js
213 ln -snf $(<F) $@
214
215 $(JQUERY_PLUGINS_PATHES): DOWNLOAD_SRC = http://plugins.jquery.com/files/$(@F)_0.txt
216 $(JQUERY_PLUGINS_PATHES):
217 @-rm htdocs/javascript/jquery.ui*.$*.js
218 @$(download)
219
220 htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js: DOWNLOAD_SRC = http://jquery-ui.googlecode.com/svn/tags/$(JQUERY_UI_VERSION)/ui/minified/jquery.ui.$*.min.js
221 htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js:
222 @$(download)
223
224 htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).datepicker-fr.js: DOWNLOAD_SRC = http://jquery-ui.googlecode.com/svn/tags/$(JQUERY_UI_VERSION)/ui/minified/i18n/jquery.ui.datepicker-fr.min.js
225 htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).datepicker-fr.js:
226 @$(download)
227
228 $(JQUERY_UI_PATHES) htdocs/javascript/jquery.ui.datepicker-fr.js: htdocs/javascript/jquery.ui.%.js: htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js
229 ln -snf $(<F) $@
230
231 htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js: DOWNLOAD_SRC = https://github.com/jquery/jquery-tmpl/raw/$(JQUERY_TMPL_VERSION)/jquery.tmpl.js --no-check-certificate
232 htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js:
233 @-rm htdocs/javascript/jquery.tmpl*.js
234 @$(download)
235
236 $(JQUERY_TMPL_PATH): htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js
237 ln -snf $(<F) $@
238
239 $(JSTREE_PATH):
240 rm -f htdocs/javascript/jquery.jstree-*.js
241 mkdir spool/tmp/jstree
242 wget http://jstree.googlecode.com/files/jsTree.v.$(JSTREE_VERSION).zip -O spool/tmp/jstree/jquery.jstree-$(JSTREE_VERSION).zip
243 unzip spool/tmp/jstree/jquery.jstree-$(JSTREE_VERSION).zip -d spool/tmp/jstree/
244 mv -f spool/tmp/jstree/themes/default/style.css htdocs/css/jstree.css
245 mv -f spool/tmp/jstree/themes/default/d.png htdocs/images/jstree.png
246 mv -f spool/tmp/jstree/jquery.jstree.js htdocs/javascript/jquery.jstree-$(JSTREE_VERSION).js
247 sed -i -e 's/"d\.png"/"..\/images\/jstree.png"/' htdocs/css/jstree.css
248 sed -i -e 's/"throbber\.gif"/"..\/images\/wait.gif"/' htdocs/css/jstree.css
249 sed -i -e 's/#ffffee/inherit/' htdocs/css/jstree.css
250 ln -snf jquery.jstree-$(JSTREE_VERSION).js htdocs/javascript/jquery.jstree.js
251 rm -Rf spool/tmp/jstree
252
253
254 ##
255 ## lists rpc
256 ##
257 start-listrpc: spool/run
258 sudo -u list /sbin/start-stop-daemon --pidfile spool/run/listrpc.pid -m -b -x $$PWD/bin/lists.rpc.py --start
259 @sleep 2
260 @sudo -u list kill -0 $$(cat spool/run/listrpc.pid)
261
262 start-listrpc-fg: spool/run
263 sudo -u list ./bin/lists.rpc.py
264
265 stop-listrpc:
266 -sudo -u list /sbin/start-stop-daemon --pidfile spool/run/listrpc.pid --stop
267 @-rm -f spool/run/listrpc.pid
268
269 restart-listrpc: stop-listrpc start-listrpc
270
271 ################################################################################
272
273 .PHONY: build dist clean core http* check test
274 .PHONY: wiki build-wiki
275 .PHONY: banana banana-sub htdocs/images/banana htdocs/css/banana.css
276 .PHONY: start-listrpc start-listrpc-fg stop-listrpc restart-listrpc
277 .PHONY: up update