Re: make ".if exists" problem/question
Am Montag, 5. September 2005 18:03 CEST schrieb Harti Brandt: > On Thu, 25 Aug 2005, Emanuel Strobl wrote: [...] > > You should think of .if and .for as "preprocessor directives". They are > processed when make reads the makefile and builds the dependency graph. > If you need something more dynamic you must use either a shell line: > > foo: > if [ -f baz ] ; then ... > > or go with sub-makes. > > Generally you don't want to use .if to check for a file that your > makefile creates. In this case you just should use make itself. Given > that the tree you need to have is named 'tree' do something like: > > installcfworld: tree > ... > > installcfconfig: tree > ... > > tree: > mkdir tree > ... Thanks, I understood it, and the project grew fine. Will be available this week :) -Harry > > harti > ___ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to > "[EMAIL PROTECTED]" pgp0AMa2ZNpul.pgp Description: PGP signature
Re: make ".if exists" problem/question
On Thu, 25 Aug 2005, Emanuel Strobl wrote: ES>Am Donnerstag, 25. August 2005 20:10 CEST schrieb David Kirchner: ES>> On 8/25/05, Emanuel Strobl <[EMAIL PROTECTED]> wrote: ES>> > Dear make gurus (bsd make, not gmake), ES>> > ES>> > it seems that make checks .if directives only at statrup. How can I ES>> > trigger a "reread"? ES>> > I have the problem that in one target I create a filetree, another ES>> > target checks if it exists, if not it creates itself again. Now it ES>> > works perfectly when I call the two targets both externally ES>> > (installcfworld installcfconfig) but when the internal higher ES>> > "install" gets to the installcfconfig target it fails! ES>> > I'm really desperate, I need to check this. Is this a nasty bug? ES>> ES>> This Makefile shows the problem: ES>> ES>> all: ES>> .if ! exists(./foobar) ES>> @echo foobar does not exist ES>> .endif ES>> touch foobar ES>> .if ! exists(./foobar) ES>> @echo foobar does not exist ES>> .endif ES>> ES>> If you run make in this directory, and foobar does not already exist ES>> beforehand: ES>> ES>> $ make ES>> foobar does not exist ES>> touch foobar ES>> foobar does not exist ES>> ES>> Looking at the make source, it appears that it maintains a cache for ES>> file lookups, and I don't see a way to have it flush the hash via some ES>> makefile command. I dunno if it is a bug but the man page does not ES>> mention a cache. ES>> ES>> I wonder if you'll have to start a separate make process for each ES>> stage of that target's handling. ES> ES>Thanks for your suggestion, you described exactly what I mean. So if ES>there's no way to flush the cache, it's IMHO a wrong behaviour and should ES>be considered as bug. ES>I'm not too experienced in make, so I don't know if I want to call sub ES>makes... ES>Do you have an idea whom to contact regarding the "bug"? You should think of .if and .for as "preprocessor directives". They are processed when make reads the makefile and builds the dependency graph. If you need something more dynamic you must use either a shell line: foo: if [ -f baz ] ; then ... or go with sub-makes. Generally you don't want to use .if to check for a file that your makefile creates. In this case you just should use make itself. Given that the tree you need to have is named 'tree' do something like: installcfworld: tree ... installcfconfig: tree ... tree: mkdir tree ... harti ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: make ".if exists" problem/question
Yes. The thing to keep in mind is that much of the .if stuff is done at parsing or rule construction time. So if you change something (creating a file, say), then that condition won't be re-evaluated. For the specific example given, one could replace much of the goo with: target: foobar foobar: touch foobar if you wanted to create foobar. Otherwise, I'd be tempted not to use .if exists. I'd be tempted to do something more like: target: @-if [ -f foobar ]; then cat foobar; else touch foobar; fi where you have the shell check. The primary use of exists() I've seen is: .if exists(foo.mk) .include "foo.mk" .endif although I have seen others. Warner ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: make ".if exists" problem/question
On 2005-08-25 20:36, Emanuel Strobl <[EMAIL PROTECTED]> 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$ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: make ".if exists" problem/question
Am Donnerstag, 25. August 2005 20:10 CEST schrieb David Kirchner: > On 8/25/05, Emanuel Strobl <[EMAIL PROTECTED]> wrote: > > Dear make gurus (bsd make, not gmake), > > > > it seems that make checks .if directives only at statrup. How can I > > trigger a "reread"? > > I have the problem that in one target I create a filetree, another > > target checks if it exists, if not it creates itself again. Now it > > works perfectly when I call the two targets both externally > > (installcfworld installcfconfig) but when the internal higher > > "install" gets to the installcfconfig target it fails! > > I'm really desperate, I need to check this. Is this a nasty bug? > > 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"? Thanks, -Harry pgpLMGpHWk1lW.pgp Description: PGP signature
make ".if exists" problem/question
Dear make gurus (bsd make, not gmake), it seems that make checks .if directives only at statrup. How can I trigger a "reread"? I have the problem that in one target I create a filetree, another target checks if it exists, if not it creates itself again. Now it works perfectly when I call the two targets both externally (installcfworld installcfconfig) but when the internal higher "install" gets to the installcfconfig target it fails! I'm really desperate, I need to check this. Is this a nasty bug? Thanks, -Harry pgpI56F8brpXo.pgp Description: PGP signature