Merge remote-tracking branch 'origin/xorg/maint' into xorg/master
[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 doc:
48 @doxygen core/doc/doxygen.cfg
49
50 ################################################################################
51 # targets
52
53 ##
54 ## core
55 ##
56
57 core:
58 [ -d core/.git ] || ( git submodule init && git submodule update )
59 make -C core all
60
61 ##
62 ## conf
63 ##
64
65 conf: spool/templates_c spool/mails_c classes/platalglobals.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp spool/banana
66
67 spool/templates_c spool/mails_c spool/uploads spool/conf spool/tmp spool/run spool/banana:
68 mkdir -p $@
69 chmod o+w $@
70
71 htdocs/.htaccess: htdocs/.htaccess.in Makefile
72 @REWRITE_BASE="/~$$(id -un)"; \
73 test "$$REWRITE_BASE" = "/~web" && REWRITE_BASE="/"; \
74 sed -e "s,@REWRITE_BASE@,$$REWRITE_BASE,g" $< > $@
75
76 ##
77 ## static content
78 ##
79 static: htdocs/javascript/core.js htdocs/javascript@VERSION
80
81 htdocs/javascript/core.js:
82 cd htdocs/javascript/ && ln -s ../../core/htdocs/javascript/core.js
83
84 %@VERSION: % Makefile ChangeLog
85 cd $< && rm -f $(VERSION) && ln -sf . $(VERSION)
86
87 ##
88 ## wiki
89 ##
90
91 WIKI_NEEDS = \
92 wiki/local/farmconfig.php \
93 wiki/pub/skins/empty \
94 wiki/cookbook/e-protect.php \
95 spool/wiki.d \
96 htdocs/uploads \
97 htdocs/wiki \
98
99 wiki: get-wiki build-wiki
100
101 build-wiki: $(WIKI_NEEDS) | get-wiki
102
103 htdocs/uploads:
104 cd htdocs && ln -sf ../spool/uploads
105
106 htdocs/wiki:
107 cd htdocs && ln -sf ../wiki/pub wiki
108
109
110 spool/wiki.d:
111 mkdir -p $@
112 chmod o+w $@
113 cd $@ && ln -sf ../../include/wiki/wiki.d/* .
114
115
116 wiki/cookbook/e-protect.php:
117 cd wiki/cookbook && ln -sf ../../include/wiki/e-protect.php
118
119 wiki/local/farmconfig.php:
120 cd wiki/local/ && ln -sf ../../include/wiki/farmconfig.php
121
122 wiki/pub/skins/empty:
123 cd wiki/pub/skins/ && ln -sf ../../../include/wiki/empty
124
125
126 get-wiki:
127 @if ! test -d wiki; then \
128 wget http://www.pmwiki.org/pub/pmwiki/pmwiki-latest.tgz; \
129 tar -xzvf pmwiki-latest.tgz; \
130 rm pmwiki-latest.tgz; \
131 mv pmwiki-* wiki; \
132 fi
133
134 ##
135 ## openid
136 ##
137
138 openid: get-openid spool/openid/store
139
140 # There is no obvious way to automatically use the latest version
141 OPENID_VERSION = 2.2.2
142 OPENID_COMMIT = 782224d
143 get-openid:
144 @if ! test -d include/Auth; then \
145 wget --no-check-certificate \
146 https://github.com/openid/php-openid/tarball/$(OPENID_VERSION) \
147 -O php-openid-$(OPENID_VERSION).tar.gz; \
148 tar -xzf php-openid-$(OPENID_VERSION).tar.gz; \
149 mv openid-php-openid-$(OPENID_COMMIT)/Auth include/; \
150 rm php-openid-$(OPENID_VERSION).tar.gz; \
151 rm -r openid-php-openid-$(OPENID_COMMIT); \
152 fi
153
154 spool/openid/store:
155 mkdir -p $@
156 chmod o+w $@
157
158 ##
159 ## banana
160 ##
161 banana: htdocs/images/banana htdocs/css/banana.css
162 htdocs/images/banana: banana-sub
163 cd $(@D) && ln -snf ../../banana/img $(@F)
164
165 htdocs/css/banana.css: banana-sub
166 cd $(@D) && ln -snf ../../banana/css/style.css $(@F)
167
168 banana-sub:
169 make -C banana
170
171 ##
172 ## Medal thumbnails
173 ##
174 MEDAL_PICTURES=$(wildcard htdocs/images/medals/*.jpg)
175 MEDAL_THUMBNAILS=$(subst /medals/,/medals/thumb/,$(MEDAL_PICTURES))
176
177 medals: $(MEDAL_THUMBNAILS)
178
179 $(MEDAL_THUMBNAILS): $(subst /medals/thumb/,/medals/,$(@F))
180 convert -resize x50 $(subst /medals/thumb/,/medals/,$@) $@
181
182 ##
183 ## jquery
184 ##
185 JQUERY_VERSION=1.5
186 JQUERY_PLUGINS=color form
187 JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQUERY_PLUGINS)))
188
189 JQUERY_UI_VERSION=1.8.7
190 JQUERY_UI=core widget tabs datepicker
191 JQUERY_UI_PATHES=$(addprefix htdocs/javascript/jquery.ui.,$(addsuffix .js,$(JQUERY_UI)))
192
193 JQUERY_TMPL_VERSION=vBeta1.0.0
194 JQUERY_TMPL_PATH=htdocs/javascript/jquery.tmpl.js
195
196 JSTREE_VERSION=1.0rc2
197 JSTREE_PATH=htdocs/javascript/jquery.jstree.js
198
199 # TODO: jquery.autocomplete.js should rather be downloaded from an official source. The issue
200 # is that the version we use is not available anymore on the Internet, and the latest version
201 # we could use is not backward compatible with our current code.
202 jquery: htdocs/javascript/jquery.xorg.js htdocs/javascript/jquery.ui.xorg.js $(JSTREE_PATH)
203
204 htdocs/javascript/jquery.xorg.js: htdocs/javascript/jquery.js $(JQUERY_PLUGINS_PATHES) $(JQUERY_TMPL_PATH) htdocs/javascript/jquery.autocomplete.js
205 cat $^ > $@
206
207 htdocs/javascript/jquery.ui.xorg.js: $(JQUERY_UI_PATHES) htdocs/javascript/jquery.ui.datepicker-fr.js
208 cat $^ > $@
209
210 htdocs/javascript/jquery-$(JQUERY_VERSION).min.js: DOWNLOAD_SRC = http://jquery.com/src/$(@F)
211 htdocs/javascript/jquery-$(JQUERY_VERSION).min.js:
212 @-rm htdocs/javascript/jquery-*.min.js
213 @$(download)
214
215 htdocs/javascript/jquery.js: htdocs/javascript/jquery-$(JQUERY_VERSION).min.js
216 ln -snf $(<F) $@
217
218 $(JQUERY_PLUGINS_PATHES): DOWNLOAD_SRC = http://plugins.jquery.com/files/$(@F)_0.txt
219 $(JQUERY_PLUGINS_PATHES):
220 @-rm htdocs/javascript/jquery.ui*.$*.js
221 @$(download)
222
223 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
224 htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js:
225 @$(download)
226
227 $(JQUERY_UI_PATHES): htdocs/javascript/jquery.ui.%.js: htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js
228 ln -snf $(<F) $@
229
230 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
231 htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js:
232 @-rm htdocs/javascript/jquery.tmpl*.js
233 @$(download)
234
235 $(JQUERY_TMPL_PATH): htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js
236 ln -snf $(<F) $@
237
238 $(JSTREE_PATH):
239 rm -f htdocs/javascript/jquery.jstree-*.js
240 mkdir spool/tmp/jstree
241 wget http://jstree.googlecode.com/files/jsTree.v.$(JSTREE_VERSION).zip -O spool/tmp/jstree/jquery.jstree-$(JSTREE_VERSION).zip
242 unzip spool/tmp/jstree/jquery.jstree-$(JSTREE_VERSION).zip -d spool/tmp/jstree/
243 mv -f spool/tmp/jstree/themes/default/style.css htdocs/css/jstree.css
244 mv -f spool/tmp/jstree/themes/default/d.png htdocs/images/jstree.png
245 mv -f spool/tmp/jstree/jquery.jstree.js htdocs/javascript/jquery.jstree-$(JSTREE_VERSION).js
246 sed -i -e 's/"d\.png"/"..\/images\/jstree.png"/' htdocs/css/jstree.css
247 sed -i -e 's/"throbber\.gif"/"..\/images\/wait.gif"/' htdocs/css/jstree.css
248 sed -i -e 's/#ffffee/inherit/' htdocs/css/jstree.css
249 ln -snf jquery.jstree-$(JSTREE_VERSION).js htdocs/javascript/jquery.jstree.js
250 rm -Rf spool/tmp/jstree
251
252
253 ##
254 ## lists rpc
255 ##
256 start-listrpc: spool/run
257 sudo -u list /sbin/start-stop-daemon --pidfile spool/run/listrpc.pid -m -b -x $$PWD/bin/lists.rpc.py --start
258 @sleep 2
259 @sudo -u list kill -0 $$(cat spool/run/listrpc.pid)
260
261 start-listrpc-fg: spool/run
262 sudo -u list ./bin/lists.rpc.py
263
264 stop-listrpc:
265 -sudo -u list /sbin/start-stop-daemon --pidfile spool/run/listrpc.pid --stop
266 @-rm -f spool/run/listrpc.pid
267
268 restart-listrpc: stop-listrpc start-listrpc
269
270 ################################################################################
271
272 .PHONY: build dist clean core http* check test
273 .PHONY: wiki build-wiki
274 .PHONY: banana banana-sub htdocs/images/banana htdocs/css/banana.css
275 .PHONY: start-listrpc start-listrpc-fg stop-listrpc restart-listrpc
276 .PHONY: up update doc