# -*- mode: makefile; coding: utf-8 -*- # Copyright © 2002,2003 Colin Walters # Copyright © 2009-2012, 2014-2017 Jonas Smedegaard # Description: Defines some useful variables, but no rules # # 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 . ifndef _cdbs_rules_buildvars _cdbs_rules_buildvars = 1 include /usr/share/dpkg/pkg-info.mk include /usr/share/dpkg/architecture.mk CDBS_VERSION = 0.4.182 # variables included from pkg-info.mk and architecture.mk #DEB_SOURCE #DEB_VERSION #DEB_VERSION_EPOCH_UPSTREAM #DEB_VERSION_UPSTREAM_REVISION #DEB_VERSION_UPSTREAM #DEB_DISTRIBUTION #SOURCE_DATE_EPOCH #DEB_ARCH #DEB_HOST_GNU_TYPE #DEB_HOST_GNU_SYSTEM #DEB_HOST_GNU_CPU #DEB_HOST_ARCH #DEB_HOST_ARCH_CPU #DEB_HOST_ARCH_OS #DEB_HOST_MULTIARCH #DEB_BUILD_GNU_TYPE #DEB_BUILD_GNU_SYSTEM #DEB_BUILD_GNU_CPU #DEB_BUILD_ARCH #DEB_BUILD_ARCH_CPU #DEB_BUILD_ARCH_OS # TODO deprecate DEB_SOURCE_PACKAGE = $(DEB_SOURCE) DEB_SUITE ?= $(DEB_DISTRIBUTION) DEB_NOEPOCH_VERSION = $(lastword \ $(subst :,$(space),\ $(DEB_VERSION))) DEB_UPSTREAM_VERSION = $(DEB_VERSION_UPSTREAM) DEB_ISNATIVE = $(strip $(if $(findstring -,$(DEB_VERSION))\ ,\ ,native)) # Split into arch/indep packages ifneq ($(DEB_INDEP_PACKAGES),cdbs) ifdef _cdbs_rules_debhelper DEB_INDEP_PACKAGES := $(strip $(shell \ dh_listpackages -i)) DEB_ARCH_PACKAGES := $(filter-out $(DEB_INDEP_PACKAGES),\ $(strip $(shell \ dh_listpackages -a))) else DEB_INDEP_PACKAGES := $(strip $(shell \ debian/list-packages indep)) DEB_ARCH_PACKAGES := $(filter-out $(DEB_INDEP_PACKAGES),\ $(strip $(shell \ debian/list-packages same))) endif endif # Support for udeb packages has been removed in 0.4.172 DEB_PACKAGES ?= $(DEB_ARCH_PACKAGES) $(DEB_INDEP_PACKAGES) DEB_ALL_PACKAGES ?= $(DEB_PACKAGES) DEB_INDEP_REGULAR_PACKAGES ?= $(DEB_INDEP_PACKAGES) DEB_ARCH_REGULAR_PACKAGES ?= $(DEB_ARCH_PACKAGES) # Some support for srcdir != builddir builds. # These are relative to the root of the package DEB_SRCDIR ?= . DEB_BUILDDIR ?= $(strip $(DEB_SRCDIR)) # TODO deprecate DEB_ARCH = $(DEB_HOST_ARCH) ifeq ($(words $(DEB_ALL_PACKAGES)),1) DEB_DESTDIR ?= $(CURDIR)/debian/$(strip $(DEB_ALL_PACKAGES))/ else DEB_DESTDIR ?= $(CURDIR)/debian/tmp/ endif # Internal useful variables/expansions cdbs_info = $(info CDBS: $1) cdbs_warn = $(info CDBS WARNING: $1) # emit warning on use of deprecated variable # * $1: variable name # * $2: optional last version before deprecation # * $3: optional alternative variable to use instead cdbs_warn_deprecated = $(call cdbs_warn,\ $1 is deprecated$(if $2, since $2)$(if $3, - please use $3 instead)) cdbs_curpkg = $(notdir $@) cdbs_cursrcdir = $(or $(DEB_PKGSRCDIR_$(cdbs_curpkg)),$(DEB_SRCDIR)) cdbs_curbuilddir = $(or $(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR)) cdbs_curdestdir = $(or $(DEB_DESTDIR_$(cdbs_curpkg)),$(DEB_DESTDIR)) cdbs_streq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),,yes) nullstring = space = $(nullstring) # <- notice the trailing space (only leading is stripped) define newline = $(nullstring) $(nullstring) endef comma = , open_parenthesis = ( close_parenthesis = ) cdbs_delimit = $(subst $(space),$2,$(strip $1)) # workaround for lack of uppercase/lowercase functions in make cdbs_uc = $(shell echo '$1' | tr '[:lower:]' '[:upper:]') cdbs_lc = $(shell echo '$1' | tr '[:upper:]' '[:lower:]') # Resolve VAR_ALL and either VAR_pkg or VAR_DEFAULT, space- or custom-delimited # * VAR_ALL applies to all packages # * VAR_pkg applies to current package # * VAR_DEFAULT applies to current package if not overridden by VAR_pkg cdbs_expand_curvar = $(strip \ $($(1)_ALL)$(if $($(1)_ALL),$(or $2,$(space)))$(strip \ $(if $(filter-out $(origin $(1)_$(cdbs_curpkg)),undefined),$(strip \ $($(1)_$(cdbs_curpkg))),$(strip \ $($(1)_DEFAULT))))) cdbs_expand_allvars = $(strip \ $(foreach stem,$(1),$(strip \ $($(stem)_ALL))$(strip \ $($(stem)))$(strip \ $(foreach pkg,$(DEB_ALL_PACKAGES),$(strip \ $($(stem)_$(pkg))))))) # List "packages multiplied with branches", or just packages if no branches # Syntax: PACKAGES BRANCHES WORDDELIMITER BRANCHDELIMITER [FALLBACK-MAIN-BRANCH] cdbs_expand_branches = $(strip $(subst WORDDELIMITER,$3,\ $(subst BRANCHDELIMITER,$4,\ $(call cdbs_delimit,\ $(if $2,\ $(foreach pkg,$1,\ $(call cdbs_delimit,$(foreach branch,$2,\ $(pkg)$(branch:%=-%)),$(strip \ BRANCHDELIMITER))),\ $(if $5,\ $(foreach pkg,$1,\ $(pkg)-$(5)BRANCHDELIMITER$(pkg)),\ $1)),$(strip \ WORDDELIMITER))))) cdbs_findargs-path-or-name = $(strip \ $(if $(findstring /,$(firstword $(1))),\ -path './$(patsubst ./%,%,$(firstword $(1)))',\ -name '$(firstword $(1))') \ $(foreach obj,$(wordlist 2,$(words $(1)),$(1)),\ -or \ $(if $(findstring /,$(obj)),\ -path './$(obj:./%=%)',\ -name '$(obj)'))) # Resolve VAR only if declared explicitly in makefile or environment cdbs_expand_nondefaultvar = $(strip $(if $(filter-out undefined default,\ $(origin $1)),\ $2)) # Declare (shell-style) variables to itself if explicitly declared cdbs_set_nondefaultvars = $(strip $(foreach v,$1,\ $(call cdbs_expand_nondefaultvar,$v,$v="$($v)"))) # Return non-empty if build system is different from host system cdbs_crossbuild = $(if $(call cdbs_streq,$(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)),,yes) endif