help-make
[Top][All Lists]
Advanced

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

Re: how to write foreach in makefile?


From: Vsyache Puz
Subject: Re: how to write foreach in makefile?
Date: Sun, 26 Jun 2016 15:28:23 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0

it's not ended, it's enDEF.


Internet people helped me to find the source of this error.
it happens because I used variable assignments inside target.
Makefiles don't work that way (makefile variables are assigned at global
scope).

On 06/26/2016 03:14 PM, Jay Lawrence wrote:
> Misspelled 'endif' as 'ended'?
>
> Sent from my iPhone
>
>> On Jun 26, 2016, at 1:58 AM, Vsyache Puz <address@hidden> wrote:
>>
>>
>> How to write foreach cycles in Makefile properly?
>>
>> I have read
>>
>> https://www.gnu.org/software/make/manual/html_node/Foreach-Function.html#Foreach-Function
>>
>> https://www.gnu.org/software/make/manual/html_node/Eval-Function.html#Eval-Function
>>
>> https://www.gnu.org/software/make/manual/html_node/Value-Function.html#Value-Function
>>
>>
>> Or what I do wrong here (it says "Makefile:16: *** missing separator. 
>> Stop."):
>>
>>
>>
>> DISTFILES := /dir2/dir3/dir4 /dir2 /dir1 /dir1/file1 /dir1/dir2/file2 
>> /dir1/dir2/file3 /dir1/file4
>>
>> .PHONY: default_target
>>
>> define DISTDIR_PROCESS_FILE_OR_DIRECTORY =
>> current_path=${file_or_dir_name}
>> ifeq ($${current_path},$${prev_path})
>> echo skip $${current_path}
>> else
>> echo mkdir -p $${current_path}
>> endif
>> prev_path:=$${current_path}
>> endef
>>
>> default_target:
>>    $(foreach file_or_dir_name,$(sort ${DISTFILES}),$(info $(value 
>> DISTDIR_PROCESS_FILE_OR_DIRECTORY)))
>>
>>
>>
>> Thanks.
>> _______________________________________________
>> Help-make mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/help-make




reply via email to

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