Name:           libgeotiff
Version:        1.4.0
Release:        16
Summary:        Open source library of GeoTIFF
License:        MIT
URL:            http://trac.osgeo.org/geotiff/
Source:         http://download.osgeo.org/geotiff/%{name}/%{name}-%{version}.tar.gz
BuildRequires:  gcc-c++ libtiff-devel libjpeg-devel proj-devel zlib-devel

Patch0001:      fix-geotifcp-usage-command-mismatch.patch

%description
This library is designed to permit the extraction and parsing of the "GeoTIFF" Key directories, as
well as definition and installation of GeoTIFF keys in new files.

%package        devel
Summary:        Development documnets for %{name}
Requires:       pkgconfig libtiff-devel
Requires:       %{name} = %{version}-%{release}

%description    devel
The packages provides developments documnets for %{name}.

%package        help
Summary:Help documents for %{name}

%description    help
Man pages and other help documents for %{name}.

%prep
%autosetup -n %{name}-%{version} -p1

%build
%configure --prefix=%{_prefix} --includedir=%{_includedir}/%{name}/ \
           --enable-debug --disable-static --with-proj --with-jpeg --with-zip
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

%make_build

%install
%make_install

cat > %{name}.pc <<EOF
prefix=%{_prefix}
exec_prefix=%{_prefix}
libdir=%{_libdir}
includedir=%{_includedir}/%{name}

Name: %{name}
Description: GeoTIFF file format library
Version: %{version}
Libs: -L\${libdir} -lgeotiff
Cflags: -I\${includedir}
EOF

install -D -p -m 644 %{name}.pc %{buildroot}%{_libdir}/pkgconfig/%{name}.pc

echo  >> %{buildroot}%{_datadir}/epsg_csv/codes.csv

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%doc LICENSE
%dir %{_datadir}/epsg_csv
%attr(0644,root,root) %{_datadir}/epsg_csv/*.csv
%{_bindir}/*
%{_libdir}/%{name}.so.2*
%exclude %{_libdir}/lib*.la

%files devel
%dir %{_includedir}/%{name}
%attr(0644,root,root) %{_includedir}/%{name}/*.{h,inc}
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc

%files help
%doc ChangeLog README
%{_mandir}/man1/listgeo.1.gz

%changelog
* Mon Sep 13 2021 lingsheng <lingsheng@huawei.com> - 1.4.0-16
- fix geotifcp usage command mismatch

* Fri Mar 6 2020 zhouyihang<zhouyihang1@huawei.com> - 1.4.0-15
- Pakcage init
