+# overwritten by the specfile
+DESTDIR="/"
+
+##########
+all: python wsdl
+
+install: python-install wsdl-install xmlbuilder-install tests-install
+
+clean: python-clean wsdl-clean
+
+uninstall: python-uninstall tests-uninstall
+
+.PHONY: all install clean uninstall
+
+##########
+rpmversion:=$(shell rpm -q --specfile sfa.spec --queryformat="%{version}\n" | head -1)
+# somehow %{taglevel} is empty, turns out %{release} has what we want
+rpmtaglevel:=$(shell rpm -q --specfile sfa.spec --queryformat="%{release}\n" 2> /dev/null | head -1)
+VERSIONTAG=$(rpmversion)-$(rpmtaglevel)
+SCMURL=should-be-redefined-by-specfile
+
+python: version
+
+version: sfa/util/version.py
+sfa/util/version.py: sfa/util/version.py.in
+ sed -e "s,@VERSIONTAG@,$(VERSIONTAG),g" -e "s,@SCMURL@,$(SCMURL),g" sfa/util/version.py.in > $@
+
+xmlbuilder-install:
+ cd xmlbuilder-0.9 && python setup.py install --root=$(DESTDIR) && cd -
+ rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/*egg-info
+
+# postinstall steps - various cleanups and tweaks for a nicer rpm
+python-install:
+ python setup.py install --root=$(DESTDIR)
+ chmod 444 $(DESTDIR)/etc/sfa/default_config.xml
+ rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/*egg-info
+ rm -rf $(DESTDIR)/usr/lib*/python*/site-packages/sfa/storage/sfa.sql
+ (cd $(DESTDIR)/usr/bin ; ln -s sfi.py sfi; ln -s sfascan.py sfascan)
+
+python-clean: version-clean
+ python setup.py clean
+# rm $(init)
+
+version-clean:
+ rm -f sfa/util/version.py
+
+.PHONY: python version python-install python-clean version-clean xmlbuilder-install
+##########
+wsdl:
+ $(MAKE) -C wsdl
+
+# propagate DESTDIR from the specfile
+wsdl-install:
+ $(MAKE) -C wsdl install
+
+wsdl-clean:
+ $(MAKE) -C wsdl clean