#!/usr/bin/perl

$folder = $ARGV[0];

open(FSMS,"ls $folder/*.fsm |");
open(INCLUDES,'>',"includes");
open(MENUITEMS,'>', "menuitems");
while($fsm = <FSMS>)
{
	print $fsm;
	system("cp $dir/$fsm ~/project/");
	$hfile = substr($fsm,0,-5);
	print INCLUDES "#include $hfile \n";
	$menuitem = substr($hfile,0,-2);
	print MENUITEMS "MENUITEM($menuitem) \n";
}
system("cat ~/project/UserBehaviors-1 includes ~/project/UserBehaviors-2 menuitems ~/project/UserBehaviors-3 > ~/project/UserBehaviors.h");
close(FSMS);
close(INCLUDES);
close(MENUITEMS);
unlink("includes");
unlink("menuitems");
