[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using "-l" libraries as targets
From: |
lukeallardyce |
Subject: |
Re: Using "-l" libraries as targets |
Date: |
Mon, 1 Jun 2015 13:11:31 +0000 |
It’s probably a very nice case, but having a prerequisite like “-lfoo” that
matches a “libfoo.a” target would be useful for decoupling say one makefile
with the rule “main.exe: -lfoo” and another in subdir “foo” that has “libfoo.a:
libfoo.a(foo/foo.o)”. The only change needed to have make choose between
building the lib and searching for it would be whether to “include
foo/Makefile” / add “-f foo/Makefile” when invoking make.
>You cannot use it for libraries make has to build, because make doesn't
>know what name to use for them. Remember make starts from the final
>target to be built and works backwards, looking at prerequisites. So
>when make sees a prerequisite like "-lfoo", it then tries to look up the
>name existing on the filesystem using the algorithms described in the
>manual. Since the file doesn't exist yet make doesn't know which one it
>should build.
Using the very first example I gave (-lfoo: libfoo.a(foo.o) ;) it does build
the lib, the only issue is that it relinks main.exe on each subsequent run even
though libfoo.a hasn’t been touched. I suppose it’s just a quirk of doing
something I shouldn’t be. As mentioned “-lfoo libfoo.a: “ fixes that, although
I get the feeling it’ll break something at some point that I haven’t considered.
- Using "-l" libraries as targets, Luke Allardyce, 2015/06/01
- Re: Using "-l" libraries as targets, Paul Smith, 2015/06/01
- Re: Using "-l" libraries as targets, Luke Allardyce, 2015/06/01
- Re: Using "-l" libraries as targets, Paul Smith, 2015/06/01
- Re: Using "-l" libraries as targets,
lukeallardyce <=
- Re: Using "-l" libraries as targets, Paul Smith, 2015/06/01
- Re: Using "-l" libraries as targets, Jed Brown, 2015/06/02
- Re: Using "-l" libraries as targets, Paul Smith, 2015/06/02
- Re: Using "-l" libraries as targets, Jed Brown, 2015/06/02