]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_clean
Add a Makefile and simplify this package's own rules file using all the new toys.
[debhelper.git] / dh_auto_clean
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_auto_clean - automatically cleans up after a build
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_auto_clean> [S<I<debhelper options>>] [S<B<--> I<params>>]
15
16 =head1 DESCRIPTION
17
18 dh_auto_clean is a debhelper program that tries to automatically clean up
19 after a package build. If there's a Makefile and it contains a "distclean",
20 "realclean", or "clean" target, then this is  done by running make (or MAKE,
21 if the environment variable is set). If there is a setup.py, it is run to
22 clean the package.
23
24 This is intended to work for about 90% of packages. If it doesn't work, or
25 tries to use the wrong clean target, you're encoruaged to skip using
26 dh_auto_clean at all, and just run make clean 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. These can be used to suppliment
35 or override the any standard parameters that dh_auto_clean passes.
36
37 =back
38
39 =cut
40
41 init();
42
43 if (-e "Makefile" || -e "makefile" || -e "GNUmakefile") {
44         $ENV{MAKE}="make" unless exists $ENV{MAKE};
45         foreach my $target (qw{distclean realclean clean}) {
46                 # Make --question returns false if the target is
47                 # up-to-date. But we still want to run the target in this
48                 # case. So ceck if a target exists by seeing if make outputs
49                 # "Making target".
50                 my $ret=`LANG=C $ENV{MAKE} --question $target 2>/dev/null`;
51                 chomp $ret;
52                 print ">>$ret for $target\n";
53                 if ($ret =~ /^Making \Q$target\E/m) {
54                         doit($ENV{MAKE}, $target, @{$dh{U_PARAMS}});
55                         last;
56                 }
57         }
58 }
59 elsif (-e "setup.py") {
60         doit("python setup.py", "clean", "-a", @{$dh{U_PARAMS}});
61 }
62
63
64 =head1 SEE ALSO
65
66 L<debhelper(7)>
67
68 This program is a part of debhelper.
69
70 =head1 AUTHOR
71
72 Joey Hess <joeyh@debian.org>
73
74 =cut