1
# -*- mode: makefile; coding: utf-8 -*-
2
# Copyright � 2003 Martin Quinson <martin.quinson@tuxfamily.org>
3
# Description: An advanced patch system based on the quilt facilities.
4
# please refere to the documentation of the quilt package for more information.
6
# Used variables for configuration:
10
# This program is free software; you can redistribute it and/or
11
# modify it under the terms of the GNU General Public License as
12
# published by the Free Software Foundation; either version 2, or (at
13
# your option) any later version.
15
# This program is distributed in the hope that it will be useful, but
16
# WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
# General Public License for more details.
20
# You should have received a copy of the GNU General Public License
21
# along with this program; if not, write to the Free Software
22
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25
ifndef _cdbs_bootstrap
26
_cdbs_scripts_path ?= /usr/lib/cdbs
27
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
28
_cdbs_class_path ?= /usr/share/cdbs/1/class
31
ifndef _cdbs_rules_patchsys_quilt
32
_cdbs_rules_patchsys_quilt := 1
34
ifdef _cdbs_rules_patchsys
35
$(error cannot load two patch systems at the same time)
38
include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
42
_cdbs_patch_system_apply_rule := apply-patches
43
_cdbs_patch_system_unapply_rule := reverse-patches
45
# DEB_PATCHDIRS: directory containing your source file for patches.
46
DEB_PATCHDIRS = $(shell pwd)/debian/patches
48
# DEB_QUILT_PATCHDIR_LINK
49
# By default, quilt expects to find the patch files into the /patches directory.
50
# Since it is often more pleasant to place them into /debian/patches, a link
51
# is created by this makefile chunk to fix it.
52
# In the case where you already have a /patches directory in your package,
53
# redefine this variable to somewhere else, and set QUILT_PATCHES in your
54
# $HOME/.quiltrc (so that quilt knows where to search for this)
55
DEB_QUILT_PATCHDIR_LINK = patches
57
# DEB_QUILT_SERIES: series file to use
58
DEB_QUILT_SERIES = $(DEB_PATCHDIRS)/series
60
# Internal variables, do not change it unless you know what you're doing
61
DEB_QUILT_CMD = cd $(DEB_SRCDIR) && $(if $(DEB_QUILT_PATCHDIR_LINK),QUILT_PATCHES=$(DEB_QUILT_PATCHDIR_LINK)) quilt
63
post-patches:: apply-patches
65
clean:: reverse-patches
68
apply-patches: pre-build debian/stamp-patched
70
if [ -n "$(DEB_QUILT_PATCHDIR_LINK)" ] ; then \
71
if [ -L $(DEB_SRCDIR)/$(DEB_QUILT_PATCHDIR_LINK) ] ; then : ; else \
72
(cd $(DEB_SRCDIR); ln -s $(DEB_PATCHDIRS) $(DEB_QUILT_PATCHDIR_LINK)) ; \
75
# quilt exits with 2 as return when there was nothing to do.
76
# That's not an error here (but it's usefull to break loops in crude scripts)
77
$(DEB_QUILT_CMD) push -a || test $$? = 2
78
touch debian/stamp-patched
81
if [ -d "$(DEB_SRCDIR)" ] ; then \
82
$(DEB_QUILT_CMD) pop -a -R || test $$? = 2 ; \
84
if [ -n "$(DEB_QUILT_PATCHDIR_LINK)" ] ; then \
85
if [ -L $(DEB_SRCDIR)/$(DEB_QUILT_PATCHDIR_LINK) ] ; then \
86
rm $(DEB_SRCDIR)/$(DEB_QUILT_PATCHDIR_LINK) ; \
89
rm -rf $(DEB_SRCDIR)/.pc
90
rm -f debian/stamp-patch*