Description: use pkgconfig instead of the discontinued imlib2-config
Origin: vendor
Bug-Debian: https://bugs.debian.org/1040223
Author: gregor herrmann <gregoa@debian.org>
Last-Update: 2023-07-29

--- a/Build.PL
+++ b/Build.PL
@@ -1,11 +1,14 @@
 use Module::Build;
 use strict;
 use Cwd;
+use ExtUtils::PkgConfig ;
 
-# We need to find imlib2-config
-my $CONFIG = "imlib2-config";
+my $pkg = 'imlib2';
+my %info = ExtUtils::PkgConfig->find ($pkg) ;
+my $version = $info{modversion} ;
+my $libs    = $info{libs} ;
+my $cflags  = $info{cflags} ;
 
-my $version = `$CONFIG --version`;
 if (!$version) {
   warn 'You must install the imlib2 library before you can install
 Image::Imlib2. You can obtain imlib2 from
@@ -15,13 +18,12 @@
 still will not work, modify the $CONFIG variable inside Build.PL to
 point to the imlib2-config program that provides.
 ';
-  exit 0;
+  exit 1;
 } else {
-  print "Found imlib2 $version";
+  print "Found imlib2 $version\n";
 }
 
-my $libs = `$CONFIG --libs`;
-my $cflags = "-DX_DISPLAY_MISSING " . `$CONFIG --cflags` . "-ffile-prefix-map=" . getcwd() . "=." ;
+$cflags = "-DX_DISPLAY_MISSING " . $cflags . "-ffile-prefix-map=" . getcwd() . "=." ;
 
 my $build = Module::Build->new(
   c_source     => './lib/Image',
