Subject: Re: Make, TMP=tmpnam => coredump
From: Brian Dessent <[email-masked]>
To: [email-masked]
Date: Fri, 08 Apr 2005 17:32:20 -0700

Larry wrote:

> The problem I found is that the Makefile contains the statement
> 'TMP=tmpnam'. The build fails after the program builds a file $(TMP).
> Apparently, the local tmpnam.exe file that gets built gets called when make
> attempts to build the remaining files. (Is there a way to disable the pwd to
> test this?) I've verified this problem on two out of three machines.
> 
> Does anybody know about this bug? Can someone please confirm what I'm
> experiencing?
> 
> Here's a simple test to confirm:
> 
> Makefile
> --------
> TMP=tmpnam
> 
> all: $(TMP) program
>     gcc -c program.c
> --------------------------
> 
> create two identical files tmpnam.c and program.c with the following code:
> --------------------------
> #include <stdio.h>
> 
> int main()
> {
>     printf("Hello World!");
> }
> --------------------------
> 
> Type make. This is what I get:
> 
> C:\Temp\Chap04\>make
> gcc     tmpnam.c   -o tmpnam
> gcc     program.c   -o program
> make: *** [program] Aborted (core dumped)

With the three files mentioned above, I get

$ make
make: *** No rule to make target `tmpnam', needed by `all'.  Stop.

...which is correct because there is nothing in the Makefile to tell
make how to make 'tmpnam'.  I suspect there is something else going on
in your case, such as some kind of implicit ".c.o" or ".c.exe" rule, or
some other makefile rules being included.  Your test makefile above
doesn't make much sense anyway, because "gcc -c program.c" will compile
but not link program.c, creating program.o, which in no way satisfies
either dependency of the rule.

Are you sure the 'make' and 'gcc' that are in your path are Cygwin's and
not some win32 tools?

And just so you know... Cygwin tries to provide a POSIX environment but
there are still many differences between it and linux.  I wouldn't
expect every example to work the same.  The .exe extension is one main
one that comes up in makefiles.  Another example is that -lm is totally
superfluous under Cygwin.  Also realize that under Windows the
environment variable $TMP is used as the location to place temporary
files, and is a horrible choice for the name of a variable to use in a
Makefile.  That's a good example of how not to write a portable
makefile...

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/