#!/bin/sh
DISTRIBUTE=./dist/Ngraph
if [ ! -d ${DISTRIBUTE} ]
then
  mkdir ${DISTRIBUTE}
  chmod 0755 ${DISTRIBUTE}
fi
for i in icon ja x11addin x11demo x11drive
do
  if [ ! -d ${DISTRIBUTE}/$i ]
  then
    mkdir ${DISTRIBUTE}/$i
    chmod 0755 ${DISTRIBUTE}/$i
  fi
done

cp gpl.txt gpl.ja.txt INSTALL.jis Ngraph.ini Ngraph .Ngraph .Ngraph.ngp .fit.ngp ${DISTRIBUTE}
cp install.sh ngraph.sh ngraph terminal ${DISTRIBUTE}
(cd ${DISTRIBUTE}
 chmod 0644 gpl.txt gpl.ja.txt INSTALL.jis Ngraph.ini Ngraph .Ngraph .Ngraph.ngp .fit.ngp
 chmod 0755 install.sh ngraph.sh ngraph terminal
)
cp  ja/Ngraph ${DISTRIBUTE}/ja
(cd ${DISTRIBUTE}/ja
 chmod 0644 Ngraph
)
cp x11drive/gra2ps x11drive/Ngraph.ps x11drive/gra2ps.ini ${DISTRIBUTE}/x11drive
cp x11drive/gra2wmf x11drive/gra2wmf.ini ${DISTRIBUTE}/x11drive
(cd ${DISTRIBUTE}/x11drive
 chmod 0644 Ngraph.ps
 chmod 0644 gra2ps.ini
 chmod 0755 gra2ps
 chmod 0644 gra2wmf.ini
 chmod 0755 gra2wmf
)
cp x11addin/append.nsc x11addin/math.nsc x11addin/text-in.nsc \
   x11addin/calc.nsc x11addin/calc.tcl x11addin/legend.nsc \
   x11addin/legend.tcl x11addin/fitrslt.nsc x11addin/fitrslt.tcl \
   x11addin/fft x11addin/fft.tcl x11addin/fft.nsc \
   ${DISTRIBUTE}/x11addin
(cd ${DISTRIBUTE}/x11addin
 chmod 0644 append.nsc math.nsc text-in.nsc \
   calc.nsc calc.tcl legend.nsc \
   legend.tcl fitrslt.nsc fitrslt.tcl
 chmod 0755 fft
)
cp x11demo/demo*.dat x11demo/*.ngp ${DISTRIBUTE}/x11demo
(cd ${DISTRIBUTE}/x11demo
 chmod 0644 demo*.dat *.ngp
)
cp icon/Ngraph.xpm ${DISTRIBUTE}/icon
(cd ${DISTRIBUTE}/icon
 chmod 0644 Ngraph.xpm
)
(cd ${DISTRIBUTE}
  if [ ! -h Install ]
  then
    ln -s install.sh Install
  fi
  if [ ! -h README.jis ]
  then
    ln -s INSTALL.jis README.jis
  fi
)
