aboutsummaryrefslogtreecommitdiffstats
path: root/grpmi/rpm/Makefile.PL
blob: b50225021de47abda7a39cd948889c0a58167f70 (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
use ExtUtils::MakeMaker;
use Config;

my $rpm_cflags = '-I/usr/include/rpm';
my $rpm_libs   = '-lrpm -lrpmdb -lrpmio -lpopt';

ccompile('#include <rpm/rpmlib.h>
          #include <rpm/misc.h>
         ',
	 'rpmdb db;',
	 $rpm_cflags,
	 $rpm_libs)
  or
  die_('rpm devel environment is needed');


WriteMakefile(
    'NAME'         => 'grpmi_rpm',
    'LIBS'         => [ $rpm_libs ],
    'VERSION_FROM' => 'grpmi_rpm.pm', # finds VERSION
    'OBJECT'       => 'grpmi_rpm.o',
    'INC'          => $rpm_cflags,
    'OPTIMIZE'     => '-O2 -Wall -Werror -g',
    'MAKEFILE'     => 'Makefile_c',
);




# Taken from Makefile.PL from Gtk-Perl
sub ccompile {
	my ($headers, $main, $cflags, $libs) = @_;
	my $fname = "temctest";
	my $r;
	chomp($cflags, $libs);
	open(CTEST, ">$fname.c") || return 0;
	print CTEST <<"EOTEST";
$headers

int main (int argc, char* argv[]) {
$main;
}
EOTEST
	close(CTEST);
	$r = system("$Config{cc} -o $fname $fname.c $cflags $libs 2>/dev/null 1>/dev/null");
	warn("RUNNING: $Config{cc} -o $fname $fname.c $cflags $libs\n") if $ENV{VERBOSE};
	unlink($fname, "$fname.c");
	return $r == 0;
}

sub chomp_ { my @l = map { my $l = $_; chomp $l; $l } @_; wantarray ? @l : $l[0] }
sub die_ { die "\n   **ERROR**: @_\n\n" }