Subject: bin/4711: make(1) tries to use directory as .TARGET
To: None <gnats-bugs@NetBSD.ORG>
From: Simon J. Gerraty <sjg@frodo.cdn.telstra.com.au>
List: netbsd-bugs
Date: 12/18/1997 13:38:32
>Number:         4711
>Category:       bin
>Synopsis:       make(1) tries to use directory as .TARGET
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 17 18:50:02 1997
>Last-Modified:
>Originator:     Simon J. Gerraty
>Organization:
>Release:        1.3_BETA 971202
>Environment:
	
System: NetBSD hobbit 1.3_BETA NetBSD 1.3_BETA (GENERIC_SCSI3) #11: Wed Dec  3 00:47:13 MET 1997     pk@flambard:/usr/src1/sys/arch/sparc/compile/GENERIC_SCSI3 sparc
Architecture: sun4c

>Description:
	
I commonly setup BSD style build trees for 3rd party packages eg TIS fwtk.
I use the convention that if ${.CURDIR}/src exists it is a symlink to
where the source live, else if ${.CURDIR:H}/dist/${.CURDIR:T} exists
then that is where the source lives.  Thus one simple Makefile suffices
for many projects.

This all works fine with 1.2G and an earlier version of NetBSD's make
built on SunOS etc etc etc.

With 1.3_BETA, make(1) appears to be looking for .TARGET via .PATH, and since 
the .TARGET is ${.CURDIR:T} it finds it via .PATH due to the above
arrangement.

The result is predictable:

: sjg:337; make
cc -O -I. -I/usr/local/src/fwall/fwtk/libexec/netacl -I/usr/local/src/fwall/fwtk/include -DSPLITFW -I/usr/local/src/sjg/include -O -I. -I/usr/local/src/fwall/fwtk/libexec/netacl -I/usr/local/src/fwall/fwtk/libexec/netacl/.. -I/usr/local/src/fwall/include -DHAVE_STDLIB_H -DSKEY -DUSE_SKEY -DHAVE_DMALLOC_H  -DLFAC=LOG_LOCAL1 -I/usr/local/src/fwall/fwtk/dist -DLFAC=LOG_LOCAL1  -DLFAC=LOG_LOCAL1  -c /usr/local/src/fwall/fwtk/libexec/netacl/netacl.c
cc   -o /usr/local/src/fwall/fwtk/dist/netacl netacl.o -lauth -lfwtk  -L/usr/local/src/sjg/lib/obj  -lmisc -ldmalloc -ldbug -lmisc -lsig -lskey  -lsig -ltcp -lmisc
ld: open: /usr/local/src/fwall/fwtk/dist/netacl: Is a directory
*** Error code 1

Stop.
: sjg:338; 

>How-To-Repeat:
	
Unpack the following in say /tmp

#!/bin/sh
# This is a shell archive.
# remove everything above the "#!/bin/sh" line
# and feed to /bin/sh
# Use -c option to overwrite existing files
#
# Contents: 
#       t/target/Makefile
#       t/dist/target/target.c
#
# packed by: <sjg@frodo> on Thu Dec 18 13:34:14 EST 1997
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo shar: making path "t/target"
test -d t || mkdir t
test -d t/target || mkdir t/target
if test -f t/target/Makefile -a x$1 != x-c ; then
  echo shar: Will not over-write existing file \"t/target/Makefile\"
else
  echo shar: Extracting \"t/target/Makefile\" \(     427 characters\)
  sed 's/^X//' > t/target/Makefile << '!EOF'
X
X# some standard stuff for building other peoples packages.
X.if exists(${.CURDIR}/src)
X.PATH: ${.CURDIR}/src
XCFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/src
X.elif exists(${.CURDIR:H}/dist)
X.if exists(${.CURDIR:H}/dist/${.CURDIR:T})
X.PATH: ${.CURDIR:H}/dist/${.CURDIR:T}
XCFLAGS+= -I${.CURDIR:H}/dist/${.CURDIR:T}
X.endif
X.PATH: ${.CURDIR:H}/dist
XCFLAGS+= -I${.CURDIR:H}/dist
X.endif
X
XPROG=${.CURDIR:T}
XNOMAN=no
X
X.include <bsd.prog.mk>
!EOF
  if test      427 -ne `wc -c < t/target/Makefile`; then
    echo shar: \"t/target/Makefile\" unpacked with wrong size!
  fi
  
fi
echo shar: making path "t/dist/target"
test -d t || mkdir t
test -d t/dist || mkdir t/dist
test -d t/dist/target || mkdir t/dist/target
if test -f t/dist/target/target.c -a x$1 != x-c ; then
  echo shar: Will not over-write existing file \"t/dist/target/target.c\"
else
  echo shar: Extracting \"t/dist/target/target.c\" \(      59 characters\)
  sed 's/^X//' > t/dist/target/target.c << '!EOF'
Xint
Xmain()
X{
X       write(1, "Hello, World!\n", 14);
X       exit(0);
X}
!EOF
  if test       59 -ne `wc -c < t/dist/target/target.c`; then
    echo shar: \"t/dist/target/target.c\" unpacked with wrong size!
  fi
  
fi
exit 0

Then:

: sjg:291; uname -a
SunOS frodo 4.1.4 2 sun4m
: sjg:292; bmake
gcc -pipe -O -g -I/home/frodo/sjg/tmp/t/dist/target -I/home/frodo/sjg/tmp/t/dist   -c /home/frodo/sjg/tmp/t/dist/target/target.c
gcc -pipe   -o target target.o 
: sjg:293; 

is what you should get.  But you get:

: sjg:345; cd t/target 
/home/frodo/sjg/tmp/t/target
: sjg:346; uname -a
NetBSD hobbit 1.3_BETA NetBSD 1.3_BETA (GENERIC_SCSI3) #11: Wed Dec  3 00:47:13 MET 1997     pk@flambard:/usr/src1/sys/arch/sparc/compile/GENERIC_SCSI3 sparc
: sjg:347; make
cc -O -I/home/frodo/sjg/tmp/t/dist/target -I/home/frodo/sjg/tmp/t/dist  -Werror  -c /home/frodo/sjg/tmp/t/dist/target/target.c
cc   -o /home/frodo/sjg/tmp/t/dist/target target.o 
ld: open: /home/frodo/sjg/tmp/t/dist/target: Is a directory
*** Error code 1

Stop.
: sjg:348; 


>Fix:
	
>Audit-Trail:
>Unformatted: