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