summaryrefslogtreecommitdiffstats
path: root/debian/_base/metapackages/tde-cdbs/tde-makefile.mk
blob: d3c09a6e1b0824de3169c5ea326aa7cb29035bf6 (plain)
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
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2002,2003 Colin Walters <walters@debian.org>
# Copyright © 2003,2012, 2014, 2016 Jonas Smedegaard <dr@jones.dk>
# Description: Builds and cleans packages which have a Makefile
#
# 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/>.

_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_makefile
_cdbs_class_makefile = 1

include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
include $(_cdbs_class_path)/tde-makefile-vars.mk$(_cdbs_makefile_suffix)

cdbs_make_flavors = $(sort $(DEB_MAKE_FLAVORS))
cdbs_make_builddir_check = $(if $(call cdbs_streq,$(DEB_BUILDDIR),$(DEB_SRCDIR)),\
	$(error DEB_MAKE_FLAVORS in use: \
		DEB_BUILDDIR must be different from DEB_SRCDIR$(comma) \
		and needs to be declared before including makefile.mk))
cdbs_make_build_stamps = $(if $(cdbs_make_flavors),\
	$(cdbs_make_builddir_check)\
	$(patsubst %,debian/stamp-makefile-build/%,\
		$(cdbs_make_flavors)),\
	debian/stamp-makefile-build)
cdbs_make_install_stamps = $(if $(cdbs_make_flavors),\
	$(cdbs_make_builddir_check)\
	$(patsubst %,debian/stamp-makefile-install/%,\
		$(cdbs_make_flavors)),\
	debian/stamp-makefile-install)
cdbs_make_check_stamps = $(if $(cdbs_make_flavors),\
	$(cdbs_make_builddir_check)\
	$(patsubst %,debian/stamp-makefile-check/%,\
		$(cdbs_make_flavors)),\
	debian/stamp-makefile-check)
cdbs_make_clean_nonstamps = $(if $(cdbs_make_flavors),\
	$(patsubst %,makefile-clean/%,$(cdbs_make_flavors)),\
	makefile-clean)
cdbs_make_curflavor = $(strip $(if $(cdbs_make_flavors),\
	$(filter-out %/,$(subst /,/ ,$@))))
cdbs_make_curbuilddir = $(strip $(if $(cdbs_make_flavors),\
	$(subst @FLAVOR@,$(cdbs_make_curflavor),$(or $(strip \
		$(DEB_MAKE_BUILDDIRSKEL_$(cdbs_make_curflavor))),$(strip \
		$(DEB_MAKE_BUILDDIRSKEL)))),\
	$(cdbs_curbuilddir)))
cdbs_make_curdestdir = $(strip $(if $(cdbs_make_flavors),\
	$(subst @FLAVOR@,$(cdbs_make_curflavor),$(or $(strip \
		$(DEB_MAKE_DESTDIRSKEL_$(cdbs_make_curflavor))),$(strip \
		$(DEB_MAKE_DESTDIRSKEL)))),\
	$(cdbs_curdestdir)))

DEB_PHONY_RULES += makefile-clean $(cdbs_make_clean_nonstamps)

pre-build::
	$(if $(cdbs_make_flavors),\
		mkdir -p \
			debian/stamp-makefile-build \
			debian/stamp-makefile-install)
	$(and $(cdbs_make_flavors),$(DEB_MAKE_CHECK_TARGET),\
		mkdir -p debian/stamp-makefile-check)

common-build-arch common-build-indep:: $(cdbs_make_build_stamps)
$(cdbs_make_build_stamps):
	+$(DEB_MAKE_INVOKE) $(DEB_MAKE_BUILD_TARGET)
	touch $@

cleanbuilddir:: makefile-clean
makefile-clean:: $(if $(cdbs_make_flavors),$(cdbs_make_clean_nonstamps))
	$(if $(cdbs_make_flavors),\
		-rmdir --ignore-fail-on-non-empty \
			debian/stamp-makefile-build \
			debian/stamp-makefile-install,\
		rm -f \
			debian/stamp-makefile-build \
			debian/stamp-makefile-install)

$(cdbs_make_clean_nonstamps)::
	$(if $(DEB_MAKE_CLEAN_TARGET),\
		+-$(DEB_MAKE_INVOKE) -k $(DEB_MAKE_CLEAN_TARGET),\
		$(call cdbs_warn,DEB_MAKE_CLEAN_TARGET unset$(comma) \
			not running clean))
	$(if $(cdbs_make_flavors),\
		rm -f \
			$(@:makefile-clean%=debian/stamp-makefile-build%) \
			$(@:makefile-clean%=debian/stamp-makefile-install%))

common-install-arch common-install-indep:: common-install-impl
common-install-impl:: $(cdbs_make_install_stamps)
$(cdbs_make_install_stamps)::
	$(if $(DEB_MAKE_INSTALL_TARGET),\
		+$(DEB_MAKE_INVOKE) $(DEB_MAKE_INSTALL_TARGET),\
		$(call cdbs_warn,DEB_MAKE_INSTALL_TARGET unset$(comma) \
			skipping default makefile.mk common-install target))
	$(if $(DEB_MAKE_INSTALL_TARGET),\
		touch $@)

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
common-build-arch common-build-indep:: $(cdbs_make_check_stamps)
$(cdbs_make_check_stamps) : debian/stamp-makefile-check% : debian/stamp-makefile-build%
	$(if $(DEB_MAKE_CHECK_TARGET),\
		+$(DEB_MAKE_INVOKE) $(DEB_MAKE_CHECK_TARGET),\
		$(call cdbs_warn,DEB_MAKE_CHECK_TARGET unset$(comma) \
			not running checks))
	$(if $(DEB_MAKE_CHECK_TARGET),\
		touch $@)

makefile-clean::
	$(if $(DEB_MAKE_CHECK_TARGET),\
		$(if $(cdbs_make_flavors),\
			-rmdir --ignore-fail-on-non-empty \
				debian/stamp-makefile-check,\
		rm -f debian/stamp-makefile-check))

$(cdbs_make_clean_nonstamps)::
	$(if $(cdbs_make_flavors),\
		rm -f $(@:makefile-clean%=debian/stamp-makefile-check%))
endif

endif