Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Aug 2005 21:46:14 +0300
From:      Giorgos Keramidas <keramida@freebsd.org>
To:        Emanuel Strobl <Emanuel.strobl@gmx.net>
Cc:        freebsd-current@freebsd.org, David Kirchner <dpk@dpk.net>, freebsd-questions@freebsd.org
Subject:   Re: make ".if exists" problem/question
Message-ID:  <20050825184614.GA97117@orion.daedalusnetworks.priv>
In-Reply-To: <200508252037.04779@harrymail>
References:  <200508251951.37319@harrymail> <35c231bf05082511101884faf@mail.gmail.com> <200508252037.04779@harrymail>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-08-25 20:36, Emanuel Strobl <Emanuel.strobl@gmx.net> wrote:
> Am Donnerstag, 25. August 2005 20:10 CEST schrieb David Kirchner:
> > This Makefile shows the problem:
> >
> > all:
> > .if ! exists(./foobar)
> >         @echo foobar does not exist
> > .endif
> >         touch foobar
> > .if ! exists(./foobar)
> >         @echo foobar does not exist
> > .endif
> >
> > If you run make in this directory, and foobar does not already exist
> > beforehand:
> >
> > $ make
> > foobar does not exist
> > touch foobar
> > foobar does not exist
> >
> > Looking at the make source, it appears that it maintains a cache for
> > file lookups, and I don't see a way to have it flush the hash via some
> > makefile command. I dunno if it is a bug but the man page does not
> > mention a cache.
> >
> > I wonder if you'll have to start a separate make process for each
> > stage of that target's handling.
>
> Thanks for your suggestion, you described exactly what I mean. So if
> there's no way to flush the cache, it's IMHO a wrong behaviour and
> should be considered as bug.  I'm not too experienced in make, so I
> don't know if I want to call sub makes...  Do you have an idea whom to
> contact regarding the "bug"?

You can call a sub-make with the help of an ``auxiliary'' target:

%       all: create-file show-file
%
%       create-file:
%       .if ! exists(./foobar)
%               @echo foobar does not exist
%       .endif
%               touch foobar
%
%       show-file:
%               @$(MAKE) show-file-aux
%
%       show-file-aux:
%       .if ! exists(./foobar)
%               @echo foobar does not exist
%       .else
%               @ls -l foobar
%       .endif

This should result in something like this:

%       orion:/tmp/foobar$ make
%       foobar does not exist
%       touch foobar
%       -rw-rw-r--  1 keramida  wheel  0 Aug 25 21:44 foobar
%       orion:/tmp/foobar$




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050825184614.GA97117>