]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_install
dh_auto_install: New program, automates running make install, or using setup.py to...
[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, 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                 # Make --question returns false if the target is
71                 # up-to-date. But we still want to run the target in this
72                 # case. So check if a target exists by seeing if make outputs
73                 # "Making target".
74                 my $ret=`LANG=C $ENV{MAKE} --question $target 2>/dev/null`;
75                 chomp $ret;
76                 if ($ret =~ /^Making \Q$target\E/m) {
77                         doit($ENV{MAKE}, $target,
78                                 @params,
79                                 @{$dh{U_PARAMS}});
80                         last;
81                 }
82         }
83 }
84 elsif (-e "setup.py") {
85         doit("python setup.py", "install", 
86                 "--root=$destdir",
87                 "--no-compile", "-O0",
88                 @{$dh{U_PARAMS}});
89 }
90
91
92 =head1 SEE ALSO
93
94 L<debhelper(7)>
95
96 This program is a part of debhelper.
97
98 =head1 AUTHOR
99
100 Joey Hess <joeyh@debian.org>
101
102 =cut