my $DEBUG = 0; # Enable if you want to see debug output
sub dbg { print STDERR @_ if $DEBUG }
-die "ERROR: No arguments" unless @ARGV;
+die "ERROR: No arguments" unless @ARGV >= 3;
+
+my $libvirt_version = shift;
+my $builddir = shift;
# Context object referenced from entire this script
my $c = Context->new;
local $self->{header_contents} = [];
$self->print("/* *DO NOT MODIFY* this file directly.\n");
- $self->print(" * This file was generated by $0 from libvirt version $ENV{LIBVIRT_VERSION} */\n");
+ $self->print(" * This file was generated by $0 from libvirt version $libvirt_version */\n");
my $ucname = uc $name;
$self->print("#ifndef _$ucname\_H_\n");
$self->print("#define _$ucname\_H_\n");
for my $header (@{ $self->{headers} || [] }) {
my ($name, $contents) = @$header;
- my $file = File::Spec->catfile($ENV{PWD}, 'libvirt', "$name.h");
+ my $file = File::Spec->catfile($builddir, "$name.h");
open my $fh, '>', $file
or die "Cannot open file $file: $!";
CORE::print $fh map { ref($_) ? ($_->{refcnt} ? $_->{body} : ()) : $_ } @$contents;