1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2002,2003 Colin Walters <walters@debian.org>
# Copyright © 2009-2016 Jonas Smedegaard <dr@jones.dk>
# Description: Defines the rule framework
#
# 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_rules_buildcore
_cdbs_rules_buildcore = 1
include $(_cdbs_rules_path)/buildvars.mk$(_cdbs_makefile_suffix)
export SOURCE_DATE_EPOCH
testdir: debian/control
test -x debian/rules
testroot:
$(if $(_cdbs_rules_debhelper),dh_testroot,test "`id -u`" = 0)
# These targets are triggered by pre-build and clean targets allowing
# for non-intrusive sanity checks of the build environment
$(patsubst %,testsanity/%,$(DEB_ALL_PACKAGES)):: testsanity/%:
testsanity:: $(patsubst %,testsanity/%,$(DEB_ALL_PACKAGES))
$(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES)):: makebuilddir/%:
$(if $(DEB_BUILDDIR_$(cdbs_curpkg)),\
mkdir -p "$(DEB_BUILDDIR_$(cdbs_curpkg))")
makebuilddir:: $(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES))
mkdir -p "$(DEB_BUILDDIR)"
cleanbuilddir:: $(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES))
-$(if $(call cdbs_streq,$(DEB_BUILDDIR),$(DEB_SRCDIR)),\
,\
rmdir $(DEB_BUILDDIR))
$(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES)):: cleanbuilddir/%:
-$(if $(DEB_BUILDDIR_$(cdbs_curpkg)),\
$(if $(call cdbs_streq,$(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_SRCDIR)),\
,\
rmdir "$(DEB_BUILDDIR_$(cdbs_curpkg))"))
config_guess := $(shell find $(DEB_SRCDIR) \( -type f -or -type l \) -name config.guess)
config_sub := $(shell find $(DEB_SRCDIR) \( -type f -or -type l \) -name config.sub)
config_rpath := $(shell find $(DEB_SRCDIR) \( -type f -or -type l \) -name config.rpath)
# This target is called before almost anything else happens. It's a good place
# to do stuff like unpack extra source tarballs, apply patches, and stuff. In
# the future it will be a good place to generate debian/control, but right
# now we don't support that very well.
pre-build:: testdir testsanity makebuilddir
$(foreach x,$(_cdbs_deprecated_vars),\
$(eval y=$(subst $(comma), ,$x))\
$(eval z=$(firstword $y))\
$(if $(call cdbs_streq,$($z),$(_cdbs_deprecated_$z_default)),\
,\
$(call cdbs_warn_deprecated,\
$z,$(word 2,$y),$(wordlist 3,$(words $y),$y))))
# This target is called after patches are applied. Used by the patch system.
post-patches:: pre-build apply-patches update-config
update-config::
$(if $(and $(config_guess),$(wildcard /usr/share/misc/config.guess)),\
set -e; \
$(foreach file,$(config_guess),\
$(if $(wildcard $(file)),$(if $(wildcard $(file).cdbs-orig),\
,\
mv $(file) $(file).cdbs-orig; \
cp --remove-destination \
/usr/share/misc/config.guess $(file);))))
$(if $(and $(config_sub),$(wildcard /usr/share/misc/config.sub)),\
set -e; \
$(foreach file,$(config_sub),\
$(if $(wildcard $(file)),$(if $(wildcard $(file).cdbs-orig),\
,\
mv $(file) $(file).cdbs-orig; \
cp --remove-destination \
/usr/share/misc/config.sub $(file);))))
$(if $(and $(config_rpath),$(wildcard /usr/share/gnulib/build-aux/config.rpath)), \
set -e; \
$(foreach file,$(config_rpath),\
$(if $(wildcard $(file)),$(if $(wildcard $(file).cdbs-orig),\
,\
mv $(file) $(file).cdbs-orig; \
cp --remove-destination \
/usr/share/gnulib/build-aux/config.rpath $(file);))))
# This target should be used to configure the package before building. Typically
# this involves running things like ./configure.
common-configure-arch:: post-patches
common-configure-indep:: post-patches
$(patsubst %,configure/%,$(DEB_ARCH_PACKAGES)):: configure/%: common-configure-arch
$(patsubst %,configure/%,$(DEB_INDEP_PACKAGES)):: configure/%: common-configure-indep
# This is a required Debian target; however, its specific semantics is
# in dispute. We are of the opinion that 'build' should invoke
# build-arch and build-indep. Policy tends to support us here.
# However, dpkg-buildpackage is currently invokes debian/rules build
# even when doing an architecture-specific (binary-arch) build. This
# essentially means Build-Depends-Indep is worthless. For more
# information, see Policy §5.2, Policy §7.6, and Debian Bug #178809.
# For now, you may override the dependencies by setting the variable
# DEB_BUILD_DEPENDENCIES, below. This is not recommended.
DEB_BUILD_DEPENDENCIES ?= build-arch build-indep
build: $(DEB_BUILD_DEPENDENCIES)
# This target should take care of actually compiling the package from source.
# Most often this involves invoking "make".
common-build-arch:: testdir $(patsubst %,configure/%,$(DEB_ARCH_PACKAGES))
common-build-indep:: testdir $(patsubst %,configure/%,$(DEB_INDEP_PACKAGES))
$(patsubst %,build/%,$(DEB_ARCH_PACKAGES)):: build/%: common-build-arch configure/%
$(patsubst %,build/%,$(DEB_INDEP_PACKAGES)):: build/%: common-build-indep configure/%
# This rule is for stuff to run after the build process. Note that this
# may run under fakeroot or sudo, so it's inappropriate for things that
# should be run under the build target.
common-post-build-arch:: common-build-arch $(patsubst %,build/%,$(DEB_ARCH_PACKAGES))
common-post-build-indep:: common-build-indep $(patsubst %,build/%,$(DEB_INDEP_PACKAGES))
# Required Debian targets.
build-arch: $(patsubst %,build/%,$(DEB_ARCH_PACKAGES))
build-indep: $(patsubst %,build/%,$(DEB_INDEP_PACKAGES))
# This rule is used to prepare the source package before a diff is generated.
# Typically you will invoke upstream's "make clean" rule here, although you
# can also hook in other stuff here. Many of the included rules and classes
# add stuff to this rule.
clean:: testdir cleanbuilddir reverse-config testsanity
reverse-config::
$(if $(config_guess)$(config_sub)$(config_rpath),\
set -e;\
$(foreach file,$(config_guess) $(config_sub) $(config_rpath),\
$(if $(wildcard $(file).cdbs-orig),\
mv $(file).cdbs-orig $(file);)))
# Style of separating build-dependencies. Perl-style: tab=\t, newline=\n
# * Default follows recommended multiline style (see Debian Policy §7.1)
# * Unset to get recomended single-line style ", "
CDBS_BUILD_DEPENDS_DELIMITER ?= ,\n$(space)
cdbs_re_squash_extended_space = s/[ \t\n]+/ /g
cdbs_pkgrel_varnames = $(patsubst %,CDBS_%,DEPENDS PREDEPENDS RECOMMENDS SUGGESTS BREAKS PROVIDES REPLACES CONFLICTS ENHANCES)
cdbs_pkgrel_allvars = $(call cdbs_expand_allvars,$(cdbs_pkgrel_varnames))
# This rule is called before the common-install target. It's currently only
# used by debhelper.mk, to run dh_clean -k.
common-install-prehook-arch::
common-install-prehook-indep::
# This target should do all the work of installing the package into the
# staging directory (debian/packagename or debian/tmp).
common-install-arch:: testdir common-install-prehook-arch common-post-build-arch
common-install-indep:: testdir common-install-prehook-indep common-post-build-indep
# Required Debian targets.
install-arch: $(patsubst %,install/%,$(DEB_ARCH_PACKAGES))
install-indep: $(patsubst %,install/%,$(DEB_INDEP_PACKAGES))
# These rules should do any installation work specific to a particular package.
$(patsubst %,install/%,$(DEB_ARCH_PACKAGES)):: install/%: testdir testroot common-install-arch build/%
$(patsubst %,install/%,$(DEB_INDEP_PACKAGES)):: install/%: testdir testroot common-install-indep build/%
_cdbs_deprecated_vars += $(patsubst %,CDBS_%$(comma)0.4.85,\
DEPENDS PREDEPENDS RECOMMENDS SUGGESTS BREAKS PROVIDES REPLACES \
CONFLICTS ENHANCES)
CDBS_DEPENDS_DEFAULT ?= $(CDBS_DEPENDS)
CDBS_PREDEPENDS_DEFAULT ?= $(CDBS_PREDEPENDS)
CDBS_RECOMMENDS_DEFAULT ?= $(CDBS_RECOMMENDS)
CDBS_SUGGESTS_DEFAULT ?= $(CDBS_SUGGESTS)
CDBS_BREAKS_DEFAULT ?= $(CDBS_BREAKS)
CDBS_PROVIDES_DEFAULT ?= $(CDBS_PROVIDES)
CDBS_REPLACES_DEFAULT ?= $(CDBS_REPLACES)
CDBS_CONFLICTS_DEFAULT ?= $(CDBS_CONFLICTS)
CDBS_ENHANCES_DEFAULT ?= $(CDBS_ENHANCES)
# Resolve CDBS-declared binary package relations and apply to substvars files
$(patsubst %,install/%,$(DEB_ALL_PACKAGES)) :: install/%:
@echo 'Adding cdbs dependencies to debian/$(cdbs_curpkg).substvars'
@echo '$(call cdbs_expand_curvar,CDBS_DEPENDS,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Depends=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_PREDEPENDS,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Pre-Depends=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_RECOMMENDS,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Recommends=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_SUGGESTS,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Suggests=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_BREAKS,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Breaks=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_PROVIDES,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Provides=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_REPLACES,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Replaces=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_CONFLICTS,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Conflicts=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
@echo '$(call cdbs_expand_curvar,CDBS_ENHANCES,$(comma) )' \
| perl -0 -n \
-e '$(cdbs_re_squash_extended_space);' \
-e '$(re_squash_commas_and_spaces);' \
-e '/\w/ and print "cdbs:Enhances=$$_\n"' \
>> debian/$(cdbs_curpkg).substvars
# This rule is called after all packages are installed.
common-binary-arch:: testdir testroot $(patsubst %,install/%,$(DEB_ARCH_PACKAGES))
common-binary-indep:: testdir testroot $(patsubst %,install/%,$(DEB_INDEP_PACKAGES))
# Required Debian targets
binary-indep: $(patsubst %,binary/%,$(DEB_INDEP_PACKAGES))
binary-arch: $(patsubst %,binary/%,$(DEB_ARCH_PACKAGES))
# These rules should do all the work of actually creating a .deb from the staging
# directory.
$(patsubst %,binary/%,$(DEB_ARCH_PACKAGES)):: binary/%: testdir testroot common-binary-arch install/%
$(patsubst %,binary/%,$(DEB_INDEP_PACKAGES)):: binary/%: testdir testroot common-binary-indep install/%
# Required Debian target
binary: binary-indep binary-arch
##
# Deprecated targets. You should use the -arch and -indep targets instead.
##
common-configure:: common-configure-arch common-configure-indep
common-build:: common-build-arch common-build-indep
common-post-build:: common-post-build-arch common-post-build-indep
common-install-prehook:: common-install-prehook-arch common-install-prehook-indep
common-install:: common-install-arch common-install-indep
common-binary:: common-binary-arch common-binary-indep
.PHONY: pre-build testsanity $(patsubst %,testsanity/%,$(DEB_ALL_PACKAGES)) apply-patches post-patches common-configure-arch common-configure-indep $(patsubst %,configure/%,$(DEB_ALL_PACKAGES)) build common-build-arch common-build-indep $(patsubst %,build/%,$(DEB_ALL_PACKAGES)) build-arch build-indep clean common-install-arch common-install-indep install-arch install-indep $(patsubst %,install/%,$(DEB_ALL_PACKAGES)) common-binary-arch common-binary-indep $(patsubst %,binary/%,$(DEB_ALL_PACKAGES)) binary-indep binary-arch binary $(DEB_PHONY_RULES)
# Parallel execution of the cdbs makefile fragments will fail, but
# this way you can call dpkg-buildpackage with MAKEFLAGS=-j in the
# environment and the package's own makefiles can use parallel make.
.NOTPARALLEL:
endif
|