(Aside: This seems like something that the upstream Makefile ought to be doing, instead of the downstream packaging.)
Depends on which framework you're using for your rules
file.
In CDBS, something like this should work...
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
# probably what you want (automagic happens),
# but I don't know details of your package
#include /usr/share/cdbs/1/class/automake.mk
DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[~-].*//')
install/$(DEB_ALL_PACKAGES)::
dh_link -p$(cdbs_curpkg) \
/usr/lib/$(cdbs_curpkg)-$(VERSION)/$(cdbs_curpkg) \
/usr/bin/$(cdbs_curpkg)
If you have a better way of getting the version (say, $(shell cat version.txt))
), use it. The Debian version is not always the source package version; here, I strip out the epoch and packaging version, if any, but this isn't always correct.
Other CDBS classes might define $${libdir}
and $${bindir}
, but I haven't seen anything common.
Note that dh_link
will make relative links if possible, even when given absolute paths. If this is a problem, you might have to resort to something really nasty like
cd debian/$(cdbs_curpkg) && ln -s ...