]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_install
remove some dh_install stuff
[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)>.
28
29 DESTDIR is used to tell make where to install the files. 
30 If the Makefile was generated by MakeMaker from a Makefile.PL, it will
31 automatically set PREFIX=/usr too, since such Makefiles need that.
32
33 This is intended to work for about 90% of packages. If it doesn't work, or
34 tries to use the wrong install target, you're encouraged to skip using
35 dh_auto_install at all, and just run make install manually.
36
37 =head1 OPTIONS
38
39 =over 4
40
41 =item B<--> I<params>
42
43 Pass "params" to the program that is run. These can be used to supplement
44 or override the any standard parameters that dh_auto_install passes.
45
46 =back
47
48 =cut
49
50 init();
51
52 my $destdir;
53 my @allpackages=getpackages();
54 if (@allpackages > 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
66         # Special case for MakeMaker generated Makefiles.
67         if (-e "Makefile" &&
68             system('grep -q "generated automatically by MakeMaker" Makefile') == 0) {
69                 push @params, "PREFIX=/usr";
70         }
71
72         foreach my $target (qw{install}) {
73                 # Use make -n to check to see if the target would do
74                 # anything. There's no good way to test if a target exists.
75                 my $ret=`$ENV{MAKE} -s -n $target 2>/dev/null`;
76                 chomp $ret;
77                 if (length $ret) {
78                         doit($ENV{MAKE}, $target,
79                                 @params,
80                                 @{$dh{U_PARAMS}});
81                         last;
82                 }
83         }
84 }
85 elsif (-e "setup.py") {
86         doit("python", "setup.py", "install", 
87                 "--root=$destdir",
88                 "--no-compile", "-O0",
89                 "--install-layout=deb",
90                 @{$dh{U_PARAMS}});
91 }
92 elsif (-e "Build.PL" && -e "Build") {
93         $ENV{MODULEBUILDRC} = "/dev/null";
94         doit("perl", "Build", "install", "destdir=$destdir",
95                 "create_packlist=0", @{$dh{U_PARAMS}});
96 }
97
98 =head1 SEE ALSO
99
100 L<debhelper(7)>
101
102 This program is a part of debhelper.
103
104 =head1 AUTHOR
105
106 Joey Hess <joeyh@debian.org>
107
108 =cut