#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2004-2008 Jonas Smedegaard <dr@jones.dk>

DEB_AUTO_UPDATE_LIBTOOL = pre
DEB_AUTO_UPDATE_ACLOCAL = 1.10
DEB_AUTO_UPDATE_AUTOMAKE = 1.10
DEB_AUTO_UPDATE_AUTOCONF = 2.60

# See debian/README.cdbs-tweaks for info on local overrides
ifneq (,$(DEB_MAINTAINER_MODE))
  # Enable stuff not policy compliant (eg. unsuitable for build daemons)
  DEB_COPYRIGHT_CHECK_STRICT = yes
  DEB_AUTO_UPDATE_DEBIAN_CONTROL = yes
endif
include debian/cdbs/1/rules/upstream-tarball.mk
include debian/cdbs/1/rules/copyright-check.mk
include /usr/share/cdbs/1/class/autotools.mk
include debian/cdbs/1/rules/buildinfo.mk
include /usr/share/cdbs/1/rules/debhelper.mk

DEB_UPSTREAM_PACKAGE = icecast
DEB_UPSTREAM_URL = http://downloads.xiph.org/releases/icecast/
DEB_UPSTREAM_TARBALL_MD5 = ff516b3ccd2bcc31e68f460cd316093f

DEB_CONFIGURE_SYSCONFDIR = /etc/icecast2
DEB_CONFIGURE_EXTRA_FLAGS = --program-transform-name="s/icecast$$/icecast2/"
DEB_MAKE_INVOKE += PACKAGE=icecast2 docdir=/usr/share/doc/icecast2 pkgdatadir=/usr/share/icecast2
DEB_INSTALL_DIRS_icecast2 = var/log/icecast2
DEB_INSTALL_MANPAGES_icecast2 = debian/icecast2.1

# Debian has a central copy of the GPL, no need to distribute again
common-binary-post-install-arch::
	rm -f $(DEB_DESTDIR)/usr/share/doc/icecast2/COPYING

# Move XSLT templates and CSS files to /etc and replace with symlinks
common-binary-post-install-arch::
	for file in `cd $(DEB_DESTDIR)/usr/share && find icecast2 -type f \( -name *.xsl -or -name *.css \)`; do \
		mkdir -p $(DEB_DESTDIR)/etc/`dirname $$file`; \
		mv $(DEB_DESTDIR)/usr/share/$$file $(DEB_DESTDIR)/etc/$$file; \
		ln -s /etc/$$file $(DEB_DESTDIR)/usr/share/$$file; \
	done

# Upstream requirements
#  Icecast is GPL so needs gnutls variant of CURL
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), libogg-dev (>> 1.0.0), libvorbis-dev (>> 1.0.0), libxslt1-dev | libxslt-dev, libxml2-dev, libcurl4-gnutls-dev, libtheora-dev (>= 0.0.0.alpha7), libspeex-dev, po-debconf

# Resolve, cleanup and apply CDBS-declared dependencies
include debian/cdbs/1/rules/package-relations.mk
