diff mbox series

[rdma-core,9/9] rpm: Add flag to include static libraries in the build

Message ID 4c471c17-ecb9-d528-7e83-14c4fbc0bf5d@suse.de (mailing list archive)
State Accepted
Headers show
Series None | expand

Commit Message

Nicolas Morey-Chaisemartin Oct. 25, 2018, 4:56 p.m. UTC
Now that we can produce them properly, make it easy to add them.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
---

Tested both ways on centos7 and tumbleweed

 redhat/rdma-core.spec | 15 +++++++++++++++
 suse/rdma-core.spec   | 18 +++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

Comments

Jason Gunthorpe Oct. 25, 2018, 9:43 p.m. UTC | #1
On Thu, Oct 25, 2018 at 06:56:46PM +0200, Nicolas Morey-Chaisemartin wrote:
> Now that we can produce them properly, make it easy to add them.
> 
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
> 
> Tested both ways on centos7 and tumbleweed
> 
>  redhat/rdma-core.spec | 15 +++++++++++++++
>  suse/rdma-core.spec   | 18 +++++++++++++++++-
>  2 files changed, 32 insertions(+), 1 deletion(-)

I updated things, thanks

> diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec
> index c281c5fa4e2c..644c3ffd01bf 100644
> +++ b/redhat/rdma-core.spec
> @@ -10,6 +10,8 @@ Summary: RDMA core userspace libraries and daemons
>  License: GPLv2 or BSD
>  Url: https://github.com/linux-rdma/rdma-core
>  Source: rdma-core-%{version}.tgz
> +# Do not build static libs by default.
> +%define with_static %{?_with_static: 1} %{?!_with_static: 0}
>  
>  BuildRequires: binutils
>  BuildRequires: cmake >= 2.8.11
> @@ -73,6 +75,13 @@ Obsoletes: librdmacm-devel < %{version}-%{release}
>  Requires: ibacm = %{version}-%{release}
>  Provides: ibacm-devel = %{version}-%{release}
>  Obsoletes: ibacm-devel < %{version}-%{release}
> +%if %{with_static}

So we don't want to use

%if %{with static}

As suggested by the RPM manual for this feature?

Jason
Doug Ledford Oct. 26, 2018, 3:49 a.m. UTC | #2
On 10/25/2018 5:43 PM, Jason Gunthorpe wrote:
> On Thu, Oct 25, 2018 at 06:56:46PM +0200, Nicolas Morey-Chaisemartin wrote:
>> Now that we can produce them properly, make it easy to add them.
>>
>> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
>> Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
>>
>> Tested both ways on centos7 and tumbleweed
>>
>>  redhat/rdma-core.spec | 15 +++++++++++++++
>>  suse/rdma-core.spec   | 18 +++++++++++++++++-
>>  2 files changed, 32 insertions(+), 1 deletion(-)
> 
> I updated things, thanks
> 
>> diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec
>> index c281c5fa4e2c..644c3ffd01bf 100644
>> +++ b/redhat/rdma-core.spec
>> @@ -10,6 +10,8 @@ Summary: RDMA core userspace libraries and daemons
>>  License: GPLv2 or BSD
>>  Url: https://github.com/linux-rdma/rdma-core
>>  Source: rdma-core-%{version}.tgz
>> +# Do not build static libs by default.
>> +%define with_static %{?_with_static: 1} %{?!_with_static: 0}
>>  
>>  BuildRequires: binutils
>>  BuildRequires: cmake >= 2.8.11
>> @@ -73,6 +75,13 @@ Obsoletes: librdmacm-devel < %{version}-%{release}
>>  Requires: ibacm = %{version}-%{release}
>>  Provides: ibacm-devel = %{version}-%{release}
>>  Obsoletes: ibacm-devel < %{version}-%{release}
>> +%if %{with_static}
> 
> So we don't want to use
> 
> %if %{with static}
> 
> As suggested by the RPM manual for this feature?

? You are quoting exactly what we are doing and then saying we don't
want to do it?
Jason Gunthorpe Oct. 26, 2018, 4:14 a.m. UTC | #3
On Thu, Oct 25, 2018 at 11:49:30PM -0400, Doug Ledford wrote:
> On 10/25/2018 5:43 PM, Jason Gunthorpe wrote:
> > On Thu, Oct 25, 2018 at 06:56:46PM +0200, Nicolas Morey-Chaisemartin wrote:
> >> Now that we can produce them properly, make it easy to add them.
> >>
> >> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> >> Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
> >>
> >> Tested both ways on centos7 and tumbleweed
> >>
> >>  redhat/rdma-core.spec | 15 +++++++++++++++
> >>  suse/rdma-core.spec   | 18 +++++++++++++++++-
> >>  2 files changed, 32 insertions(+), 1 deletion(-)
> > 
> > I updated things, thanks
> > 
> >> diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec
> >> index c281c5fa4e2c..644c3ffd01bf 100644
> >> +++ b/redhat/rdma-core.spec
> >> @@ -10,6 +10,8 @@ Summary: RDMA core userspace libraries and daemons
> >>  License: GPLv2 or BSD
> >>  Url: https://github.com/linux-rdma/rdma-core
> >>  Source: rdma-core-%{version}.tgz
> >> +# Do not build static libs by default.
> >> +%define with_static %{?_with_static: 1} %{?!_with_static: 0}
> >>  
> >>  BuildRequires: binutils
> >>  BuildRequires: cmake >= 2.8.11
> >> @@ -73,6 +75,13 @@ Obsoletes: librdmacm-devel < %{version}-%{release}
> >>  Requires: ibacm = %{version}-%{release}
> >>  Provides: ibacm-devel = %{version}-%{release}
> >>  Obsoletes: ibacm-devel < %{version}-%{release}
> >> +%if %{with_static}
> > 
> > So we don't want to use
> > 
> > %if %{with static}
> > 
> > As suggested by the RPM manual for this feature?
> 
> ? You are quoting exactly what we are doing and then saying we don't
> want to do it?

Look closely, the patch does this:

+%define with_static %{?_with_static: 1} %{?!_with_static: 0}
%if %{with_static}

Where as the manual seems to say to do

%if %{with static}

Notice the stuble difference of no _ and no intermediate variable..

Jason
Nicolas Morey-Chaisemartin Oct. 26, 2018, 5:58 a.m. UTC | #4
On 10/26/18 6:14 AM, Jason Gunthorpe wrote:
> On Thu, Oct 25, 2018 at 11:49:30PM -0400, Doug Ledford wrote:
>> On 10/25/2018 5:43 PM, Jason Gunthorpe wrote:
>>> On Thu, Oct 25, 2018 at 06:56:46PM +0200, Nicolas Morey-Chaisemartin wrote:
>>>> Now that we can produce them properly, make it easy to add them.
>>>>
>>>> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
>>>> Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
>>>>
>>>> Tested both ways on centos7 and tumbleweed
>>>>
>>>>  redhat/rdma-core.spec | 15 +++++++++++++++
>>>>  suse/rdma-core.spec   | 18 +++++++++++++++++-
>>>>  2 files changed, 32 insertions(+), 1 deletion(-)
>>> I updated things, thanks
>>>
>>>> diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec
>>>> index c281c5fa4e2c..644c3ffd01bf 100644
>>>> +++ b/redhat/rdma-core.spec
>>>> @@ -10,6 +10,8 @@ Summary: RDMA core userspace libraries and daemons
>>>>  License: GPLv2 or BSD
>>>>  Url: https://github.com/linux-rdma/rdma-core
>>>>  Source: rdma-core-%{version}.tgz
>>>> +# Do not build static libs by default.
>>>> +%define with_static %{?_with_static: 1} %{?!_with_static: 0}
>>>>  
>>>>  BuildRequires: binutils
>>>>  BuildRequires: cmake >= 2.8.11
>>>> @@ -73,6 +75,13 @@ Obsoletes: librdmacm-devel < %{version}-%{release}
>>>>  Requires: ibacm = %{version}-%{release}
>>>>  Provides: ibacm-devel = %{version}-%{release}
>>>>  Obsoletes: ibacm-devel < %{version}-%{release}
>>>> +%if %{with_static}
>>> So we don't want to use
>>>
>>> %if %{with static}
>>>
>>> As suggested by the RPM manual for this feature?
>> ? You are quoting exactly what we are doing and then saying we don't
>> want to do it?
> Look closely, the patch does this:
>
> +%define with_static %{?_with_static: 1} %{?!_with_static: 0}
> %if %{with_static}
>
> Where as the manual seems to say to do
>
> %if %{with static}
>
> Notice the stuble difference of no _ and no intermediate variable..
>
> Jason

As said somewhere else in the thread. I tried using the %(with static} and it fails weirdly on centos7 (works on in tumbleweed).
If any one from RHEL wants to give it a try.

As a side note bcond is doing the same thing underneath. --with=static means that a variable called _with_static is defined to 1 :)

Nicolas
Doug Ledford Oct. 26, 2018, 9:47 p.m. UTC | #5
On 10/26/2018 12:14 AM, Jason Gunthorpe wrote:
> On Thu, Oct 25, 2018 at 11:49:30PM -0400, Doug Ledford wrote:
>> On 10/25/2018 5:43 PM, Jason Gunthorpe wrote:
>>> On Thu, Oct 25, 2018 at 06:56:46PM +0200, Nicolas Morey-Chaisemartin wrote:
>>>> Now that we can produce them properly, make it easy to add them.
>>>>
>>>> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
>>>> Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
>>>>
>>>> Tested both ways on centos7 and tumbleweed
>>>>
>>>>  redhat/rdma-core.spec | 15 +++++++++++++++
>>>>  suse/rdma-core.spec   | 18 +++++++++++++++++-
>>>>  2 files changed, 32 insertions(+), 1 deletion(-)
>>>
>>> I updated things, thanks
>>>
>>>> diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec
>>>> index c281c5fa4e2c..644c3ffd01bf 100644
>>>> +++ b/redhat/rdma-core.spec
>>>> @@ -10,6 +10,8 @@ Summary: RDMA core userspace libraries and daemons
>>>>  License: GPLv2 or BSD
>>>>  Url: https://github.com/linux-rdma/rdma-core
>>>>  Source: rdma-core-%{version}.tgz
>>>> +# Do not build static libs by default.
>>>> +%define with_static %{?_with_static: 1} %{?!_with_static: 0}
>>>>  
>>>>  BuildRequires: binutils
>>>>  BuildRequires: cmake >= 2.8.11
>>>> @@ -73,6 +75,13 @@ Obsoletes: librdmacm-devel < %{version}-%{release}
>>>>  Requires: ibacm = %{version}-%{release}
>>>>  Provides: ibacm-devel = %{version}-%{release}
>>>>  Obsoletes: ibacm-devel < %{version}-%{release}
>>>> +%if %{with_static}
>>>
>>> So we don't want to use
>>>
>>> %if %{with static}
>>>
>>> As suggested by the RPM manual for this feature?
>>
>> ? You are quoting exactly what we are doing and then saying we don't
>> want to do it?
> 
> Look closely, the patch does this:
> 
> +%define with_static %{?_with_static: 1} %{?!_with_static: 0}
> %if %{with_static}
> 
> Where as the manual seems to say to do
> 
> %if %{with static}
> 
> Notice the stuble difference of no _ and no intermediate variable..

I seem to recall this is needed to accommodate all possible situations
of firing off an rpmbuild with --with=static, --without=static, and
neither.  And it might only be because of some buggy rpm versions, not
all versions.
diff mbox series

Patch

diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec
index c281c5fa4e2c..644c3ffd01bf 100644
--- a/redhat/rdma-core.spec
+++ b/redhat/rdma-core.spec
@@ -10,6 +10,8 @@  Summary: RDMA core userspace libraries and daemons
 License: GPLv2 or BSD
 Url: https://github.com/linux-rdma/rdma-core
 Source: rdma-core-%{version}.tgz
+# Do not build static libs by default.
+%define with_static %{?_with_static: 1} %{?!_with_static: 0}
 
 BuildRequires: binutils
 BuildRequires: cmake >= 2.8.11
@@ -73,6 +75,13 @@  Obsoletes: librdmacm-devel < %{version}-%{release}
 Requires: ibacm = %{version}-%{release}
 Provides: ibacm-devel = %{version}-%{release}
 Obsoletes: ibacm-devel < %{version}-%{release}
+%if %{with_static}
+# Since our pkg-config files include private references to these packages they
+# need to have their .pc files installed too, even for dynamic linking, or
+# pkg-config breaks.
+BuildRequires: pkgconfig(libnl-3.0)
+BuildRequires: pkgconfig(libnl-route-3.0)
+%endif
 
 %description devel
 RDMA core development libraries and headers.
@@ -233,6 +242,9 @@  discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand.
          -DCMAKE_INSTALL_RUNDIR:PATH=%{_rundir} \
          -DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name}-%{version} \
          -DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir} \
+%if %{with_static}
+         -DENABLE_STATIC=1 \
+%endif
          %{EXTRA_CMAKE_FLAGS}
 %make_jobs
 
@@ -352,6 +364,9 @@  rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh
 %dir %{_includedir}/rdma
 %{_includedir}/infiniband/*
 %{_includedir}/rdma/*
+%if %{with_static}
+%{_libdir}/lib*.a
+%endif
 %{_libdir}/lib*.so
 %{_libdir}/pkgconfig/*.pc
 %{_mandir}/man3/ibv_*
diff --git a/suse/rdma-core.spec b/suse/rdma-core.spec
index 4bb4086cdc78..3eafce39afd2 100644
--- a/suse/rdma-core.spec
+++ b/suse/rdma-core.spec
@@ -17,6 +17,9 @@ 
 
 
 %bcond_without  systemd
+# Do not build static libs by default.
+%define with_static %{?_with_static: 1} %{?!_with_static: 0}
+
 %define         git_ver %{nil}
 Name:           rdma-core
 Version:        21.0
@@ -143,7 +146,14 @@  Obsoletes:      librdmacm-devel < %{version}-%{release}
 #Requires:       ibacm = %%{version}-%%{release}
 Provides:       ibacm-devel = %{version}-%{release}
 Obsoletes:      ibacm-devel < %{version}-%{release}
-
+%if %{with_static}
+# Since our pkg-config files include private references to these packages they
+# need to have their .pc files installed too, even for dynamic linking, or
+# pkg-config breaks.
+BuildRequires: pkgconfig(libnl-3.0)
+BuildRequires: pkgconfig(libnl-route-3.0)
+%endif
+ 
 %description devel
 RDMA core development libraries and headers.
 
@@ -348,6 +358,9 @@  on those changes.
          -DCMAKE_INSTALL_RUNDIR:PATH=%{_rundir} \
          -DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name}-%{version} \
          -DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir} \
+%if %{with_static}
+         -DENABLE_STATIC=1 \
+%endif
          %{EXTRA_CMAKE_FLAGS}
 %make_jobs
 
@@ -526,6 +539,9 @@  rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh
 %dir %{_includedir}/rdma
 %{_includedir}/infiniband/*
 %{_includedir}/rdma/*
+%if %{with_static}
+%{_libdir}/lib*.a
+%endif
 %{_libdir}/lib*.so
 %{_libdir}/pkgconfig/*.pc
 %{_mandir}/man3/ibv_*