help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

VPATH, vpath, separate source and output dir, pattern rule


From: Leeuwesteijn,Joost
Subject: VPATH, vpath, separate source and output dir, pattern rule
Date: Tue, 2 May 2006 16:44:00 +0200

Hi all,

In order to reuse my code I tried to use pattern rules but because I'm using
different source and output directories I'm not quite sure what to put in
the patterns and/or vpaths.
See pseudo makefile below.

I'd like to specify my module CFLAGS, the target and the .o files and
possibly a vpath for the source directories. This should keep my module
makefiles small and tidy. And then put a generic cc/asm/link rule in my
toplevel makefile.

But now the pattern rule can't find/match the .c files because they are in a
different source directory. And the vpath doesn't seem to work in
combination with the pattern rule:

make: *** No rule to make target `OUTPUT/MOD1/mod1file1.o', needed by
`OUTPUT/MOD1/module1.a'.  Stop.

[ Hmm, a post from Billy Patton just popped up in my mailbox; does he have
the exact same question? ]

What am I missing here? Do I need to add more, something like (pseudo):
$(foreach .o) -> add ./OUTPUT/MOD1/*.o : *.c
Or is there a cleverer way to do this? For each module: convert .c to .o
from module sourcedir to module outputdir using generic recipe with target
specific variables.

BTW, I'm not looking for a complete solution for all my make problems. A
small hint would be appreciated.

Regards,
Joost Leeuwesteijn

##########################################
#
# Pseudo makefile
#
##########################################

# sourcefiles in ./MODn/
# outputfiles in ./OUTPUT/MODn/

# Find source files here.
vpath
vpath ./OUTPUT/MOD1/%.o ./MOD1
vpath ./OUTPUT/MOD2/%.o ./MOD2

# ----------------------------------------

app : ./OUTPUT/MOD1/module1.a ./OUTPUT/MOD2/module2.a

# ----------------------------------------

./OUTPUT/MOD1/module1.a : CFLAGS=foo
./OUTPUT/MOD1/module1.a : ./OUTPUT/MOD1/mod1file1.o
./OUTPUT/MOD1/mod1file2.o

# ----------------------------------------

./OUTPUT/MOD2/module2.a : CFLAGS=bar
./OUTPUT/MOD2/module2.a : ./OUTPUT/MOD2/mod2file1.o
./OUTPUT/MOD2/mod2file2.o

# ----------------------------------------

%.o : %.c
        @echo2 "Compiling $@ (module=$(MODULE), CFLAGS=$(CFLAGS))"
        @touch $@





reply via email to

[Prev in Thread] Current Thread [Next in Thread]