#!/usr/bin/make -f

patch-stamp:
	patch -p1 < debian/csound-default-pulse.patch
	touch $@

configure-stamp: patch-stamp
	dh_testdir
	
	touch $@

build: configure-stamp
	dh_testdir
	scons useJack=0 usePortAudio=0 buildInterfaces=1 buildPythonWrapper=1 dynamicCsoundLibrary=1 customCCFLAGS="$(CFLAGS) -UHAVE_SOCKETS" customCXXFLAGS="$(CFLAGS) -UHAVE_SOCKETS"

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	python install-olpc.py --install-python --install-headers --instdir=$(CURDIR)/debian/sweets-csound-python/0bs.dist --prefix=/
	python $(CURDIR)/debian/sweet_install.py move deb $(CURDIR)/debian/sweets-csound-python/0bs.dist $(CURDIR)/debian/sweets-csound-python/opt/sweets/csound-python '' '' > sweets-csound-python.files
	python $(CURDIR)/debian/sweet_install.py move deb $(CURDIR)/debian/sweet_files $(CURDIR)/debian/sweets-csound-python/opt/sweets/csound-python '' '' >> sweets-csound-python.files
	chmod 0755 $(CURDIR)/debian/sweets-csound-python/opt/sweets/csound-python/*.run 2>/dev/null || true
	rm -rf $(CURDIR)/debian/sweets-csound-python/0bs.dist

clean:
	dh_testdir
	dh_testroot
	dh_clean configure-stamp patch-stamp

binary-indep: install
	dh_testdir
	dh_testroot
	dh_installchangelogs -i
	dh_install -i
	dh_link -i
	dh_strip -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs -s
	dh_install -s
	dh_link -s
	dh_strip -s
	dh_compress -s
	dh_fixperms -s
	dh_installdeb -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

binary: binary-indep binary-arch

.PHONY: build clean install binary-indep binary-arch binary
