bktr2netbsd revision 1.2
11.1Swiz#! /bin/sh
21.1Swiz#
31.2Swiz#	$NetBSD: bktr2netbsd,v 1.2 2000/05/07 03:01:58 wiz Exp $
41.1Swiz#
51.1Swiz# Copyright (c) 2000 The NetBSD Foundation, Inc.
61.1Swiz# All rights reserved.
71.1Swiz#
81.1Swiz# Redistribution and use in source and binary forms, with or without
91.1Swiz# modification, are permitted provided that the following conditions
101.1Swiz# are met:
111.1Swiz# 1. Redistributions of source code must retain the above copyright
121.1Swiz#    notice, this list of conditions and the following disclaimer.
131.1Swiz# 2. Redistributions in binary form must reproduce the above copyright
141.1Swiz#    notice, this list of conditions and the following disclaimer in the
151.1Swiz#    documentation and/or other materials provided with the distribution.
161.1Swiz# 3. All advertising materials mentioning features or use of this software
171.1Swiz#    must display the following acknowledgement:
181.1Swiz#	This product includes software developed by the NetBSD
191.1Swiz#	Foundation, Inc. and its contributors.
201.1Swiz# 4. Neither the name of The NetBSD Foundation nor the names of its
211.1Swiz#    contributors may be used to endorse or promote products derived
221.1Swiz#    from this software without specific prior written permission.
231.1Swiz#
241.1Swiz# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
251.1Swiz# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
261.1Swiz# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
271.1Swiz# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
281.1Swiz# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
291.1Swiz# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
301.1Swiz# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
311.1Swiz# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
321.1Swiz# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
331.1Swiz# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
341.1Swiz# POSSIBILITY OF SUCH DAMAGE.
351.1Swiz#
361.1Swiz# bktr2netbsd:  convert a bktr source directory tree into a
371.1Swiz# netbsd bktr source tree, under sys/dev/pci/bktr
381.1Swiz# based on bind2netbsd by Bernd Ernesti
391.1Swiz
401.1Swizif [ $# -ne 2 ]; then echo "bktr2netbsd src dest"; exit 1; fi
411.1Swiz
421.1Swizr=$1
431.1Swizd=$2/sys/dev/pci/bktr
441.1Swiz
451.1Swizcase "$d" in
461.1Swiz	/*)
471.1Swiz		;;
481.1Swiz	*)
491.1Swiz		d=`/bin/pwd`/$d
501.1Swiz		;;
511.1Swizesac
521.1Swiz
531.1Swizcase "$r" in
541.1Swiz	/*)
551.1Swiz		;;
561.1Swiz	*)
571.1Swiz		r=`/bin/pwd`/$r
581.1Swiz		;;
591.1Swizesac
601.1Swiz
611.1Swizecho preparing directory $d
621.1Swizrm -rf $d
631.1Swizmkdir -p $d
641.1Swiz
651.1Swiz### Copy the files
661.1Swizecho copying $r to $d
671.1Swizcd $r
681.1Swizpax -rw * $d
691.1Swiz
701.1Swizecho removing unneeded files
711.1Swiz
721.1Swiz### Remove unneeded files
731.1Swizcd $d
741.1Swizrm CHANGELOG.TXT README.* bktr_i2c.[ch]
751.1Swiz
761.1Swiz### Remove the $'s around RCS tags
771.1Swizfind $d -type f -print | xargs egrep -l '\$(Id|Created|Header|FreeBSD)' | while read f; do
781.1Swiz	sed -e 's/\$\(Id.*\) \$/\1/' \
791.1Swiz	    -e 's/\$\(Created.*\) \$/\1/' \
801.1Swiz	    -e 's/\$\(FreeBSD.*\) \$/\1/' \
811.1Swiz	    -e 's/\$\(Header.*\) \$/\1/' \
821.1Swiz	    < $f > /tmp/bktr1f$$ && mv /tmp/bktr1f$$ $f && \
831.1Swiz	echo removed \$RCS tag from $f
841.1Swizdone
851.1Swiz
861.1Swiz### create bt8xx.h from ioctl_meteor.h and ioctl_bt848.h
871.1Swizecho merging ioctl_meteor.h and ioctl_bt848.h to bt8xx.h
881.1Swizecho "/* This file is merged from ioctl_meteor.h and ioctl_bt848.h from FreeBSD. */" > bt8xx.h
891.1Swizecho "/* The copyright below only applies to the ioctl_meteor.h part of this file. */" >> bt8xx.h
901.2Swizecho "" >> bt8xx.h
911.2Swizecho "#ifndef _DEV_IC_BT8XX_H_" >> bt8xx.h
921.2Swizecho "#define _DEV_IC_BT8XX_H_" >> bt8xx.h
931.1Swizcat ioctl_meteor.h ioctl_bt848.h | grep -v _MACHINE_IOCTL_METEOR_H_ | \
941.1Swiz	grep -v _MACHINE_IOCTL_BT848_H >> bt8xx.h
951.2Swizecho "#endif /* _DEV_IC_BT8XX_H_ */" >> bt8xx.h
961.1Swizrm ioctl_meteor.h ioctl_bt848.h
971.1Swiz
981.1Swiz### Add our NetBSD RCS Id
991.1Swizfind $d -name '*.[chly]' -print | while read c; do
1001.1Swiz	sed 1q < $c | grep -q '\$NetBSD' || (
1011.1Swizecho "/*	\$NetBSD\$	*/" >/tmp/bktr3n$$
1021.1Swizecho "" >>/tmp/bktr3n$$
1031.1Swizcat $c  >> /tmp/bktr3n$$
1041.1Swizmv /tmp/bktr3n$$ $c && echo added NetBSD RCS tag to $c
1051.1Swiz	)
1061.1Swizdone
1071.1Swiz
1081.1Swizecho done
1091.1Swiz
1101.1Swiz### move bt8xx.h to correct place
1111.1Swizecho moving bt8xx.h to dev/ic
1121.1Swizmkdir -p $d/../../ic
1131.1Swizmv bt8xx.h $d/../../ic
1141.1Swiz
1151.1Swiz### Clean up any CVS directories that might be around.
1161.1Swizecho "cleaning up CVS residue."
1171.1Swiz(
1181.1Swiz	cd $d
1191.1Swiz	find . -type d -name "CVS" -print | xargs rm -r
1201.1Swiz)
1211.1Swizecho done
1221.1Swiz
1231.1Swiz### Fixing file and directory permissions.
1241.1Swizecho "Fixing file/directory permissions."
1251.1Swiz(
1261.1Swiz	cd $d
1271.1Swiz	find . -type f -print | xargs chmod u+rw,go+r
1281.1Swiz	find . -type d -print | xargs chmod u+rwx,go+rx
1291.1Swiz)
1301.1Swizecho done
1311.1Swiz
1321.1Swizecho Do not forget to also import bt8xx.h in dev/ic!
1331.1Swizexit 0
134