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

# export DH_VERBOSE = 1

%:
	dh $@

override_dh_auto_configure:
	# Qt 6.2 build for gcc 8
	sed -i 's,->GetProperty({,->GetProperty(GetPropertyRequest{,g' qtwebengine/src/3rdparty/chromium/ui/gfx/x/property_cache.cc
	sed -i 's/max(),/max()/g' qtwebengine/src/3rdparty/chromium/ui/gfx/x/property_cache.cc
	sed -i 's,PresentPixmap({,PresentPixmap(x11::Present::PresentPixmapRequest{,g' qtwebengine/src/3rdparty/chromium/components/viz/service/display_embedder/output_presenter_x11.cc
	sed -i 's/last_target_msc_,/last_target_msc_/g' qtwebengine/src/3rdparty/chromium/components/viz/service/display_embedder/output_presenter_x11.cc
	# Avoid MakeFlatSet
	sed -i 's,const auto& GetNeverSniffedMimeTypes,/*const auto& GetNeverSniffedMimeTypes{,g' qtwebengine/src/3rdparty/chromium/services/network/public/cpp/cross_origin_read_blocking.cc
	sed -i '1,/\/\/ static/{s/\/\/ static/*\/\}\/\/ static/;}' qtwebengine/src/3rdparty/chromium/services/network/public/cpp/cross_origin_read_blocking.cc
	cp qtwebengine/src/3rdparty/chromium/services/network/public/cpp/cross_origin_read_blocking.cc temp
	tac temp | sed '1,/return MimeType::kOthers/{s/return MimeType::kOthers/*\/return MimeType::kOthers/;}' | tac > qtwebengine/src/3rdparty/chromium/services/network/public/cpp/cross_origin_read_blocking.cc
	rm temp -f
	sed -i 's,if (base::Contains,/*if (base::Contains,g' qtwebengine/src/3rdparty/chromium/services/network/public/cpp/cross_origin_read_blocking.cc
	CXXFLAGS="-flto -flto-partition=none" CFLAGS="-flto -flto-partition=none" ./configure \
	  -opensource \
	  -confirm-license \
	  -nomake examples \
	  -nomake tests \
	  -prefix "${QT_JAMI_PREFIX}"

override_dh_auto_build:
	cmake --build . --parallel

override_dh_auto_install:
	cmake --install . --prefix $(CURDIR)/debian/tmp/${QT_JAMI_PREFIX}
