-# A module for loading and managing debhelper buildsystem plugins.
-# This module is intended to be used by all dh_auto_* helper commands.
+# A module for loading and managing debhelper build system class.
+# This module is intended to be used by all dh_auto_* programs.
#
# Copyright: © 2009 Modestas Vainius
# License: GPL-2+
our @EXPORT=qw(&buildsystems_init &buildsystems_do &load_buildsystem &load_all_buildsystems);
# Historical order must be kept for backwards compatibility. New
-# buildsystems MUST be added to the END of the list.
+# build systems MUST be added to the END of the list.
our @BUILDSYSTEMS = (
"autoconf",
"perl_makemaker",
my $opt_sourcedir;
my $opt_builddir;
my $opt_list;
+my $opt_help_buildsys;
sub create_buildsystem_instance {
my $system=shift;
eval "use $module";
if ($@) {
- error("unable to load buildsystem class '$system': $@");
+ error("unable to load build system class '$system': $@");
}
if (!exists $bsopts{builddir} && defined $opt_builddir) {
return $module->new(%bsopts);
}
-# Similar to create_buildsystem_instance(), but it attempts to autoselect
-# a buildsystem if none was specified. In case autoselection fails, undef
+# Similar to create_build system_instance(), but it attempts to autoselect
+# a build system if none was specified. In case autoselection fails, undef
# is returned.
sub load_buildsystem {
my $system=shift;
}
}
- # Push debhelper built-in buildsystems first
+ # Push standard debhelper build systems first
for my $name (@BUILDSYSTEMS) {
- error("Debhelper built-in buildsystem '$name' could not be found/loaded")
+ error("standard debhelper build system '$name' could not be found/loaded")
if not exists $buildsystems{$name};
push @buildsystems, $buildsystems{$name};
delete $buildsystems{$name};
}
- # The rest are 3rd party buildsystems
+ # The rest are 3rd party build systems
for my $name (keys %buildsystems) {
my $inst = $buildsystems{$name};
$inst->{thirdparty} = 1;
# Available command line options
my %options = (
- "d" => undef, # cancel default D_FLAG option spec
- "d=s" => \$opt_sourcedir,
+ "D=s" => \$opt_sourcedir,
"sourcedirectory=s" => \$opt_sourcedir,
- "b:s" => \$opt_builddir,
+ "B:s" => \$opt_builddir,
"builddirectory:s" => \$opt_builddir,
- "c=s" => \$opt_buildsys,
+ "S=s" => \$opt_buildsys,
"buildsystem=s" => \$opt_buildsys,
"l" => \$opt_list,
- "--list" => \$opt_list,
+ "list" => \$opt_list,
+
+ "help-buildsystem" => \$opt_help_buildsys,
);
$args{options}{$_} = $options{$_} foreach keys(%options);
-
- # Pass options from the DH_AUTO_OPTIONS environment variable
- if (defined $ENV{DH_AUTO_OPTIONS}) {
- $args{extra_args} = $ENV{DH_AUTO_OPTIONS};
- }
Debian::Debhelper::Dh_Lib::init(%args);
}
sub buildsystems_list {
my $step=shift;
- # List buildsystems (including auto and specified status)
+ # List build systems (including auto and specified status)
my ($auto, $specified);
my @buildsystems = load_all_buildsystems();
for my $inst (@buildsystems) {
if ! defined $auto && ! defined $specified;
}
+sub help_buildsystem {
+ my $step=shift;
+
+ # Print build system help page to standard output
+
+ my $inst = load_buildsystem($opt_buildsys, $step);
+ if ($inst) {
+ my $pmfile = ref $inst;
+ $pmfile =~ s#::#/#g;
+ $pmfile = $INC{"$pmfile.pm"};
+
+ # Display help with perldoc if it is installed and output is
+ # a tty
+ my $perldoc;
+ if (-t STDOUT) {
+ eval "use Pod::Perldoc";
+ $perldoc = "Pod::Perldoc" if (!$@);
+ }
+ if ($perldoc) {
+ $perldoc = new Pod::Perldoc();
+ $perldoc->{args} = [ '-oman',
+ '-w', 'section=7" "--name=dh_auto_'.lc($inst->NAME()),
+ '-w', 'center=Dh_auto build system documentation',
+ '-w', 'release=',
+ '-F', $pmfile ];
+ $perldoc->process();
+ }
+ else {
+ # No perldoc on the system. Use Pod::Usage to emit simple text
+ eval "use Pod::Usage";
+ pod2usage( -message => "Help page for the ".$inst->NAME()." build system\n" .
+ '<' . '-'x74 . '>',
+ -input => $pmfile, -exitval => 'NOEXIT',
+ -verbose => 2, -noperldoc => 1 );
+ print '<', '-'x74, '>', "\n";
+ }
+ return 0;
+ }
+ else {
+ print STDERR "No system auto-selected or specified. Try using --buildsystem option\n";
+ return 1;
+ }
+}
+
sub buildsystems_do {
my $step=shift;
exit 0;
}
+ if ($opt_help_buildsys) {
+ exit help_buildsystem($step);
+ }
+
my $buildsystem = load_buildsystem($opt_buildsys, $step);
if (defined $buildsystem) {
$buildsystem->pre_building_step($step);