Stack Exchange
RPM package dependencies
I modified the .spec file from a source RPM available in the EPEL repository.
# yumdownloader pjproject
# yumdownloader --source pjproject

# diff -u pjproject.spec{.orig,}
--- pjproject.spec.orig 2018-03-27 15:42:37.780641678 +0100
+++ pjproject.spec  2018-03-27 12:54:54.298556634 +0100
@@ -24,13 +24,13 @@


 BuildRequires: alsa-lib-devel
-BuildRequires: gsm-devel
-BuildRequires: libsrtp-devel
+#BuildRequires: gsm-devel
+#BuildRequires: libsrtp-devel
 BuildRequires: libuuid-devel
 BuildRequires: openssl-devel
 BuildRequires: pkgconfig
 BuildRequires: portaudio-devel
-BuildRequires: speex-devel
+#BuildRequires: speex-devel


 %description
@@ -76,23 +76,23 @@
 rm -rf third_party/bdsound
 rm -rf third_party/bin
 rm -rf third_party/g7221
-rm -rf third_party/gsm
+#rm -rf third_party/gsm
 rm -rf third_party/milenage
 rm -rf third_party/mp3
 rm -rf third_party/portaudio
 rm -rf third_party/resample
-rm -rf third_party/speex
-rm -rf third_party/srtp
+#rm -rf third_party/speex
+#rm -rf third_party/srtp
 rm -rf third_party/ilbc
 rm -rf third_party/build/baseclasses
 rm -rf third_party/build/g7221
-rm -rf third_party/build/gsm
+#rm -rf third_party/build/gsm
 rm -rf third_party/build/milenage
 rm -rf third_party/build/portaudio/src
 rm -rf third_party/build/resample
 rm -rf third_party/build/samplerate
-rm -rf third_party/build/speex
-rm -rf third_party/build/srtp
+#rm -rf third_party/build/speex
+#rm -rf third_party/build/srtp
 rm -rf third_party/build/ilbc

 %build
@@ -101,12 +101,8 @@
 # that functionality, and it made it easier to ensure that we don't 
 # bundle any unnecessary libraries.  Please contact me if your project
 # needs this support, and I'll re-enable it
-export CFLAGS="-DPJ_HAS_IPV6=1 ${ARCHFLAGS} %{optflags}"
+export CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1 ${ARCHFLAGS} %{optflags}"
 %configure --enable-shared        \
-           --with-external-gsm    \
-           --with-external-pa     \
-           --with-external-speex  \
-           --with-external-srtp   \
            --disable-opencore-amr \
            --disable-resample     \
            --disable-sound        \
@@ -116,7 +112,7 @@
            --without-libyuv       \
            --disable-g7221-codec  

-export CFLAGS="-DPJ_HAS_IPV6=1 %{optflags}"
+export CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1 %{optflags}"
 make %{?_smp_mflags} dep
 make %{?_smp_mflags}

Now, I don't see any Requires option in the spec file however the original RPM still tries to install some additional packages. Where these dependencies are specified? Is this done in the configure script?
Original RPM:
# yum install pjproject-2.3-6.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining pjproject-2.3-6.el7.x86_64.rpm: pjproject-2.3-6.el7.x86_64
Marking pjproject-2.3-6.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pjproject.x86_64 0:2.3-6.el7 will be installed
--> Processing Dependency: libgsm.so.1()(64bit) for package: pjproject-2.3-6.el7.x86_64
Loading mirror speeds from cached hostfile
 * base: mirror.econdc.com
 * epel: mirror.netweaver.uk
 * extras: mozart.ee.ic.ac.uk
 * ius: mirrors.ircam.fr
 * updates: mirror.econdc.com
--> Processing Dependency: libspeex.so.1()(64bit) for package: pjproject-2.3-6.el7.x86_64
--> Processing Dependency: libspeexdsp.so.1()(64bit) for package: pjproject-2.3-6.el7.x86_64
--> Processing Dependency: libsrtp.so.0()(64bit) for package: pjproject-2.3-6.el7.x86_64
--> Running transaction check
---> Package gsm.x86_64 0:1.0.13-11.el7 will be installed
---> Package libsrtp.x86_64 0:1.4.4-10.20101004cvs.el7 will be installed
---> Package speex.x86_64 0:1.2-0.19.rc1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================
 Package                                    Arch                                    Version                                                     Repository                                                    Size
===================================================================================================================================================================================================================
Installing:
 pjproject                                  x86_64                                  2.3-6.el7                                                   /pjproject-2.3-6.el7.x86_64                                  2.1 M
Installing for dependencies:
 gsm                                        x86_64                                  1.0.13-11.el7                                               base                                                          30 k
 libsrtp                                    x86_64                                  1.4.4-10.20101004cvs.el7                                    base                                                         275 k
 speex                                      x86_64                                  1.2-0.19.rc1.el7                                            base                                                          98 k

Transaction Summary
===================================================================================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Custom RPM:
# yum install pjproject-2.3-7.el7.centos.x86_64.rpm 
Loaded plugins: fastestmirror
Examining /var/lib/mock/epel-7-x86_64/result/pjproject-2.3-7.el7.centos.x86_64.rpm: pjproject-2.3-7.el7.centos.x86_64
Marking /var/lib/mock/epel-7-x86_64/result/pjproject-2.3-7.el7.centos.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pjproject.x86_64 0:2.3-7.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================
 Package                                    Arch                                    Version                                              Repository                                                           Size
===================================================================================================================================================================================================================
Installing:
 pjproject                                  x86_64                                  2.3-7.el7.centos                                     /pjproject-2.3-7.el7.centos.x86_64                                  2.3 M

Transaction Summary
===================================================================================================================================================================================================================
Install  1 Package

Total size: 2.3 M
Installed size: 2.3 M

Edit: Tue 27 Mar 20:55:48 UTC 2018
So, I've installed the custom version and repoquery still shows speex and others although they were not required during yum installation. Where is this information pulled from?
# repoquery --requires --resolve pjproject
speex-0:1.2-0.19.rc1.el7.x86_64
libstdc++-0:4.8.5-16.el7_4.2.x86_64
libgcc-0:4.8.5-16.el7_4.2.x86_64
glibc-0:2.17-196.el7_4.2.i686
libuuid-0:2.23.2-43.el7_4.2.x86_64
gsm-0:1.0.13-11.el7.x86_64
glibc-0:2.17-196.el7.x86_64
libsrtp-0:1.4.4-10.20101004cvs.el7.x86_64
openssl-libs-1:1.0.2k-8.el7.x86_64


RPM automatically finds runtime dependencies, so Requires: usually isn't necessary. If the requires are in the RPM, it's because the program as compiled actually needs them.

You can force no automatic requirements with AutoReq: no. In that case the rpm will likey don't pull any dependencies unless you specify them yourself.

Build Requires:    and    Requires:    are 2 different things. Now if you look at your %configure in %build you can see %configure --enable-shared        \


      --with-external-gsm    \



      --with-external-pa     \



      --with-external-speex  \



      --with-external-srtp   \ 



So these determine as third party libs which needed on install

One of the handy/annoying things that RPM does for you is the automatic discovery of Provides and Requires. There is a documented way to filter its helpfulness.  For example, these lines in your spec file will effectively remove the direct dependencies on the three libraries you're trying to excise:
# https://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering
%global _privatelibs lib(gsmcodec|srtp|speex)[.]so.*
%global __provides_exclude ^(%{_privatelibs})$
%global __requires_exclude ^(%{_privatelibs})$

You can verify that they are gone, by inspecting the generated rpm file:

$ rpm -q --provides -p ../RPMS/x86_64/pjproject-2.3-6.el7.centos.x86_64.rpm
libpj.so.2()(64bit)
libpjlib-util.so.2()(64bit)
libpjmedia-audiodev.so.2()(64bit)
libpjmedia-codec.so.2()(64bit)
libpjmedia-videodev.so.2()(64bit)
libpjmedia.so.2()(64bit)
libpjnath.so.2()(64bit)
libpjsip-simple.so.2()(64bit)
libpjsip-ua.so.2()(64bit)
libpjsip.so.2()(64bit)
libpjsua.so.2()(64bit)
libpjsua2.so.2()(64bit)
pjproject = 2.3-6.el7.centos
pjproject(x86-64) = 2.3-6.el7.centos

However, if you use repoquery, you get the results of interrogating the upstream package repo instead of your own custom build.

Since I believe pjsip's source bundles those libraries, check your Install section in the spec to see if the locally built libs for those deps are being left out of the binary RPM. It's likely something like there's auto reqs being determined and since they're left out of the RPM, the external RPMs are being included instead. You could also try disabling --enable-shared to build a monolithic binary

# repoquery --requires --resolve pjproject
speex-0:1.2-0.19.rc1.el7.x86_64
libstdc++-0:4.8.5-16.el7_4.2.x86_64
libgcc-0:4.8.5-16.el7_4.2.x86_64
glibc-0:2.17-196.el7_4.2.i686
libuuid-0:2.23.2-43.el7_4.2.x86_64
gsm-0:1.0.13-11.el7.x86_64
glibc-0:2.17-196.el7.x86_64
libsrtp-0:1.4.4-10.20101004cvs.el7.x86_64
openssl-libs-1:1.0.2k-8.el7.x86_64

