Hi, I realize there exists an RPM spec file distributed with OMPI tarball
but I've found it to be broken on several counts (e.g. a not-so-advertized
'feature' of spec files is that nested %if statements are unpredictable at
best) so I'm inlining one that I've been using successfully for quite some
time. This one permits you to enable/disable many of the config options on
your rpmbuild command line with --with <option> semantics, e.g:

rpmbuild --with openib=/opt/IB/ibgd-2.0.1-rc6

will build your pkg against OpenIB rooted at the specified directory.
Another handy feature is that your build arguments are kept in the info
section of your installed RPM so you can simply 'rpm -qi openmpi' to see
what options were used to build it. Enjoy,