#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2014 Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for Marpa::R2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

include /usr/share/cdbs/1/rules/upstream-tarball.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/class/perl-build.mk
include /usr/share/cdbs/1/rules/debhelper.mk

pkg = $(DEB_SOURCE_PACKAGE)

DEB_UPSTREAM_PACKAGE = Marpa-R2
DEB_UPSTREAM_URL = http://www.cpan.org/CPAN/authors/id/J/JK/JKEGL
DEB_UPSTREAM_TARBALL_MD5 = 1fe355bb35ddb679cc8553a71ae5e678

DEB_UPSTREAM_REPACKAGE_EXCLUDES += \
 ./t/etc/wall_proof.txt

# needed by upstream build
bdeps = perl (>= 5.17.1) | libcpan-meta-perl (>= 2.120921)
bdeps +=, libconfig-autoconf-perl (>= 0.22)
bdeps +=, perl (>= 5.11.2) | libextutils-cbuilder-perl
bdeps +=, perl (>= 5.17.3) | libmodule-build-perl (>= 0.4003)

# needed by upstream build and (always) at runtime
#  * perl 5.11 needed for Data::Dumper 2.125 (not packaged separately)
deps +=, perl (>= 5.11)
deps +=, libhtml-parser-perl (>= 3.69)

# Needed (always/optionally) by upstream testsuite
deps-test = perl (>= 5.11.1) | libtest-simple-perl (>= 0.94)
deps-test-opt = libppi-perl

CDBS_BUILD_DEPENDS +=, $(bdeps), $(deps), $(deps-test), $(deps-test-opt)
CDBS_DEPENDS_$(pkg) = $(deps)

# install demos and their pod files only as example files
binary-post-install/$(pkg)::
	mkdir -p debian/$(pkg)/usr/share/doc/$(pkg)/examples
	mv -t debian/$(pkg)/usr/share/doc/$(pkg)/examples \
		debian/$(pkg)/usr/bin/marpa_r2_html_* \
		debian/$(pkg)/usr/lib/perl5/Marpa/R2/html_* \
		debian/$(pkg)/usr/share/man/man3/Marpa::R2::html_*

binary-fixup/$(pkg)::
	chmod -x debian/$(pkg)/usr/share/doc/$(pkg)/examples/*.pod*
