summaryrefslogtreecommitdiff
path: root/perllib/Debian/Debhelper/Buildsystem/kf5.pm
blob: c472b2867e817058dba5654e2e0ee0b2e11d3973 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# A debhelper build system class for building KDE Frameworks 5 packages.
# It is based on cmake class but passes Frameworks 5 flags by default.
#
# Copyright: © 2009 Modestas Vainius
# License: GPL-2+

package Debian::Debhelper::Buildsystem::kf5;

use strict;
use warnings;
use Debian::Debhelper::Dh_Lib qw(error dpkg_architecture_value);
use Dpkg::Version qw();

use base 'Debian::Debhelper::Buildsystem::cmake';

sub DESCRIPTION {
    "CMake with KDE Frameworks 5 flags"
}

sub KF5_FLAGS_FILE {
    my $file = "kf5_flags";
    if (! -r $file) {
        $file = "/usr/share/pkg-kde-tools/lib/kf5_flags";
    }
    if (! -r $file) {
        error "kf5_flags file could not be found";
    }
    return $file;
}

# Use shell for parsing contents of the kf5_flags file
sub get_kf5_flags {
    my $this=shift;
    my $file = KF5_FLAGS_FILE;
    my ($escaped_flags, @escaped_flags);
    my $flags;

    # Read escaped flags from the file
    open(KF5_FLAGS, "<", $file) || error("unable to open KDE Frameworks 5 flags file: $file");
    @escaped_flags = <KF5_FLAGS>;
    chop @escaped_flags;
    $escaped_flags = join(" ", @escaped_flags);
    close KF5_FLAGS;

    # Unescape flags using shell
    $flags = `$^X -w -Mstrict -e 'print join("\\x1e", \@ARGV);' -- $escaped_flags`;
    $flags = $flags . " -DECM_MKSPECS_INSTALL_DIR=usr/lib/" . dpkg_architecture_value('DEB_HOST_MULTIARCH') . "/qt5/mkspecs/modules/";
    return split("\x1e", $flags);
}

sub configure {
    my $this=shift;
    my @flags = $this->get_kf5_flags();

    return $this->SUPER::configure(@flags, @_);
}

1;