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