Users of \OHPC{} may find it desirable to rebuild one of the supplied packages
to apply build customizations or satisfy local requirements. One way to
accomplish this is to install the appropriate source RPM, modify the spec file
as needed, and rebuild to obtain an updated binary RPM. \OHPC{} spec files
contain macros to facilitate local customizations of compiler, compilation
flags and MPI family. A brief example using
the FFTW library is highlighted below.  Note that the source RPMs can be downloaded from the
community repository server at \href{http://repos.openhpc.community}
{\color{blue}{http://repos.openhpc.community}} via a web browser or directly
via \texttt{dnf} as highlighted below. In this example we make an explicit
change to FFTW's configuration, as well as modifying the CFLAGS environment
variable. The package is also tagged with an additional delimiter to allow easy
co-installation and use.

\begin{lstlisting}[language=bash,keywords={},basicstyle=\fontencoding{T1}\footnotesize\ttfamily,
    literate={ARCH}{\arch{}}1 {-}{-}1]
# Install rpm-build package and dnf tools from base OS distro
[test@sms ~]$ sudo (*\install*) rpm-build dnf-plugins-core

# Install FFTW's build dependencies
[test@sms ~]$ sudo dnf builddep fftw-gnu9-openmpi4-ohpc

# Download SRPM from OpenHPC repository and install locally
[test@sms ~]$ dnf download --source fftw-gnu9-openmpi4-ohpc
[test@sms ~]$ rpm -i ./fftw-gnu9-openmpi4-ohpc-3.3.8-5.1.ohpc.2.0.src.rpm

# Modify spec file as desired
[test@sms ~]$ cd ~/rpmbuild/SPECS
[test@sms ~rpmbuild/SPECS]$ perl -pi -e "s/enable-static=no/enable-static=yes/" fftw.spec

# Increment RPM release so the package manager will see an update
[test@sms ~rpmbuild/SPECS]$ perl -pi -e "s/Release:   5.1/Release:   6.1/" fftw.spec

# Rebuild binary RPM. Note that additional directives can be specified to modify build
[test@sms ~rpmbuild/SPECS]$ rpmbuild -bb --define "OHPC_CFLAGS '-O3 -mtune=native'" \
        --define "OHPC_CUSTOM_DELIM static" fftw.spec

# Install the new package
[test@sms ~rpmbuild/SPECS]$ sudo (*\install*) \
        ../RPMS/ARCH/fftw-gnu9-openmpi4-static-ohpc.2.0-3.3.8-6.1.ARCH.rpm

# The new module file appears along side the default
[test@sms ~]$ module avail fftw

-------------------------- /opt/ohpc/pub/moduledeps/gnu9-openmpi4 ---------------------------
   fftw/3.3.8-static    fftw/3.3.8 (D)
\end{lstlisting}
