#!/bin/sh

DIR=$1

cd $1

make clean
[ ! -e build ] && mkdir build
cd build
make clean
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS:STRING="-O2 -fPIC"     -DCMAKE_CXX_FLAGS:STRING="-O2 -fPIC"     -DCMAKE_INSTALL_PREFIX=/usr     -DLIB_SUFFIX=64 -DOPENJPEG_INSTALL_LIB_DIR=/usr/lib64
make

VER=${DIR/openjpeg-/}

IDIR=/tmp/openjpeg-${VER}

rm -rf $IDIR

make install DESTDIR=$IDIR
make clean

cd $IDIR
mv lib/ lib64/
makepkg -l y -c y /tmp/openjpeg-${VER}-x86_64-1airaghi.txz