#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2014 IOhannes m zmölnig <zmoelnig@iem.at>
# Description: Main Debian packaging script for snd
#
# The authors hereby grant permission to use, copy, modify, distribute,
# and license this software and its documentation for any purpose.  No
# written agreement, license, or royalty fee is required.  Modifications
# to this software may be copyrighted by their authors and need not
# follow the licensing terms described here.
#
# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
# MODIFICATIONS.

# needs to be declared before including makefile.mk
DEB_MAKE_FLAVORS = nox gtk-jack gtk-pulse

DEB_BUILDDIR = build

export AUTOHEADER=true

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/rules/utils.mk

DEB_COPYRIGHT_CHECK_IGNORE_REGEX = \
	^(pix/.*\.png|debian/(changelog|copyright(|_hints|_newhints)))$

DEB_CONFIGURE_EXTRA_FLAGS = \
	--with-ladspa \
	--with-gmp \
	--prefix=/usr

## per flavor configure options

# nox, use ALSA on linux and OSS non non-linux
DEB_CONFIGURE_EXTRA_FLAGS_nox       = --without-gui
ifneq (,$(findstring linux,$(DEB_HOST_ARCH_OS)))
DEB_CONFIGURE_EXTRA_FLAGS_nox += --with-alsa
else
DEB_CONFIGURE_EXTRA_FLAGS_nox += --with-oss
endif

# jack
DEB_CONFIGURE_EXTRA_FLAGS_gtk-jack  = --with-gtk
# the code includes inline-asm for atomic ops, but only for i386/amd64/powerpc
# see https://bugs.debian.org/#555538
ifneq (,$(findstring :$(DEB_HOST_ARCH_CPU):,:i386:powerpc:amd64:))
DEB_CONFIGURE_EXTRA_FLAGS_gtk-jack  += --with-jack
endif

## pulse
DEB_CONFIGURE_EXTRA_FLAGS_gtk-pulse = --with-gtk --with-pulseaudio
DEB_CONFIGURE_EXTRA_FLAGS += $(DEB_CONFIGURE_EXTRA_FLAGS_$(cdbs_make_curflavor))

# upstream naively (and worngly) assumes
# that they only need to link against "-lpulse-simple"
DEB_MAKE_EXTRA_ARGS_gtk-pulse=AUDIO_LIB="$(shell pkg-config --libs libpulse-simple)"
DEB_MAKE_EXTRA_ARGS += $(DEB_MAKE_EXTRA_ARGS_$(cdbs_make_curflavor))

## right; everybody their own changelog filename!
DEB_INSTALL_CHANGELOGS_ALL=HISTORY.Snd
