# -*- cperl -*-
# Makefile generation script for the Perl Zephyr interface.

use strict;
use ExtUtils::MakeMaker;

$0 =~ s@.*/@@g;

# Set up things for test installing (inside my homedir).
use vars qw( $sys @testopt @opt $no_opt );
$sys = $ENV{'ATHENA_SYS'};
unless (defined $sys) {
  my ($sysname) = `fs sys`	|| die "'fs sys' failed";
  $sysname =~/'([^\']+)'/	|| die "Can't parse 'fs sys' output";
  $sys = $1			|| die "Can't determine \@sys name";
}
@testopt = (
  PREFIX =>		'/mit/bert/project/perl5',
  INSTALLPRIVLIB =>	'/mit/bert/project/perl5/arch/share/lib',
  INSTALLARCHLIB =>	"/mit/bert/project/perl5/arch/$sys/lib",
  INSTALLSITELIB =>	'/mit/bert/project/perl5/arch/share/lib',
  INSTALLSITEARCH =>	"/mit/bert/project/perl5/arch/$sys/lib",
  INSTALLBIN =>		"/mit/bert/project/perl5/arch/$sys/bin",
  INSTALLSCRIPT =>	"/mit/bert/project/perl5/arch/share/bin",
  INSTALLMAN1DIR =>	'/mit/bert/project/perl5/man/man1',
  INSTALLMAN3DIR =>	'/mit/bert/project/perl5/man/man3',

  CC => 'gcc',
  OPTIMIZE => '-g',
);

# If this is for testing, use by temporary staging area.
# Require the '-i' flag to install for real.
for (@ARGV) {
  /^-t$/ && (@opt = @testopt, next);
  /^-i$/ && ($no_opt = 1,     next);
  die "usage: $0 [-t | -i]\n";
}
@opt && $no_opt
  && die "$0: can't use both -t (test installation) and -i (real install)\n";
@opt || $no_opt
  || die "$0: use either -t (test installation) or -i (real install)\n";

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    NAME	=> 'Zephyr',
    VERSION_FROM => 'Zephyr.pm',		# finds $VERSION
    LIBS	=> ["-L/mit/zephyr/arch/$sys/lib -lzephyr -lcom_err"
		    . " -L/usr/athena/lib -lkrb -ldes"],
    LIBS	=> ["-L/usr/athena/lib -lzephyr -lcom_err -lkrb -ldes"],
    DEFINE	=> '',				# e.g., '-DHAVE_SOMETHING' 
    INC	=> '-I/mit/zephyr/include -I/usr/athena/include',
    @opt
);
