Subject: patch for pkgsrc/cross/COMMON
To: None <tech-pkg@netbsd.org>
From: Kazuki Sakamoto <sakamoto@splhack.org>
List: tech-pkg
Date: 05/26/2000 13:16:42
Hi,

The following patch is to add make and
cpp(taken from src/gnu/usr.bin/egcs/cpp/usr.bin.cpp.sh)
script to cross NetBSD pkgs.

May I commit it?

sakamoto
--
Index: PLIST-egcs
===================================================================
RCS file: /cvsroot/pkgsrc/cross/COMMON/PLIST-egcs,v
retrieving revision 1.2
diff -u -r1.2 PLIST-egcs
--- PLIST-egcs	1999/01/06 01:14:20	1.2
+++ PLIST-egcs	2000/05/23 06:49:07
@@ -1,7 +1,9 @@
 @comment $NetBSD: PLIST-egcs,v 1.2 1999/01/06 01:14:20 tv Exp $
 ${TARGET_ARCH}/bin/cc
+${TARGET_ARCH}/bin/cpp
 ${TARGET_ARCH}/bin/gcc
 bin/${TARGET_ARCH}-cc
+bin/${TARGET_ARCH}-cpp
 bin/${TARGET_ARCH}-gcc
 lib/gcc-lib/${TARGET_ARCH}/${EGCS_INTVERSION}/cc1
 lib/gcc-lib/${TARGET_ARCH}/${EGCS_INTVERSION}/collect2
Index: cross.mk
===================================================================
RCS file: /cvsroot/pkgsrc/cross/COMMON/cross.mk,v
retrieving revision 1.14
diff -u -r1.14 cross.mk
--- cross.mk	1999/12/18 02:14:38	1.14
+++ cross.mk	2000/05/23 06:49:07
@@ -205,14 +205,18 @@
 .if !defined(EGCS_NO_OBJC) && !defined(EGCS_NO_OBJC_RUNTIME)
 	@cd ${EGCS_WRKSRC}/gcc && ${EGCS_MAKE} objc-runtime
 .endif
+	@${SED} -e 's|/usr/libexec\(/cpp\)|${PREFIX}/lib/gcc-lib/${TARGET_ARCH}/${EGCS_INTVERSION}\1|' \
+		${COMMON_DIR}/usr.bin.cpp.sh > ${WRKSRC}/${TARGET_ARCH}-cpp
 
 egcs-install:
 	@cd ${EGCS_WRKSRC}/gcc && ${SETENV} ${MAKE_ENV} \
 		${MAKE_PROGRAM} ${MAKE_FLAGS} ${EGCS_MAKE_FLAGS} \
 		install-common install-headers install-libgcc install-driver
-	chown -R ${BINOWN}:${BINGRP} ${PREFIX}/lib/gcc-lib/${TARGET_ARCH}/${EGCS_INTVERSION}
+	${CHOWN} -R ${BINOWN}:${BINGRP} ${PREFIX}/lib/gcc-lib/${TARGET_ARCH}/${EGCS_INTVERSION}
 	${LN} -f ${PREFIX}/bin/${TARGET_ARCH}-gcc ${PREFIX}/bin/${TARGET_ARCH}-cc
 	${LN} -f ${PREFIX}/bin/${TARGET_ARCH}-gcc ${TARGET_DIR}/bin/cc
+	${INSTALL_SCRIPT} ${WRKSRC}/${TARGET_ARCH}-cpp ${PREFIX}/bin
+	${LN} -f ${PREFIX}/bin/${TARGET_ARCH}-cpp ${TARGET_DIR}/bin/cpp
 .if !defined(EGCS_NO_F77)
 .if !defined(EGCS_NO_F77_RUNTIME)
 	@cd ${EGCS_WRKSRC} && ${EGCS_MAKE} install-target-libf2c
@@ -234,6 +239,22 @@
 .endif
 	@${RMDIR} -p ${PREFIX}/info 2>/dev/null || ${TRUE}
 	@${RMDIR} -p ${PREFIX}/man/man1 2>/dev/null || ${TRUE}
+.endif
+
+.if ${TARGET_ARCH:C/.*-//:C/elf$$//} == "netbsd"
+PLIST_PRE+=		${COMMON_DIR}/PLIST-make
+
+do-build: cross-make-build
+do-install: cross-make-install
+
+cross-make-build:
+	@${SED} -e 's|$${PREFIX}|${PREFIX}|g' \
+		-e 's|$${MACHINE_ARCH}|${TARGET_ARCH:C/-netbsd//}|g' \
+		-e 's|$${TARGET_ARCH}|${TARGET_ARCH}|g' \
+		${COMMON_DIR}/cross-make > ${WRKSRC}/${TARGET_ARCH}-make
+
+cross-make-install:
+	${INSTALL_SCRIPT} ${WRKSRC}/${TARGET_ARCH}-make ${PREFIX}/bin
 .endif
 
 .if defined(CROSS_DISTFILES)
--- /dev/null	Tue May 23 14:49:20 2000
+++ PLIST-make	Mon May 22 21:18:47 2000
@@ -0,0 +1,2 @@
+@comment $NetBSD$
+bin/${TARGET_ARCH}-make
--- /dev/null	Tue May 23 14:49:20 2000
+++ cross-make	Tue May 23 15:27:08 2000
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+if [ x"${MACHINE}" = x ]; then
+	echo "Please set \"MACHINE\" environment variable."
+	exit 1
+fi
+if [ x"${DESTDIR}" = x -o "${DESTDIR}" = "/" ]; then
+	echo "Please set \"DESTDIR\" environment variable. Don't set \"/\"."
+	exit 1
+fi
+
+MACHINE_ARCH=${MACHINE_ARCH} export MACHINE_ARCH
+
+WHICH=${TARGET_ARCH}
+BINDIR=${PREFIX}/bin
+PATH=${BINDIR}:${PATH} export PATH
+
+AR=${BINDIR}/${WHICH}-ar export AR
+AS=${BINDIR}/${WHICH}-as export AS
+CC=${BINDIR}/${WHICH}-gcc export CC
+CPP=${BINDIR}/${WHICH}-cpp export CPP
+CXX=${BINDIR}/${WHICH}-c++ export CXX
+FC=${BINDIR}/${WHICH}-f77 export FC
+LD=${BINDIR}/${WHICH}-ld export LD
+NM=${BINDIR}/${WHICH}-nm export NM
+RANLIB=${BINDIR}/${WHICH}-ranlib export RANLIB
+SIZE=${BINDIR}/${WHICH}-size export SIZE
+ADDR2LINE=${BINDIR}/${WHICH}-addr2line export ADDR2LINE
+GASP=${BINDIR}/${WHICH}-gasp export GASP
+OBJCOPY=${BINDIR}/${WHICH}-objcopy export OBJCOPY
+OBJDUMP=${BINDIR}/${WHICH}-objdump export OBJDUMP
+STRINGS=${BINDIR}/${WHICH}-strings export STRINGS
+STRIP=${BINDIR}/${WHICH}-strip export STRIP
+
+MKPROFILE=no export MKPROFILE
+#MKMAN=no export MKMAN
+MKLINT=no export MKLINT
+
+HOSTED_CC=cc export HOSTED_CC
+
+MAKE=make export MAKE
+#MAKE="make -f ${DESTDIR}/usr/share/mk/sys.mk -f Makefile" export MAKE
+#MAKEFLAGS="-I ${DESTDIR}/usr/share/mk" export MAKEFLAGS
+
+set -x
+exec ${MAKE} "$@"
--- /dev/null	Tue May 23 14:49:20 2000
+++ usr.bin.cpp.sh	Tue Aug 10 12:35:30 1999
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# Copyright (c) 1990 The Regents of the University of California.
+# All rights reserved.
+#
+# This code is derived from software contributed to Berkeley by
+# the Systems Programming Group of the University of Utah Computer
+# Science Department.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#	This product includes software developed by the University of
+#	California, Berkeley and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+#	@(#)usr.bin.cpp.sh	6.5 (Berkeley) 4/1/91
+#
+# Transitional front end to CCCP to make it behave like (Reiser) CCP:
+#	specifies -traditional
+#	doesn't search gcc-include
+#
+PATH=/usr/bin:/bin
+CC=${CC-gcc}
+CPP=/usr/libexec/cpp
+ALST="-traditional -D__GNUC__ -$ "
+NSI=no
+OPTS=""
+INCS="-nostdinc"
+FOUNDFILES=no
+
+while [ $# -gt 0 ]
+do
+	A="$1"
+	shift
+
+	case $A in
+	-nostdinc)
+		NSI=yes
+		;;
+	-traditional)
+		;;
+	-B*)
+		CPP=`${CC} $A -print-prog-name=cpp`
+		;;
+	-ansi)
+		ALST=`echo $ALST | sed -e 's/-traditional//'`
+		;;
+	-I*)
+		INCS="$INCS $A"
+		;;
+	-U__GNUC__)
+		ALST=`echo $ALST | sed -e 's/-D__GNUC__//'`
+		;;
+	-imacros|-include|-idirafter|-iprefix|-iwithprefix)
+		INCS="$INCS '$A' '$1'"
+		shift
+		;;
+	-*)
+		OPTS="$OPTS '$A'"
+		;;
+	*)
+		FOUNDFILES=yes
+		if [ $NSI = "no" ]
+		then
+			INCS="$INCS -I/usr/include"
+			NSI=skip
+		fi
+		eval $CPP $ALST $INCS $OPTS $A || exit $?
+		;;
+	esac
+done
+
+if [ $FOUNDFILES = "no" ]
+then
+	# read standard input
+	if [ $NSI = "no" ]
+	then
+		INCS="$INCS -I/usr/include"
+	fi
+	eval exec $CPP $ALST $INCS $OPTS
+fi
+
+exit 0