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