Re: Makefile Rule: idl/%.idl -> src/%.c
- From: Michael B Allen <mba2000@xxxxxxxxxx>
- Date: Wed, 26 Apr 2006 16:47:19 -0400
On Wed, 26 Apr 2006 13:31:26 -0700, Maxim Yegorushkin wrote:
Michael B Allen wrote:
If I compile an idl file to produce a c file with a command like:
$ idlc -o src/foo idl/foo.idl
this will generate a src/foo.h and src/foo.c file.
My question is, given a list of idl files (or perhaps just the names like
'foo') can I create a single Makefile target to generate these files?
I was thinking of something like:
IDL = idl/foo.idl idl/bar.idl idl/zap.idl
.SUFFIXES: .idl
.idl.c:
idlc -o src/$* $<
but of course $* would be wrong and regardless the rule doesn't even
match:
$ make src/foo.c
make: *** No rule to make target `src/foo.c'. Stop.
Any ideas?
I am no expert in makefiles, but something like this you might find of
help:
idl := a.idl b.idl
idl_c := $(idl:.idl=.c)
idl_h := $(idl:.idl=.h)
all: $(idl_c) $(idl_h)
idl_cmd := cp
%.h: %.idl
$(idl_cmd) $< $@
%.c : %.idl
$(idl_cmd) $< $@
clean:
rm *.{c,h}
.PHONY: clean
Yeah, that helps. Two issues remain. One is creating the .h and .c
output in the src/ directory. For this I suppose a simple
mv $(IDL_C) $(IDL_H) src/
would suffice. But I still need to address the .o files for linking. For
that I'm thinking I can use subst like:
IDL2SRC = $(subst idl/,src/,$(IDL))
OBJS = $(SRCIDL:.idl=.o)
but I have to wonder if this is portable.
Mike
.
- Follow-Ups:
- Re: Makefile Rule: idl/%.idl -> src/%.c
- From: Erik Max Francis
- Re: Makefile Rule: idl/%.idl -> src/%.c
- From: Maxim Yegorushkin
- Re: Makefile Rule: idl/%.idl -> src/%.c
- References:
- Makefile Rule: idl/%.idl -> src/%.c
- From: Michael B Allen
- Re: Makefile Rule: idl/%.idl -> src/%.c
- From: Maxim Yegorushkin
- Makefile Rule: idl/%.idl -> src/%.c
- Prev by Date: Re: Makefile Rule: idl/%.idl -> src/%.c
- Next by Date: Re: sockets, closing and TIME_WAIT
- Previous by thread: Re: Makefile Rule: idl/%.idl -> src/%.c
- Next by thread: Re: Makefile Rule: idl/%.idl -> src/%.c
- Index(es):