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

include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export PREFIX = /usr
export LIBDIR = /usr/lib/$(DEB_HOST_MULTIARCH)

#sonameVersion = $(shell echo $(DEB_VERSION_UPSTREAM) | cut -d '+' -f 1 | cut -d '.' -f -3)
sonameVersion = 9.3.0
sonameAlias = $(shell echo $(sonameVersion) | cut -d '.' -f -2)

export SONAME = libllhttp.so.$(sonameVersion)
export SONAMEALIAS = libllhttp.so.$(sonameAlias)

%:
	dh $@

override_dh_auto_clean-indep:
	- dh_auto_clean --buildsystem=nodejs

override_dh_auto_configure-indep:
	dh_auto_configure --buildsystem=nodejs

override_dh_auto_build-indep:
	dh_auto_build --buildsystem=nodejs
	RELEASE=$(sonameVersion) make release
	WASM_OPT=/usr/bin/wasm-opt WASM_CC=/usr/bin/clang WASM_CFLAGS="--sysroot=/usr -target wasm32-unknown-wasi" node debian/wasm.js

override_dh_auto_install-indep:
	dh_auto_install --buildsystem=nodejs

override_dh_auto_test-indep:
	dh_auto_test --buildsystem=nodejs


override_dh_auto_clean-arch:
	rm -rf release
	- dh_auto_clean --buildsystem=cmake --builddir=build-arch

execute_before_dh_auto_configure-arch:
	cp -rf /usr/src/llhttp release

override_dh_auto_configure-arch:
	dh_auto_configure --buildsystem=cmake --builddir=build-arch --sourcedir=release -- -DBUILD_STATIC_LIBS=ON

override_dh_auto_build-arch:
	dh_auto_build --buildsystem=cmake --builddir=build-arch --sourcedir=release

override_dh_auto_install-arch:
	dh_auto_install --buildsystem=cmake --builddir=build-arch --sourcedir=release

