# -*- rpm-spec -*-
BuildRoot:      @CPACK_RPM_DIRECTORY@/@CPACK_PACKAGE_FILE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@
Summary:        @CPACK_RPM_PACKAGE_SUMMARY@
Name:           @CPACK_RPM_PACKAGE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_NAME@
Version:        @CPACK_RPM_PACKAGE_VERSION@
Release:        @CPACK_RPM_PACKAGE_RELEASE@
License:        @CPACK_RPM_PACKAGE_LICENSE@
Group:          @CPACK_RPM_PACKAGE_GROUP@
Vendor:         @CPACK_RPM_PACKAGE_VENDOR@
@TMP_RPM_URL@
@TMP_RPM_REQUIRES@
@TMP_RPM_PROVIDES@
@TMP_RPM_OBSOLETES@
@TMP_RPM_CONFLICTS@
@TMP_RPM_AUTOPROV@
@TMP_RPM_AUTOREQ@
@TMP_RPM_AUTOREQPROV@
@TMP_RPM_BUILDARCH@
@TMP_RPM_PREFIX@

%define _rpmdir @CPACK_RPM_DIRECTORY@
%define _rpmfilename @CPACK_RPM_FILE_NAME@
%define _unpackaged_files_terminate_build 0
%define _topdir @CPACK_RPM_DIRECTORY@
# This is a hack to change platform default path with our cmake/cpack ones
%define _bindir @CPACK_OPENCPN_RPM_BINDIR@
%define _libdir @CPACK_OPENCPN_RPM_LIBDIR@
%define _datadir @CPACK_OPENCPN_RPM_DATADIR@
@TMP_RPM_SPEC_INSTALL_POST@
@CPACK_RPM_SPEC_MORE_DEFINE@
@CPACK_RPM_COMPRESSION_TYPE_TMP@

%description
@CPACK_RPM_PACKAGE_DESCRIPTION@

# This is a shortcutted spec file generated by CMake RPM generator
# we skip _install step because CPack does that for us.
# We do only save CPack installed tree in _prepr
# and then restore it in build.
%prep
mv $RPM_BUILD_ROOT "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot"

%install
if [ -e $RPM_BUILD_ROOT ];
then
  rm -rf $RPM_BUILD_ROOT
fi
mv "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot" $RPM_BUILD_ROOT
desktop-file-install \
--dir=%{buildroot}%{_datadir}/applications              \
%{buildroot}/%{_datadir}/applications/%{name}.desktop
%find_lang %{name}
%find_lang %{name}-chartdldr_pi
%find_lang %{name}-dashboard_pi
%find_lang %{name}-grib_pi
%find_lang %{name}-wmm_pi

%clean

%post
@CPACK_RPM_SPEC_POSTINSTALL@

%postun
@CPACK_RPM_SPEC_POSTUNINSTALL@

%pre
@CPACK_RPM_SPEC_PREINSTALL@

%preun
@CPACK_RPM_SPEC_PREUNINSTALL@

%files
%files -f %{name}.lang
%files -f %{name}-chartdldr_pi.lang
%files -f %{name}-dashboard_pi.lang
%files -f %{name}-grib_pi.lang
%files -f %{name}-wmm_pi.lang
%defattr(-,root,root,-)

%dir %{_bindir}
%{_bindir}/opencpn

%dir %{_libdir}/%{name}
%{_libdir}/%{name}/libchartdldr_pi.so
%{_libdir}/%{name}/libdashboard_pi.so
%{_libdir}/%{name}/libgrib_pi.so
%{_libdir}/%{name}/libwmm_pi.so

%dir %{_datadir}/applications
%{_datadir}/applications/%{name}.desktop

%dir %{_datadir}/icons/hicolor/48x48/apps
%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
%dir %{_datadir}/icons/hicolor/scalable/apps
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg

%dir %{_datadir}/%{name}
%doc %{_datadir}/%{name}/license.txt

%dir %{_datadir}/%{name}/uidata
%config %{_datadir}/%{name}/uidata/*

%dir %{_datadir}/%{name}/s57data
%config %{_datadir}/%{name}/s57data/*.csv
%config %{_datadir}/%{name}/s57data/*.RLE
%config %{_datadir}/%{name}/s57data/*.xml
%{_datadir}/%{name}/s57data/*.png

%if %{_include_gshhs_min} == "ON"
  %dir %{_datadir}/%{name}/gshhs
  %{_datadir}/%{name}/gshhs/poly-c-1.dat
%endif
%if %{_include_gshhs_crude} == "ON"
  %{_datadir}/%{name}/gshhs/wdb_borders_c.b
  %{_datadir}/%{name}/gshhs/wdb_rivers_c.b
%endif
%if %{_include_gshhs_low} == "ON"
  %{_datadir}/%{name}/gshhs/wdb_borders_l.b
  %{_datadir}/%{name}/gshhs/wdb_rivers_l.b
  %{_datadir}/%{name}/gshhs/poly-l-1.dat
%endif
%if %{_include_gshhs_intermediate} == "ON"
  %{_datadir}/%{name}/gshhs/wdb_borders_i.b
  %{_datadir}/%{name}/gshhs/wdb_rivers_i.b
  %{_datadir}/%{name}/gshhs/poly-i-1.dat
%endif
%if %{_include_gshhs_high} == "ON"
  %{_datadir}/%{name}/gshhs/wdb_borders_h.b
  %{_datadir}/%{name}/gshhs/wdb_rivers_h.b
  %{_datadir}/%{name}/gshhs/poly-h-1.dat
%endif
%if %{_include_gshhs_full} == "ON"
  %{_datadir}/%{name}/gshhs/wdb_borders_f.b
  %{_datadir}/%{name}/gshhs/wdb_rivers_f.b
  %{_datadir}/%{name}/gshhs/poly-f-1.dat
%endif

%if %{_include_tcdata} == "ON"
  %dir %{_datadir}/%{name}/tcdata
  %{_datadir}/%{name}/tcdata/HARMONIC
  %{_datadir}/%{name}/tcdata/HARMONIC.IDX
  %doc %{_datadir}/%{name}/tcdata/README*
%endif

%dir %{_datadir}/%{name}/sounds
%{_datadir}/%{name}/sounds/*.wav
%doc %{_datadir}/%{name}/sounds/README*

%docdir %{_datadir}/%{name}/doc
%doc %{_datadir}/%{name}/doc/help_web.html
%if %{_include_docs} == "ON"
  %exclude %{_datadir}/%{name}/doc/readme*
  %doc %{_datadir}/%{name}/doc/help_en_US.html
  %doc %{_datadir}/%{name}/doc/images/*
%endif

%docdir %{_datadir}/doc/%{name}
%doc %{_datadir}/doc/%{name}/copyright
%doc %{_datadir}/doc/%{name}/changelog

%dir %{_datadir}/%{name}/plugins/chartdldr_pi/data
%config %{_datadir}/%{name}/plugins/chartdldr_pi/data/*.xml
%{_datadir}/%{name}/plugins/chartdldr_pi/data/*.png
%if %{_include_docs} == "ON"
  %docdir %{_datadir}/%{name}/plugins/chartdldr_pi/data/doc
  %doc %{_datadir}/%{name}/plugins/chartdldr_pi/data/doc/*
%else
  %exclude %{_datadir}/%{name}/plugins/chartdldr_pi/data/doc
%endif

%dir %{_datadir}/%{name}/plugins/dashboard_pi/data
%{_datadir}/%{name}/plugins/dashboard_pi/data/*.svg

%dir %{_datadir}/%{name}/plugins/grib_pi/data
%{_datadir}/%{name}/plugins/grib_pi/data/*.svg

%dir %{_datadir}/%{name}/plugins/wmm_pi/data
%config %{_datadir}/%{name}/plugins/wmm_pi/data/*.COF
%{_datadir}/%{name}/plugins/wmm_pi/data/*.svg



%changelog
@CPACK_RPM_SPEC_CHANGELOG@
