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.


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to