#!/bin/bash
# BEGIN_ICS_COPYRIGHT8 ****************************************
# 
# Copyright (c) 2015-2017, Intel Corporation
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 
#     * Redistributions of source code must retain the above copyright notice,
#       this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of Intel Corporation nor the names of its contributors
#       may be used to endorse or promote products derived from this software
#       without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
# END_ICS_COPYRIGHT8   ****************************************

#[ICS VERSION STRING: @(#) ./build_rpms 10_8_0_0_202 [08/22/18 23:06]
# This script shows a sample of how to build the OFA Delta src.rpms delivered
# in IFS
# Note that some of the src.rpms are not applicable to some distros.
# In many cases, the IFS delivered binary rpms may need to be installed prior to
# rebuilding a given source rpm.
# This does not include building of MPI, FM and some other src.rpms not in
# the OFA_DELTA subdirectory.

# use this script as a sample of commands which may be run within the OFA_DELTA
# subdirectory.  Comment out and edit this script as desired to build the
# desired subset of rpms.  The results of the build will update the
# rpms in the OFA_DELTA directory such that the next run of INSTALL from the
# parent directory will install the rebuilt rpms.
set -x

rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/opa-scripts-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/infiniband-diags-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/ibacm-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/libibmad-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/srptools-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/libibumad-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/libhfi1-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/libpsm2-*.src.rpm
rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/hfi1-diagtools-sw-0.8-81.src.rpm

# Cuda enabled PSM src.rpm and rpm are in special CUDA sub-directory
PSM_CUDA=1 rpmbuild --rebuild --define "_topdir $(pwd)" SRPMS/CUDA/libpsm2-*cuda.src.rpm
cp RPMS/libpsm2-*cuda.x86_64.rpm RPMS/CUDA/

rpmbuild --rebuild --define "_topdir $(pwd)" --define "shell_startup_dir /etc/profile.d" SRPMS/mpi-selector-*.src.rpm

rpmbuild --rebuild --define 'configopts --disable-rxd --disable-rxm CFLAGS="-lnl-3 " CC=' --define 'debug_package %{nil}' --define '__strip /bin/true' --define "_topdir $(pwd)" SRPMS/libfabric-*.src.rpm

rpmbuild --rebuild --define 'configopts --disable-sockets --disable-verbs --disable-psm2 --disable-rxd --disable-rxm --disable-udp --disable-usnic --enable-psm=dl CFLAGS="-lnl-3 " CC=' --define 'debug_package %{nil}' --define '__strip /bin/true' --define "_topdir $(pwd)" SRPMS/libfabric-psm-*.src.rpm

rpmbuild --rebuild --define 'configopts --disable-sockets --disable-verbs --disable-psm --disable-rxd --disable-rxm --disable-udp --disable-usnic --enable-psm2=dl CFLAGS="-lnl-3 " CC=' --define 'debug_package %{nil}' --define '__strip /bin/true' --define "_topdir $(pwd)" SRPMS/libfabric-psm2-*.src.rpm

rpmbuild --rebuild --define 'configopts --disable-sockets --disable-psm2 --disable-psm --disable-rxd --disable-rxm --disable-udp --disable-usnic --enable-verbs=dl CFLAGS="-lnl-3 " CC=' --define 'debug_package %{nil}' --define '__strip /bin/true' --define "_topdir $(pwd)" SRPMS/libfabric-verbs-*.src.rpm

rpmbuild --rebuild --define 'configargs --disable-bounce-buffers --prefix=/usr/shmem/gcc/sandia-openshmem-1.3.3-hfi --enable-remote-virtual-addressing --enable-pmi-simple --with-ofi  CFLAGS="-O3"' --define '_prefix /usr/shmem/gcc/sandia-openshmem-1.3.3-hfi' --define "_topdir $(pwd)" SRPMS/sandia-openshmem-*.src.rpm
