]> git.donarmstrong.com Git - debhelper.git/blob - t/buildsystems/autoconf/configure
Add a test suite for build systems.
[debhelper.git] / t / buildsystems / autoconf / configure
1 #!/usr/bin/perl
2
3 # Emulate autoconf behaviour and do some checks
4
5 use strict;
6 use warnings;
7
8 my @OPTIONS=qw(
9    ^--build=.*$
10    ^--prefix=/usr$
11    ^--includedir=\$\{prefix\}/include$
12    ^--mandir=\$\{prefix\}/share/man$
13    ^--infodir=\$\{prefix\}/share/info$
14    ^--sysconfdir=/etc$
15    ^--localstatedir=/var$
16    ^--libexecdir=\$\{prefix\}/lib/.*$
17    ^--disable-maintainer-mode$
18    ^--disable-dependency-tracking$
19 );
20
21 # Verify if all command line arguments were passed
22 my @options = map { { regex => qr/$_/,
23                       str => $_,
24                       found => 0 } } @OPTIONS;
25 my @extra_args;
26 ARGV_LOOP: foreach my $arg (@ARGV) {
27         foreach my $opt (@options) {
28                 if ($arg =~ $opt->{regex}) {
29                         $opt->{found} = 1;
30                         next ARGV_LOOP;
31                 }
32         }
33         # Extra / unrecognized argument
34         push @extra_args, $arg;
35 }
36
37 my @notfound = grep { ! $_->{found} and $_ } @options;
38 if (@notfound) {
39         print STDERR "Error: the following default options were NOT passed\n";
40         print STDERR "  ", $_->{str}, "\n" foreach (@notfound);
41         exit 1;
42 }
43
44 # Create a simple Makefile
45 open(MAKEFILE, ">", "Makefile");
46 print MAKEFILE <<EOF;
47 CONFIGURE := $0
48 all: stamp_configure \$(CONFIGURE)
49         \@echo Package built > stamp_build
50
51 # Tests if dh_auto_test executes 'check' target if 'test' does not exist
52 check: \$(CONFIGURE) stamp_build
53         \@echo Tested > stamp_test
54
55 install: stamp_build
56         \@echo DESTDIR=\$(DESTDIR) > stamp_install
57
58 # Tests whether dh_auto_clean executes distclean but does not touch
59 # this target
60 clean:
61         echo "This should not have been executed" >&2 && exit 1
62
63 distclean:
64         \@rm -f stamp_* Makefile
65
66 .PHONY: all check install clean distclean
67 EOF
68 close MAKEFILE;
69
70 open(STAMP, ">", "stamp_configure");
71 print STAMP $_, "\n" foreach (@extra_args);
72 close STAMP;
73
74 exit 0;