5 dh_auto_clean - automatically cleans up after a build
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_auto_clean> [S<I<debhelper options>>] [S<B<--> I<params>>]
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 or Build.PL, it
22 is run to clean the package.
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 encouraged to skip using
26 dh_auto_clean at all, and just run make clean manually.
34 Pass "params" to the program that is run. These can be used to supplement
35 or override the any standard parameters that dh_auto_clean passes.
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 # Use make -n to check to see if the target would do
47 # anything. There's no good way to test if a target exists.
48 my $ret=`$ENV{MAKE} -s -n $target 2>/dev/null`;
51 doit($ENV{MAKE}, $target, @{$dh{U_PARAMS}});
56 elsif (-e "setup.py") {
57 doit("python", "setup.py", "clean", "-a", @{$dh{U_PARAMS}});
58 # The setup.py might import files, leading to python creating pyc
60 doit('find', '.', '-name', '*.pyc', '-exec', 'rm', '{}', ';');
62 elsif (-e "Build.PL" && -e "Build") {
63 $ENV{MODULEBUILDRC} = "/dev/null";
64 doit("perl", "Build", "--allow_mb_mismatch", 1, "distclean", @{$dh{U_PARAMS}});
71 This program is a part of debhelper.
75 Joey Hess <joeyh@debian.org>