Add conditional for static library

This commit is contained in:
Björn Esser 2019-01-30 12:39:14 +01:00
parent c001230d49
commit 5e0cebbeb7
No known key found for this signature in database
GPG Key ID: F52E98007594C21D

View File

@ -19,6 +19,9 @@
%bcond_with enosys_stubs %bcond_with enosys_stubs
%endif %endif
# Build the static library?
%bcond_without staticlib
# Run memcheck? # Run memcheck?
%ifarch %{valgrind_arches} %ifarch %{valgrind_arches}
# Valgrind does not work well on %%{power64} arches. # Valgrind does not work well on %%{power64} arches.
@ -94,7 +97,11 @@
--disable-failure-tokens \\\ --disable-failure-tokens \\\
--disable-silent-rules \\\ --disable-silent-rules \\\
--enable-shared \\\ --enable-shared \\\
%if %{with staticlib} \
--enable-static \\\ --enable-static \\\
%else \
--disable-static \\\
%endif \
%if %{with memcheck} \ %if %{with memcheck} \
--enable-valgrind \\\ --enable-valgrind \\\
%else \ %else \
@ -112,8 +119,10 @@
%{__arch_install_post} \ %{__arch_install_post} \
%{__os_install_post} \ %{__os_install_post} \
%{_bindir}/fipshmac %{buildroot}/%{_lib}/libcrypt.a \ %{_bindir}/fipshmac %{buildroot}/%{_lib}/libcrypt.a \
%{__ln_s} .libcrypt.a.hmac \\\ if [[ %{with staticlib} == 1 ]]; then \
%{buildroot}/%{_lib}/.libxcrypt.a.hmac \ %{__ln_s} .libcrypt.a.hmac \\\
%{buildroot}/%{_lib}/.libxcrypt.a.hmac \
fi \
%{_bindir}/fipshmac %{buildroot}/%{_lib}/libcrypt.so.%{sov} \ %{_bindir}/fipshmac %{buildroot}/%{_lib}/libcrypt.so.%{sov} \
%{__ln_s} .libcrypt.so.%{sov}.hmac \\\ %{__ln_s} .libcrypt.so.%{sov}.hmac \\\
%{buildroot}/%{_lib}/.libcrypt.so.%{soc}.hmac \ %{buildroot}/%{_lib}/.libcrypt.so.%{soc}.hmac \
@ -237,6 +246,7 @@ The %{name}-devel package contains libraries and header files for
developing applications that use %{name}. developing applications that use %{name}.
%if %{with staticlib}
%package static %package static
Summary: Static library for -static linking with %{name} Summary: Static library for -static linking with %{name}
@ -249,6 +259,7 @@ linking.
You don't need this, unless you link statically, which is highly You don't need this, unless you link statically, which is highly
discouraged. discouraged.
%endif
%prep %prep
@ -290,12 +301,14 @@ should work unmodified with the provided version of the
libcrypt.so.1 library in place. libcrypt.so.1 library in place.
EOF EOF
%endif %endif
%if %{with staticlib}
%{__cat} << EOF >> README-STATIC %{__cat} << EOF >> README-STATIC
Applications that use certain legacy APIs supplied by glibcs Applications that use certain legacy APIs supplied by glibcs
libcrypt (encrypt, encrypt_r, setkey, setkey_r, and fcrypt) libcrypt (encrypt, encrypt_r, setkey, setkey_r, and fcrypt)
cannot be compiled nor linked against the supplied build of cannot be compiled nor linked against the supplied build of
the object files provided in the static library libcrypt.a. the object files provided in the static library libcrypt.a.
EOF EOF
%endif
%{__mkdir_p} %{_vpath_builddir}{,-compat} %{__mkdir_p} %{_vpath_builddir}{,-compat}
@ -347,7 +360,8 @@ popd
# Install documentation to shared %%_pkgdocdir. # Install documentation to shared %%_pkgdocdir.
%{__install} -Dpm 0644 -t %{buildroot}%{_pkgdocdir} \ %{__install} -Dpm 0644 -t %{buildroot}%{_pkgdocdir} \
ChangeLog NEWS README README-STATIC THANKS TODO ChangeLog NEWS README THANKS TODO
# Install distribution README file, if existing, to shared %%_pkgdocdir. # Install distribution README file, if existing, to shared %%_pkgdocdir.
if [ -f README%{distname} ]; then if [ -f README%{distname} ]; then
@ -361,6 +375,12 @@ if [ -f README-POSIX ]; then
README-POSIX README-POSIX
fi fi
# Install README-STATIC file, if existing, to shared %%_pkgdocdir.
if [ -f README-STATIC ]; then
%{__install} -Dpm 0644 -t %{buildroot}%{_pkgdocdir} \
README-STATIC
fi
%check %check
%if %{with compat_pkg} %if %{with compat_pkg}
@ -437,10 +457,12 @@ done
%{_mandir}/man3/crypt_preferred_method.3.* %{_mandir}/man3/crypt_preferred_method.3.*
%if %{with staticlib}
%files static %files static
%doc %{_pkgdocdir}/README-STATIC %doc %{_pkgdocdir}/README-STATIC
/%{_lib}/.lib{,x}crypt.a.hmac /%{_lib}/.lib{,x}crypt.a.hmac
/%{_lib}/lib{,x}crypt.a /%{_lib}/lib{,x}crypt.a
%endif
%changelog %changelog