This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Make, TMP=tmpnam => coredump


Hello,

Using cygwin, I'm building the code from the book, Beginning Linux
Programming. I ran across a bug that chewed up a considerable amount of my
time. As a newbie, perhaps I'm doing something wrong. On the chance that
this is a bug, I hope I can save others from grief.

Chapter 4 of the book is where I discovered the problem. It turns out to be
inside the makefile.

Here's the Makefile:
------------
# Makefile for Beginning Linux Programming 3rd Edition
# Chapter 4

ARGS=args argopt longopt
ENV=environ showenv
TIME=envtime gmtime ctime strftime
TMP=tmpnam
USER=user
HOST=hostget
LOG=syslog logmask
RES=limits

CC = g++ -v
CFLAGS = -ggdb
LDFLAGS=-lm

ALL= $(ARGS) $(ENV) $(TIME) $(TMP) $(USER) $(HOST) $(LOG) $(RES)

all: $(ALL)

user: user
	g++ -v -ggdb  -lm  user.c   -o user

clean:
	@rm -f $(ALL) *~
------------

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)

C:\Temp\Chap04\>ls
Makefile  gcc.exe.stackdump  program.c  tmpnam.c  tmpnam.exe

------------

Any ideas?

HTH someone else.


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]