#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh $@ --buildsystem cmake

# CMAKE_PROJECT_whisper.cpp_INCLUDE to be removed when upstream is upgraded from v1.8.2
override_dh_auto_configure:
	dh_auto_configure -- \
	      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
	      -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_TARGET_MULTIARCH)" \
	      -DWHISPER_USE_SYSTEM_GGML=ON \
	      -DWHISPER_SDL2=ON \
	      -DCMAKE_PROJECT_whisper.cpp_INCLUDE=debian/cmake/debian-whisper.cpp.cmake \

execute_after_dh_auto_install:
	mkdir -p debian/tmp/usr/share/sounds/debian/samples
	# Convert English sample to lightweight portable WAV
	ffmpeg -acodec libvorbis -i debian/tests/samples/Wikipedia_Ignore_All_Rules.ogx \
	 -acodec pcm_s16le -ac 1 -ar 16000 \
	 debian/tmp/usr/share/sounds/debian/samples/en-Wikipedia-Ignore_All_Rules.wav
	# Shorten and convert Arabic sample to lightweight portable WAV
	ffmpeg -ss 00:00:00 -to 00:00:51 -i debian/tests/samples/ويكيبيديا_الركائز_الخمس.ogx \
	 -acodec pcm_s16le -ac 1 -ar 16000 \
	 debian/tmp/usr/share/sounds/debian/samples/ar-Wikipedia-Five_Pillars.wav

# Disabled for now, needs data with uncertain license
override_dh_auto_test:
	:
