[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to do recursive "subsystem" make properly?
From: |
Bart Robinson |
Subject: |
Re: how to do recursive "subsystem" make properly? |
Date: |
Tue, 3 Nov 2009 17:10:33 -0800 |
On Tue, Nov 3, 2009 at 4:16 PM, Mark Galeck (CW) <address@hidden> wrote:
>
> So then, I finally got it to work by combining two of Pauls suggestions,
> the sentinel and the FORCE:
>
> top makefile is
>
> foobar: subdir/sentinel
> echo making foobar
> touch foobar
> subdir/sentinel: FORCE
> $(MAKE) -C subdir
> FORCE: ;
>
> bottom makefile is
>
> .PHONY: all
> all: foobaro foobazo
> sentinel: all
>
> foobaro: foobarc
> touch foobaro
> echo making foobaro
> touch sentinel
>
> foobazo: foobazc
> touch foobazo
> echo making foobazo
> touch sentinel
>
>
> Now, if I touch foobarc or foobarz, then and only then foobar gets rebuilt!
> Great, finally I got it!
This sentinel stuff seems a little gross and would get in the way of
$^ use, here is an alternate way to achieve what I think you're aiming
for, w/o using the FORCE/sentinel stuff:
-- makefile --
prog: main.o lib/libfoo.a lib/libbar.a
cc -o $@ $^
%.o: %.c
cc -c -o $@ $<
# empty commands are magic
lib/libfoo.a: build-libs ;
lib/libbar.a: build-libs ;
.PHONY: build-libs
build-libs:
$(MAKE) -C lib
clean:
rm -f *.o prog lib/*.o lib/*.a
-- lib/makefile --
.PHONY: all
all: libfoo.a libbar.a
%.o: %.c
cc -c -o $@ $<
# have the .c files spring into existence for this test
%.c:
touch $@
libfoo.a: foo.o
ar rcs $@ $^
libbar.a: bar.o
ar rcs $@ $^
-----------------------
The empty commands for the libfoo.a rules are a little magic. Without
them "make" won't check the mtime of the lib since there are no
commands that could have changed it, and the "prog" target won't get
relinked. (The previously mentioned order-only suggestions have this
same problem.)
-- bart
- Re: how to do recursive "subsystem" make properly?, (continued)
- Re: how to do recursive "subsystem" make properly?, John Calcote, 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Mark Galeck (CW), 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Paul Smith, 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Mark Galeck (CW), 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Paul Smith, 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Mark Galeck (CW), 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Mark Galeck (CW), 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Paul Smith, 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Mark Galeck (CW), 2009/11/03
- RE: how to do recursive "subsystem" make properly?, Mark Galeck (CW), 2009/11/03
- Re: how to do recursive "subsystem" make properly?,
Bart Robinson <=
- Re: how to do recursive "subsystem" make properly?, Christophe LYON, 2009/11/09
- RE: how to do recursive "subsystem" make properly?, Mark Galeck (CW), 2009/11/09
- Re: how to do recursive "subsystem" make properly?, Paul Smith, 2009/11/09
- Re: how to do recursive "subsystem" make properly?, Christophe LYON, 2009/11/10
- Re: how to do recursive "subsystem" make properly?, Bart Robinson, 2009/11/10
- Re: how to do recursive "subsystem" make properly?, Stephan Beal, 2009/11/03