%global packname Rcpp

%global __suggests_exclude ^R\\((pkgKitten|rbenchmark|tinytest)\\)

Name:          R-%{packname}
Version:       1.0.8.3
Release:       1
Summary:       Seamless R and C++ Integration

License:       GPLv2+ and Boost
URL:           https://cran.r-project.org/package=%{packname}
Source0:       %{url}&version=%{version}#/%{packname}_%{version}.tar.gz

BuildRequires: gcc-c++
BuildRequires: R-core-devel
BuildRequires: R-inline
BuildRequires: dos2unix

Requires:      R-core%{?_isa}

%description
The Rcpp package provides R functions as well as C++ classes which
offer a seamless integration of R and C++. Many R data types and
objects can be mapped back and forth to C++ equivalents which
facilitates both writing of new code as well as easier integration of
third-party libraries.
Documentation about Rcpp is provided by several vignettes included in
this package, via the Rcpp Gallery site at http://gallery.rcpp.org,
the paper by Eddelbuettel and Francois (2011, JSS), and the book by
Eddelbuettel (2013, Springer).
See citation("Rcpp") for details on the last two.

%package devel
Summary: Rcpp Development Files
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: R-core-devel%{?_isa}

%description devel
Header files for Rcpp.

%package examples
Summary: Rcpp Examples
Requires: %{name}%{?_isa} = %{version}-%{release}

%description examples
Examples for using Rcpp.

%prep
%setup -q -c

dos2unix -k \
    %{packname}/inst/tinytest/cpp/InternalFunction.cpp \
    %{packname}/inst/tinytest/cpp/InternalFunctionCPP11.cpp

%build

%install
mkdir -p %{buildroot}%{_libdir}/R/library
%{_bindir}/R CMD INSTALL -l %{buildroot}%{_libdir}/R/library %{packname}
test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
rm -rf %{buildroot}%{_libdir}/R/library/R.css
rm -rf %{buildroot}%{_libdir}/R/library/%{packname}/tinytest

sed 's!/bin/env Rscript!/usr/bin/Rscript!' \
    -i %{buildroot}%{_libdir}/R/library/%{packname}/discovery/cxx0x.R
chmod 755 %{buildroot}%{_libdir}/R/library/%{packname}/discovery/cxx0x.R

for f in ConvolveBenchmarks/overhead.r ConvolveBenchmarks/overhead.sh \
  Misc/ifelseLooped.r Misc/newFib.r OpenMP/OpenMPandInline.r ; do
    chmod 755 %{buildroot}%{_libdir}/R/library/%{packname}/examples/$f
done

%check
_R_CHECK_FORCE_SUGGESTS_=0 %{_bindir}/R CMD check %{packname}

%files
%dir %{_libdir}/R/library/%{packname}
%doc %{_libdir}/R/library/%{packname}/NEWS.Rd
%doc %{_libdir}/R/library/%{packname}/announce
%doc %{_libdir}/R/library/%{packname}/bib
%doc %{_libdir}/R/library/%{packname}/doc
%doc %{_libdir}/R/library/%{packname}/html
%{_libdir}/R/library/%{packname}/CITATION
%{_libdir}/R/library/%{packname}/DESCRIPTION
%{_libdir}/R/library/%{packname}/INDEX
%{_libdir}/R/library/%{packname}/NAMESPACE
%{_libdir}/R/library/%{packname}/Meta
%{_libdir}/R/library/%{packname}/R
%{_libdir}/R/library/%{packname}/discovery
%{_libdir}/R/library/%{packname}/help
%{_libdir}/R/library/%{packname}/libs
%{_libdir}/R/library/%{packname}/prompt
%{_libdir}/R/library/%{packname}/skeleton

%files devel
%{_libdir}/R/library/%{packname}/include

%files examples
%{_libdir}/R/library/%{packname}/examples

%changelog
* Wed Jun 15 2022 misaka00251 <misaka00251@misakanet.cn> - 1.0.8.3-1
- Init package (Thanks to fedora team)
