#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/buildtools.mk

%:
	dh $@

override_dh_auto_configure:

override_dh_auto_build:
	$(CXX) -o liblodepng.so.0 -shared -fPIC -rdynamic lodepng.cpp \
		$(shell dpkg-buildflags --get CXXFLAGS) \
		$(shell dpkg-buildflags --get CPPFLAGS) \
		$(shell dpkg-buildflags --get LDFLAGS) \
		-Wl,-soname,liblodepng.so.0
	ln -s liblodepng.so.0 liblodepng.so

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) unittest
	./unittest
endif

override_dh_auto_install:
	install -Dm0755 -t debian/liblodepng-dev/usr/include lodepng.h 
	mkdir -p debian/liblodepng-dev/usr/lib/$(shell dpkg-architecture -q DEB_HOST_MULTIARCH)/
	cp -av liblodepng.so debian/liblodepng-dev/usr/lib/$(shell dpkg-architecture -q DEB_HOST_MULTIARCH)/
	install -Dm0755 -t debian/liblodepng0/usr/lib/$(shell dpkg-architecture -q DEB_HOST_MULTIARCH) liblodepng.so.0
