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