# $Id$ prefix:=/usr/local DESTDIR:= PKG=relevation VERSION=$(shell printf 'import relevation\nprint relevation.__version__' | python - && $(RM) $(PKG).pyc) PKGVER=$(PKG)-$(VERSION) PACKAGER:=$(shell finger -lp `echo $USER` 2>/dev/null | head -n1 | cut -d: -f3) ifeq ($(PACKAGER),) PACKAGER:=$(shell getent passwd "`id -un`" | cut -d: -f5 | cut -d, -f1) endif TAR_EXCLUDES=--exclude-vcs --exclude=$(PKGVER) \ --exclude=*.swp --exclude=*.pyo --exclude=*.pyc \ --exclude=manpage.html --exclude=manpage.pdf IS_RELEASE=$(shell printf 'import relevation\nif not relevation.RELEASE:\n\traise Exception("RELEASE is False")' | python - ) INSTALLROOT=$(DESTDIR)$(prefix) MANROOT=$(INSTALLROOT)/share/man all: $(PKG).1 testman: docbook-to-man manpage.sgml | nroff -man | less clean: -$(RM) *.pyc *.pyo manpage.html manpage.pdf $(PKG).spec distclean: clean -$(RM) $(PKGVER).tar.gz $(PKGVER).zip -$(RM) -r dist build $(PKGVER)/ install: install -D -m755 $(PKG).py $(INSTALLROOT)/bin/$(PKG) install -D -m644 $(PKG).1 $(MANROOT)/man1/$(PKG).1 # Extra tools install -d $(INSTALLROOT)/share/doc/$(PKG)/extra for tool in gui.py devtools/*.py; do \ install -D -m755 $$tool $(INSTALLROOT)/share/doc/$(PKG)/extra/ ; \ done uninstall: -$(RM) $(INSTALLROOT)/bin/$(PKG) $(INSTALLROOT)/share/man/man1/$(PKG).1 -for tool in gui.py devtools/*.py; do \ $(RM) $(INSTALLROOT)/share/doc/$(PKG)/extra/`basename $$tool` ; \ done -rmdir --parents $(INSTALLROOT)/share/doc/$(PKG)/extra/ \ $(MANROOT)/man1/ \ $(INSTALLROOT)/bin/ $(PKG).1: manpage_source.sgml docbook-to-man $< > $@ manpage.html: $(PKG).1 man2html $< | sed '1,2d' > $@ manpage.pdf: $(PKG).1 man -t ./$(PKG).1 | ps2pdf14 - > $@ is_release: # Only allowed if RELEASE printf 'import relevation\nif not relevation.RELEASE:\n\traise Exception("RELEASE is False")' | python - package_copy: @# Make a temporary copy to package -mkdir $(PKGVER) tar c . $(TAR_EXCLUDES) | ( cd $(PKGVER) && tar x ) dist: $(PKGVER).tar.gz $(PKGVER).zip -$(RM) -r $(PKGVER) $(PKGVER).tar.gz: is_release distclean $(PKG).spec package_copy tar cv $(PKGVER) | gzip -c9 > $(PKGVER).tar.gz zip: $(PKGVER).zip $(PKGVER).zip: is_release distclean manpage.pdf manpage.html $(PKG).spec package_copy cp manpage.pdf manpage.html $(PKGVER) zip -9 -r $(PKGVER).zip $(PKGVER) -$(RM) $(PKGVER)/manpage.pdf $(PKGVER)/manpage.html $(PKG).spec: $(PKG).spec.in test -n "$(VERSION)" # Version (=$(VERSION)) must be defined @echo "[creating $@]" @cat "$<" | sed -e 's/@VERSION@/$(VERSION)/g' \ -e 's/@PACKAGER@/$(PACKAGER)/g' > "$@" exe: python setup_py2exe.py py2exe .PHONY: testman clean distclean dist exe is_release zip