#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2012-2013, 2015-2017, Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for ical2html
#
# 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/>.

DEB_AUTO_UPDATE_AUTOCONF = ,
DEB_AUTO_UPDATE_AUTOHEADER = ,
DEB_AUTO_UPDATE_ACLOCAL = ,
DEB_AUTO_UPDATE_AUTOMAKE = ,
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk

pkg = ical2html
cmds = ical2html icalfilter icalmerge
manpages = $(cmds:%=debian/%.1)

# Needed by upstream build process
CDBS_BUILD_DEPENDS +=, libical-dev (>= 2.0.0)

# suppress checking license during build
DEB_COPYRIGHT_CHECK_LICENSECHECK =
CDBS_BUILD_DEPENDS_rules_utils_copyright-check =

DEB_UPSTREAM_CRUFT_MOVE = Makefile.in aclocal.m4 missing depcomp install-sh configure config.h.in

# bootstrap autotools files (CDBS normally only updates them)
DEB_AUTOMAKE_ARGS = --add-missing --copy

# Install CSS only as example file
DEB_INSTALL_EXAMPLES_$(pkg) = calendar.css
binary-post-install/$(pkg)::
	rm -f debian/$(cdbs_curpkg)/usr/share/calendar.css

# generate manpage based on --help of script itself
CDBS_BUILD_DEPENDS +=, help2man
DEB_INSTALL_MANPAGES_$(pkg) = $(manpages)
help2man_invoke = help2man --version-string="$(DEB_UPSTREAM_VERSION)" --no-info --no-discard-stderr --output=$@
build/$(pkg):: $(manpages)
debian/ical2html.1: debian/%.1: %
	$(help2man_invoke) --name="create an HTML table from icalendar data" ./$<
debian/icalfilter.1: debian/%.1: %
	$(help2man_invoke) --name="filter an iCalendar file based on class and/or category" ./$<
debian/icalmerge.1: debian/%.1: %
	$(help2man_invoke) --name="merge icalendar files, keeping only the most recent version of each event" ./$<
clean::
	rm -f $(manpages)
