#!/usr/bin/perl
#
# @(#)devmake     1998-03-06
#
# G. Arnold, SAP AG
#
#
#    ========== licence begin  GPL
#    Copyright (C) 2001 SAP AG
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of the GNU General Public License
#    as published by the Free Software Foundation; either version 2
#    of the License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#    ========== licence end
#

package DevStudio;
require 5.000;
# use Tk;
use Env;



# collect options for im?
my @Options = ();
my @Files =();
my %OwnHash;

foreach (@ARGV)
{
	if (/^-(.*)/)
	{  push @Options, $_;}
	else
	{  push @Files, $_;}
}

foreach (@Files)
{	push @${$OwnHash{getOwn($_)}}, $_; }

foreach (keys (%OwnHash))
{
	$ENV{'OWN'} = "$_";
	my $cmd_line = "call \"$_\\iprofile.bat\" && perl %TOOL%\\bin\\lcmake.pl ";
	scalar(@Options) and $cmd_line .= join  " ", @Options . " ";
	$cmd_line .= join  " ", @${$OwnHash{$_}};
system("$cmd_line");

}



sub getOwn
{
	my $FullFileName = shift;

	#search $OWN
	($FullFileName =~ /^(.*)[\\\/]sys[\\\/](src|desc)[\\\/](.*)/) or
		die "File '$FullFileName' not in a right source path\n";
	$own = $1;
	-e "$own\\iprofile.bat" or die "Error: Profile ($own\\iprofile.bat) for executing does not exists\n";
	return $own;
}

