separate templates from static files
[myslice.git] / Makefile
1 SHELL = /bin/bash
2
3 MAKE-SILENT = $(MAKE) --no-print-directory
4
5 ### first purpose, build and install from setup.py
6 all: build
7
8 force:
9
10 # clean up and recompute
11 redo: redo-static redo-templates
12
13 DESTDIR := /
14 datadir := /usr/share
15 bindir := /usr/bin
16
17 PWD := $(shell pwd)
18
19
20 build: static templates force
21         python setup.py build
22
23 install: 
24         python setup.py install \
25             --install-purelib=$(DESTDIR)/$(datadir)/unfold \
26             --install-scripts=$(DESTDIR)/$(datadir)/unfold \
27             --install-data=$(DESTDIR)/$(datadir)/unfold
28
29 redo-static static: force
30         rm -rf static/
31         ./manage.py collectstatic --noinput
32
33 ####################
34 # general stuff
35 DATE=$(shell date -u +"%a, %d %b %Y %T")
36
37 # This is called from the build with the following variables set 
38 # (see build/Makefile and target_debian)
39 # (.) RPMTARBALL
40 # (.) RPMVERSION
41 # (.) RPMRELEASE
42 # (.) RPMNAME
43 DEBVERSION=$(RPMVERSION).$(RPMRELEASE)
44 DEBTARBALL=../$(RPMNAME)_$(DEBVERSION).orig.tar.bz2
45
46 debian: static templates debian/changelog debian.source debian.package
47
48 debian/changelog: debian/changelog.in
49         sed -e "s|@VERSION@|$(DEBVERSION)|" -e "s|@DATE@|$(DATE)|" debian/changelog.in > debian/changelog
50
51 debian.source: force 
52         rsync -a $(RPMTARBALL) $(DEBTARBALL)
53
54 debian.package:
55         debuild -uc -us -b 
56
57 debian.clean:
58         $(MAKE) -f debian/rules clean
59         rm -rf build/ MANIFEST ../*.tar.gz ../*.dsc ../*.build
60         find . -name '*.pyc' -delete
61
62
63 ### #################### third-party layout is kind of special 
64 ### # because we have differents versions, and also we 
65 ### # try to preserve the file structure from upstream
66 ### # so let's handle this manually
67 ### THIRD-PARTY-RESOURCES =
68 ### # ignore variants, use the main symlink     third-party/bootstrap
69 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/bootstrap/*/*)
70 ### # just the single js as identified with a symlink
71 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/js/dataTables.js)
72 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/js/dataTables.bootstrap.js)
73 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/css/dataTables.bootstrap.css)
74 ### # likewise
75 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.js)
76 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.min.js)
77 ### # for storing the visible status of plugins
78 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-html5storage/jquery.html5storage.js)
79 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-html5storage/jquery.html5storage.min.js)
80 ### # creating queries uuids on the fly
81 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/uuid/Math.uuid.js)
82 ### # spin comes in plain or min, + the jquery plugin, and our own settings
83 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/spin/*.js)
84 ### # used in QueryCode
85 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shCore.js)
86 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shAutoloader.js)
87 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shBrushPython.js)
88 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/scripts/shBrushRuby.js)
89 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/shCore.css)
90 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/shCoreDefault.css)
91 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/shThemeDefault.css)
92 ### # wizard plugin
93 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/smartwizard-1636c86/js/jquery.smartWizard-2.0.js)
94 ### #THIRD-PARTY-RESOURCES += $(shell ls third-party/smartwizard-1636c86/js/jquery.smartWizard-2.0.min.js)
95 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/smartwizard-1636c86/styles/smart_wizard.css)
96 ### # jquery.notify
97 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-notify/jquery.notify.js)
98 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-notify/jquery.notify.min.js)
99 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-notify/ui.notify.css)
100 ### # CodeMirror
101 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/codemirror-3.15/lib/codemirror.js) 
102 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/codemirror-3.15/lib/codemirror.css) 
103 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/codemirror-3.15/mode/sql/sql.js)
104 ### # Mustache.js
105 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/mustache/mustache.js)
106 ### # markerclustererplus for the googlemap plugin
107 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/markerclusterer/markerclusterer.js)
108 ### THIRD-PARTY-RESOURCES += $(shell ls third-party/markerclusterer/markerclusterer_packed.js)
109 ### 
110 ### thirdparty-js:
111 ###     @find $(THIRD-PARTY-RESOURCES) -name '*.js'
112 ### thirdparty-css:
113 ###     @find $(THIRD-PARTY-RESOURCES) -name '*.css'
114 ### thirdparty-img:
115 ###     @find $(THIRD-PARTY-RESOURCES) -name '*.png' -o -name '*.ico'
116 ### 
117 ### # we might have any of these as templates - e.g. ./unfold/templates/plugin-init.js
118 ### # so if there's a /templates/ in the path ignore the file
119 ### local-js: force
120 ###     @find . -type f -name '*.js' | egrep -v '/all-(static|templates)/|/third-party/|/templates/'
121 ### local-css: force
122 ###     @find . -type f -name '*.css' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
123 ### local-img: force
124 ###     @find . -type f -name '*.png' -o -name '*.ico' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
125 ### 
126 ### list-js: thirdparty-js local-js
127 ### list-css: thirdparty-css local-css
128 ### list-img: thirdparty-img local-img
129
130 # having templates in a templates/ subdir is fine most of the time except for plugins
131 plugins-templates: force
132         @find plugins -type f -name '*.html' 
133 local-templates: force
134         @$(foreach tmpl,$(shell find . -name templates),ls -1 $(tmpl)/*;)
135
136 list-templates: plugins-templates local-templates
137
138 ### #################### manage static contents (extract from all the modules into the single all-static location)
139 ### static run-static static-run: force
140 ###     mkdir -p ./all-static/js all-static/css all-static/img
141 ###     ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-js),../../$(x)) ./all-static/js
142 ###     ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-css),../../$(x)) ./all-static/css
143 ###     ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-img),../../$(x)) ./all-static/img
144 ### 
145 ### clean-static static-clean: force
146 ###     rm -rf ./all-static
147 ### 
148 ### all-static: clean-static run-static
149
150 #################### manage templates for the plugin area
151 templates: force
152         mkdir -p templates
153         ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-templates),../$(x)) ./templates
154
155 clean-templates templates-clean: force
156         rm -rf ./templates
157
158 redo-templates: clean-templates templates
159
160 ####################
161 ### list-all list-resources: list-templates list-js list-css list-img
162
163 #################### compute emacs tags
164 # list files under git but exclude third-party stuff like bootstrap and jquery
165 myfiles: force
166         @git ls-files | egrep -v 'insert(_|-)above|third-party/|play/'
167
168 # in general it's right to rely on the contents as reported by git
169 tags: force
170         $(MAKE-SILENT) myfiles | xargs etags
171
172 # however sometimes we have stuff not yet added, so in this case
173 ftags: force
174         find . -type f | fgrep -v '/.git/' | xargs etags
175
176 #################### sync : push current code on a (devel) box running myslice
177 SSHURL:=root@$(MYSLICEBOX):/
178 SSHCOMMAND:=ssh root@$(MYSLICEBOX)
179
180 ### rsync options
181 # the config file should probably not be overridden ??
182 # --exclude settings.py 
183 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude config.py --exclude static --exclude templates --exclude '*.sqlite3'  --exclude play/ 
184 # usual excludes
185 RSYNC_EXCLUDES          := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES) 
186 # make -n will propagate as rsync -n 
187 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
188 # putting it together
189 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
190
191 ##### convenience for development only, push code on a specific test box
192 # xxx until we come up with a packaging this is going to be a wild guess
193 # on debian04 I have stuff in /usr/share/myslice and a symlink in /root/myslice
194 #INSTALLED=/usr/share/myslice
195 INSTALLED=/root/myslice
196
197 sync:
198 ifeq (,$(MYSLICEBOX))
199         @echo "you need to set MYSLICEBOX, like in e.g."
200         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
201         @exit 1
202 else
203         +$(RSYNC) ./ $(SSHURL)/$(INSTALLED)/
204 endif
205
206 # xxx likewise until we run this under apache it's probably hard to restart from here
207 restart:
208 ifeq (,$(MYSLICEBOX))
209         @echo "you need to set MYSLICEBOX, like in e.g."
210         @echo "  $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@""
211         @exit 1
212 else
213         @echo "$@" target not yet implemented - for an apache based depl it would read ...; exit; @$(SSHCOMMAND) /etc/init.d/apache2 restart
214 endif