#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2009 Adrian Knoth <adi@drcomp.erfurt.thur.de>
# Copyright © 2010 Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for calf
#
# 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/>.

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

# suppress optional build-dependencies
CDBS_BUILD_DEPENDS_rules_upstream-tarball =
CDBS_BUILD_DEPENDS_rules_utils_copyright-check =
CDBS_BUILD_DEPENDS_rules_utils_buildinfo =

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

# Avoid useless linking
LDFLAGS += -Wl,--as-needed

# put aside upstream-shipped temp files during build but after copyright-check
upstreamtmpfiles = calf.desktop
pre-build:: debian/stamp-upstreamtmpstuff
debian/stamp-upstreamtmpstuff: debian/stamp-copyright-check
	for file in $(upstreamtmpfiles); do \
		[ ! -e $$file ] || [ -e $$file.upstream ] || mv $$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

# Needed by upstream build process
#  * ALSA is optional upstream and only available on some archs
#    (potentially varying, so we resolve list in maintainer builds)
#  * libjack-dev 0.105 recommended (better MIDI) but not required
alsa_archs := $(if $(DEB_MAINTAINER_MODE),$(shell sh debian/pkgarchs.sh libasound2-dev))
CDBS_BUILD_DEPENDS += , libglib2.0-dev, libgtk2.0-dev (>= 2.8), libglade2-dev (>= 2.4), libreadline-dev, libexpat1-dev
CDBS_BUILD_DEPENDS += , libasound2-dev [$(alsa_archs)]
CDBS_BUILD_DEPENDS += , ladspa-sdk, dssi-dev, libjack-dev (>= 0.103.0), lv2core

# Needed for our packaging
#  * devscript needed by pkgarchs.sh (only really needed for maintainer
#    builds, but adding always as it won't hurt and avoids confusion)
CDBS_BUILD_DEPENDS += , devscripts
