help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with automatic "computation" of prerequisites


From: Frank Küster
Subject: Problem with automatic "computation" of prerequisites
Date: Wed, 19 Jan 2005 14:07:53 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Hello,

I have written a Makefile for convenient handling of a set of patches to
a piece of sourcecode. I have tried to write it in a way that it can
easily be reused, and therefore most targets are automatically
"generated" either by variable operations or by static pattern rules or
implicit rules. However, I have a problem in creating the
interdependencies between different patches.

This is how it works currently: For every patch in $(patchdir), I also
have a file that lists all files changed by the patch:

ls patchdir/
patch-doc patch-doc.files patch-src patch-src.files patch-tmp patch-tmp.files

What I want to do in the Makefile is to only give it a list of patches
(in the above example

patchnames = patch-deb patch-src patch-texdoc patch-texdoctk patch-tmp

) and let the Makefile generate all the necessary targets. The targets I
want are, with the example of patch-src

apply-patch-src
unapply-patch-src

(with their obvious meanings)

and

edit-patch-src
create-patch-src

The edit target creates a copy for every file in patch-src.files, then
applies the patch, and I can edit the files. After that, I do
create-patch-src, and it diffs all files in patch-src.files and cats the
diffs into the new patch-src file.

This structure already works, I attach the files below. However, what I
would like is to be able to say, e.g., "before applying patch-tmp,
patch-src must be applied" (because they have some files in common). And
with this dependency, it is clear that edit-patch-src is a prerequisite
to edit-patch-tmp (the latter taking proper care to move
edit-patch-src's copies out of the way), and that create-patch-tmp must
restore the moved-away copies of edit-patch-src and subsequently
recreate patch-src (which should not be modified, but this is needed to
get back to a consistent state).

Currently I do the following, "manually":


# define dependencies between patches
# (needed if some patches act on the same file)
PATCH_TMP_PREREQUISITES = patch-deb patch-src patch-texdoc patch-texdoctk

edit-patch-tmp-prereq = $(foreach prereq,$(PATCH_TMP_PREREQUISITES), 
$(patchdir)/edit-$(prereq)-stamp)
apply-patch-tmp-prereq = $(foreach prereq,$(PATCH_TMP_PREREQUISITES), 
$(patchdir)/apply-$(prereq)-stamp)
create-patch-tmp-targets = $(foreach prereq,$(PATCH_TMP_PREREQUISITES), 
$(patchdir)/create-$(prereq))
unapply-patch-tmp-targets = $(foreach prereq,$(PATCH_TMP_PREREQUISITES), 
$(patchdir)/unapply-$(prereq))

edit-patch-tmp: $(edit-patch-tmp-prereq)
apply-patch-tmp: $(apply-patch-tmp-prereq)
create-patch-tmp: after-create-targets += $(create-patch-tmp-targets)
unapply-patch-tmp: after-unapply-targets += $(unapply-patch-tmp-targets)

(the after-*-targets variables are previously initialised to "nothing",
there's a nothing target that does, well, nothing, and the unapply rule
calls 

$(MAKE) -f thismakefile $(after-create-targets)

However, I would like it simpler. From a logical point of view, the
first line above,

PATCH_TMP_PREREQUISITES = patch-deb patch-src patch-texdoc patch-texdoctk

should be sufficient to determine all the necessary coherencies and
"write" the following bunch of lines. Furthermore, this is always the
same for all targets (except that mostly the lists will be just empty,
because the patches act on different files).

Is there a way to automatically create these prerequisites and command
variables, similar to the way I create the targets with pattern rules?

I'd appreciate any comments, thank you in advance,
Frank

And here come the files. They are meant to be included in a makefile
that compiles (or whatever) the patched sources, and the variable
DSF-PATCHLIST must be exported in this top Makefile and point to the
filename of the second file, which is meant for user configuration

Attachment: dsf-patch.mk
Description: main Makefile snippet

Attachment: patchlist.mk
Description: file where the user defines the actual patch names and dependencies

-- 
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]