# -*- mode: makefile; coding: utf-8 -*-
#
# meta-subst.mk
#
# CDBS makefile fragment to parse meta-package relationships into
# ${meta:Depends} and ${meta:Conflicts} substvars.
#
# Copyright (C) 2011 Elmar Hoffmann
#
# 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 of the License, 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

# The name of the package using the substvars
DEB_META_SUBST_PACKAGE ?= $(DEB_SOURCE_PACKAGE)

# Path of meta-subst.sed
DEB_META_SUBST__SED_SCRIPT ?= /lib/elho/meta-subst.sed

cdbs_meta_substvars_file = debian/$(DEB_META_SUBST_PACKAGE).substvars

$(patsubst %,binary-fixup/%,$(DEB_META_SUBST_PACKAGE))::
	if [ -e debian/meta.depends ]; then \
		meta_deps=$$(sed --quiet --file=$(DEB_META_SUBST__SED_SCRIPT) debian/meta.depends) ; \
	else \
		meta_deps='' ; \
	fi ; \
	echo "meta:Depends=$${meta_deps}" >> $(cdbs_meta_substvars_file)
	if [ -e debian/meta.conflicts ]; then \
		meta_confs=$$(sed --quiet --file=$(DEB_META_SUBST__SED_SCRIPT) debian/meta.conflicts) ; \
	else \
		meta_confs='' ; \
	fi ; \
	echo "meta:Conflicts=$${meta_confs}" >> $(cdbs_meta_substvars_file)
