1
1
# -*- mode: makefile; coding: utf-8 -*-
2
# Copyright � 2003 Martin Quinson <martin.quinson@tuxfamily.org>
2
# Copyright © 2003 Martin Quinson <martin.quinson@tuxfamily.org>
3
3
# Description: An advanced patch system based on the quilt facilities.
4
4
# please refere to the documentation of the quilt package for more information.
38
38
include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
42
41
_cdbs_patch_system_apply_rule := apply-patches
43
42
_cdbs_patch_system_unapply_rule := reverse-patches
44
# standard targets, as recommended by Debian policy 3.8.0
47
unpatch: reverse-patches
45
49
# DEB_PATCHDIRS: directory containing your source file for patches.
46
DEB_PATCHDIRS = $(shell pwd)/debian/patches
51
# You might find it convenient to add the snippet below to your
52
# $HOME/.quiltrc so that you can use quilt without having to reset
53
# QUILT_PATCHES when you switch from one project to the other:
54
# for where in ./ ../ ../../ ../../../ ../../../../ ../../../../../; do
55
# if [ -e ${where}debian/rules -a -d ${where}debian/patches ]; then
56
# export QUILT_PATCHES=debian/patches
59
DEB_PATCHDIRS = $(CURDIR)/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
61
# DEB_QUILT_TOPDIR: directory where patches will be applied
62
# Use it only to override back to "." when CDBS sets DEB_SRCDIR
63
# and you don't want the quilt patching to happen in a subdirectory
64
DEB_QUILT_TOPDIR ?= $(DEB_SRCDIR)
57
66
# Internal variables, do not change it unless you know what you're doing
58
DEB_QUILT_CMD = cd $(DEB_SRCDIR) && $(if $(DEB_QUILT_PATCHDIR_LINK),QUILT_PATCHES=$(DEB_QUILT_PATCHDIR_LINK)) quilt --quiltrc /dev/null
67
DEB_QUILT_CMD = cd $(DEB_QUILT_TOPDIR) && QUILT_PATCHES=$(DEB_PATCHDIRS) quilt --quiltrc /dev/null
60
69
# Declare Build-Dep of packages using this file onto quilt
61
70
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), quilt
67
76
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), patchutils (>= 0.2.25)
69
78
# target reverse-config, which we use, don't exist in old cdbs
70
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), cdbs (>= 0.4.27-1)
79
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), cdbs (>= 0.4.27)
72
81
evil_patches_that_do_nasty_things := $(shell \
73
82
if lsdiff=`which lsdiff` ; then \
74
83
patchlist=`$(DEB_QUILT_CMD) series \
75
| sed 's|^|$(if $(DEB_QUILT_PATCHDIR_LINK),$(DEB_QUILT_PATCHDIR_LINK)/)|' \
84
| sed 's|^|$(DEB_PATCHDIRS)/|' \
77
86
if [ "x$$patchlist" != x ] ; then \
78
87
$$lsdiff -H $$patchlist \
91
100
# The patch subsystem
92
101
apply-patches: pre-build debian/stamp-patched
93
102
debian/stamp-patched:
94
# reverse-config must be first
103
# reverse-config must be first
95
104
$(MAKE) -f debian/rules reverse-config
97
if [ -n "$(DEB_QUILT_PATCHDIR_LINK)" ] ; then \
98
if [ -L $(DEB_SRCDIR)/$(DEB_QUILT_PATCHDIR_LINK) ] ; then : ; else \
99
(cd $(DEB_SRCDIR); ln -s $(DEB_PATCHDIRS) $(DEB_QUILT_PATCHDIR_LINK)) ; \
102
# quilt exits with 2 as return when there was nothing to do.
103
# That's not an error here (but it's usefull to break loops in crude scripts)
106
# quilt exits with 2 as return when there was nothing to do.
107
# That's not an error here (but it's usefull to break loops in crude scripts)
104
108
$(DEB_QUILT_CMD) push -a || test $$? = 2
105
109
touch debian/stamp-patched
107
111
$(MAKE) -f debian/rules update-config
108
# update-config must be last
112
# update-config must be last
111
# reverse-config must be first
115
# reverse-config must be first
112
116
$(MAKE) -f debian/rules reverse-config
114
if [ -d "$(DEB_SRCDIR)" ] ; then \
118
if [ -d "$(DEB_QUILT_TOPDIR)" ]; then \
115
119
$(DEB_QUILT_CMD) pop -a -R || test $$? = 2 ; \
117
if [ -n "$(DEB_QUILT_PATCHDIR_LINK)" ] ; then \
118
if [ -L $(DEB_SRCDIR)/$(DEB_QUILT_PATCHDIR_LINK) ] ; then \
119
rm $(DEB_SRCDIR)/$(DEB_QUILT_PATCHDIR_LINK) ; \
122
rm -rf $(DEB_SRCDIR)/.pc
121
rm -rf $(DEB_QUILT_TOPDIR)/.pc
123
122
rm -f debian/stamp-patch*