Name:             proj
Version:          4.9.3
Release:          8
Summary:          A generic coordinate transformation software
License:          MIT
URL:              https://proj4.org
Source0:          http://download.osgeo.org/proj/proj-%{version}.tar.gz
Source1:          http://download.osgeo.org/proj/proj-datumgrid-1.6.zip
BuildRequires:    libtool

%description
PROJ is a generic coordinate transformation software that transforms
geospatial coordinates from one coordinate reference system (CRS) to
another. This includes cartographic projections as well as geodetic
transformations. PROJ is released under the X/MIT open source license.

%package          help
Summary:          Help documentation for the proj

%description      help
Help documentation for the proj.

%package          devel
Summary:          Development files for PROJ.4
Requires:         proj = %{version}-%{release}
Provides:         proj-static = %{version}-%{release}
Obsoletes:        proj-static < %{version}-%{release}

%description      devel
This package contains libproj and the appropriate header files and man pages
and libproj static library.This package alse contains additional US and
Canadian datum shift grids and additional EPSG dataset.

%package          nad
Summary:          US and Canadian datum shift grids for PROJ.4
Requires:         proj = %{version}-%{release}

%description      nad
This package contains additional US and Canadian datum shift grids.

%package          epsg
Summary:          EPSG dataset for PROJ.4
Requires:         proj = %{version}-%{release}

%description      epsg
This package contains additional EPSG dataset.

%prep
%autosetup -n proj-%{version}

for makefile in `find . -type f -name 'Makefile.in'`; do
sed -i 's|@LIBTOOL@|%{_bindir}/libtool|g' $makefile
done

pushd nad
unzip -o %{SOURCE1}
cd ..

for script in `find nad/ -type f -perm -a+x`; do
sed -i -e '1,1s|:|#!/bin/bash|' $script
done

%build
sed -i -e 's|5\:4\:5|6\:4\:6|' src/Makefile*
%configure
%make_build OPTIMIZE="$RPM_OPT_FLAGS"

%install
%makeinstall
install -p -m 0644 nad/pj_out27.dist nad/pj_out83.dist nad/td_out.dist %{buildroot}%{_datadir}/proj
install -p -m 0755 nad/test27 nad/test83 nad/testvarious %{buildroot}%{_datadir}/proj
install -p -m 0644 nad/epsg %{buildroot}%{_datadir}/proj
install -p -m 0644 src/projects.h %{buildroot}%{_includedir}/

%check
cd nad
export PROJ_LIB=%{buildroot}%{_datadir}/proj
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH%{buildroot}%{_libdir}
for i in 27 83 IGNF ntv2 various;do
./test$i      %{buildroot}%{_bindir}/proj || exit 0
done
cd -

%post
/sbin/ldconfig
%postun
/sbin/ldconfig

%files
%doc AUTHORS COPYING
%{_bindir}/*
%{_libdir}/libproj.so.12*

%files help
%doc NEWS README ChangeLog
%{_mandir}/man1/*.1*
%{_mandir}/man3/*.3*

%files devel
%{_includedir}/*.h
%{_libdir}/{libproj.so,libproj.a,libproj.la}
%attr(0755,root,root) %{_libdir}/pkgconfig/proj.pc

%files nad
%doc nad/README
%attr(0755,root,root) %{_datadir}/proj/{test27,test83,testvarious}
%attr(0755,root,root) %{_libdir}/pkgconfig/proj.pc
%{_datadir}/proj
%exclude %{_datadir}/proj/epsg

%files epsg
%doc nad/README
%attr(0644,root,root) %{_datadir}/proj/epsg

%changelog
* Wed Feb 19 2020 Senlin Xia <xiasenlin1@huawei.com> 4.9.3-8
- package init
