开发者

Symlink Prerequisites in a Makefile Without check-symlink-times

My project uses a static library from an external supplier, libext.a. The library is kept in a central location shared among all the project developers, central/, and with each updated release of the library, the new file with a suffix of the current version is added: central/libext.a.1, central/libext.a.2, central/libext.a.3, ...

The project's Subversion repository contains a symbolic link, libext.a, that points to the latest version of the library in central. Whenever a new version is added, the link is changed and committed to the repository.

The problem is that when recompiling the project after the link was changed and the working copy updated, make looks at the modification time of the link's target, and not at the modification time of the link itself (libext.a). So the library used in effect in the compiled project is still the old version.

I am aware of the -L/--check-symlink-times flag available in GNU Make since version 3.81, which makes make look at the modification times of both the link's target and the link itself, but my project uses version 3.80, and upgrading would be very difficult as compilation has to be supported on ma开发者_运维问答ny different machines, of some of which I have no control.

What is the most simple way to emulate the behavior of this new flag in my older version of make? I prefer something that can be local to a specific Makefile and implemented within it, not a script that has to be run before running make or a command line option that has to be specified with it, although it is not completely unacceptable.


Perhaps you can use something like the technique outlined here, which is a trick to get gmake to rebuild when file checksums change, rather than simply when timestamps change.


The best solution I've come up with so far is to add libext.a.timestamp as a requirement in the Makefile that requires libext.a, and add it as a prerequisite to the rule that has libext.a as a prerequisite.

Also, I added a rule:

%.timestamp
  touch $@

Now I need to find a way to touch the timestamp whenever the link is updated. Unfortunately, I didn't find a way to do this yet (there is no post-updated hook in SVN)...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜