#! /bin/bash

#source ${HOME}/mlfscripts/setup.sh
source ../mlf_build_env.sh

export OPT="${PYMANYO}/.opt"
export OPTLIB="${OPT}/lib/cpp"
export PYROOT="${OPT}/python"
export PYBIN="${PYROOT}/bin"


export PY3LIB=${BUILDMANYO}/opt/mlfsoft/python${PyVer}
export MANYO_PATH=${PY3LIB}/manyo

#source "${MLFSCRIPTS}/pystart.sh"
























#
# installer
#

echo
echo "#"
echo "# set up installer > ${MLFOUT}/manyo_${MANYOREVNAME}.pkg"
echo "#"
echo

# fix directory hierachy

rm -rf "${BUILDMANYO}/AppRoot"
mkdir -p "${BUILDMANYO}/AppRoot/Applications"

export ROOT="${BUILDMANYO}/AppRoot/Applications/Manyo"

cp -a "${MLFDATA}/manyo_template" "${ROOT}"
cp -a "${MLFDATA}/py_manyo/.opt/python" "${ROOT}/.opt/"
cp -a "${PY3LIB}/manyo" "${ROOT}/.opt/manyo"



mkdir "${ROOT}/.opt/lib"
cp -a "${OPTLIB}" "${ROOT}/.opt/lib/cpp"

# build package

pkgbuild --identifier manyo --root "${BUILDMANYO}/AppRoot" "${MLFOUT}/manyo_${MANYOREVNAME}.pkg"

echo
echo "INSTALLER READY: ${MLFOUT}/manyo_${MANYOREVNAME}.pkg"
echo
