#!/bin/bash
set -e
source $1

out=/dev/null
if [ -n "$DEBUG" ];then
    out=/dev/stdout
fi

BUILDDIR=${BUILDDIR:=/LLXXAMP}
TAG=${TAG:=$BUILDDIR/123456789123456789123456789123456789123456789}
PREFIX=$TAG/php
PROCS=$(nproc)

echo Compiling PHP

if [ -e "$DECOMPRESSED_DIR/mariadb/bin/mariadb" ];then
    suffix=mariadb
else
    suffix=mysql
fi
sock=$TAG/$suffix/var/$suffix/$suffix.sock
cd $DECOMPRESSED_DIR/php
./configure --prefix=$PREFIX --with-apxs2=$TAG/httpd/bin/apxs --with-mysqli --with-mysql-sock=$sock --enable-mbstring --with-bz2 --enable-filter --enable-bcmath --enable-fpm --with-curl --enable-filter --enable-gd --with-freetype --with-jpeg --enable-intl --with-openssl --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-pcntl --enable-shmop --with-xsl --enable-opcache --enable-calendar --enable-sockets --with-readline --with-zip --with-mhash --with-gettext --with-zlib > $out 2>&1
make clean > $out 2>&1
make -j$PROCS > $out 2>&1
make install > $out 2>&1
make clean > $out 2>&1

