[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to methodically generate a set of rules?
From: |
Nick Patavalis |
Subject: |
Re: how to methodically generate a set of rules? |
Date: |
Tue, 28 Mar 2006 03:42:03 +0300 |
User-agent: |
Mutt/1.5.9i |
On Tue, Mar 28, 2006 at 03:32:20AM +0300, Nick Patavalis wrote:
>
> Don't use "make" to do the loop. Use the shell for this. Use the shell
> to generate a "new" Makefile, and included it from you "main"
> Makefile. Something like this:
>
> auto.mk : s1.c s2.c ... sN.c
> rm -f $@
> for i in $+; do
> write_rule $i >> $@
> done
>
> include auto.mk
>
Correcting myself. This has the disadvantage of re-calculating *all*
rules if *one* source-file chagnes. You could do better (recalculate
only the relevant rules) like this: ::
SRCS := s1.c s2.c ... sN.c
%.mk : %.c
write_rule $< >> $@
include $(SRCS:.c=.mk)
This will of-course create many "autogenerted" makefiles, one for
every source-file, which will all get included.
/npat
--
Developing skills that depend on a proprietary product makes you a
sharecropper on your own brain.
-- Donald B. Marti Jr.