#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
export DH_VERBOSE = 1
export DH_OPTIONS=-v
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

#include /usr/share/dpkg/architecture.mk


# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed



#override_dh_auto_configure:
#	dh_auto_configure -- -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_HOST_MULTIARCH)"

include /usr/share/dpkg/architecture.mk
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


clean:
	dh_testdir
	dh_testroot
	rm -fr CMakeFiles CMakeCache.txt Makefile cmake_install.cmake

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.
	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir
	cmake .
	$(MAKE)
	touch build-stamp

install: build
	dh_testdir
	dh_update_autotools_config
	dh_autoreconf
	#dh_auto_configure
	install -d $(CURDIR)/debian/libyyjson/usr/lib/yyjson
	install -d $(CURDIR)/debian/libyyjson/etc/ld.so.conf.d/
	install $(CURDIR)/libyyjson.so $(CURDIR)/debian/libyyjson/usr/lib/yyjson/libyyjson.so.0.4.0
	install $(CURDIR)/etc/ld.so.conf.d/yyjsonlib.conf $(CURDIR)/debian/libyyjson/etc/ld.so.conf.d/yyjsonlib.conf
	install -d $(CURDIR)/debian/libyyjson-dev/usr/include
	install $(CURDIR)/src/yyjson.h $(CURDIR)/debian/libyyjson-dev/usr/include/yyjson.h

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

binary-arch: build install
	dh_testdir
	dh_testroot
#<----->dh_installdebconf<----->
	dh_installdocs
	dh_installexamples
	dh_installmenu
#<----->dh_installlogrotate
#<----->dh_installemacsen
#<----->dh_installpam
#<----->dh_installmime
#<----->dh_installinit
	dh_installcron
	dh_installman
	dh_installinfo
#<----->dh_undocumented
#<----->dh_installchangelogs ChangeLog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#<----->dh_makeshlibs
	dh_installdeb
#<----->dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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


