#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2003-2004 Robert Jordens <rjo@gmx.de>
# Copyright © 2010-2011 Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for liblrdf
#
# 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 2, 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_LIBTOOL = pre
DEB_AUTO_UPDATE_AUTOCONF = 2.65
DEB_AUTO_UPDATE_AUTOHEADER = 2.65
DEB_AUTO_UPDATE_ACLOCAL = 1.11
DEB_AUTO_UPDATE_AUTOMAKE = 1.11

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

DEB_UPSTREAM_URL = http://downloads.sourceforge.net/lrdf

CDBS_BUILD_DEPENDS += , d-shlibs, ladspa-sdk
# Explicitly depend on versioned libraptor. See #613675.
CDBS_BUILD_DEPENDS += , libraptor1-dev (>= 1.4.21-3)

# put aside upstream-shipped temp files during build but after copyright-check
upstreamtmpfiles = INSTALL \
		Makefile.in \
		aclocal.m4 \
		config.guess \
		config.h.in \
		config.sub \
		configure \
		depcomp \
		examples/Makefile.in \
		install-sh \
		ltmain.sh \
		missing \
		mkinstalldirs \
		src/Makefile.am \
		src/Makefile.in \
		src/lrdf_md5.h
pre-build:: debian/stamp-upstreamtmpstuff
debian/stamp-upstreamtmpstuff: debian/stamp-copyright-check
	for file in $(upstreamtmpfiles); do \
		[ ! -e $$file ] || [ -e $$file.upstream ] || cp $$file $$file.upstream; \
	done
	touch $@
clean::
	for file in $(upstreamtmpfiles); do \
		[ ! -e $$file.upstream ] || mv -f $$file.upstream $$file; \
	done
	rm -f debian/stamp-upstreamtmpstuff

clean::
	rm -f stamp-h

binary-post-install/liblrdf0::
	d-shlibmove --commit \
		--movedev "debian/tmp/usr/include/*" usr/include/ \
		--movedev "debian/tmp/usr/lib/pkgconfig/*.pc" usr/lib/pkgconfig/ \
		--moveshl debian/tmp/usr/share/ladspa/rdf/ladspa.rdfs usr/share/ladspa/rdf/ \
		debian/tmp/usr/lib/liblrdf.so

binary-predeb/liblrdf0-dev::
	find debian/liblrdf0-dev/ -type f -name '*.la' -delete
