19

I have a Makefile with a pair of rules like the following:

file.c: filesvn

filesvn: .svn/entries
     action1
     action2

Within the svn repository, this of course works fine. The file is dependent upon living in a subversion repository. When exported from the repository, this does not work (No rule to make target...), and I would like to fix that. I have tried to simply bring a previously-generated version of filesvn out into the exported directory, but Make still insists on verifying filesvn's dependency.

Simply deleting the dependency of .svn/entries does work, of course, but then the spirit of the rule is broken since watching for a revision update is the goal.

Is there a way to get Make to not care that the .svn/entries file is not there?

The merits of such a technique are not really part of the question. I can't fundamentally change this, but if there is a change that maintains the spirit that might work. An answer of "You can't" is perfectly valid of course. :)

0

3 Answers 3

32

You can use the wildcard function to ignore the file unless it exists:

filesvn: $(wildcard .svn/entries)

Aside: Subversion 1.7 changes the format of the local working copy, so this rule would stop working even in working copies.

2
3

Pattern % rules

For pattern rules, you need .SECONDEXPANSION:

.SECONDEXPANSION:
%.a: %.b $$(wildcard $$*.c)
    cc $< -o $@

See also: How can I make a pattern rule dependency optional in a Makefile?

Tested in Make 4.1.

2

You can add a target that generates copy of actual makefile with changes that drop the svn dependency, run make with it and then deletes it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.