#!/bin/bash
#                                               -*- Shell-script -*-
#
#  Copyright 2005-2015 Airbus-EDF-IMACS-Phimeca
#
#  This library 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 3 of the License, or
#  (at your option) any later version.
#
#  This library 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
#  along with this library.  If not, see <http://www.gnu.org/licenses/>.
#
#  @author dutka
#  @date   2007-10-05 12:49:51 +0200 (ven, 05 oct 2007)
#  Id      bootstrap 555 2007-10-05 10:49:51Z dutka
#
#  This file customizes the file tree to the user's needs
#  Call it before the bootstrap script
#


case $# in
  1)
    newname=$1
    oldname="wcode"

    filelist="CMakeLists.txt test.py ${oldname}.xml wrapper.c"

    for file in $filelist
    do
     if [[ -f $file ]]
     then
       sed -e "s/${oldname}/${newname}/g" < $file > $file.mod && mv $file.mod $file
     else
       echo "$file not found"
     fi
    done

    mv ${oldname}.xml ${newname}.xml
    ;;

  2)
    newname=$1
    oldname="wcode"

    file=$2
    if [[ -f $file ]]
    then
      sed -e "s/${oldname}/${newname}/g" < $file > $file.mod && mv $file.mod $file
    else
      echo "$file not found"
      exit 1
    fi
    ;;

  *)
    echo "usage: $0 <new_wrapper_name> [ <file> ]"
    exit 1
esac

