#!/usr/bin/make -f

confflags = --with-libxml2 --with-freetype \
	--enable-bdjava --with-bdj-type=j2se \
	--disable-silent-rules
# --enable-bdjava-jar is introduced by 03_split-jar-build-for-arch-all.patch.
# This enables us to build the JAR file only if the Architecture: all package
# libbluray-bdj is built.
confflags_java = --enable-bdjava-jar

# Use default java implementation
export JDK_HOME=/usr/lib/jvm/default-java
ifeq (,$(wildcard $(JDK_HOME)))
    $(info "warning: No suitable jni.h was found. Package will most probably FTBFS!")
endif

# Set CFLAGS to DEB_CFLAGS
CFLAGS=$(shell dpkg-buildflags --get CFLAGS 2>/dev/null | sed -e 's/-O2//g')

%:
	dh $@ --parallel --with javahelper,autoreconf

override_dh_auto_configure:
ifneq (,$(findstring libbluray-bdj,$(shell dh_listpackages)))
	dh_auto_configure -- $(confflags) $(confflags_java)
else
	dh_auto_configure -- $(confflags)
endif

override_dh_auto_build-indep:
	make doxygen-doc

override_dh_strip:
	dh_strip -plibbluray1 --dbg-package=libbluray1-dbg
	dh_strip

override_dh_installdocs:
	dh_installdocs --exclude=jquery.js

override_dh_install:
	dh_install -X.la --fail-missing

override_dh_clean:
	dh_clean
	rm -rf src/libbluray/bdj/build

get-orig-source:
	$(dir $_)libbluray-get-orig-source
