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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Enable verbose builds to detect missing (hardening) flags.
#export verbose=1

# This has to be exported to make some magic below work.
export DH_OPTIONS
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
# The build system doesn't use CPPFLAGS, pass them to CFLAGS to enable the
# missing (hardening) flags.
CFLAGS += $(CPPFLAGS)

ifneq (,$(filter x-fpic,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -fPIC
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

override_dh_auto_build:
	# Use system libjpeg jconfig.h
	-rm scripts/jconfig.h
	$(MAKE) build=release OS=Linux

override_dh_auto_install:
	$(MAKE) build=release OS=Linux prefix=$(CURDIR)/debian/tmp/usr install

override_dh_auto_clean:
	-rm -rf build
	-rm -rf generated

%:
	dh $@
