3 use Test::More tests => 297;
9 use File::Temp qw(tempfile tempdir);
10 use File::Basename ();
12 # Let the tests to be run from anywhere but currect directory
13 # is expected to be the one where this test lives in.
14 chdir File::Basename::dirname($0) or die "Unable to chdir to ".File::Basename::dirname($0);
16 use_ok( 'Debian::Debhelper::Dh_Lib' );
17 use_ok( 'Debian::Debhelper::Buildsystem' );
18 use_ok( 'Debian::Debhelper::Dh_Buildsystems' );
21 my @STEPS = qw(configure build test install clean);
22 my $BS_CLASS = 'Debian::Debhelper::Buildsystem';
25 my ($tmp, @tmp, %tmp);
26 my ($tmpdir, $builddir, $default_builddir);
32 open FILE, ">", $file and close FILE or die "Unable to touch $file";
33 chmod $chmod, $file if defined $chmod;
38 system ("find", $dir, "-type", "f", "-delete");
49 my ($cmdline, $stdin) = @_;
50 my ($reader, $writer);
52 my $pid = open2($reader, $writer, $cmdline) or die "Unable to exec $cmdline";
53 print $writer $stdin if $stdin;
56 $? = $? >> 8; # exit status
57 return readlines($reader);
60 sub write_debian_rules {
64 if (-f "debian/rules") {
65 (undef, $backup) = tempfile(DIR => ".", OPEN => 0);
66 rename "debian/rules", $backup;
68 # Write debian/rules if requested
70 open(my $f, ">", "debian/rules");
73 chmod 0755, "debian/rules";
78 ### Test Buildsystem class API methods
79 is( $BS_CLASS->canonpath("path/to/the/./nowhere/../../somewhere"),
80 "path/to/somewhere", "canonpath no1" );
81 is( $BS_CLASS->canonpath("path/to/../forward/../../somewhere"),
82 "somewhere","canonpath no2" );
83 is( $BS_CLASS->canonpath("path/to/../../../somewhere"),
84 "../somewhere","canonpath no3" );
85 is( $BS_CLASS->canonpath("./"), ".", "canonpath no4" );
86 is( $BS_CLASS->canonpath("/absolute/path/./somewhere/../to/nowhere"),
87 "/absolute/path/to/nowhere", "canonpath no5" );
88 is( $BS_CLASS->_rel2rel("path/my/file", "path/my", "/tmp"),
89 "file", "_rel2rel no1" );
90 is( $BS_CLASS->_rel2rel("path/dir/file", "path/my", "/tmp"),
91 "../dir/file", "_rel2rel no2" );
92 is( $BS_CLASS->_rel2rel("file", "/root/path/my", "/root"),
93 "/root/file", "_rel2rel abs no3" );
94 is( $BS_CLASS->_rel2rel(".", ".", "/tmp"), ".", "_rel2rel no4" );
95 is( $BS_CLASS->_rel2rel("path", "path/", "/tmp"), ".", "_rel2rel no5" );
96 is( $BS_CLASS->_rel2rel("/absolute/path", "anybase", "/tmp"),
97 "/absolute/path", "_rel2rel abs no6");
98 is( $BS_CLASS->_rel2rel("relative/path", "/absolute/base", "/tmp"),
99 "/tmp/relative/path", "_rel2rel abs no7");
101 ### Test Buildsystem class path API methods under different configurations
102 sub test_buildsystem_paths_api {
103 my ($bs, $config, $expected)=@_;
107 is( $got, $expected->{$name}, "paths API ($config): $name")
110 &$api_is( $bs->get_sourcedir(), 'get_sourcedir()' );
111 &$api_is( $bs->get_sourcepath("a/b"), 'get_sourcepath(a/b)' );
112 &$api_is( $bs->get_builddir(), 'get_builddir()' );
113 &$api_is( $bs->get_buildpath(), 'get_buildpath()' );
114 &$api_is( $bs->get_buildpath("a/b"), 'get_buildpath(a/b)' );
115 &$api_is( $bs->get_source_rel2builddir(), 'get_source_rel2builddir()' );
116 &$api_is( $bs->get_source_rel2builddir("a/b"), 'get_source_rel2builddir(a/b)' );
117 &$api_is( $bs->get_build_rel2sourcedir(), 'get_build_rel2sourcedir()' );
118 &$api_is( $bs->get_build_rel2sourcedir("a/b"), 'get_build_rel2sourcedir(a/b)' );
122 $bs = $BS_CLASS->new();
123 $default_builddir = $bs->DEFAULT_BUILD_DIRECTORY();
125 "get_sourcedir()" => ".",
126 "get_sourcepath(a/b)" => "./a/b",
127 "get_builddir()" => undef,
128 "get_buildpath()" => ".",
129 "get_buildpath(a/b)" => "./a/b",
130 "get_source_rel2builddir()" => ".",
131 "get_source_rel2builddir(a/b)" => "./a/b",
132 "get_build_rel2sourcedir()" => ".",
133 "get_build_rel2sourcedir(a/b)" => "./a/b",
135 test_buildsystem_paths_api($bs, "no builddir, no sourcedir", \%tmp);
138 $bs = $BS_CLASS->new(builddir => "bld/dir");
140 "get_sourcedir()" => ".",
141 "get_sourcepath(a/b)" => "./a/b",
142 "get_builddir()" => "bld/dir",
143 "get_buildpath()" => "bld/dir",
144 "get_buildpath(a/b)" => "bld/dir/a/b",
145 "get_source_rel2builddir()" => "../..",
146 "get_source_rel2builddir(a/b)" => "../../a/b",
147 "get_build_rel2sourcedir()" => "bld/dir",
148 "get_build_rel2sourcedir(a/b)" => "bld/dir/a/b",
150 test_buildsystem_paths_api($bs, "builddir=bld/dir, no sourcedir", \%tmp);
152 # Default builddir, sourcedir=autoconf
153 $bs = $BS_CLASS->new(builddir => undef, sourcedir => "autoconf");
155 "get_sourcedir()" => "autoconf",
156 "get_sourcepath(a/b)" => "autoconf/a/b",
157 "get_builddir()" => "$default_builddir",
158 "get_buildpath()" => "$default_builddir",
159 "get_buildpath(a/b)" => "$default_builddir/a/b",
160 "get_source_rel2builddir()" => "../autoconf",
161 "get_source_rel2builddir(a/b)" => "../autoconf/a/b",
162 "get_build_rel2sourcedir()" => "../$default_builddir",
163 "get_build_rel2sourcedir(a/b)" => "../$default_builddir/a/b",
165 test_buildsystem_paths_api($bs, "default builddir, sourcedir=autoconf", \%tmp);
167 # sourcedir=autoconf (builddir should be dropped)
168 $bs = $BS_CLASS->new(builddir => "autoconf", sourcedir => "autoconf");
170 "get_sourcedir()" => "autoconf",
171 "get_sourcepath(a/b)" => "autoconf/a/b",
172 "get_builddir()" => undef,
173 "get_buildpath()" => "autoconf",
174 "get_buildpath(a/b)" => "autoconf/a/b",
175 "get_source_rel2builddir()" => ".",
176 "get_source_rel2builddir(a/b)" => "./a/b",
177 "get_build_rel2sourcedir()" => ".",
178 "get_build_rel2sourcedir(a/b)" => "./a/b",
180 test_buildsystem_paths_api($bs, "no builddir, sourcedir=autoconf", \%tmp);
182 # Prefer out of source tree building when
183 # sourcedir=builddir=autoconf hence builddir should be dropped.
184 $bs->prefer_out_of_source_building(builddir => "autoconf");
185 test_buildsystem_paths_api($bs, "out of source prefered, sourcedir=builddir", \%tmp);
187 # builddir=bld/dir, sourcedir=autoconf. Should be the same as sourcedir=autoconf.
188 $bs = $BS_CLASS->new(builddir => "bld/dir", sourcedir => "autoconf");
189 $bs->enforce_in_source_building();
190 test_buildsystem_paths_api($bs, "in source enforced, sourcedir=autoconf", \%tmp);
192 # builddir=../bld/dir (relative to the curdir)
193 $bs = $BS_CLASS->new(builddir => "bld/dir/", sourcedir => "autoconf");
195 "get_sourcedir()" => "autoconf",
196 "get_sourcepath(a/b)" => "autoconf/a/b",
197 "get_builddir()" => "bld/dir",
198 "get_buildpath()" => "bld/dir",
199 "get_buildpath(a/b)" => "bld/dir/a/b",
200 "get_source_rel2builddir()" => "../../autoconf",
201 "get_source_rel2builddir(a/b)" => "../../autoconf/a/b",
202 "get_build_rel2sourcedir()" => "../bld/dir",
203 "get_build_rel2sourcedir(a/b)" => "../bld/dir/a/b",
205 test_buildsystem_paths_api($bs, "builddir=../bld/dir, sourcedir=autoconf", \%tmp);
207 ### Test check_auto_buildable() of each buildsystem
208 sub test_check_auto_buildable {
212 my @steps=@_ || @STEPS;
214 if (! ref $expected) {
216 $all_steps{$_} = $expected foreach (@steps);
217 $expected = \%all_steps;
219 for my $step (@steps) {
221 if (exists $expected->{$step}) {
222 $e = $expected->{$step};
223 } elsif (exists $expected->{default}) {
224 $e = $expected->{default};
226 is( $bs->check_auto_buildable($step), $e,
227 $bs->NAME() . "($config): check_auto_buildable($step) == $e" );
231 $tmpdir = tempdir("tmp.XXXXXX");
232 $builddir = "$tmpdir/builddir";
235 builddir => "$tmpdir/builddir",
239 # Test if all buildsystems can be loaded
240 @bs = load_all_buildsystems([ $INC[0] ], %tmp);
241 @tmp = map { $_->NAME() } @bs;
242 ok(@Debian::Debhelper::Dh_Buildsystems::BUILDSYSTEMS >= 1, "some build systems are built in" );
243 is_deeply( \@tmp, \@Debian::Debhelper::Dh_Buildsystems::BUILDSYSTEMS, "load_all_buildsystems() loads all built-in buildsystems" );
245 # check_auto_buildable() fails with numeric 0
247 test_check_auto_buildable($bs, "fails with numeric 0", 0);
252 $bs{$bs->NAME()} = $bs;
255 touch "$tmpdir/configure", 0755;
256 test_check_auto_buildable($bs{autoconf}, "configure", { configure => 1 });
258 touch "$tmpdir/CMakeLists.txt";
259 test_check_auto_buildable($bs{cmake}, "CMakeLists.txt", { configure => 1 });
261 touch "$tmpdir/Makefile.PL";
262 test_check_auto_buildable($bs{perl_makemaker}, "Makefile.PL", { configure => 1 });
265 touch "$builddir/Makefile";
266 test_check_auto_buildable($bs{makefile}, "Makefile", 1);
267 test_check_auto_buildable($bs{autoconf}, "configure+Makefile", { configure => 1 });
268 test_check_auto_buildable($bs{cmake}, "CMakeLists.txt+Makefile", 1);
269 touch "$builddir/CMakeCache.txt"; # strong evidence that cmake was run
270 test_check_auto_buildable($bs{cmake}, "CMakeCache.txt+Makefile", 2);
272 # Makefile.PL forces in-source
273 #(see note in check_auto_buildable() why always 1 here)
274 unlink "$builddir/Makefile";
275 touch "$tmpdir/Makefile";
276 test_check_auto_buildable($bs{perl_makemaker}, "Makefile.PL+Makefile", 1);
278 # Perl Build.PL - handles always
279 test_check_auto_buildable($bs{perl_build}, "no Build.PL", 0);
280 touch "$tmpdir/Build.PL";
281 test_check_auto_buildable($bs{perl_build}, "Build.PL", { configure => 1 });
282 touch "$tmpdir/Build"; # forced in source
283 test_check_auto_buildable($bs{perl_build}, "Build.PL+Build", 1);
286 test_check_auto_buildable($bs{python_distutils}, "no setup.py", 0);
287 touch "$tmpdir/setup.py";
288 test_check_auto_buildable($bs{python_distutils}, "setup.py", 1);
292 ### Now test if it can autoselect a proper buildsystem for a typical package
293 sub test_autoselection {
297 for my $step (@STEPS) {
298 my $bs = load_buildsystem(undef, $step, @_);
300 $e = $expected->{$step} if ref $expected;
302 is( $bs->NAME(), $e, "autoselection($testname): $step=".((defined $e)?$e:'undef') );
305 is ( undef, $e, "autoselection($testname): $step=".((defined $e)?$e:'undef') );
307 &{$args{"code_$step"}}() if exists $args{"code_$step"};
311 # Auto-select nothing when no supported build system can be found
313 test_autoselection("auto-selects nothing", undef, %tmp);
316 touch "$tmpdir/configure", 0755;
317 touch "$builddir/Makefile";
318 test_autoselection("autoconf",
319 { configure => "autoconf", build => "makefile",
320 test => "makefile", install => "makefile", clean => "makefile" }, %tmp);
323 # Perl Makemaker (build, test, clean fail with builddir set [not supported])
324 touch "$tmpdir/Makefile.PL";
325 touch "$tmpdir/Makefile";
326 test_autoselection("perl_makemaker", "perl_makemaker", %tmp);
330 touch "$builddir/Makefile";
331 test_autoselection("makefile", "makefile", %tmp);
335 touch "$tmpdir/setup.py";
336 test_autoselection("python_distutils", "python_distutils", %tmp);
340 touch "$tmpdir/Build.PL";
341 touch "$tmpdir/Build";
342 test_autoselection("perl_build", "perl_build", %tmp);
346 touch "$tmpdir/CMakeLists.txt";
348 touch "$builddir/Makefile";
350 test_autoselection("cmake without CMakeCache.txt",
351 { configure => "cmake", build => "makefile",
352 test => "makefile", install => "makefile", clean => "makefile" }, %tmp,
353 code_configure => $tmp);
356 touch "$tmpdir/CMakeLists.txt";
358 touch "$builddir/Makefile";
359 touch "$builddir/CMakeCache.txt";
361 test_autoselection("cmake with CMakeCache.txt",
362 "cmake", %tmp, code_configure => $tmp);
365 touch "$tmpdir/CMakeLists.txt";
366 touch "$builddir/Makefile";
367 test_autoselection("cmake and existing Makefile", "makefile", %tmp);
370 ### Test Buildsystem::rmdir_builddir()
371 sub do_rmdir_builddir {
374 $system = $BS_CLASS->new(builddir => $builddir, sourcedir => $tmpdir);
375 $system->mkdir_builddir();
376 $system->rmdir_builddir();
379 $builddir = "$tmpdir/builddir";
380 do_rmdir_builddir($builddir);
381 ok ( ! -e $builddir, "testing rmdir_builddir() 1: builddir parent '$builddir' deleted" );
382 ok ( -d $tmpdir, "testing rmdir_builddir() 1: sourcedir '$tmpdir' remains" );
384 $builddir = "$tmpdir/bld";
385 do_rmdir_builddir("$builddir/dir");
386 ok ( ! -e $builddir, "testing rmdir_builddir() 2: builddir parent '$builddir' deleted" );
387 ok ( -d $tmpdir, "testing rmdir_builddir() 2: sourcedir '$tmpdir' remains" );
389 $builddir = "$tmpdir/bld";
391 touch "$builddir/afile";
392 mkdir "$builddir/dir";
393 touch "$builddir/dir/afile2";
394 do_rmdir_builddir("$builddir/dir");
395 ok ( ! -e "$builddir/dir", "testing rmdir_builddir() 3: builddir '$builddir/dir' not empty, but deleted" );
396 ok ( -d $builddir, "testing rmdir_builddir() 3: builddir parent '$builddir' not empty, remains" );
400 ### Test buildsystems_init() and commandline/env argument handling
401 sub get_load_bs_source {
402 my ($system, $step)=@_;
403 $step = (defined $step) ? "'$step'" : 'undef';
404 $system = (defined $system) ? "'$system'" : 'undef';
409 use Debian::Debhelper::Dh_Buildsystems;
412 my \$bs = load_buildsystem($system, $step);
414 print 'NAME=', \$bs->NAME(), "\\n";
415 print \$_, "=", (defined \$bs->{\$_}) ? \$bs->{\$_} : 'undef', "\\n"
416 foreach (sort keys \%\$bs);
421 $tmp = Cwd::getcwd();
422 # NOTE: disabling parallel building explicitly (it might get automatically
423 # enabled if run under dpkg-buildpackage -jX) to make output deterministic.
424 is_deeply( process_stdout("$^X -- - --builddirectory='autoconf/bld dir' --sourcedirectory autoconf --max-parallel=1",
425 get_load_bs_source(undef, "configure")),
426 [ 'NAME=autoconf', 'builddir=autoconf/bld dir', "cwd=$tmp", 'makecmd=make', 'parallel=1', 'sourcedir=autoconf' ],
427 "autoconf autoselection and sourcedir/builddir" );
429 is_deeply( process_stdout("$^X -- - -Sautoconf -D autoconf --max-parallel=1", get_load_bs_source("autoconf", "build")),
430 [ 'NAME=autoconf', 'builddir=undef', "cwd=$tmp", 'makecmd=make', 'parallel=1', 'sourcedir=autoconf' ],
431 "forced autoconf and sourcedir" );
433 is_deeply( process_stdout("$^X -- - -B -Sautoconf --max-parallel=1", get_load_bs_source("autoconf", "build")),
434 [ 'NAME=autoconf', "builddir=$default_builddir", "cwd=$tmp", 'makecmd=make', 'parallel=1', 'sourcedir=.' ],
435 "forced autoconf and default build directory" );
437 # Build the autoconf test package
438 sub dh_auto_do_autoconf {
443 my (@lines, @extra_args);
444 my $buildpath = $sourcedir;
445 my @dh_auto_args = ("-D", $sourcedir);
446 my $dh_auto_str = "-D $sourcedir";
448 push @dh_auto_args, "-B", $builddir;
449 $dh_auto_str .= " -B $builddir";
450 $buildpath = $builddir;
453 my $do_dh_auto = sub {
457 if (exists $args{"${step}_args"}) {
458 push @extra_args, @{$args{"${step}_args"}};
459 $extra_str .= " $_" foreach (@extra_args);
461 is ( system("$TOPDIR/dh_auto_$step", @dh_auto_args, "--", @extra_args), 0,
462 "dh_auto_$step $dh_auto_str$extra_str" );
466 @extra_args = &$do_dh_auto('configure');
467 ok ( -f "$buildpath/Makefile", "$buildpath/Makefile exists" );
469 if (ok( open(FILE, "$buildpath/stamp_configure"), "$buildpath/stamp_configure exists") ) {
470 @lines = @{readlines(\*FILE)};
472 is_deeply( \@lines, \@extra_args, "$buildpath/stamp_configure contains extra args" );
474 &$do_dh_auto('build');
475 ok ( -f "$buildpath/stamp_build", "$buildpath/stamp_build exists" );
476 &$do_dh_auto('test');
477 ok ( -f "$buildpath/stamp_test", "$buildpath/stamp_test exists" );
478 &$do_dh_auto('install');
480 if ( ok(open(FILE, "$buildpath/stamp_install"), "$buildpath/stamp_install exists") ) {
481 @lines = @{readlines(\*FILE)};
483 is_deeply( \@lines, [ "DESTDIR=".Cwd::getcwd()."/debian/testpackage" ],
484 "$buildpath/stamp_install contains DESTDIR" );
485 &$do_dh_auto('clean');
487 ok ( ! -e "$buildpath", "builddir $buildpath was removed" );
490 ok ( ! -e "$buildpath/Makefile" && ! -e "$buildpath/stamp_configure", "Makefile and stamps gone" );
492 ok ( -x "$sourcedir/configure", "configure script renamins after clean" );
495 dh_auto_do_autoconf('autoconf');
496 dh_auto_do_autoconf('autoconf', 'bld/dir', configure_args => [ "--extra-autoconf-configure-arg" ]);
497 ok ( ! -e 'bld', "bld got deleted too" );
499 #### Test parallel building and related options / routines
500 @tmp = ( $ENV{MAKEFLAGS}, $ENV{DEB_BUILD_OPTIONS} );
502 # Test clean_jobserver_makeflags.
504 $ENV{MAKEFLAGS} = "--jobserver-fds=103,104 -j";
505 clean_jobserver_makeflags();
506 ok(! exists $ENV{MAKEFLAGS}, "unset makeflags");
508 $ENV{MAKEFLAGS} = "-a --jobserver-fds=103,104 -j -b";
509 clean_jobserver_makeflags();
510 is($ENV{MAKEFLAGS}, "-a -b", "clean makeflags");
512 $ENV{MAKEFLAGS} = " --jobserver-fds=1,2 -j ";
513 clean_jobserver_makeflags();
514 ok(! exists $ENV{MAKEFLAGS}, "unset makeflags");
516 $ENV{MAKEFLAGS} = "-a -j -b";
517 clean_jobserver_makeflags();
518 is($ENV{MAKEFLAGS}, "-a -j -b", "clean makeflags does not remove -j");
520 $ENV{MAKEFLAGS} = "-a --jobs -b";
521 clean_jobserver_makeflags();
522 is($ENV{MAKEFLAGS}, "-a --jobs -b", "clean makeflags does not remove --jobs");
524 $ENV{MAKEFLAGS} = "-j6";
525 clean_jobserver_makeflags();
526 is($ENV{MAKEFLAGS}, "-j6", "clean makeflags does not remove -j6");
528 $ENV{MAKEFLAGS} = "-a -j6 --jobs=7";
529 clean_jobserver_makeflags();
530 is($ENV{MAKEFLAGS}, "-a -j6 --jobs=7", "clean makeflags does not remove -j or --jobs");
532 $ENV{MAKEFLAGS} = "-j6 --jobserver-fds=103,104 --jobs=8";
533 clean_jobserver_makeflags();
534 is($ENV{MAKEFLAGS}, "-j6 --jobs=8", "jobserver options removed");
536 # Test parallel building with makefile build system.
537 $ENV{MAKEFLAGS} = "";
538 $ENV{DEB_BUILD_OPTIONS} = "";
541 my $dh_opts=shift || "";
542 my $make_opts=shift || "";
543 return process_stdout(
544 "LANG=C LC_ALL=C LC_MESSAGES=C $TOPDIR/dh_auto_build -Smakefile $dh_opts " .
545 "-- -s -f parallel.mk $make_opts 2>&1 >/dev/null", "");
548 sub test_isnt_parallel {
549 my ($got, $desc) = @_;
550 my @makemsgs = grep /^make[\d\[\]]*:/, @$got;
552 like( $makemsgs[0], qr/Error 10/, $desc );
555 ok( scalar(@makemsgs) > 0, $desc );
559 sub test_is_parallel {
560 my ($got, $desc) = @_;
561 is_deeply( $got, [] , $desc );
562 is( $?, 0, "(exit status=0) $desc");
565 test_isnt_parallel( do_parallel_mk(),
566 "No parallel by default" );
567 test_isnt_parallel( do_parallel_mk("parallel"),
568 "No parallel by default with --parallel" );
569 test_isnt_parallel( do_parallel_mk("--max-parallel=5"),
570 "No parallel by default with --max-parallel=5" );
572 $ENV{DEB_BUILD_OPTIONS}="parallel=5";
573 test_isnt_parallel( do_parallel_mk(),
574 "DEB_BUILD_OPTIONS=parallel=5 without parallel options" );
575 test_is_parallel( do_parallel_mk("--parallel"),
576 "DEB_BUILD_OPTIONS=parallel=5 with --parallel" );
577 test_is_parallel( do_parallel_mk("--max-parallel=2"),
578 "DEB_BUILD_OPTIONS=parallel=5 with --max-parallel=2" );
579 test_isnt_parallel( do_parallel_mk("--max-parallel=1"),
580 "DEB_BUILD_OPTIONS=parallel=5 with --max-parallel=1" );
582 $ENV{MAKEFLAGS} = "--jobserver-fds=105,106 -j";
583 $ENV{DEB_BUILD_OPTIONS}="";
584 test_isnt_parallel( do_parallel_mk(),
585 "makefile.pm (no parallel): no make warnings about unavailable jobserver" );
586 $ENV{DEB_BUILD_OPTIONS}="parallel=5";
587 test_is_parallel( do_parallel_mk("--parallel"),
588 "DEB_BUILD_OPTIONS=parallel=5: no make warnings about unavail parent jobserver" );
590 $ENV{MAKEFLAGS} = "-j2";
591 $ENV{DEB_BUILD_OPTIONS}="";
592 test_isnt_parallel( do_parallel_mk(),
593 "MAKEFLAGS=-j2: dh_auto_build ignores MAKEFLAGS" );
594 test_isnt_parallel( do_parallel_mk("--max-parallel=1"),
595 "MAKEFLAGS=-j2 with --max-parallel=1: dh_auto_build enforces -j1" );
597 # Test dh dpkg-buildpackage -jX detection
598 sub do_rules_for_parallel {
599 my $cmdline=shift || "";
600 my $stdin=shift || "";
601 return process_stdout("LANG=C LC_ALL=C LC_MESSAGES=C PATH=$TOPDIR:\$PATH " .
602 "make -f - $cmdline 2>&1 >/dev/null", $stdin);
605 doit("ln", "-sf", "parallel.mk", "Makefile");
607 # Test if dh+override+$(MAKE) legacy punctuation hack work as before
608 $ENV{MAKEFLAGS} = "-j5";
609 $ENV{DEB_BUILD_OPTIONS} = "parallel=5";
611 $tmp = write_debian_rules(<<'EOF');
613 override_dh_auto_build:
616 @dh_clean > /dev/null 2>&1
617 @+dh --buildsystem=makefile --after=dh_auto_configure --until=dh_auto_build $@
618 @dh_clean > /dev/null 2>&1
620 test_is_parallel( do_rules_for_parallel("build", "include debian/rules"),
621 "legacy punctuation hacks: +dh, override with \$(MAKE)" );
622 unlink "debian/rules";
625 rename($tmp, "debian/rules");
628 unlink("debian/rules");
631 # Clean up after parallel testing
633 system("rm", "-f", "Makefile");
635 $ENV{MAKEFLAGS} = $tmp[0] if defined $tmp[0];
636 $ENV{DEB_BUILD_OPTIONS} = $tmp[1] if defined $tmp[1];
639 system("rm", "-rf", $tmpdir);
640 system("$TOPDIR/dh_clean");