# -*- mode: makefile; coding: utf-8 -*- # Copyright © 2010 Emilio Pozuelo Monfort # Based on pygobject's debian/rules # Copyright © FIXME add pygobject's debian/rules copyright holders # Description: A class to build Python packages that use autoconf and automake # # 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 . _cdbs_scripts_path ?= /usr/lib/cdbs _cdbs_rules_path ?= /usr/share/cdbs/1/rules _cdbs_class_path ?= /usr/share/cdbs/1/class ifndef _cdbs_class_python_autotools _cdbs_class_python_autotools = 1 include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix) include $(_cdbs_class_path)/python-vars.mk$(_cdbs_makefile_suffix) include $(_cdbs_class_path)/makefile-vars.mk$(_cdbs_makefile_suffix) include $(_cdbs_class_path)/autotools-vars.mk$(_cdbs_makefile_suffix) # FIXME: use rule: and rule:: consistently! # Copied from python-module.mk. We can't include it directly yet # as it calls dh_pyfoo before dh_strip, and then when dh_strip is called # dh_pyfoo has moved the files around and the debugging symbols will # not end in the right place. So we call dh_pyfoo after dh_strip here. # FIXME: try to make dh_strip use build-ids ASAP and remove this hack! # Optionally use debhelper (if not then these rules are simply ignored) $(patsubst %,binary-fixup/%,$(DEB_PACKAGES)) :: binary-fixup/%: binary-install-python/% $(patsubst %,binary-install-python/%,$(DEB_PACKAGES)) :: binary-install-python/%: binary-install/% binary-strip/% dh_$(cdbs_python_system) -p$(cdbs_curpkg) $(DEB_PYTHON_PRIVATE_MODULES_DIRS) $(DEB_PYTHON_PRIVATE_MODULES_DIRS_$(cdbs_curpkg)) ifeq ($(words $(DEB_DBG_PACKAGES)),1) DEB_DBG_PACKAGE ?= $(DEB_DBG_PACKAGES) endif PYDEFAULTVER := $(cdbs_python_current_version) # Put the default python version at the end (only if it's requested) to avoid things like #500118 # FIXME: do this directly in python-vars.mk? ifeq (, $(filter $(cdbs_python_current_version), $(cdbs_python_supported_versions))) PYVERS := $(cdbs_python_supported_versions) else PYVERS := $(filter-out $(cdbs_python_current_version), $(cdbs_python_supported_versions)) $(cdbs_python_current_version) endif maybe_check = $(if $(findstring nocheck,$(DEB_BUILD_OPTIONS)),,check) # from makefile.mk cdbs_make_curbuilddir = $(or $(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR)) cdbs_make_curdestdir = $(or $(DEB_DESTDIR_$(cdbs_curpkg)),$(DEB_DESTDIR)) build-%/configure-stamp: cdbs_make_curbuilddir = build-$* build-%/configure-stamp: DEB_CONFIGURE_SCRIPT_ENV += PYTHON=/usr/bin/python$* build-%/configure-stamp: mkdir -p build-$* $(DEB_CONFIGURE_INVOKE) \ $(DEB_CONFIGURE_EXTRA_FLAGS) $(DEB_CONFIGURE_USER_FLAGS) touch $@ dbg-build-%/configure-stamp: cdbs_make_curbuilddir = dbg-build-$* dbg-build-%/configure-stamp: DEB_CONFIGURE_SCRIPT_ENV += PYTHON=/usr/bin/python$*-dbg dbg-build-%/configure-stamp: CFLAGS += -O0 dbg-build-%/configure-stamp: mkdir -p dbg-build-$* $(DEB_CONFIGURE_INVOKE) \ $(DEB_CONFIGURE_EXTRA_FLAGS) $(DEB_CONFIGURE_USER_FLAGS) touch $@ build-%/build-stamp: DEB_MAKE_ENVVARS += PYTHON=/usr/bin/python$* build-%/build-stamp: DEB_MAKE_EXTRA_ARGS += pyexecdir=/usr/lib/pymodules/python$* build-%/build-stamp: cdbs_make_curbuilddir = build-$* build-%/build-stamp: build-%/configure-stamp $(DEB_MAKE_INVOKE) $(DEB_MAKE_BUILD_TARGET) touch $@ dbg-build-%/build-stamp: DEB_MAKE_ENVVARS += PYTHON=/usr/bin/python$*-dbg dbg-build-%/build-stamp: cdbs_make_curbuilddir = dbg-build-$* dbg-build-%/build-stamp: dbg-build-%/configure-stamp $(DEB_MAKE_INVOKE) $(DEB_MAKE_BUILD_TARGET) touch $@ build: $(PYVERS:%=build-%/build-stamp) $(if $(DEB_DBG_PACKAGE),$(PYVERS:%=dbg-build-%/build-stamp)) build-%/check-stamp: DEB_MAKE_ENVVARS += PYTHON=/usr/bin/python$* build-%/check-stamp: cdbs_make_curbuilddir = build-$* build-%/check-stamp: build-%/build-stamp $(if $(DEB_MAKE_CHECK_TARGET),+$(DEB_MAKE_INVOKE) $(DEB_MAKE_CHECK_TARGET),@echo "DEB_MAKE_CHECK_TARGET unset, not running checks") touch $@ dbg-build-%/check-stamp: DEB_MAKE_ENVVARS += PYTHON=/usr/bin/python$*-dbg dbg-build-%/check-stamp: cdbs_make_curbuilddir = dbg-build-$* dbg-build-%/check-stamp: dbg-build-%/build-stamp $(if $(DEB_MAKE_CHECK_TARGET),+$(DEB_MAKE_INVOKE) $(DEB_MAKE_CHECK_TARGET),@echo "DEB_MAKE_CHECK_TARGET unset, not running checks") touch $@ check: $(PYVERS:%=build-%/check-stamp) $(if $(DEB_DBG_PACKAGE),$(PYVERS:%=dbg-build-%/check-stamp)) # FIXME $(patsubst %,build-%/install-stamp,$(PYVERS)) :: build-%/install-stamp: build-%/install-stamp:: DEB_MAKE_ENVVARS += PYTHON=/usr/bin/python$* build-%/install-stamp:: DEB_MAKE_EXTRA_ARGS += pyexecdir=/usr/lib/pymodules/python$* build-%/install-stamp:: cdbs_make_curbuilddir = build-$* build-%/install-stamp:: build-%/build-stamp $(if $(DEB_MAKE_INSTALL_TARGET),+$(DEB_MAKE_INVOKE) $(DEB_MAKE_INSTALL_TARGET),@echo "DEB_MAKE_INSTALL_TARGET unset, not running install") touch $@ dbg-build-%/install-stamp: DEB_MAKE_ENVVARS += PYTHON=/usr/bin/python$*-dbg dbg-build-%/install-stamp: cdbs_make_curbuilddir = dbg-build-$* dbg-build-%/install-stamp: cdbs_make_curdestdir = $(CURDIR)/debian/$(DEB_DBG_PACKAGE) dbg-build-%/install-stamp: dbg-build-%/build-stamp ifeq (, $(DEB_MAKE_INSTALL_TARGET)) @echo "DEB_MAKE_INSTALL_TARGET unset, not running install" else $(DEB_MAKE_INVOKE) $(DEB_MAKE_INSTALL_TARGET) # FIXME: does this stuff belong here or should it be in packages' debian/rules? find $(cdbs_make_curdestdir) ! -type d ! \( -name '*.so' -o -name '*.so.*' \) -delete find $(cdbs_make_curdestdir) -type d -empty -delete endif touch $@ install-stamp:: $(PYVERS:%=build-%/install-stamp) $(if $(DEB_DBG_PACKAGE),$(PYVERS:%=dbg-build-%/install-stamp)) ifneq (,$(DEB_DBG_PACKAGE)) for i in $$(find debian/$(DEB_DBG_PACKAGE) -name '*.so' -path 'debian/$(DEB_DBG_PACKAGE)/usr/lib/python*/*-packages/*'); do \ b=$$(basename $$i .so); \ mv $$i $$(dirname $$i)/$${b}_d.so; \ done endif touch $@ install: install-stamp clean:: rm -f install-stamp rm -rf build-* $(if $(DEB_DBG_PACKAGE),dbg-build-*) common-binary-indep:: install $(maybe_check) common-binary-arch:: install $(maybe_check) .PHONY: check endif