]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_install
dh_auto_*: Also support packages using Module::Build.
[debhelper.git] / dh_auto_install
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_auto_install - automatically runs make install or similar
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11 use Cwd;
12
13 =head1 SYNOPSIS
14
15 B<dh_auto_install> [S<I<debhelper options>>] [S<B<--> I<params>>]
16
17 =head1 DESCRIPTION
18
19 dh_auto_install is a debhelper program that tries to automatically install
20 built files. If there's a Makefile and it contains a "install" target,
21 then this is done by running make (or MAKE, if the environment variable is
22 set). If there is a setup.py or Build.PL, it is used.
23
24 The files are installed into debian/<package>/ if there is only one binary
25 package to act on. In the multiple binary package case, the files are
26 instead installed into debian/tmp/, and should be moved from there to the
27 appropriate package build directory using L<dh_install(1)> or
28 L<dh_movefiles(1)>.
29
30 DESTDIR is used to tell make where to install the files. 
31 If the Makefile was generated by MakeMaker from a Makefile.PL, it will
32 automatically set PREFIX=/usr too, since such Makefiles need that.
33
34 This is intended to work for about 90% of packages. If it doesn't work, or
35 tries to use the wrong clean target, you're encoruaged to skip using
36 dh_auto_install at all, and just run make install manually.
37
38 =head1 OPTIONS
39
40 =over 4
41
42 =item B<--> I<params>
43
44 Pass "params" to the program that is run. These can be used to suppliment
45 or override the any standard parameters that dh_auto_clean passes.
46
47 =back
48
49 =cut
50
51 init();
52
53 my $destdir;
54 if (@{$dh{DOPACKAGES}} > 1) {
55         $destdir="debian/tmp";
56 }
57 else {
58         $destdir=tmpdir($dh{MAINPACKAGE});
59 }
60 $destdir=cwd()."/".$destdir;
61
62 if (-e "Makefile" || -e "makefile" || -e "GNUmakefile") {
63         $ENV{MAKE}="make" unless exists $ENV{MAKE};
64         my @params="DESTDIR=$destdir";
65         # Special case for MakeMaker.
66         if (-e "Makefile.PL") {
67                 push @params, "PREFIX=/usr";
68         }
69         foreach my $target (qw{install}) {
70                 # Use make -n to check to see if the target would do
71                 # anything. There's no good way to test if a target exists.
72                 my $ret=`$ENV{MAKE} -s -n $target 2>/dev/null`;
73                 chomp $ret;
74                 if (length $ret) {
75                         doit($ENV{MAKE}, $target,
76                                 @params,
77                                 @{$dh{U_PARAMS}});
78                         last;
79                 }
80         }
81 }
82 elsif (-e "setup.py") {
83         doit("python", "setup.py", "install", 
84                 "--root=$destdir",
85                 "--no-compile", "-O0",
86                 @{$dh{U_PARAMS}});
87 }
88 elsif (-e "Build.PL" && -e "Build") {
89         doit("perl", "Build", "install", "destdir=$destdir",
90                 "create_packlist=0", @{$dh{U_PARAMS}});
91 }
92
93 =head1 SEE ALSO
94
95 L<debhelper(7)>
96
97 This program is a part of debhelper.
98
99 =head1 AUTHOR
100
101 Joey Hess <joeyh@debian.org>
102
103 =cut