#! /bin/bash

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

export PREFIX=$1
export PYSRC="${MLFDATA}/Python-3.7.2.tar.xz"

mkdir -p ${PREFIX}

if [[ -a ${PYSRC} ]]
then
    echo "${PYSRC} found"
else
    curl -fsSL https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz > ${PYSRC}
fi
echo $PREFIX
rm -rf ${MLFDATA}/python
mkdir -p ${MLFDATA}/python
cd ${MLFDATA}/python
tar xf ${PYSRC}

#export LDFLAGS="-L/usr/local/opt/openssl/lib"
#export PATH=/usr/local/opt/openssl/include:$PATH
#export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
#CFLAGS="-I$(brew --prefix openssl)/include ${CFLAGS}" 
#LDFLAGS="-L$(brew --prefix openssl)/lib ${LDFLAGS}"


cd Python-3.7.2
./configure --prefix ${PREFIX} --enable-shared --with-openssl=/usr/local/opt/openssl
make
make install
