#!/usr/bin/perl

BEGIN {
   # Look for the library
   @pos = split /:/,$ENV{PATH};

   $0 =~ s!/[^/]*$!!;
   if(length($0) > 2) {
      push @pos, $0;
   }

   foreach (@pos)
   {
      s/bin$/lib/;
      if(-f "$_/Gen.pm") {
         $libdir = $_ ;
         last;
      }
   } 

   die "Couldn't find the Architecture library (Gen.pm).\nI checked in @pos using your PATH variable (replacing bin with lib) and this executable's path.\n" if !defined($libdir);

   push @INC, "$libdir"; 
}

use Getopt::Std;
use Gen qw(genframe);

getopts("b");

die "Usage: genframe -b material name width_in height_in depth_in plank_thickness_in\n   -b: Include a bottom plank (default is a 3-sided frame for a door)\n" if($#ARGV < 5); 

$bottom = 0;
$bottom = 1 if(defined($opt_b));

genframe($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $bottom);
