#!/usr/bin/make -f

clc-files	:= usr/share/common-lisp/source/stumpwm

DEBIAN_VERSION	:= Debian Git checkout $(shell echo -n `head -1 debian/changelog | sed -e 's/^.*(\(.*\)).*$$/\\1/'`)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --with-lisp=sbcl

override_dh_auto_build-indep:
	XDG_CACHE_HOME=$(shell pwd)/.cache $(MAKE) stumpwm.info

override_dh_auto_clean:
	dh_auto_clean
	rm -rf autom4te.cache Makefile make-image.lisp config.log config.status configure load-stumpwm.lisp .cache
	dh_clean

override_dh_auto_install:

override_dh_install:
	# Rewrite source-registry post-build to ensure the correct runtime
	# path, does not leak the build path, and is reproducible.
	sed -i -e 's@\((:directory "\)[^\"]*\(")\)@\1/$(clc-files)\2@g' load-stumpwm.lisp
	dh_install -Xmake-image.lisp -Xsample-stumpwmrc.lisp

	dh_installdirs /usr/bin
	cp debian/stumpwm.bin debian/stumpwm/usr/bin/stumpwm
