# file dsf-patch.mk - keeping patches against single files # $Id$ # # dsf-patch stands for "Debian single file patch system" # # this file is meant to be included from debian/rules, # and will itself include the file specified in $(DSF-PATCHLIST) # # Copyright (C) 2005 by Frank Küster . # # This file 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 2 of the License, or (at your # option) any later version. # # This file 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, write to: The Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # # On Debian GNU/Linux System you can find a copy of the GNU General Public # License in "/usr/share/common-licenses/GPL". # the following can be used to recreate or update the patches. # # First the patches should be applied by running debian/rules edit-* # or edit-patches. Then do the edits, then call debian/rules patches # or patch-*. Afterwards, clean is a good idea before committing # define variables, may be overridden in $(DSF-PATCHLIST) patchdir = debian/patches patchopts = -p0 -g0 -N SHELL = /bin/bash # include the local patch specification include $(DSF-PATCHLIST) # compute names for auxiliary targets apply-patchnames = $(foreach patchname,$(patchnames), apply-$(patchname)) unapply-patchnames = $(foreach patchname,$(patchnames), unapply-$(patchname)) edit-patchnames = $(foreach patchname,$(patchnames), edit-$(patchname)) create-patchnames = $(foreach patchname,$(patchnames), create-$(patchname)) apply-stamps = $(foreach patchname,$(patchnames),$(patchdir)/apply-$(patchname)-stamp) unapply-nostamps = $(foreach patchname,$(patchnames),$(patchdir)/unapply-$(patchname)) edit-stamps = $(foreach patchname,$(patchnames),$(patchdir)/edit-$(patchname)-stamp) after-create-targets = nothing after-unapply-targets = nothing THISMAKE = $(MAKE) -f debian/rules.d/dsf-patch.mk # compute dependency prerequesites ## main targets: # applying a patch $(apply-patchnames): %: $(patchdir)/%-stamp # unapplying a patch $(unapply-patchnames): %: $(patchdir)/% # for editing patches $(edit-patchnames): %: $(patchdir)/%-stamp # for recreating a patch after editing $(create-patchnames): %: $(patchdir)/% ## auxiliary targets: # needed for calls of $(THISMAKE) $(somevariable), where somevariable may be empty nothing: true # applying a patch $(apply-stamps): $(patchdir)/apply-%-stamp: $(patchdir)/% patch $(patchopts) -i $< touch $@ # unapplying a patch $(unapply-nostamps): $(patchdir)/unapply-%: $(patchdir)/% $(patchdir)/apply-%-stamp patch $(patchopts) -R -i $< rm $(patchdir)/apply-$*-stamp $(THISMAKE) $(after-unapply-targets) # edit a patch $(patchdir)/setup-edit-patches-stamp: $(THISMAKE) clean touch $@ $(edit-stamps): $(patchdir)/edit-%-stamp: $(patchdir)/%.files $(patchdir)/setup-edit-patches-stamp for file in `cat $<`; do cp $$file{,.orig}; done $(THISMAKE) apply-$* touch $@ # recreate a patch $(patchdir)/create-%: $(patchdir)/%.files $(patchdir)/edit-%-stamp -mv $(patchdir)/$* $(patchdir)/$*.old for file in `cat $<`; do echo "comparing $$file"; diff -u $$file{.orig,} >> $(patchdir)/$*; done || true patch $(patchopts) -Ri $(patchdir)/$* rm $(patchdir)/edit-$*-stamp $(patchdir)/apply-$*-stamp $(THISMAKE) $(after-create-targets) # for the general clean target clean-patches: test ! -f $(patchdir)/edit-*-stamp || $(patchclean-error) -rm $(patchdir)/setup-edit-patches-stamp for patch in $(patchnames); do \ patch $(patchopts) -Ri $(patchdir)/$$patch || true; \ rm -f $(patchdir)/apply-$$patch-stamp; \ done # patch -p0 -NRi debian/patches/patch-tmp || true # patch -g0 -p0 -NRi debian/patches/patch-deb || true # patch -p0 -NRi debian/patches/patch-src || true # patch -p0 -NRi debian/patches/patch-texdoctk || true # patch -p0 -NRi debian/patches/patch-texdoc || true # -rm $(apply-stamps) define patchclean-error (echo;\ echo 'Found edit-*-stamp file in $(patchdir)'; \ echo 'Please recreate patches before cleaning the source tree!'; \ echo; \ exit 1) endef