Subject: unique id for makefile target
To: None <netbsd-users@netbsd.org>
From: George Georgalis <george@galis.org>
List: netbsd-users
Date: 01/26/2007 14:25:38
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???

// George


-- 
George Georgalis, systems architect, administrator <IXOYE><