#!/usr/bin/perl
#
#  Copyright Statement:
#  --------------------
#  This software is protected by Copyright and the information contained
#  herein is confidential. The software may not be copied and the information
#  contained herein may not be used or disclosed except with the written
#  permission of MediaTek Inc. (C) 2005
#
#  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
#  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
#  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
#  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
#  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
#  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
#  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
#  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
#  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
#  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
#  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
#
#  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
#  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
#  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
#  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
#  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
#
#  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
#  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
#  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
#  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
#  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
#
#
$custom = "Dragonfly_Demo";
$proj = "gprs"; # gprs or gsm
@objs = ();#qw(custom_wap_cust_pack.obj nvram_cust_pack.obj);
$outputdir = "C:\\CustPack\\BIN";
$dboutputdir = "C:\\CustPack";
$extractObjExe = "ExtractObj.exe";

$ini_file = "ExtractObj.ini";
if (!-e $ini_file) {
  die "$ini_file OR pcore\\tools\\$ini_file did NOT exist!\n" if (!-e "pcore\\tools\\$ini_file");
  $ini_file = "pcore\\tools\\$ini_file";
}

open INI_FILE, "<$ini_file" or die "cannot open $ini_file\n";

while (<INI_FILE>) {
  if (/^\s*CUSTOM\s*=\s*\"(\S+)\"\s/) {
    $custom = $1;
  } elsif (/^\s*PROJECT\s*=\s*\"(\S+)\"\s/) {
    $proj = $1;
  } elsif (/^\s*OBJ\d+\s*=\s*\"(\S+)\"\s/) {
    push(@objs, $1);
  } elsif (/^\s*OUTPUTDIR\s*=\s*\"(\S+)\"\s/) {
    $dboutputdir = $1;
    $outputdir = $1."\\BIN";
  }
}
close INI_FILE;

while ($#ARGV != -1) {
  if ($ARGV[0] =~ /-h/) {
    Usage();
  } elsif ($ARGV[0] =~ /^custom=(\w+)/) {
    $custom = $1;
  } elsif ($ARGV[0] =~ /(gprs|gsm|umts)/i) {
    $proj = $ARGV[0];
  } elsif ($ARGV[0] =~ /^objs=(\S+)/) {
    @objs = split(',', $1);
  } else {
    Usage();
  }
  shift(@ARGV);
}

$fromelf = "fromelf";
$builddir = "build\\${custom}\\${proj}";

$makefolder = "make";
if (!-d $makefolder) {
  die "$makefolder OR ..\\$makefolder did NOT exist!\n" if (!-d "..\\$makefolder");
  $makefolder = "..\\$makefolder";
}
$custombld = "${makefolder}\\custom.bld";
die "$custombld did NOT exist!\n" if (!-e $custombld);
open (FILE_HANDLE, "<$custombld") or die "cannot open $custombld\n";
while (<FILE_HANDLE>) {
  if (/^(\S+)\s*=\s*(\S+)/) {
    $keyname = lc($1);
    defined($${keyname}) && warn "$1 redefined in $custombld!\n";
    $${keyname} = uc($2);
  }
}
close FILE_HANDLE;

if ($custom_release eq "TRUE") {
  $dbfileprefix = "BPLGUInfoCustomAppSrcP_MT62";
} else {
  $dbfileprefix = "BPLGUInfoCustomApp_MT62";
}


#system("rd /s /q $outputdir") if (-d $outputdir);
#system("rd /s /q $dboutputdir") if (-d $dboutputdir);
system("md $dboutputdir") if (!-d $dboutputdir);
system("md $outputdir") if (!-d $outputdir);
if (!-d $builddir) {
  die "$builddir OR ..\\$builddir did NOT exist!\n" if (!-d "..\\$builddir");
  $builddir = "..\\$builddir";
}

$not_found_flag = 0;
foreach $chkobj (@objs) {
  if (!-e $chkobj) { $not_found_flag = 1; last; }
  else { $found{$chkobj} = $chkobj; }
}

if ($not_found_flag == 0) { goto DEAL_OBJ; }

if (opendir(OBJDIRS, $builddir)) {
  @syndirs = sort readdir(OBJDIRS);
  closedir(OBJDIRS);
  shift(@syndirs); shift(@syndirs); ## . and ..
} else {
  die "Could not open $builddir";
}

CHIP_DIR: foreach $tarDir (@syndirs) {
  next if ($tarDir !~ m/o$/);
  $tarDir = "$builddir\\$tarDir";
  if (opendir(OBJDIRS, $tarDir)) {
    @moduledirs = sort readdir(OBJDIRS);
    closedir(OBJDIRS);
    shift(@moduledirs); shift(@moduledirs); ## . and ..
  } else {
    warn "Could not open $tarDir\n";
    next;
  }

  foreach $chkobj (@objs) { undef($found{$chkobj}); }

  CHIP_OBJ:  foreach $m (@moduledirs) {
    next if ($m eq "lib");
    $tarDir2 = "$tarDir\\$m";
    if (opendir(OBJDIRS, $tarDir2)) {
      @objfiles = sort readdir(OBJDIRS);
      closedir(OBJDIRS);
      shift(@objfiles); shift(@objfiles); ## . and ..
    } else {
      warn "Could not open $tarDir2\n";
      next;
    }
    foreach $objfile (@objfiles) {
      foreach $chkobj (@objs) {
        next if (defined($found{$chkobj}));
        next if ($objfile ne $chkobj);
        $found{$chkobj} = "$tarDir2\\$chkobj";
      }
    }
    foreach $chkobj (@objs) { next CHIP_OBJ if (!defined($found{$chkobj}));}
    print "Found all obj files @ $tarDir\n";
    last CHIP_DIR;
  }
}

DEAL_OBJ:
$allObjs = "";
foreach $chkobj (@objs) { 
  $chktxt = $found{$chkobj};
  die "$chkobj did NOT exist!\n" if (!-e $found{$chkobj});
  $allObjs .= " $chktxt";
  $chktxt =~ s/\.obj/\.txt/;
  system("del /f /q $chktxt") if (-e $chktxt);
  print("$fromelf -text -v -s $found{$chkobj} > $chktxt\n");
  system("$fromelf -text -v -s $found{$chkobj} > $chktxt");
}

if (!-e $extractObjExe) {
  die "$extractObjExe OR pcore\\tools\\$extractObjExe did NOT exist!\n" if (!-e "pcore\\tools\\$extractObjExe");
  $extractObjExe = "pcore\\tools\\$extractObjExe";
}
print("$extractObjExe $outputdir $allObjs\n");
system("$extractObjExe $outputdir $allObjs");

$dbfolder = "tst\\database";

if (!-d $dbfolder) {
  die "$dbfolder OR ..\\$dbfolder did NOT exist!\n" if (!-d "..\\$dbfolder");
  $dbfolder = "..\\$dbfolder";
}
print("$extractObjExe $outputdir $allObjs\n");
if (opendir(OBJDIRS, $dbfolder)) {
  @dbfiles= sort readdir(OBJDIRS);
  closedir(OBJDIRS);
  shift(@dbfiles); shift(@dbfiles); ## . and ..
} else {
  die "Could not open $dbfolder\n";
}
foreach $dbfile (@dbfiles) { 
  next if ($dbfile !~ /$dbfileprefix/);
  system("copy /Y ${dbfolder}\\$dbfile ${dboutputdir}\\$dbfile");
}

exit 0;

sub Usage {
  print <<"__EOFUSAGE";
Usage: $0 [-h | custom=\$custom | (gprs|gsm) | [objs=a.obj,b.obj]]
        -h       Help.
__EOFUSAGE
  exit 0;
}
