Hey Joey,

After reading #363150 and #409953 and observing that a few packages call
a versioned qmake binary (eg. qmake-qt4) rather than just 'qmake', and also
seeing that build classes might possibly support option parsing in the future
I'd like to put forward a version of the build class which would accept
a --qmake= option, based on the examples in the option parsing patch attached
to #543507. It'd allow:

    dh_auto_configure --qmake=qmake-qt3

... and the build class would call qmake-qt3 instead of the unversioned qmake,
which may point to an alternative qmake binary if other versions of qt are
installed in system.

What are your thoughts about it? Example packages which may use the option
are touchfreeze, keepassx.

Where's the best place to document the build system? POD in the class file?

Thanks, Kel
---
# A debhelper build system class for Qt projects
# (based on the makefile class).
#
# Copyright: © 2010 Kelvin Modderman
# License: GPL-2+

package Debian::Debhelper::Buildsystem::qmake;

use strict;
use warnings;
use Debian::Debhelper::Dh_Lib qw(error);
use base 'Debian::Debhelper::Buildsystem::makefile';

sub DESCRIPTION {
        "qmake (*.pro)";
}

sub OPTIONS {
        my $this=shift;
        ("qmake=s" => \$this->{opt_qmake})
}

sub check_auto_buildable {
        my $this=shift;
        my @projects=glob($this->get_sourcepath('*.pro'));
        my $ret=0;

        if (@projects > 0) {
                $ret=1;
                # Existence of a Makefile generated by qmake indicates qmake
                # class has already been used by a prior build step, so should
                # be used instead of the parent makefile class.
                my $mf=$this->get_buildpath("Makefile");
                if (-e $mf) {
                        $ret = $this->SUPER::check_auto_buildable(@_);
                        open(my $fh, '<', $mf)
                                or error("unable to open Makefile: $mf");
                        while(<$fh>) {
                                if (m/^# Generated by qmake/i) {
                                        $ret++;
                                        last;
                                }
                        }
                        close($fh);
                }
        }

        return $ret;
}

sub configure {
        my $this=shift;
        my $qmake=$this->{opt_qmake} ? $this->{opt_qmake} : "qmake";
        my @options;
        my @flags;

        push @options, '-makefile';
        push @options, '-nocache';

        if ($ENV{CFLAGS}) {
                push @flags, "QMAKE_CFLAGS_RELEASE=$ENV{CFLAGS}";
                push @flags, "QMAKE_CFLAGS_DEBUG=$ENV{CFLAGS}";
        }
        if ($ENV{CXXFLAGS}) {
                push @flags, "QMAKE_CXXFLAGS_RELEASE=$ENV{CXXFLAGS}";
                push @flags, "QMAKE_CXXFLAGS_DEBUG=$ENV{CXXFLAGS}";
        }
        if ($ENV{LDFLAGS}) {
                push @flags, "QMAKE_LFLAGS_RELEASE=$ENV{LDFLAGS}";
                push @flags, "QMAKE_LFLAGS_DEBUG=$ENV{LDFLAGS}";
        }
        push @flags, "QMAKE_STRIP=:";
        push @flags, "PREFIX=/usr";

        $this->doit_in_builddir($qmake, @options, @flags, @_);
}

sub install {
        my $this=shift;
        my $destdir=shift;

        # qmake generated Makefiles use INSTALL_ROOT in install target
        # where one would expect DESTDIR to be used.
        $this->SUPER::install($destdir, "INSTALL_ROOT=$destdir", @_);
}

1;
---



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to