summaryrefslogtreecommitdiff
path: root/Toolchain/BuildPython.sh
blob: e56d8fe934f958511bc5a253419d69e6c466bb97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e

# This file will need to be run in bash, for now.

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "$DIR"

TARGET=i686-pc-serenity
PREFIX="$DIR/Local"
SYSROOT="$DIR/../Root"

source "$DIR/../Ports/python-3.6/version.sh"

echo PYTHON_VERSION is "$PYTHON_VERSION"
echo PYTHON_URL is "$PYTHON_URL"

echo PREFIX is "$PREFIX"
echo SYSROOT is "$SYSROOT"

mkdir -p "$DIR/Tarballs"

source "$DIR/UseIt.sh"

pushd "$DIR/Tarballs"
    if [ ! -e "$PYTHON_ARCHIVE" ]; then
        curl -O "$PYTHON_URL"
    else
        echo "Skipped downloading Python-$PYTHON_VERSION"
    fi

    md5="$(md5sum $PYTHON_ARCHIVE | cut -f1 -d' ')"
    echo "python md5='$md5'"
    if  [ "$md5" != "$PYTHON_MD5SUM" ] ; then
        echo "python md5 sum mismatching, please run script again."
        rm $PYTHON_ARCHIVE
        exit 1
    fi

    if [ ! -d "Python-$PYTHON_VERSION" ]; then
        echo "Extracting python..."
        tar -xf "$PYTHON_ARCHIVE"
    else
        echo "Skipped extracting python"
    fi
popd

mkdir -p "$PREFIX"
mkdir -p "$DIR/Build/python"

if [ -z "$MAKEJOBS" ]; then
    MAKEJOBS=$(nproc)
fi

pushd "$DIR/Build/"
    pushd python
        "$DIR"/Tarballs/Python-$PYTHON_VERSION/configure --prefix="$PREFIX" || exit 1
        make -j "$MAKEJOBS" || exit 1
        make install || exit 1
    popd
popd