[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
|
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
8634.0. "Can make create names with timestamps?" by APACHE::CHAMBERS () Wed Jan 29 1997 10:28
This looks like a bug in make, but maybe there's a way ...
We've been using make to link binaries to a second name that has a timestamp
at the end. The basic idea is sorta trivial:
D=`date +%y%m%d`
all: foo
foo: ;echo This is foo. >foo
ln -f foo foo-$D
This toy example creates foo and foo-970129 when I run it today. This is
proof that make understands the definition of D, because it generates the
correct name in the `ln -f foo foo-$D` command.
This has a problem, however: If I type "make" tomorrow (or rm foo-970129
and type "make" today), nothing happens. It's obviously because there's
no rule for foo-$D, so let's make one:
D=`date +%y%m%d`
all: foo foo-$D
foo: ;echo This is foo. >foo
foo-$D: foo; ln -f foo foo-$D
This doesn't work. When I type a "make" command, the response is:
: make
Make: `...` dependencies must be whole names. Stop.
Ooops! What's the problem? Well, maybe make has a problem with calculated
names before the ':'. But I can easily disprove this hypothesis:
D=`date +%y%m%d`
T=tmp
all: foo $T/foo
foo: ;echo This is foo. >foo
ln -f foo foo-$D
$T: ;mkdir $T
$T/foo: $T foo ; ln -f foo $T/foo
Now, when I type "make", the directory tmp and the files foo, tmp/foo and
foo-970129 all appear. So make can obviously handle rules for targets with
names like $T and $T/foo; it just can't handle foo-$D as a target (though
this name is ok in a command).
Further experiments quickly disprove hypotheses such as that it's the hypen
that bothers make; the same error message appears if the target is changed
to foo_$D, foo.$D, $D_foo, $D/foo, or just foo$D. It seems that make has
some sort of problem with using $D in a target name, though other sorts of
calculated target names work just fine.
So is there any way to do what we want here? Can you modify this makefile
so that it correctly builds foo-$D, where $D is the current date, and does
it whenever foo-$D doesn't exist or is older than foo?
I've tried this on several releases of Dunix, mostly 3.2f and 3.2g, and a
couple of 4.0 systems lurking about. On all of them, make rejects rules that
include $D in the name, though it seems to accept all sorts of other complex
calculated names.
T.R | Title | User | Personal Name | Date | Lines |
---|
8634.1 | | VAXCPU::michaud | Jeff Michaud - ObjectBroker | Wed Jan 29 1997 10:59 | 22 |
| > ln -f foo foo-$D
> This toy example creates foo and foo-970129 when I run it today....
> foo-$D: foo; ln -f foo foo-$D
The first one works and the second one doesn't because "make"
is not calculating "D" to be 970129, it's simply replacing
occurances of "D" with `date ...`, so in the first case
the command it's passing to the shell is:
ln -f foo foo-`date ...`
In the second case it's expanded to:
foo-`date ...`: foo; ln -f foo foo-`date ...`
I didn't read the rest of your note after this point (too long!)
but what you really want to do is to is to use $D in the Makefile
but don't define it there, instead pass it on the make command
line such as:
% make D=`date ...`
|