#!/bin/bash

echo "Moved to LLVM"
exit
set -e

mkdir -p $ROCM_BUILD_DIR/rocm-compilersupport
cd $ROCM_BUILD_DIR/rocm-compilersupport

DEST=$OUTPUT/package-comgr
PRGNAM=rocm-comgr
NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}

pushd .

cmake \
    -Wno-dev \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=$ROCM_INSTALL_DIR \
    -D CPACK_PACKAGING_INSTALL_PREFIX=$ROCM_INSTALL_DIR \
    -D FILE_REORG_BACKWARD_COMPATIBIL=ON \
    -D BUILD_TESTING=OFF \
    -G Ninja \
    -D CMAKE_PREFIX_PATH=${ROCM_INSTALL_DIR}/lib/llvm \
    $ROCM_REL_DIR/llvm-project-$LDIR/amd/comgr

"${NINJA:=ninja}" $NUMJOBS || exit 1
DESTDIR=$DEST "$NINJA" install/strip || exit 1

mkdir -p $DEST/install
cat >> $DEST/install/slack-desc << 'END'
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':' except on otherwise blank lines.

     |-----handy-ruler------------------------------------------------------|
comgr: Code Object Manager (comgr)
comgr:
comgr: The Comgr library provides APIs for compiling and inspecting AMDGPU
comgr: code objects.
comgr:
comgr:
comgr:
comgr:
comgr:
comgr:
comgr:
END

cd $DEST
makepkg -l y -c n $OUTPUT/$PRGNAM-$PKGVER-$ARCH-${BUILD}$TAG.txz

popd

