Page 1 of 1

External dependencies for Makefile

Posted: Mon Feb 04, 2019 6:11 pm
by dflogeras
Hi all,

I frequently set up my Chibi projects to depend on my own common libraries for sharing code between different projects. They are built separately and installed into a dir where I point the Chibi build system. So I typically have something like this in my Makefile:

ULIBDIR = some/path/where/installed
ULIBS = -lfoo -lbar

However, during development sometimes I'll recompile libfoo.a and rebuild my Chibi project afterwards. If I haven't made any changes to the Chibi project itself, it thinks it is already up to date. Is there a way to set up the Chibi makefile to have a proper dependency on the libfoo.a timestamp so it knows to rebuild when the underlying libraries have been modified?


Re: External dependencies for Makefile

Posted: Mon Feb 04, 2019 7:22 pm
by Giovanni

Not sure how to implement that, there is not a direct path to library files, even the library name is not the real file name.


Re: External dependencies for Makefile

Posted: Tue Feb 05, 2019 5:02 pm
by dflogeras
So the nice folks in #gnu IRC channel pointed me in the right direction. In case anyone else needs, you can easily make the project elf target depend on an arbitrary file's time. The trick is making sure you put it _after_ the include which defines the elf target.

Code: Select all

RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
include $(RULESPATH)/

# Relink whenever a static library is updated

The use of $(ULIBDIR) may need to be tweaked in other situations, since if it is a list, and not all directories contain .a files, it will fail. YMMV