# Copyright (C) 1998-2009 Yves Renard
#
# This file is a part of GETFEM++
#
# Getfem++  is  free software;  you  can  redistribute  it  and/or modify it
# under  the  terms  of the  GNU  Lesser General Public License as published
# by  the  Free Software Foundation;  either version 2.1 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 Lesser General Public
# License for more details.
# You  should  have received a copy of the GNU Lesser General Public License
# along  with  this program;  if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
# -*- perl -*-

eval 'exec perl -S $0 "$@"'
  if 0;

# list all GETFEM++ internal dependencies of a file

open(FICHIER, $ARGV[0]) or die "Open file impossible : $!\n";
while ($line = <FICHIER>)
{
  if ($line =~ /^([ ])*\#include/)
  {
    ($f1, $f2) = split('#include', $line, 2);
    if ($line =~ /</)
    { ($f1, $f2) = split('<', $f2, 2); ($f2, $f1) =  split('>', $f2, 2); }
    else
    { ($f1, $f2) = split('\"', $f2, 2); ($f2, $f1) =  split('\"', $f2, 2); }


    if (($f2 =~ /^getfem\_/) or ($f2 =~ /^dal\_/) or ($f2 =~ /^bgeot\_/)
	or ($f2 =~ /^linkmsg\_/) or ($f2 =~ /^ftool/) or ($f2 =~ /^matlabint\_/) or ($f2 =~ /^gensolv\_/))
    {
      while ($f2 =~ /\//) { ($f1, $f2) = split('\/', $f2, 2); }
      print $f2, "\n";
    }
  }
}
