FROM tce_llvm

ARG GIT_COMMIT=master
ARG TCE_COMMIT=master
ARG LLVM_VERSION=80

ENV LD_LIBRARY_PATH=/home/LLVM_$LLVM_VERSION/lib:/home/TCE_$LLVM_VERSION/lib
ENV PATH=/home/TCE_$LLVM_VERSION/bin:/home/LLVM_$LLVM_VERSION/bin:${PATH}

################ BUILD TCE

RUN apt install -y tk-dev tcl-dev libxerces-c-dev libsqlite3-dev libboost-all-dev

RUN cd /home ; git clone https://github.com/cpc/tce -b $TCE_COMMIT

# TODO patch tce configure.ac

RUN cd /home/tce/tce ; git clean -f -d -x

RUN cd /home/tce/tce ; ./autogen.sh

RUN cd /home/tce/tce ; ./configure --prefix=/home/TCE_$LLVM_VERSION

RUN cd /home/tce/tce ; make -j4

RUN cd /home/tce/tce ; make install

RUN cd /home/tce/tce/newlib-*/tce-llvm/ ; make install

CMD /bin/bash
