My aim is to build a library which includes version information. 

I have a script which will update ./version.cpp only if the version has changed. This to prevent unnecessary rebuilds.

I have a lib target which globs *.cpp, which is inclusive of version.cpp.

The problem is that if I run bjam I can see it execute the script, and update version.cpp, but the library is not rebuilt. 
Only when I run bjam again does it see that version.cpp has changed, and rebuild the lib

This is my jam file:

    Echo [ SHELL "./write_version.sh" ] ;

    lib foo
        : [ glob *.cc ]
        ;

This is the output of running bjam:

$ bjam
Updating version.cpp

...found 119 targets...

$ bjam
...found 121 targets...
...updating 3 targets...
gcc.compile.c++ ../foo/bin/gcc-4.8/debug/link-static/version.o
gcc.archive ../foo/bin/gcc-4.8/debug/link-static/libfoo.a
...updated 3 targets...

How can I get both the script and the library build working together?

TIA
Steve