help-make
[Top][All Lists]
Advanced

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

Re: Deferred targets or second expansion? (rename results from split)


From: Peng Yu
Subject: Re: Deferred targets or second expansion? (rename results from split)
Date: Tue, 15 Jun 2010 23:14:44 -0500

On Tue, Jun 15, 2010 at 10:58 PM, Peng Yu <address@hidden> wrote:
> My problem is that I have a number of files to be splitted. Then I
> want to add a suffix to each file.
>
> According to the manual, targets are always immediate. I think that
> probably secondexpansion may help in this case. But I'm not clear how
> to apply it to my case below. Would you please show me?
>
>
> $ ll -go *
> -rw------- 1 478 2010-06-15 22:43 Makefile
>
> txt:
> total 8
> -rw------- 1 3893 2010-06-15 22:26 aaa.txt
> -rw------- 1 3893 2010-06-15 22:26 bbb.txt
>
> $ cat Makefile
> .PHONY: all clear
> .NOTPARALLEL: all
>
> TXT:=$(wildcard txt/*_sequence.txt)

Correction: the above line should be
TXT:=$(wildcard txt/*.txt)

But I still get errors.

> PREFIX:=$(patsubst txt/%.txt,output/%,$(TXT))
>
> ALL_SPLIT_FILES=$(wildcard output/*/*)
> RENAME_ALL_SPLIT_FILES=$(patsubst %,%.txt,$(ALL_SPLIT_FILES))
>
> all: ; $(RENAME_ALL_SPLIT_FILES)
>
> .SECONDEXPANSION:
> $$(RENAME_ALL_SPLIT_FILES): %.txt: %
>        mv $< $@
>
> $(RENAME_ALL_SPLIT_FILES): split
>
> split: $(PREFIX)
>
> $(PREFIX): output/%: txt/%.txt
>        mkdir -p $@; split --lines 100 --numeric-suffixes $< $@/; touch .
>
> clean:
>        $(RM) -r output
>
> --
> Regards,
> Peng
>



-- 
Regards,
Peng



reply via email to

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