#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS = -Wall -g -O0 -g
	CPPFLAGS =
else
	CFLAGS = $(shell dpkg-buildflags --get CFLAGS)
	CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
	LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
endif

PYVERS=$(shell pyversions -vs)


build: build-arch build-indep
build-arch: $(PYVERS:%=build-python%)
	touch $@
build-python%:
	CFLAGS="$(CFLAGS) $(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" python$* setup.py build
	touch $@

install-arch: build $(PYVERS:%=install-python%)
install-python%:
	dh_testdir
	dh_testroot
	dh_installdirs
	python$* setup.py install --install-layout=deb --root $(CURDIR)/debian/python-pyclamav

clean: $(PYVERS:%=clean-python%)
clean-python%:
	dh_testdir
	python$* setup.py clean
	dh_testroot
	rm -fr build build-python$*
	dh_clean 

binary-common:
	dh_testdir
	dh_testroot
	dh_installchangelogs CHANGELOG
	dh_installdocs
	dh_installexamples
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_python2
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-independent files here.
binary-indep: build-indep install-indep
	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common

# Build architecture-dependent files here.
binary-arch: build-arch install-arch
	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common

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