File linenoise.spec of Package linenoise
#
# spec file for package linenoise
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2015 Oleksandr Chumachenko <ledest@gmail.com>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define sover 0
%define libname lib%{name}
Name: linenoise
Version: 1.0
Release: 0
Summary: A minimal, zero-config, readline replacement
License: BSD-2-Clause
Group: Development/Libraries/C and C++
URL: https://github.com/antirez/%{name}
Source: https://github.com/antirez/linenoise/archive/1.0.tar.gz#/%{name}-%{version}.tar.gz
Patch0: %{name}-1.0-git.patch
Patch1: fix-type-ppc.patch
Patch2: rest-arguments.diff
Patch3: %{name}-1.0-fix-includes.patch
BuildRequires: pkgconfig
%description
Guerrilla line editing library against the idea that a line editing lib needs to
be 20,000 lines of C code
%package -n %{libname}%{sover}
Summary: A minimal, zero-config, readline replacement
Group: System/Libraries
Provides: %{libname} = %{version}
%description -n %{libname}%{sover}
Guerrilla line editing library against the idea that a line editing
lib needs to be 20,000 lines of C code. This is the runtime library.
%package devel
Summary: A minimal, zero-config, readline replacement
Group: Development/Libraries/C and C++
Requires: %{libname} = %{version}
%description devel
Guerrilla line editing library against the idea that a line editing lib needs to
be 20,000 lines of C code.
This devel package contains the actual linenoise stuff, it's distributed as .c
and .h, the lib is built by your humble packager.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2
%patch3 -p1
%build
gcc \
-D_DEFAULT_SOURCE=1 \
%{optflags} -std=c99 -pedantic -W -Wextra -Werror -fPIC -shared -Wl,-soname,%{libname}.so.%{sover} -flto \
-o %{libname}.so.%{sover}.0.0 %{name}.c
%install
install -d -m 0755 %{buildroot}%{_includedir} %{buildroot}%{_libdir}
install -p -m 0644 %{name}.h %{buildroot}%{_includedir}/
install -p -m 0755 %{libname}.so.%{sover}.0.0 %{buildroot}%{_libdir}/
ln -sf %{libname}.so.%{sover}.0.0 %{buildroot}%{_libdir}/%{libname}.so.%{sover}
ln -sf %{libname}.so.%{sover}.0.0 %{buildroot}%{_libdir}/%{libname}.so
install -pD -m 0644 README.m* %{buildroot}%{_docdir}/%{name}/README.md
install -p -m 0644 example.c %{buildroot}%{_docdir}/%{name}/
# creates support file for pkg-config
mkdir %{buildroot}/%{_libdir}/pkgconfig
tee %{buildroot}/%{_libdir}/pkgconfig/linenoise.pc << "EOF"
prefix=%{_prefix}
exec_prefix=${prefix}
libdir=${exec_prefix}/%{_lib}
includedir=${prefix}/include
Name: linenoise
Description: A minimal, zero-config, readline replacement
Version: %{version}
Libs: -L${libdir} -llinenoise
Cflags: -I${includedir}
EOF
%post -n %{libname}%{sover} -p /sbin/ldconfig
%postun -n %{libname}%{sover} -p /sbin/ldconfig
%files -n %{libname}%{sover}
%license LICENSE
%{_libdir}/%{libname}.so.%{sover}*
%files devel
%doc %{_docdir}/%{name}
%{_includedir}/%{name}.h
%{_libdir}/%{libname}.so
%{_libdir}/pkgconfig/%{name}.pc
%changelog