#!/usr/bin/env bash
processor_count=`grep -c "^processor" /proc/cpuinfo`
count=$((${processor_count} - 1))
echo "Detected ${processor_count} processors, using ${count}"

make distclean
pushd ..
./autogen.sh
popd

rm -fR alepha-build
mkdir alepha-build
cd alepha-build
echo "Setting up Alepha"
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../../Alepha
cp ../../Alepha/helpful-things/Makefile .
echo "Building Alepha"
make
cd ..

../configure --prefix=/usr --enable-ipv6 CXXFLAGS="-O0 -g"
make -kj${count}
