edit = sed \
	-e "s|@version\@|"`cat conf-version`"|g" \
	-e "s|@release\@|"`cat conf-release`"|g" \
	-e 's|@email\@|'"`cat conf-email`"'|g' \
	-e 's}@VERSION\@}$(VERSION)}g' \
	-e 's}@prefix\@}$(prefix)}g'

ALL: librespot.spec librespot.dsc debian.changelog

clean:
	rm -f librespot.spec librespot.dsc debian.changelog ibrespot-Debian_12.dsc \
		librespot-Raspbian_12.dsc librespot-xUbuntu_24.04.dsc

distclean:
	rm -rf librespot.spec librespot.dsc debian.changelog

librespot.spec: librespot.spec.in catChangeLog doc/ChangeLog conf-version \
conf-release conf-email
	(cat $@.in;./catChangeLog) | $(edit) > $@

librespot.dsc: librespot.dsc.in catChangeLog doc/ChangeLog conf-version \
conf-release conf-email
	$(edit) $@.in > $@

debian.changelog: doc/ChangeLog Makefile conf-version conf-release \
conf-email catChangeLog
	./catChangeLog --debian --name=librespot --state=unstable \
		--urgency=low doc/ChangeLog > $@
