+DESTDIR := /
+datadir := /usr/share
+bindir := /usr/bin
+
+PWD := $(shell pwd)
+
+build: static templates
+ python setup.py build
+
+install:
+ python setup.py install \
+ --install-purelib=$(DESTDIR)/$(datadir)/myslice \
+ --install-scripts=$(DESTDIR)/$(datadir)/myslice \
+ --install-data=$(DESTDIR)/$(datadir)/myslice
+
+
+#################### third-party layout is kind of special
+# because we have differents versions, and also we
+# try to preserve the file structure from upstream
+# so let's handle this manually
+THIRD-PARTY-RESOURCES =
+# ignore variants, use the main symlink third-party/bootstrap
+THIRD-PARTY-RESOURCES += $(shell ls third-party/bootstrap/*/*)
+# just the single js as identified with a symlink
+THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/js/dataTables.js)
+# likewise
+THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.js)
+# spin comes in plain or min, + the jquery plugin, and our own settings
+THIRD-PARTY-RESOURCES += $(shell ls third-party/spin/*.js)
+
+thirdparty-js:
+ @find $(THIRD-PARTY-RESOURCES) -name '*.js'
+thirdparty-css:
+ @find $(THIRD-PARTY-RESOURCES) -name '*.css'
+thirdparty-img:
+ @find $(THIRD-PARTY-RESOURCES) -name '*.png' -o -name '*.ico'
+
+# we might have any of these as templates - e.g. ./unfold/templates/plugin-init.js
+# so if there's a /templates/ in the path ignore the file
+local-js: force
+ @find . -type f -name '*.js' | egrep -v '/all-(static|templates)/|/third-party/|/templates/'
+local-css: force
+ @find . -type f -name '*.css' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
+local-img: force
+ @find . -type f -name '*.png' -o -name '*.ico' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
+
+list-js: thirdparty-js local-js
+list-css: thirdparty-css local-css
+list-img: thirdparty-img local-img
+
+# having templates in a templates/ subdir is fine most of the time except for plugins
+plugins-templates: force
+ @find plugins -type f -name '*.html'
+local-templates: force
+ @$(foreach tmpl,$(shell find . -name templates),ls -1 $(tmpl)/*;)
+
+list-templates: plugins-templates local-templates
+
+#################### manage static contents (extract from all the modules into the single all-static location)
+static run-static static-run: force
+ mkdir -p ./all-static/js all-static/css all-static/img
+ ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-js),../../$(x)) ./all-static/js
+ ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-css),../../$(x)) ./all-static/css
+ ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-img),../../$(x)) ./all-static/img
+
+clean-static static-clean: force
+ rm -rf ./all-static
+
+all-static: clean-static run-static
+
+#################### manage templates for the plugin area
+templates run-templates templates-run: force
+ mkdir -p all-templates
+ ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-templates),../$(x)) ./all-templates
+
+clean-templates templates-clean: force
+ rm -rf ./all-templates
+
+all-templates: clean-templates run-templates
+
+####################
+list-all list-resources: list-templates list-js list-css list-img
+
+#################### compute emacs tags
+# list files under git but exclude third-party stuff like bootstrap and jquery
+myfiles: force
+ @git ls-files | egrep -v 'insert(_|-)above|third-party/|play/'
+