File libmaxminddb.spec of Package GeoIP2

%define realname libmaxminddb
%define realver  1.4.2
%define srcext   tar.gz

%define so_ver   0

# Common info
Name:          GeoIP2
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       Apache-2.0
Group:         Productivity/Networking/Other
URL:           http://maxmind.github.io/libmaxminddb/
Summary:       Utility to find the location of an IP address

# Install-time parameters
Provides:      %{realname}-utils

# Build-time parameters
BuildRequires: pkg-config
BuildRoot:     %{_tmppath}/%{name}-root
Source:        https://github.com/maxmind/libmaxminddb/releases/download/%{version}/%{realname}-%{version}%{?extraver}.%{srcext}

%description
The libmaxminddb library provides a C library for reading MaxMind DB files,
including the GeoIP2 databases from MaxMind. This is a custom binary format
designed to facilitate fast lookups of IP addresses while allowing for great
flexibility in the type of data associated with an address.

The MaxMind DB format is an open format. The spec is available at
http://maxmind.github.io/MaxMind-DB/. This spec is licensed under the Creative
Commons Attribution-ShareAlike 3.0 Unported License.

See http://dev.maxmind.com/ for more details about MaxMind's GeoIP2 products.

%package -n %{realname}%{?so_ver}
Group:         Development/Libraries/C and C++
Summary:       GeoIP is a C library finds the location of an IP address
Provides:      lib%{name}

%description -n %{realname}%{?so_ver}
GeoIP is a C library that enables the user to find geographical and
network information of an IP address.
Included is a free GeoLite Country database
that is updated at the beginning of every month.
To download the latest free GeoLite Country database, go to:
http://www.maxmind.com/app/geoip_country

There is also a free city-level geolocation database, GeoLite City,
available from:
http://www.maxmind.com/app/geolitecity

%package -n %{realname}-devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{realname}%{?so_ver}
Requires:      %{realname}%{?so_ver} = %{version}
Provides:      %{name}-devel lib%{name}-devel

%description -n %{realname}-devel
Development files for %{realname}

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}

%build
%configure \
 --disable-static \
 --enable-binaries \
 --disable-tests \
 CFLAGS="%{optflags} %{?gcc_lto}" \
 LDFLAGS="-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"
%{__make} %{?_smp_mflags}

%install
%{__make} install DESTDIR=%{buildroot}

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc AUTHORS LICENSE NOTICE README.md doc/mmdblookup.md
%{_bindir}/mmdblookup

# Library package
%files -n %{realname}%{?so_ver}
%defattr(-,root,root)
%doc AUTHORS LICENSE NOTICE README.md doc/libmaxminddb.md
%{_libdir}/*.so.%{?so_ver}*
# At now this manpages are fake
%exclude %{_mandir}/man1/*
%exclude %{_mandir}/man3/*

# Development stuff
%files -n %{realname}-devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/libmaxminddb.pc
%{_includedir}/*.h
%{_libdir}/*.so
%exclude %{_libdir}/*.la

%post   -n %{realname}%{?so_ver} -p /sbin/ldconfig
%postun -n %{realname}%{?so_ver} -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by