# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2008-2012, 2014, 2016 Jonas Smedegaard <dr@jones.dk>
# Description: Class to configure + build GNU autoconf+automake+python packages
#
# 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/>.

#PATH_RULES#

ifndef _cdbs_class_python_autotools
_cdbs_class_python_autotools = 1

include $(_cdbs_class_path)/python-module.mk$(_cdbs_makefile_suffix)

# Flavors are used if more than a single Python build is needed
# Used in implicit rules, so must be set before including makefile
# (leading "python" stripped to stay compatible with CDBS << 0.4.140)
cdbs_make_pythonflavors = $(strip \
	$(if $(word 2,$(cdbs_python_flavors)),\
		$(patsubst python%,%,$(cdbs_python_flavors))))
DEB_MAKE_FLAVORS ?= $(cdbs_make_pythonflavors)

include $(_cdbs_class_path)/autotools.mk$(_cdbs_makefile_suffix)

CDBS_BUILD_DEPENDS_class_python-autotools ?= $(cdbs_python_builddeps_cdbs)
CDBS_BUILD_DEPENDS +=, $(CDBS_BUILD_DEPENDS_class_python-autotools)

# Python-related dependencies according to Python policy, appendix A
CDBS_BUILD_DEPENDS_class_python-autotools_python ?= $(cdbs_python_builddeps)
CDBS_BUILD_DEPENDS +=, $(CDBS_BUILD_DEPENDS_class_python-autotools_python)

# (prepend "python" to digit flavors to stay compatible with CDBS << 0.4.140)
cdbs_make_curpythonruntime = $(strip \
	$(call cdbs_expand_pythonruntime,,$(strip \
		$(patsubst 2%,python2%,\
			$(patsubst 3%,python3%,\
				$(cdbs_make_curflavor))))))

DEB_CONFIGURE_SCRIPT_ENV_PYTHON ?= PYTHON="$(cdbs_make_curpythonruntime)"
cdbs_autotools_configure_env += $(DEB_CONFIGURE_SCRIPT_ENV_PYTHON)

# Install all flavors on top of each other by default
DEB_MAKE_DESTDIRSKEL = $(cdbs_curdestdir)

endif
