]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_configure
clarify
[debhelper.git] / dh_auto_configure
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_auto_configure - automatically configure a package prior to building
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_auto_configure> [S<I<debhelper options>>] [S<B<--> I<params>>]
15
16 =head1 DESCRIPTION
17
18 dh_auto_configure is a debhelper program that tries to automatically
19 configure a package prior to building. It looks for and runs a ./configure
20 script, Makefile.PL, or Build.PL. A standard set of parameters is
21 determined and passed to the program that is run. If no program to run is
22 found, dh_auto_configure will exit without doing anything.
23
24 This is intended to work for about 90% of packages. If it doesn't work,
25 you're encouraged to skip using dh_auto_configure at all, and just run
26 ./configure or its equivalent manually.
27
28 =head1 OPTIONS
29
30 =over 4
31
32 =item B<--> I<params>
33
34 Pass "params" to the program that is run, after the standard
35 parameters that dh_auto_configure passes. This can be used to supplement
36 or override those parameters.
37
38 =back
39
40 =cut
41
42 init();
43
44 sub dpkg_architecture_value {
45         my $var=shift;
46         my $value=`dpkg-architecture -q$var 2>/dev/null` || error("dpkg-architecture failed");
47         chomp $value;
48         return $value;
49 }
50
51 sub sourcepackage {
52         open (CONTROL, 'debian/control') ||
53                 error("cannot read debian/control: $!\n");
54         while (<CONTROL>) {
55                 chomp;
56                 s/\s+$//;
57                 if (/^Source:\s*(.*)/) {
58                         close CONTROL;
59                         return $1;
60                 }
61         }
62
63         close CONTROL;
64         error("could not find Source: line in control file.");
65 }
66
67 if (-x "configure") {
68         # Standard set of options for configure.
69         my @opts;
70         push @opts, "--build=".dpkg_architecture_value("DEB_BUILD_GNU_TYPE");
71         push @opts, "--prefix=/usr";
72         push @opts, "--includedir=\${prefix}/include";
73         push @opts, "--mandir=\${prefix}/share/man";
74         push @opts, "--infodir=\${prefix}/share/info";
75         push @opts, "--sysconfdir=/etc";
76         push @opts, "--localstatedir=/var";
77         push @opts, "--libexecdir=\${prefix}/lib/".sourcepackage();
78         push @opts, "--disable-maintainer-mode";
79         push @opts, "--disable-dependency-tracking";
80         # Provide --host only if different from --build, as recommended in
81         # autotools-dev README.Debian: When provided (even if equal) autotools
82         # 2.52+ switches to cross-compiling mode.
83         if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
84                 push @opts, "--host=".dpkg_architecture_value("DEB_HOST_GNU_TYPE");
85         }
86         doit("./configure", @opts, @{$dh{U_PARAMS}});
87 }
88 elsif (-e "Makefile.PL") {
89         # If set to a true value then MakeMaker's prompt function will
90         # # always return the default without waiting for user input.
91         $ENV{PERL_MM_USE_DEFAULT}=1;
92         doit("perl", "Makefile.PL", "INSTALLDIRS=vendor", @{$dh{U_PARAMS}});
93 }
94 elsif (-e "Build.PL") {
95         $ENV{PERL_MM_USE_DEFAULT}=1; # Module::Build can also use this.
96         $ENV{MODULEBUILDRC} = "/dev/null";
97         doit("perl", "Build.PL", "installdirs=vendor", @{$dh{U_PARAMS}});
98 }
99
100 =head1 SEE ALSO
101
102 L<debhelper(7)>
103
104 This program is a part of debhelper.
105
106 =head1 AUTHOR
107
108 Joey Hess <joeyh@debian.org>
109
110 =cut