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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

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

# Needed by upstream build
bdeps = cmake, libqt4-dev, libz-dev, pkg-config, libarchive-dev
bdeps +=, docbook-utils, poxml, xmlto, libxml2-utils
bdeps +=, libasound2-dev [linux-any], libjack-dev, liblrdf-dev
bdeps +=, libsndfile1-dev, portaudio19-dev, libportmidi-dev [linux-any]
bdeps +=, libpulse-dev

CDBS_BUILD_DEPENDS +=, $(bdeps)

DEB_CMAKE_EXTRA_FLAGS = -DWANT_SHARED=OFF \
 -DWANT_PORTAUDIO=ON \
 -DWANT_PORTMIDI=ON \
 -DWANT_RUBBERBAND=ON

# according to upstream INSTALL.txt this avoids potential clash with Qt3
export QTDIR=/usr/share/qt4

common-build-indep:: debian/docs.stamp
debian/docs.stamp:
	$(MAKE) -C data/doc
	touch $@
clean::
	rm -f debian/docs.stamp
	rm -rf CMakeCache.txt CMakeFiles/ try/
	rm -f qt4.pyc version.cpp config.h

# (Re)generate locale files from code sources
DEB_UPSTREAM_CRUFT_MOVE = usr/share/hydrogen/data/i18n/*.qm
build/hydrogen-data:: debian/l10n.stamp
debian/l10n.stamp:
	cd data/i18n && ./updateTranslations.sh
	touch $@
clean::
	rm -f debian/l10n.stamp

binary-install/hydrogen::
	find $(CURDIR)/debian/hydrogen/usr/share/ -type d -empty -delete
	rm -rf $(CURDIR)/debian/hydrogen/usr/lib/
	rm -rf $(CURDIR)/debian/hydrogen/usr/include/
