Subject: Re: unique id for makefile target
To: None <netbsd-users@netbsd.org>
From: George Georgalis <george@galis.org>
List: netbsd-users
Date: 01/31/2007 13:28:55
On Sat, Jan 27, 2007 at 12:44:52AM +0000, Christos Zoulas wrote:
>In article <20070126192538.GI21722@run.galis.org>,
>George Georgalis <george@galis.org> wrote:
>>I'm developing a makefile target that does some
>>administrative tasks. Some targets modify /etc
>>files. I'd like to generate a unique id when I make
>>the target, so on it's completion, we can check for
>>any files that have changed.
>>
>>If this was shell, I'd use something like
>>
>> lock=/tmp/${0}-$$ ; [ -e "$lock"] || touch $lock
>>
>>but in a makefile target, a new shell is spawned for
>>each line and $$ changes. the goal here is something like
>>
>>newconf :
>> touch /tmp/$@-$$$$
>> .... files to change /etc ...
>> @echo "The following files have been changed..."
>> @find /etc -newer /tmp/$@-$$$$
>> rm /tmp/$@-$$$$
>>
>>but that won't work because $$$$ is different on
>>each line. I could make a macro that uses "date +%s"
>>but that would be expanded (to a new time) on each
>>reference and a day-of-the-week id would be exposed
>>to a race condition, and other problems if run near
>>midnight.
>>
>>Is the desired effect possible in a makefile target???
>>
>
>use the same shell:
>
>newconf :
> @(touch /tmp/$@-$$$$; \
> .... files to change /etc ...; \
> echo "The following files have been changed..."; \
> find /etc -newer /tmp/$@-$$$$; \
> rm /tmp/$@-$$$$;)
humm, I usually join commands with && when I do
that... but the LOCK!=date macro is really ideal
because I may call several targets before I test
-newer. Logging was really the goal so I may end up
writting -newer files to it, too. Thanks.
// George
--
George Georgalis, systems architect, administrator <IXOYE><