#!/bin/bash
set -x
set -e
set -o pipefail
set -u

#xz
gmp=6.1.2

#xz
mpfr=3.1.5

#gz
mpc=1.0.3

# isl stands for Integer Set Library.  The version of fsf is older (0.16.1) than the one at inria (0.17.1), but we use the recommended fsf version.  There is no cryptographic signature.

#bz2
#isl=0.16.1

#lets try the inria version, dl bz2 version even though xz exists
isl=0.18

#bz2
gcc=7.1.0


. /tmp/lxc02c.sh
which gcc
which g++
cd /tmp
cat > a.c <<EOF
#include <stdio.h>
int main(void){
printf("straight c\n");
return 0;
}
EOF
gcc a.c
ldd ./a.out
./a.out
cat > a.cpp <<EOF
#include <iostream>
int main(){
std::cout << "cplusplus" << std::endl;
}
EOF
g++ a.cpp
ldd ./a.out
./a.out

pushd /tmp/gcc-$gcc
ln -s ../gmp-$gmp gmp
ln -s ../mpfr-$mpfr mpfr
ln -s ../mpc-$mpc mpc
ln -s ../isl-$isl isl
patch -p0 < ../Makefile.def.patch
autogen Makefile.def
popd

mkdir /tmp/build
cd /tmp/build

# making target needed for isl configure
mkdir /tmp/h

# --enable-languages=all,ada,go,jit,obj-c++
# --enable-languages=ada,c,c++
# --disable-multilib
# --enable-languages=jit
../gcc-$gcc/configure --prefix=/tmp/h --enable-languages=ada,c,c++ --enable-host-shared --enable-threads=posix --with-tune=generic --with-system-zlib > configure.ken.log 2>&1

bash /tmp/lxc02b.sh -j1 > make01.log 2>&1
