On Mon, Aug 02, 2004 at 05:10:17PM +0200, Hyams Iftach wrote:
>  I need a portable script that can be automatically executed during build
> (old system - make 3.74).
> Suppose I can't make others to upgrade their utilities (shell, sed, make
> ..) so no new features are allowed.

What about perl -pi as a sed -i replacement?

What about providing your own wrapper sed_i script?

>
>  The source is a directory with many files, all have a common word ('CDU' in
> my example).
>  I need to create two different copies, each will be renamed (abcCDUdef.h ->
> abcCDU_1def.h
> and the same with _2). Then, inside each (new) file to rename all functions,
> variables and
> comments with the same rule (sed -ise "/s/CDU/CDU_1/g" * will do but the
> original sed is 2.05
> so no I or s flags are valid).

all: $(LIST_OF_ALL_TARGET_FILES)

%_1def.h: %def.h
        $(SED_I) -e '   s/CDU/CDU_1/g'

%_2def.h: %def.h
        $(SED_I) -e '   s/CDU/CDU_2/g'

> 
>  Bottom line - primitive sed and old make are the common denominator.
> 
>  Is this the right way to go :
> 
> LIST   = $(wildcard *CDU*)

This seems a bit dangerous. What happens if you run this and there is
already some file_1.h created before?

> LIST1  = $(subst CDU,CDU_1,$(LIST))
> LIST1A = $(subst .h,'.h;',$(LIST1))
> LIST1B = $(subst .c,'.c;',$(LIST1A))

Why bother? subst works on each word separately.

> COPY1  = $(join $(LIST),$(LIST1B))
> COPY1A = $(subst .h,'.h ',$(COPY1))
> COPY1B = $(subst .c,'.c ',$(COPY1A))
> COPY1C = $(subst ;,';cp ',$(COPY1B))
> COPY1D = copy $(COPY1C)
> RESULT := $(shell $(COPY1D))

Whoops. This performs the cp operation whenever you run make. Even if
make will report "nothing to do". 

> all:
>       @echo $(COPY1D)
> 
> ?

-- 
Tzafrir Cohen                       +---------------------------+
http://www.technion.ac.il/~tzafrir/ |vim is a mutt's best friend|
mailto:[EMAIL PROTECTED]       +---------------------------+

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to