| 1 |
# A debhelper build system class for building KDE 4 packages. |
| 2 |
# It is based on cmake class but passes KDE 4 flags by default. |
| 3 |
# |
| 4 |
# Copyright: © 2009 Modestas Vainius |
| 5 |
# License: GPL-2+ |
| 6 |
|
| 7 |
package Debian::Debhelper::Buildsystem::kde; |
| 8 |
|
| 9 |
use strict; |
| 10 |
use warnings; |
| 11 |
use Debian::Debhelper::Dh_Lib qw(error); |
| 12 |
use Dpkg::Version qw(); |
| 13 |
|
| 14 |
use base 'Debian::Debhelper::Buildsystem::cmake'; |
| 15 |
|
| 16 |
sub DESCRIPTION { |
| 17 |
"CMake with KDE 4 flags" |
| 18 |
} |
| 19 |
|
| 20 |
sub KDE4_FLAGS_FILE { |
| 21 |
my $file = "kde4_flags"; |
| 22 |
if (! -r $file) { |
| 23 |
$file = "/usr/share/pkg-kde-tools/lib/kde4_flags"; |
| 24 |
} |
| 25 |
if (! -r $file) { |
| 26 |
error "kde4_flags file could not be found"; |
| 27 |
} |
| 28 |
return $file; |
| 29 |
} |
| 30 |
|
| 31 |
# Use shell for parsing contents of the kde4_flags file |
| 32 |
sub get_kde4_flags { |
| 33 |
my $this=shift; |
| 34 |
my $file = KDE4_FLAGS_FILE; |
| 35 |
my ($escaped_flags, @escaped_flags); |
| 36 |
my $flags; |
| 37 |
|
| 38 |
# Read escaped flags from the file |
| 39 |
open(KDE4_FLAGS, "<", $file) || error("unable to open KDE 4 flags file: $file"); |
| 40 |
@escaped_flags = <KDE4_FLAGS>; |
| 41 |
chop @escaped_flags; |
| 42 |
$escaped_flags = join(" ", @escaped_flags); |
| 43 |
close KDE4_FLAGS; |
| 44 |
|
| 45 |
# Unescape flags using shell |
| 46 |
$flags = `$^X -w -Mstrict -e 'print join("\\x1e", \@ARGV);' -- $escaped_flags`; |
| 47 |
return split("\x1e", $flags); |
| 48 |
} |
| 49 |
|
| 50 |
sub configure { |
| 51 |
my $this=shift; |
| 52 |
my @flags = $this->get_kde4_flags(); |
| 53 |
|
| 54 |
my $kdever = `dpkg-query -f='\${Version}' -W kdelibs5-dev 2>/dev/null`; |
| 55 |
if ($kdever) { |
| 56 |
if (Dpkg::Version::version_compare($kdever, "4:4.4.0") < 0) { |
| 57 |
# Skip RPATH if kdelibs5-dev is older than 4:4.4.0 |
| 58 |
push @flags, "-DCMAKE_SKIP_RPATH:BOOL=ON"; |
| 59 |
} elsif (Dpkg::Version::version_compare($kdever, "4:4.6.1") < 0) { |
| 60 |
# Manually set ENABLE_LIBKDEINIT_RUNPATH:BOOL=ON if kdelibs5-dev is |
| 61 |
# older than 4:4.6.1. Later kdelibs5-dev revisions enable this |
| 62 |
# automatically whenever CMAKE_BUILD_TYPE is set to Debian (default) |
| 63 |
push @flags, "-DENABLE_LIBKDEINIT_RUNPATH:BOOL=ON"; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
return $this->SUPER::configure(@flags, @_); |
| 68 |
} |
| 69 |
|
| 70 |
1; |