#!/usr/bin/env bash

set -x
set -e

rm -rf ~/.xdebug-build
mkdir ~/.xdebug-build
cd ~/.xdebug-build

version=$1
versions=(${version//./ })
tag="XDEBUG_${versions[0]}_${versions[1]}_${versions[2]}"

wget https://github.com/xdebug/xdebug/archive/$tag.zip -q -O xdebug.zip
unzip xdebug.zip
mv xdebug-$tag source
cd source

phpize
./configure --enable-xdebug

make -j32

cp modules/xdebug.so ~/php/7.1.0/lib/php/extensions/debug-non-zts-20160303/xdebug.so

