Thanks for the tip. I'm not sure why it doesn't just fail immediately then, 
instead of taking a few steps and stumbling on itself. Just out of curiosity, I 
tested the same thing with FreeBSD make (`LDFLAGS=-ll make`) and it compiled 
`lang` as expected with this output:

lex -t  lang.l > lang.c
cc -O2 -pipe -ll lang.c  -o lang

________________________________
From: Philip Guenther <guent...@gmail.com>
Sent: Sunday, May 19, 2019 11:11 AM
To: Mohamed Akram
Cc: bug-make@gnu.org
Subject: Re: lex implicit rule chain is broken

On Sat, May 18, 2019 at 9:07 PM Mohamed Akram 
<mohd.ak...@outlook.com<mailto:mohd.ak...@outlook.com>> wrote:
echo "lang: lang.l" > Makefile

This Makefile is incorrect, as it tells make that 'lang.l' is a *direct* 
dependency of lang.  That's not true: lang.l has to be run through lex to get a 
.c file that can compiled to get lang.


It tries to link the .l file.

make doesn't need any special instructions to tell it how to generate an 
executable from a .l file, but it'll do the Wrong Thing if you tell it the 
wrong thing.  To achieve your apparent goal you can simply run it with *no* 
Makefile and give it the name of the matching executable (ala "make lang" in 
this case) or use a Makefile sets the default target ala
   echo ".DEFAULT_GOAL = lang" >Makefile
and it'll deduce the rest from its default pattern rules.


Philip Guenther

_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to