1 # A buildsystem plugin for handling simple Makefile based projects.
3 # Copyright: © 2008 Joey Hess
4 # © 2008-2009 Modestas Vainius
7 package Debian::Debhelper::Buildsystem::makefile;
10 use Debian::Debhelper::Dh_Lib;
11 use base 'Debian::Debhelper::Dh_Buildsystem';
15 if ($self->get_builddir()) {
16 return $self->{makecmd} . " -C " . $self->get_builddir();
18 return $self->{makecmd};
21 sub exists_make_target {
22 my ($self, $target) = @_;
23 my $makecmd=$self->get_makecmd_C();
25 # Use make -n to check to see if the target would do
26 # anything. There's no good way to test if a target exists.
27 my $ret=`$makecmd -s -n $target 2>/dev/null`;
32 sub make_first_existing_target {
36 foreach my $target (@$targets) {
37 if ($self->exists_make_target($target)) {
38 $self->doit_in_builddir($self->{makecmd}, $target, @_);
46 "support for building Makefile based packages (make && make install)"
51 my $self=$cls->SUPER::new(@_);
52 $self->{makecmd} = (exists $ENV{MAKE}) ? $ENV{MAKE} : "make";
56 sub check_auto_buildable {
60 # Handles build, test, install, clean; configure - next class
61 # XXX JEH shouldn't it also handle configure, just as a no-op?
62 # XXX MDX No, then cmake.mk would have no chance of hitting for
64 if (grep /^\Q$action\E$/, qw{build test install clean}) {
65 # This is always called in the source directory, but generally
66 # Makefiles are created (or live) in the the build directory.
67 return -e $self->get_buildpath("Makefile") ||
68 -e $self->get_buildpath("makefile") ||
69 -e $self->get_buildpath("GNUmakefile");
76 $self->doit_in_builddir($self->{makecmd}, @_);
81 $self->make_first_existing_target(['test', 'check'], @_);
87 $self->make_first_existing_target(['install'], "DESTDIR=$destdir", @_);
92 if (!$self->clean_builddir()) {
93 $self->make_first_existing_target(['distclean', 'realclean', 'clean'], @_);