#!/usr/bin/perl
# $Id: configure,v 1.1 2006/07/06 13:04:24 gavin Exp $
use strict;
use Getopt::Long;

my ($help, $prefix);
GetOptions('help' => \$help, 'prefix=s' => \$prefix);

if (defined($help)) {
	print <<"END";
Usage: configure [options]
Options:
  --help                  print this message
  --prefix=DIR            installation destination (will use
                          `pkg-config gtk+-2.0 --variable=prefix` by default)
END
} else {
	if (!defined($prefix)) {
		chomp($prefix = `pkg-config gtk+-2.0 --variable=prefix`);
	}
	printf("Configuration options:\n    prefix: %s\nWriting Makefile...\n", $prefix);
	open(SRC, 'Makefile.in');
	open(DST, '>Makefile');
	while (<SRC>) {
		s/\@PREFIX\@/$prefix/g;
		print DST $_;
	}
	close(SRC);
	close(DST);
	print "Now type 'make' to build.\n";
}
