Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Marking a makefile dependency as optional or otherwise unimportant

Tags:

makefile

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. :)

like image 422
Nick Veys Avatar asked Nov 17 '11 23:11

Nick Veys


People also ask

What does := mean in makefile?

":=" is for defining simply expanded variable, which is expanded once and for all.

What are makefile dependencies?

A dependency is a file that is used as input to create the target. A target often depends on several files. A command is an action that make carries out. A rule may have more than one command, each on its own line.

What is $( make?

And in your scenario, $MAKE is used in commands part (recipe) of makefile. It means whenever there is a change in dependency, make executes the command make --no-print-directory post-build in whichever directory you are on. For example if I have a case where in test.o: test.c cd /root/ $(MAKE) all.

What is makefile target?

A simple makefile consists of “rules” with the following shape: target … : prerequisites … recipe … … A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. A target can also be the name of an action to carry out, such as ' clean ' (see Phony Targets).


1 Answers

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.

like image 138
slowdog Avatar answered Oct 01 '22 11:10

slowdog