#!/bin/sh
######################################################################
#                                                                    #
#  .symlinks for CBFlib directory                                    #
#                                                                    #
#  originally a csh script by H. J. Bernstein                        #
#  converted to sh by J. Wright, 12 Jun 2007                         #
#                                                                    #
# Version 0.9.4.1 09 Mar 2014                                        #
#                                                                    #
#                          Paul Ellis and                            #
#         Herbert J. Bernstein (yaya@bernstein-plus-sons.com)        #
#                                                                    #
# (C) Copyright 2006 - 2014 Herbert J. Bernstein                     #
#                                                                    #
######################################################################

######################################################################
#                                                                    #
# YOU MAY REDISTRIBUTE THE CBFLIB PACKAGE UNDER THE TERMS OF THE GPL #
#                                                                    #
# ALTERNATIVELY YOU MAY REDISTRIBUTE THE CBFLIB API UNDER THE TERMS  #
# OF THE LGPL                                                        #
#                                                                    #
######################################################################

########################### GPL NOTICES ##############################
#                                                                    #
# 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                                                    #
#                                                                    #
######################################################################

######################### LGPL NOTICES ###############################
#                                                                    #
# 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 2.1 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   #
# License along with this library; if not, write to the Free         #
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,    #
# MA  02110-1301  USA                                                #
#                                                                    #
######################################################################

# Usage ./.symlinks [--use_cp]

if [ ${1:-NOARG} = "--use_cp" ] ; then
  LN="cp -p"
else
  LN="ln -s"
fi
if [ ! -e index.html ] ; then
  $LN README.html index.html
fi
if [ ! -e gpl.txt ] ; then
  $LN doc/gpl.txt gpl.txt
fi
if [ ! -e lgpl.txt ] ; then
  $LN doc/lgpl.txt lgpl.txt
fi
if [ ! -e CBFlib.tar.gz ] ; then
  $LN ../CBFlib-0.9.5.tar.gz CBFlib.tar.gz
fi
if [ ! -e template_adscquantum315_3072x3072.cbf ] ; then
  $LN examples/template_adscquantum315_3072x3072.cbf template_adscquantum315_3072x3072.cbf
fi
if [ ! -e template_adscquantum4_2304x2304.cbf ] ; then
  $LN examples/template_adscquantum4_2304x2304.cbf template_adscquantum4_2304x2304.cbf
fi
if [ ! -e template_mar345_2300x2300.cbf ] ; then
  $LN examples/template_mar345_2300x2300.cbf template_mar345_2300x2300.cbf
fi
if [ ! -e template_pilatus6m_2463x2527.cbf ] ; then
  $LN examples/template_pilatus6m_2463x2527.cbf template_pilatus6m_2463x2527.cbf
fi
for file in *
do
  if [ -d "$file" ] ; then
    if [ -e "$file/.symlinks" ] ; then
      (cd "$file"; sh -c "./.symlinks $1")
    fi
  fi
done
