Recursively making directories

From:

Norman Wilson

Subject:

Recursively making directories

Date:

Tue, 19 Sep 2006 11:07:32 +0100

It's a common pattern to do something like this when you want a
directory as a prerequisite of a target:
dir/foo: dir/.dummy
%/.dummy:
mkdir -p $(@D) && touch $(@)
The .dummy file provides a pattern you can write a rule to match. It's
also there to prevent dir/foo being out of date whenever dir changes.
It's recently occurred to me that you don't actually need the dummy file
since 1) you can make the directory an order only dependency, 2) you can
use %/. as the directory creation pattern. (This works on Unix based
system. I've no idea if there is an equivalent in dos world.) So you end
up with the more natural looking:
dir/foo: | dir/.
%/.:
mkdir -p $(@D)
After working this out I had another flash of inspiration. I can make
each directory depend on it's parent and thus do away with the -p flag
to mkdir:
%/.: | %/../.
mkdir $(@D)
However this doesn't work. So is this a bug or a feature. If it's a
feature can someone explain the rules.
Cheers.
=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the
intended addressee(s). Unauthorised reproduction, disclosure, modification,
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message do not
necessarily reflect those of Atos Euronext Market Solutions.
L'information contenue dans cet e-mail est confidentielle et uniquement
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee.
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail
vous parvient par erreur, nous vous prions de bien vouloir prevenir
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre
systeme. Le contenu de ce message electronique ne represente pas necessairement
la position ou le point de vue d'Atos Euronext Market Solutions.