File: Builder.pm

package info (click to toggle)
liblinux-systemd-perl 1.201600-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 284 kB
  • sloc: perl: 640; makefile: 7
file content (38 lines) | stat: -rw-r--r-- 749 bytes parent folder | download
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
package My::Builder;

use v5.16;
use strict;
use warnings;
use base 'Module::Build';

use ExtUtils::PkgConfig;

sub new {
    my ($class, %args) = @_;

    my $pkg_name = 'libsystemd';
    my %pkg_info;

    eval {
        %pkg_info = ExtUtils::PkgConfig->find($pkg_name);
    };
    if ($@) {
        say
          'Do you need to install libsystemd-dev (debian) or systemd-devel (fedora)?';
        exit;
    }

    say "Found libsystemd-dev version: $pkg_info{modversion}";

    if (defined $pkg_info{cflags}) {
        $args{extra_compiler_flags} = $pkg_info{cflags};
    }
    $args{extra_compiler_flags} .= ' -std=c99';
    $args{extra_linker_flags} = $pkg_info{libs};

    my $builder = Module::Build->new(%args);

    return $builder;
}

1;