]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/qmake.pm
update from Kel
[debhelper.git] / Debian / Debhelper / Buildsystem / qmake.pm
1 # A debhelper build system class for Qt projects
2 # (based on the makefile class).
3 #
4 # Copyright: © 2010 Kelvin Modderman
5 # License: GPL-2+
6
7 package Debian::Debhelper::Buildsystem::qmake;
8
9 use strict;
10 use warnings;
11 use Debian::Debhelper::Dh_Lib qw(error);
12 use base 'Debian::Debhelper::Buildsystem::makefile';
13
14 sub DESCRIPTION {
15         "qmake (*.pro)";
16 }
17
18 sub check_auto_buildable {
19         my $this=shift;
20         my @projects=glob($this->get_sourcepath('*.pro'));
21         my $ret=0;
22
23         if (@projects > 0) {
24                 $ret=1;
25                 # Existence of a Makefile generated by qmake indicates qmake
26                 # class has already been used by a prior build step, so should
27                 # be used instead of the parent makefile class.
28                 my $mf=$this->get_buildpath("Makefile");
29                 if (-e $mf) {
30                         $ret = $this->SUPER::check_auto_buildable(@_);
31                         open(my $fh, '<', $mf)
32                                 or error("unable to open Makefile: $mf");
33                         while(<$fh>) {
34                                 if (m/^# Generated by qmake/i) {
35                                         $ret++;
36                                         last;
37                                 }
38                         }
39                         close($fh);
40                 }
41         }
42
43         return $ret;
44 }
45
46 sub configure {
47         my $this=shift;
48         my @options;
49         my @flags;
50
51         push @options, '-makefile';
52         push @options, '-nocache';
53
54         if ($ENV{CFLAGS}) {
55                 push @flags, "QMAKE_CFLAGS_RELEASE=$ENV{CFLAGS}";
56                 push @flags, "QMAKE_CFLAGS_DEBUG=$ENV{CFLAGS}";
57         }
58         if ($ENV{CXXFLAGS}) {
59                 push @flags, "QMAKE_CXXFLAGS_RELEASE=$ENV{CXXFLAGS}";
60                 push @flags, "QMAKE_CXXFLAGS_DEBUG=$ENV{CXXFLAGS}";
61         }
62         if ($ENV{LDFLAGS}) {
63                 push @flags, "QMAKE_LFLAGS_RELEASE=$ENV{LDFLAGS}";
64                 push @flags, "QMAKE_LFLAGS_DEBUG=$ENV{LDFLAGS}";
65         }
66         push @flags, "QMAKE_STRIP=:";
67         push @flags, "PREFIX=/usr";
68
69         $this->doit_in_builddir('qmake', @options, @flags, @_);
70 }
71
72 sub install {
73         my $this=shift;
74         my $destdir=shift;
75
76         # qmake generated Makefiles use INSTALL_ROOT in install target
77         # where one would expect DESTDIR to be used.
78         $this->SUPER::install($destdir, "INSTALL_ROOT=$destdir", @_);
79 }
80
81 1