]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_install
dh_auto_install: Still contained copy&paste doc from dh_auto_clean
[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. In the multiple binary package case, the files are instead
26 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 install target, you're encouraged 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_install passes.
46
47 =back
48
49 =cut
50
51 init();
52
53 my $destdir;
54 my @allpackages=getpackages();
55 if (@allpackages > 1) {
56         $destdir="debian/tmp";
57 }
58 else {
59         $destdir=tmpdir($dh{MAINPACKAGE});
60 }
61 $destdir=cwd()."/".$destdir;
62
63 if (-e "Makefile" || -e "makefile" || -e "GNUmakefile") {
64         $ENV{MAKE}="make" unless exists $ENV{MAKE};
65         my @params="DESTDIR=$destdir";
66         # Special case for MakeMaker.
67         if (-e "Makefile.PL") {
68                 push @params, "PREFIX=/usr";
69         }
70         foreach my $target (qw{install}) {
71                 # Use make -n to check to see if the target would do
72                 # anything. There's no good way to test if a target exists.
73                 my $ret=`$ENV{MAKE} -s -n $target 2>/dev/null`;
74                 chomp $ret;
75                 if (length $ret) {
76                         doit($ENV{MAKE}, $target,
77                                 @params,
78                                 @{$dh{U_PARAMS}});
79                         last;
80                 }
81         }
82 }
83 elsif (-e "setup.py") {
84         doit("python", "setup.py", "install", 
85                 "--root=$destdir",
86                 "--no-compile", "-O0",
87                 @{$dh{U_PARAMS}});
88 }
89 elsif (-e "Build.PL" && -e "Build") {
90         doit("perl", "Build", "install", "destdir=$destdir",
91                 "create_packlist=0", @{$dh{U_PARAMS}});
92 }
93
94 =head1 SEE ALSO
95
96 L<debhelper(7)>
97
98 This program is a part of debhelper.
99
100 =head1 AUTHOR
101
102 Joey Hess <joeyh@debian.org>
103
104 =cut