Mon 07 Sep 2009 05:47:46 PM UTC, original submission:
Consider the following Makefile:
-----
lib1.a: lib1.a(foo.o) lib1.a(bar.o)
foo.o: lib.h
bar.o: lib.h bar.h
-----
In another directory I'd like to be able to do the following:
-----
all: prog
prog: main.o ../lib/lib1.a
@include ../lib/Makefile
-----
The @include would treat all the relative pathnames in ../lib/Makefile as relative to ../lib, yielding the equivalent of:
-----
../lib/lib1.a: ../lib/lib1.a(../lib/foo.o) ../lib/lib1.a(../lib/bar.o)
../lib/foo.o: ../lib/lib.h
../lib/bar.o: ../lib/lib.h ../lib/bar.h
-----
The syntax of @include could be something else - maybe include @../lib/Makefile, or some other idea. It should work with -include, so @-include or -@include if you want both (or -include @../lib/Makefile for that syntax).
This is intended to make non-recursive build trees easier to create. You'd still need to use target-specific variables and such, but this would make things easier. In particular, you could @include a gcc-generated dependency file and have it do the right thing.
|