%define pkg_name    udunits2
%define pkg_version 2.2.26
%define pkg_release 1%{?_dist_release}

Summary: A library for manipulating units of physical quantities
Name:    %{pkg_name}
Version: %{pkg_version}
Release: %{pkg_release}

License: UCAR
Group:   System Environment/Libraries
URL: http://www.unidata.ucar.edu/software/udunits/

Source0: ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-%{version}.tar.gz

BuildRequires: gcc-c++, groff, byacc, expat-devel, CUnit-devel
BuildRequires: chrpath


%description
The Unidata units utility, udunits2, supports conversion of unit specifications 
between formatted and binary forms, arithmetic manipulation of unit 
specifications, and conversion of values between compatible scales of 
measurement. A unit is the amount by which a physical quantity is measured. For 
example:

                  Physical Quantity   Possible Unit
                  _________________   _____________
                        time              weeks
                      distance         centimeters
                        power             watts

This utility works interactively and has two modes. In one mode, both an input 
and output unit specification are given, causing the utility to print the 
conversion between them. In the other mode, only an input unit specification is 
given. This causes the utility to print the definition -- in standard units -- 
of the input unit.

%package devel
Group:    Development/Libraries
Summary:  Headers and libraries for udunits2
Requires: %{name} = %{version}-%{release}

%description devel
This package contains the files needed for compiling programs using
the udunits2 library.


%prep
%setup -q -n udunits-%{version}

%build
%configure --disable-static --docdir %{_docdir}/%{name}-%{version}
%{__make} %{?_smp_mflags}

%install
%{__make} DESTDIR=${RPM_BUILD_ROOT} install install-html install-pdf

# Remove rpath
chrpath -d %{buildroot}%{_bindir}/*

# Install info and doc
%{__mkdir_p} ${RPM_BUILD_ROOT}%{_infodir}/
%{__install} -p -m0644 %{name}.info ${RPM_BUILD_ROOT}%{_infodir}
%{__install} -p -m0644 ANNOUNCEMENT ${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}/

# we get this in %%license
%{__rm} -rf ${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}/COPYRIGHT

# We need to do this to avoid conflicting with udunits v1
%{__mkdir_p} ${RPM_BUILD_ROOT}%{_includedir}/%{name}/
%{__mv} ${RPM_BUILD_ROOT}%{_includedir}/*.h ${RPM_BUILD_ROOT}%{_includedir}/%{name}/
%{__rm} -rf ${RPM_BUILD_ROOT}%{_libdir}/*.la
%{__rm} -rf ${RPM_BUILD_ROOT}%{_infodir}/dir

%check
%{__make} check

%post
%{_syssbindir}/ldconfig
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :


%preun
if [ $1 = 0 ] ; then
  /sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi

%postun -p %{_syssbindir}/ldconfig


%files
%{_bindir}/%{name}
%{_libdir}/libudunits2.so.*
%{_datadir}/udunits/
%{_docdir}/%{name}-%{version}
%{_infodir}/%{name}*.info*

%files devel
%{_includedir}/%{name}/
%{_libdir}/libudunits2.so


%changelog
* Tue Mar 12 2019 Toshiaki Ara <ara_t@384.jp> 2.2.26-1
- first release for Vine Linux
