External dependencies for Makefile

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

External dependencies for Makefile

Postby dflogeras » Mon Feb 04, 2019 6:11 pm

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?

Thanks
Dave

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: External dependencies for Makefile

Postby Giovanni » Mon Feb 04, 2019 7:22 pm

Hi,

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.

Giovanni

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Re: External dependencies for Makefile

Postby dflogeras » Tue Feb 05, 2019 5:02 pm

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 rules.mk which defines the elf target.

Code: Select all

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

# Relink whenever a static library is updated
$(BUILDDIR)/$(PROJECT).elf: $(ULIBDIR)/*.a


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


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 35 guests