Subject: bug in libg++/genclass/Makefile
To: None <netbsd-bugs@sun-lamp.cs.berkeley.edu>
From: None <carrel@cisco.com>
List: netbsd-bugs
Date: 06/26/1994 22:42:33
>Submitter-Id:	net
>Originator:	David Carrel
>Organization:
Just a regular guy!
>Confidential:	no
>Synopsis:	The genclass Makefile evaluates DESTDIR too soon
>Severity:	non-critical
>Priority:	medium
>Category:	lib
>Class:		sw-bug
>Release:	0.9C (sources from June 26 94)
>Environment:
	Present for all architectures
	Tested on hp300

>Description:
	src/gnu/lib/libg++/genclass/Makefile uses sed to fill in the
correct value of "PROTODIR", but it is evaluating $DESTDIR when creating
the genclass script, instead of placing the expression "$DESTDIR" into the
file for run-time evaluation.

	Basically, just because I am installing into a mounted disk (eg.
DESTDIR=/mnt) doesn't mean that the executables will always live there.

	Also since the sed line uses `_' as the substitution separator, the
early evaluation of $DESTDIR will cause a "make install" to fail if DESTDIR
has a `_' in it (eg. DESTDIR=/main_sys)

>How-To-Repeat:
	cd /usr/src/gnu/lib/libg++/genclass/
	DESTDIR=/mnt
	make install
will create a file "/mnt/usr/bin/genclass" (which is correct) that has the
value of PROTODIR set to "/mnt/usr/include/g++/genclass" (which is unwieldy).

or:
	cd /usr/src/gnu/lib/libg++/genclass/
	DESTDIR=/main_sys
	make install
causes a sed error and the make exits.

>Fix:
	The following patch fixes the early evaluation of DESTDIR

*** Makefile.orig	Sun Jun 26 22:14:53 1994
--- Makefile	Wed Jun  1 07:40:15 1994
***************
*** 3,9 ****
  NOMAN=	noman
  
  afterinstall:
! 	sed -e '/^PROTODIR/s_PROTODIR.*_PROTODIR=${DESTDIR}/usr/include/g++/gen_; s_<VERSION>_2.4_;' $(.CURDIR)/genclass.sh > $(DESTDIR)$(BINDIR)/genclass
  	chown ${BINOWN}:${BINGRP} $(DESTDIR)$(BINDIR)/genclass
  	chmod ${BINMODE} $(DESTDIR)$(BINDIR)/genclass
  
--- 3,9 ----
  NOMAN=	noman
  
  afterinstall:
! 	sed -e '/^PROTODIR/s_PROTODIR.*_PROTODIR=$${DESTDIR}/usr/include/g++/gen_; s_<VERSION>_2.4_;' $(.CURDIR)/genclass.sh > $(DESTDIR)$(BINDIR)/genclass
  	chown ${BINOWN}:${BINGRP} $(DESTDIR)$(BINDIR)/genclass
  	chmod ${BINMODE} $(DESTDIR)$(BINDIR)/genclass
  

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