+DESTDIR := /
+datadir := /usr/share
+bindir := /usr/bin
+
+PWD := $(shell pwd)
+
+#
+build: static templates force
+ python setup.py build
+
+install:
+ python setup.py install \
+ --install-purelib=$(DESTDIR)/$(datadir)/unfold \
+ --install-scripts=$(DESTDIR)/$(datadir)/unfold \
+ --install-data=$(DESTDIR)/$(datadir)/unfold
+
+#################### third-party layout is managed as part of collectstatic
+static: force
+ ./manage.py collectstatic --noinput
+
+clean-static:
+ rm -rf static/
+
+redo-static: clean-static static
+
+####################
+# general stuff
+DATE=$(shell date -u +"%a, %d %b %Y %T")
+
+# This is called from the build with the following variables set
+# (see build/Makefile and target_debian)
+# (.) RPMTARBALL
+# (.) RPMVERSION
+# (.) RPMRELEASE
+# (.) RPMNAME
+DEBVERSION=$(RPMVERSION).$(RPMRELEASE)
+DEBTARBALL=../$(RPMNAME)_$(DEBVERSION).orig.tar.bz2
+
+debian: static templates debian/changelog debian.source debian.package
+
+debian/changelog: debian/changelog.in
+ sed -e "s|@VERSION@|$(DEBVERSION)|" -e "s|@DATE@|$(DATE)|" debian/changelog.in > debian/changelog
+
+debian.source: force
+ rsync -a $(RPMTARBALL) $(DEBTARBALL)
+
+debian.package:
+ debuild --set-envvar PREFIX=/usr -uc -us -b
+
+debian.clean:
+ $(MAKE) -f debian/rules clean
+ rm -rf build/ MANIFEST ../*.tar.gz ../*.dsc ../*.build
+ find . -name '*.pyc' -delete
+
+
+# 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 | grep -v '^\./templates$$'),find $(tmpl) -maxdepth 2 -type f -name *.html;)
+local-templates2: force
+ @$(foreach tmpl,$(shell find . -name templates | grep -v '^\./templates$$'),ls -1 $(tmpl)/*;)
+
+
+list-templates: plugins-templates local-templates
+
+#################### manage templates for the plugin area
+templates: force
+ @mkdir -p templates
+ ln -sf $(foreach x,$(shell $(MAKE-SILENT) list-templates),"../$(x)") ./templates
+
+clean-templates templates-clean: force
+ rm -rf ./templates
+
+redo-templates: clean-templates templates
+
+####################
+### list-all list-resources: list-templates list-js list-css list-img
+