| 1 |
# A debhelper build system class for building KDE Frameworks 5 packages. |
| 2 |
# It is based on cmake class but passes Frameworks 5 flags by default. |
| 3 |
# |
| 4 |
# Copyright: © 2009 Modestas Vainius |
| 5 |
# License: GPL-2+ |
| 6 |
|
| 7 |
package Debian::Debhelper::Buildsystem::kf5; |
| 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 Frameworks 5 flags" |
| 18 |
} |
| 19 |
|
| 20 |
sub KF5_FLAGS_FILE { |
| 21 |
my $file = "kf5_flags"; |
| 22 |
if (! -r $file) { |
| 23 |
$file = "/usr/share/pkg-kde-tools/lib/kf5_flags"; |
| 24 |
} |
| 25 |
if (! -r $file) { |
| 26 |
error "kf5_flags file could not be found"; |
| 27 |
} |
| 28 |
return $file; |
| 29 |
} |
| 30 |
|
| 31 |
# Use shell for parsing contents of the kf5_flags file |
| 32 |
sub get_kf5_flags { |
| 33 |
my $this=shift; |
| 34 |
my $file = KF5_FLAGS_FILE; |
| 35 |
my ($escaped_flags, @escaped_flags); |
| 36 |
my $flags; |
| 37 |
|
| 38 |
# Read escaped flags from the file |
| 39 |
open(KF5_FLAGS, "<", $file) || error("unable to open KDE Frameworks 5 flags file: $file"); |
| 40 |
@escaped_flags = <KF5_FLAGS>; |
| 41 |
chop @escaped_flags; |
| 42 |
$escaped_flags = join(" ", @escaped_flags); |
| 43 |
close KF5_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_kf5_flags(); |
| 53 |
|
| 54 |
return $this->SUPER::configure(@flags, @_); |
| 55 |
} |
| 56 |
|
| 57 |
1; |