Re: Optimizing directory creation

Heime <[email protected]> Thu, 30 Apr 2026 19:26:31 +0000
Newsgroups gmane.comp.gnu.make.general
Message-ID <fHG_HoibMohCsCXqNidMXrtpezppZvf_aXCV3rft-Ea412MYJgnr2todw5vdDgArY-qamjy_hFdS-XPo2iziJAha6YnFQsQ49YYbUayWkfs=@protonmail.com>
On Friday, May 1st, 2026 at 6:59 AM, Tim Murphy <[email protected]> wrote:

> Hi,
>=20
> I did have a reason, which wasn't tied up with GNU make. Trying to explai=
n wont help you but there is a other way.
>=20
> One problem with directories is that their time and date change when anyt=
hing is done on the directory e.g. if a new file is created. I think you mi=
ght need to check that adding a file to one of your directories doesn't tri=
gger m=C4=B1d=C4=B1r on anything below it. Does this matter a lot? Not real=
ly in this case.

You recommond a variation to this:=20

${infdir}: $(docdir)
${hmldir}: ${docdir}
${docdir} ${infdir} ${hmldir}:
    mkdir -p $@
=20
> In my unusual situation it causes a very bad performance regression so I =
had to use another scheme.
>=20
> What was effective for me was a variable that one appended the directory =
to and then at the end of the makefile a for loop that ran something like $=
(eval $$(shell mkd=C4=B1r -p ... ) on batches of about 20 directories at a =
time.

Right.  Followed by the rules to make your targets after making the directo=
ries
present in the variable.
=20
> If you're not making 100s of directories you don't need to be too sophist=
icated.

I will only have a few directories.  Nothing more.=20
=20
> Best regards,
>=20
> Tim Murphy
>=20
>=20
> On Thu, 30 Apr 2026, 19:29 Heime, <[email protected]> wrote:
>=20
> >=20
> > I made the following makefile, where .info and html files are
> > stored in docs/info and docs/html directories. Whilst single
> > file antares.pdf and antares.dvi are stored in directory docs.
> >=20
> > Have included order-only prerequisite for directories with the
> > rules defined as shown. Would one rather do something different
> > for making the directories if they don't exist?
> >=20
> > docdir =3D ${HOME}/Opfeld/hist/build/${btnver}/docs
> > infdir =3D ${HOME}/Opfeld/hist/build/${btnver}/docs/info
> > hmldir =3D ${HOME}/Opfeld/hist/build/${btnver}/docs/html
> >=20
> > srcs =3D ${srcdir}/antares.texi
> >=20
> > opts =3D --force --enable-encoding -I ${srcdir}
> >=20
> > $(infdir)/antares.info: $(srcs) | $(infdir)
> > makeinfo $(opts) -o $@ $<
> >=20
> > $(hmldir)/antares.html: $(srcs) | $(hmldir)
> > makeinfo $(opts) --html -o $@ $<
> >=20
> > $(docdir)/antares.pdf: $(srcs) | $(docdir)
> > makeinfo $(opts) --pdf -o $@ $<
> >=20
> > $(docdir)/antares.dvi: $(srcs) | $(docdir)
> > makeinfo $(opts) --dvi -o $@ $<
> >=20
> > ${infdir}: $(docdir)
> > ${hmldir}: ${docdir}
> > ${docdir} ${infdir} ${hmldir}:
> > mkdir -p $@