Makefile: infinite loop when including generated file!
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Makefile: infinite loop when including generated file!




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Makefile: infinite loop when including generated file!  
Markus Dehmann


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-30-05 01:50 AM

In my Makefile, I include another, generated Makefile:

include Makefile2
Makefile2:
generateMakefile.sh > $@

That's no problem.  But if the path for Makefile2 is created by a shell
command, then that Makefile2 is created in an infinite loop, make does
not stop anymore:

MAKEFILE2 := $(shell mktemp -d /tmp/tmp.XXXXXX)/Makefile2
include $(MAKEFILE2)
$(MAKEFILE2):
generateMakefile.sh > $@

$ make
Makefile:2: /tmp/tmp.wIqe0W/Makefile2: No such file or directory
./generateMakefile.sh > /tmp/tmp.wIqe0W/Makefile2
Makefile:2: /tmp/tmp.LoxxQo/Makefile2: No such file or directory
./generateMakefile.sh > /tmp/tmp.LoxxQo/Makefile2
Makefile:2: /tmp/tmp.Ipt1H6/Makefile2: No such file or directory
./generateMakefile.sh > /tmp/tmp.Ipt1H6/Makefile2
Makefile:2: /tmp/tmp.hIgHFG/Makefile2: No such file or directory
./generateMakefile.sh > /tmp/tmp.hIgHFG/Makefile2
[...]

Why is that, and how can I fix it?  I want that the generated Makefile
is in a random tmp directory.  I made a point of using the :=
assignment, but it obviously doesn't help.

Markus





[ Post a follow-up to this message ]



    Re: Makefile: infinite loop when including generated file!  
Pascal Bourguignon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-30-05 07:48 AM

Markus Dehmann <markus.dehmann@gmail.com> writes:

> In my Makefile, I include another, generated Makefile:
>
> include Makefile2
> Makefile2:
> 	generateMakefile.sh > $@
>
> That's no problem.  But if the path for Makefile2 is created by a
> shell command, then that Makefile2 is created in an infinite loop,
> make does not stop anymore:
>
> MAKEFILE2 := $(shell mktemp -d /tmp/tmp.XXXXXX)/Makefile2
> include $(MAKEFILE2)
> $(MAKEFILE2):
> 	generateMakefile.sh > $@
>
> $ make
> Makefile:2: /tmp/tmp.wIqe0W/Makefile2: No such file or directory
> ./generateMakefile.sh > /tmp/tmp.wIqe0W/Makefile2
> Makefile:2: /tmp/tmp.LoxxQo/Makefile2: No such file or directory
> ./generateMakefile.sh > /tmp/tmp.LoxxQo/Makefile2
> Makefile:2: /tmp/tmp.Ipt1H6/Makefile2: No such file or directory
> ./generateMakefile.sh > /tmp/tmp.Ipt1H6/Makefile2
> Makefile:2: /tmp/tmp.hIgHFG/Makefile2: No such file or directory
> ./generateMakefile.sh > /tmp/tmp.hIgHFG/Makefile2
> [...]
>
> Why is that, and how can I fix it?  I want that the generated Makefile
> is in a random tmp directory.  I made a point of using the :=
> assignment, but it obviously doesn't help.

MAKEFILE2=dummy
all:
$(MAKE) real MAKEFILE2=$(shell mktemp -d /tmp/tmp.XXXXXX)/Makefile2

real:
@echo done real

-include $(MAKEFILE2)
$(MAKEFILE2):
generateMakefile.sh > $@


--
__Pascal Bourguignon__                     http://www.informatimago.com/
The mighty hunter
Returns with gifts of plump birds,
Your foot just squashed one.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:14 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register