-%include /usr/lib/rpm/macros.perl
-Summary: Net-IP perl module
-Summary(pl): Modu³ perla Net-IP
-Name: perl-Net-IP
-Version: 1.0
-Release: 1
-License: GPL
+#
+############################################################
+#
+# NOTE
+# - use the SOURCES/pldcpan.pl script for new perl packages
+# also available in pldcpan package.
+#
+############################################################
+#
+# Conditional build:
+%bcond_without tests # do not perform "make test"
+#
+%define pdir PDIR
+%define pnam PNAM
+Summary: -
+Summary(pl.UTF-8): -
+Name: perl-PDIR-PNAM
+Version: -
+Release: -
+# note if it is "same as perl"
+#License: GPL v1+ or Artistic
+License: (enter GPL/LGPL/BSD/BSD-like/Artistic/other license name here)
Group: Development/Languages/Perl
-Group(de): Entwicklung/Sprachen/Perl
-Group(es): Desarrollo/Lenguages/Perl
-Group(fr): Development/Langues/Perl
-Group(pl): Programowanie/Jêzyki/Perl
-Source0: ftp://ftp.perl.org/pub/CPAN/modules/by-module/Net/Net-IP-%{version}.tar.gz
-Patch0: %{name}-doc.patch
-Patch1: %{name}-perl-path.patch
-BuildRequires: rpm-perlprov >= 3.0.3-16
-BuildRequires: perl >= 5.6
+Source0: http://www.cpan.org/modules/by-module/PDIR/%{pdir}-%{pnam}-%{version}.tar.gz
+# Source0-md5:
+Patch0: %{name}-foo.patch
+# most of CPAN modules have generic URL (substitute pdir and pnam here)
+URL: https://metacpan.org/release/PDIR-PNAM
+BuildRequires: perl-devel >= 1:5.8.0
+BuildRequires: rpm-perlprov >= 4.1-13
+BuildRequires: rpmbuild(macros) >= 1.745
+BuildRequires: -
+%if %{with tests}
+BuildRequires: perl-
+BuildRequires: perl-
+%endif
+Requires: -
+Provides: -
+Obsoletes: -
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+%define _noautoreq_perl anything_fake_or_conditional
+
%description
-Net-iP Perl extension for the IP protocol.
-%description -l pl
-Net-IP - wsparcie dla protoko³u IP.
+%description -l pl.UTF-8
%prep
-%setup -q -n Net-IP-%{version}
+%setup -q -n %{pdir}-%{pnam}-%{version}
%patch0 -p1
-%patch1 -p1
+
+# fix #!/usr/bin/env perl -w -> #!/usr/bin/perl:
+%{__sed} -i -e '1s,^#!.*perl,#!%{__perl},' tofu
%build
-perl Makefile.PL
+# Don't use pipes here: they generally don't work. Apply a patch.
+%{__perl} Makefile.PL \
+ INSTALLDIRS=vendor
+
+# Build.PL based packages
+%{__perl} Build.PL \
+ perl=%{__perl} \
+ installdirs=vendor
+./Build
+
%{__make}
+# if module isn't noarch, use:
+# %{__make} \
+# CC="%{__cc}"
+# OPTIMIZE="%{rpmcflags}"
+
+# for C++ programs, use also CC but specify __cxx:
+# NOTE: (this) Perl build system doesn't have CXX, but CC is used
+#%{__make} \
+# CC="%{__cxx}" \
+# OPTIMIZE="%{rpmcflags}"
+
+%{?with_tests:%{__make} test}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{_bindir}
-
-%{__make} install \
+%{__make} pure_install \
DESTDIR=$RPM_BUILD_ROOT
-
-install ipcount.pl $RPM_BUILD_ROOT%{_bindir}
-gzip -9nf Changes README
+./Build install \
+ destdir=$RPM_BUILD_ROOT
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc *.gz
-%{perl_sitelib}/Net/IP.pm
-%attr(755,root,root) %{_bindir}/*.pl
+%doc Changes README
+# NOTE it's mostly easier to copy unpackaged filelist here, and run adapter over the spec.
+# use macros:
+#%%{perl_vendorlib}/PDIR...
+#%%{perl_vendorarch}/PDIR...
%{_mandir}/man3/*