]> git.donarmstrong.com Git - debhelper.git/blob - dh_builddeb
cmake: Pass CPPFLAGS in CFLAGS. Closes: #668813 Thanks, Simon Ruderich for the patch...
[debhelper.git] / dh_builddeb
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_builddeb - build Debian binary packages
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_builddeb> [S<I<debhelper options>>] [B<--destdir=>I<directory>] [B<--filename=>I<name>] [S<B<--> I<params>>]
15
16 =head1 DESCRIPTION
17
18 B<dh_builddeb> simply calls L<dpkg-deb(1)> to build a Debian package or
19 packages.
20
21 =head1 OPTIONS
22
23 =over 4
24
25 =item B<--destdir=>I<directory>
26
27 Use this if you want the generated F<.deb> files to be put in a directory
28 other than the default of "F<..>".
29
30 =item B<--filename=>I<name>
31
32 Use this if you want to force the generated .deb file to have a particular
33 file name. Does not work well if more than one .deb is generated!
34
35 =item B<--> I<params>
36
37 Pass I<params> to L<dpkg-deb(1)> when it is used to build the
38 package.
39
40 =item B<-u>I<params>
41
42 This is another way to pass I<params> to L<dpkg-deb(1)>.
43 It is deprecated; use B<--> instead.
44
45 =back
46
47 =cut
48
49 init(options => {
50         "filename=s" => \$dh{FILENAME},
51         "destdir=s" => \$dh{DESTDIR},
52 });
53
54 # Set the default destination directory.
55 if (! defined $dh{DESTDIR}) {
56         $dh{DESTDIR}='..';
57 }
58
59 if (! defined $dh{FILENAME}) {
60         $dh{FILENAME}='';
61 }
62 else {
63         $dh{FILENAME}="/$dh{FILENAME}";
64 }
65
66 my $max_procs=get_buildoption("parallel") || 1;
67
68 my $processes=1;
69 my $exit=0;
70 sub reap {
71         if (wait == -1) {
72                 $processes=0;
73         }
74         else {
75                 $processes--;
76                 $exit=1 if $? != 0;
77         }
78 }
79
80 foreach my $package (@{$dh{DOPACKAGES}}) {
81         my $pid=fork();
82         if (! defined $pid) {
83                 error("fork failed! $!");
84         }
85         if ($pid) { # parent
86                 $processes++;
87                 reap while $processes > $max_procs;
88                 next;
89         }
90
91         # child
92         my $tmp=tmpdir($package);
93         if (exists $ENV{DH_ALWAYS_EXCLUDE} && length $ENV{DH_ALWAYS_EXCLUDE}) {
94                 if (! compat(5)) {
95                         complex_doit("find $tmp $dh{EXCLUDE_FIND} | xargs rm -rf");
96                 }
97                 else {
98                         # Old broken code here for compatibility. Does not
99                         # remove everything.
100                         complex_doit("find $tmp -name $_ | xargs rm -rf")
101                                 foreach split(":", $ENV{DH_ALWAYS_EXCLUDE});
102                 }
103         }
104         if (! is_udeb($package)) {
105                 doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$dh{FILENAME});
106         }
107         else {
108                 my $filename=$dh{FILENAME};
109                 if (! $filename) {
110                         $filename="/".udeb_filename($package);
111                 }
112                 doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$filename);
113         }
114         exit 0;
115 }
116
117 reap while $processes;
118 exit $exit;
119
120 =head1 SEE ALSO
121
122 L<debhelper(7)>
123
124 This program is a part of debhelper.
125
126 =head1 AUTHOR
127
128 Joey Hess <joeyh@debian.org>
129
130 =cut