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