Serves javascript file from a per-version directory, to prevent cross-version caching...
[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 BANANA := $(shell ( [ -d ../banana ] && echo `pwd`"/../banana" ) || echo "/home/web/dev/banana")
9
10 VERSION = $(VERSNUM)$(VERSTAG)
11
12 PKG_NAME = platal
13 PKG_DIST = $(PKG_NAME)-$(VERSION)
14 PKG_FILES = AUTHORS ChangeLog COPYING README Makefile
15 PKG_DIRS = configs htdocs include install.d plugins po scripts templates upgrade
16
17 VCS_FILTER = ! -name .arch-ids ! -name CVS
18
19 define download
20 @echo "Downloading $@ from $(DOWNLOAD_SRC)"
21 wget $(DOWNLOAD_SRC) -O $@ -q || ($(RM) $@; exit 1)
22 endef
23
24 ################################################################################
25 # global targets
26
27 all: build
28
29 build: core conf static banana wiki openid medals jquery
30
31 q:
32 @echo -e "Code statistics\n"
33 @sloccount $(filter-out wiki/ spool/, $(wildcard */)) 2> /dev/null | egrep '^[a-z]*:'
34
35 %: %.in Makefile ChangeLog
36 sed -e 's,@VERSION@,$(VERSION),g' $< > $@
37
38 ################################################################################
39 # targets
40
41 ##
42 ## core
43 ##
44
45 core:
46 [ -d core/.git ] || ( git submodule init && git submodule update )
47 make -C core all
48
49 ##
50 ## conf
51 ##
52
53 conf: spool/templates_c spool/mails_c classes/platalglobals.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp
54
55 spool/templates_c spool/mails_c spool/uploads spool/conf spool/tmp:
56 mkdir -p $@
57 chmod o+w $@
58
59 htdocs/.htaccess: htdocs/.htaccess.in Makefile
60 @REWRITE_BASE="/~$$(id -un)"; \
61 test "$$REWRITE_BASE" = "/~web" && REWRITE_BASE="/"; \
62 sed -e "s,@REWRITE_BASE@,$$REWRITE_BASE,g" $< > $@
63
64 ##
65 ## static content
66 ##
67 static: htdocs/javascript@VERSION
68
69 %@VERSION: % Makefile ChangeLog
70 cd $< && rm -f $(VERSION) && ln -sf . $(VERSION)
71
72 ##
73 ## wiki
74 ##
75
76 WIKI_NEEDS = \
77 wiki/local/farmconfig.php \
78 wiki/pub/skins/empty \
79 wiki/cookbook/e-protect.php \
80 spool/wiki.d \
81 htdocs/uploads \
82 htdocs/wiki \
83
84 wiki: get-wiki build-wiki
85
86 build-wiki: $(WIKI_NEEDS) | get-wiki
87
88 htdocs/uploads:
89 cd htdocs && ln -sf ../spool/uploads
90
91 htdocs/wiki:
92 cd htdocs && ln -sf ../wiki/pub wiki
93
94
95 spool/wiki.d:
96 mkdir -p $@
97 chmod o+w $@
98 cd $@ && ln -sf ../../include/wiki/wiki.d/* .
99
100
101 wiki/cookbook/e-protect.php:
102 cd wiki/cookbook && ln -sf ../../include/wiki/e-protect.php
103
104 wiki/local/farmconfig.php:
105 cd wiki/local/ && ln -sf ../../include/wiki/farmconfig.php
106
107 wiki/pub/skins/empty:
108 cd wiki/pub/skins/ && ln -sf ../../../include/wiki/empty
109
110
111 get-wiki:
112 @if ! test -d wiki; then \
113 wget http://www.pmwiki.org/pub/pmwiki/pmwiki-latest.tgz; \
114 tar -xzvf pmwiki-latest.tgz; \
115 rm pmwiki-latest.tgz; \
116 mv pmwiki-* wiki; \
117 fi
118
119 ##
120 ## openid
121 ##
122
123 openid: get-openid spool/openid/store
124
125 # There is no obvious way to automatically use the latest version
126 OPENID_VERSION = 2.1.3
127 get-openid:
128 @if ! test -d include/Auth; then \
129 wget http://openidenabled.com/files/php-openid/packages/php-openid-$(OPENID_VERSION).tar.bz2; \
130 tar -xjf php-openid-$(OPENID_VERSION).tar.bz2; \
131 mv php-openid-$(OPENID_VERSION)/Auth include/; \
132 rm php-openid-$(OPENID_VERSION).tar.bz2; \
133 rm -r php-openid-$(OPENID_VERSION); \
134 fi
135
136 spool/openid/store:
137 mkdir -p $@
138 chmod o+w $@
139
140 ##
141 ## banana
142 ##
143
144 banana: htdocs/images/banana htdocs/css/banana.css include/banana/banana.inc.php
145 htdocs/images/banana:
146 cd $(@D) && ln -snf $(BANANA)/img $(@F)
147
148 htdocs/css/banana.css:
149 cd $(@D) && ln -snf $(BANANA)/css/style.css $(@F)
150
151 include/banana/banana.inc.php:
152 cd $(@D) && find $(BANANA)/banana/ -name '*.php' -exec ln -snf {} . ";"
153
154 ##
155 ## Medal thumbnails
156 ##
157 MEDAL_PICTURES=$(wildcard htdocs/images/medals/*.jpg)
158 MEDAL_THUMBNAILS=$(subst /medals/,/medals/thumb/,$(MEDAL_PICTURES))
159
160 medals: $(MEDAL_THUMBNAILS)
161
162 $(MEDAL_THUMBNAILS): $(subst /medals/thumb/,/medals/,$(@F))
163 convert -resize x50 $(subst /medals/thumb/,/medals/,$@) $@
164
165 ##
166 ## jquery
167 ##
168
169 JQUERY_PLUGINS=color
170 JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQUERY_PLUGINS)))
171
172 # TODO: jquery.autocomplete.js should rather be downloaded from an official source. The issue
173 # is that the version we use is not available anymore on the Internet, and the latest version
174 # we could use is not backward compatible with our current code.
175 jquery: htdocs/javascript/jquery.js $(JQUERY_PLUGINS_PATHES)
176
177 htdocs/javascript/jquery.js: DOWNLOAD_SRC = http://jquery.com/src/jquery-latest.min.js
178 htdocs/javascript/jquery.js:
179 @$(download)
180
181 $(JQUERY_PLUGINS_PATHES): DOWNLOAD_SRC = http://plugins.jquery.com/files/$(@F).txt
182 $(JQUERY_PLUGINS_PATHES):
183 @$(download)
184
185 ################################################################################
186
187 .PHONY: build dist clean core wiki build-wiki banana htdocs/images/banana htdocs/css/banana.css include/banana/banana.inc.php http*
188