dwctwo2netbsd revision 1.1
11.1Sskrll#! /bin/sh
21.1Sskrll#
31.1Sskrll#	$NetBSD: dwctwo2netbsd,v 1.1 2013/09/05 20:25:27 skrll Exp $
41.1Sskrll#
51.1Sskrll# Copyright (c) 2013 The NetBSD Foundation, Inc.
61.1Sskrll# All rights reserved.
71.1Sskrll#
81.1Sskrll# Redistribution and use in source and binary forms, with or without
91.1Sskrll# modification, are permitted provided that the following conditions
101.1Sskrll# are met:
111.1Sskrll# 1. Redistributions of source code must retain the above copyright
121.1Sskrll#    notice, this list of conditions and the following disclaimer.
131.1Sskrll# 2. Redistributions in binary form must reproduce the above copyright
141.1Sskrll#    notice, this list of conditions and the following disclaimer in the
151.1Sskrll#    documentation and/or other materials provided with the distribution.
161.1Sskrll#
171.1Sskrll# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
181.1Sskrll# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
191.1Sskrll# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
201.1Sskrll# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
211.1Sskrll# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
221.1Sskrll# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
231.1Sskrll# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
241.1Sskrll# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
251.1Sskrll# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
261.1Sskrll# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
271.1Sskrll# POSSIBILITY OF SUCH DAMAGE.
281.1Sskrll#
291.1Sskrll# dwctwo2netbsd:  prepare the synopsys driver sources for import into the
301.1Sskrll# netbsd dwc2 source tree, under src/sys/external/bsd/dwc2/dist,
311.1Sskrll# based on the other *2netbsd scripts in the NetBSD source tree
321.1Sskrll#
331.1Sskrll# Instructions for importing new dwc2 release:
341.1Sskrll#
351.1Sskrll#	$ DATE=$(date +%F)
361.1Sskrll#	$ cd /some/where/temporary
371.1Sskrll#	$ git clone -b staging.next git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
381.1Sskrll#	$ DWC2SRCS=$(pwd)/drivers/staging/dwc2
391.1Sskrll#	$ cd /an/other/temporary
401.1Sskrll#	$ sh /usr/src/sys/external/bsd/dwc2/dwctwo2netbsd $DWC2SRCS $(pwd)
411.1Sskrll#	$ cvs -d cvs.netbsd.org:/cvsroot import -m "Import dwc2 $DATE" src/sys/external/bsd/dwc2/dist SYNOPSYS dwc2-$DATE
421.1Sskrll#
431.1Sskrll
441.1Sskrllif [ $# -ne 2 ]; then echo "dwctwo2netbsd src dest"; exit 1; fi
451.1Sskrll
461.1Sskrllr=$1
471.1Sskrlld=$2
481.1Sskrll
491.1Sskrllcase "$d" in
501.1Sskrll	/*)
511.1Sskrll		;;
521.1Sskrll	*)
531.1Sskrll		d=`/bin/pwd`/$d
541.1Sskrll		;;
551.1Sskrllesac
561.1Sskrll
571.1Sskrllcase "$r" in
581.1Sskrll	/*)
591.1Sskrll		;;
601.1Sskrll	*)
611.1Sskrll		r=`/bin/pwd`/$r
621.1Sskrll		;;
631.1Sskrllesac
641.1Sskrll
651.1Sskrllecho preparing directory $d
661.1Sskrllrm -rf $d
671.1Sskrllmkdir -p $d
681.1Sskrll
691.1Sskrll### Copy the files and directories
701.1Sskrllecho copying $r to $d
711.1Sskrllcd $r
721.1Sskrll
731.1Sskrll# Not copied
741.1Sskrll# pci.c platform.c
751.1Sskrll#
761.1Sskrllfor f in \
771.1Sskrll    core.c core.h core_intr.c hcd.c hcd.h hcd_ddma.c hcd_intr.c hcd_queue.c \
781.1Sskrll    hw.h
791.1Sskrlldo
801.1Sskrll	n=$(echo $f | sed -e 's:_::')
811.1Sskrll	cp $r/$f $d/dwc2_$n
821.1Sskrlldone
831.1Sskrll
841.1Sskrll# cd to import directory
851.1Sskrllcd $d
861.1Sskrll
871.1Sskrll### dwc2 distribution doesn't have RCS/CVS tags, so add them.
881.1Sskrll
891.1Sskrll### Add our NetBSD RCS Id
901.1Sskrllfind $d -type f -name '*.[ch]' -print | while read c; do
911.1Sskrll	sed 1q < $c | grep -q '\$NetBSD' || (
921.1Sskrllecho "/*	\$NetBSD\$	*/" >/tmp/dwc2n$$
931.1Sskrllecho "" >>/tmp/dwc2n$$
941.1Sskrllcat $c  >> /tmp/dwc2n$$
951.1Sskrllmv /tmp/dwc2n$$ $c && echo added NetBSD RCS tag to $c
961.1Sskrll	)
971.1Sskrlldone
981.1Sskrll
991.1Sskrllecho done
1001.1Sskrll
1011.1Sskrll### Clean up any CVS directories that might be around.
1021.1Sskrllecho "cleaning up CVS residue."
1031.1Sskrll(
1041.1Sskrll	cd $d
1051.1Sskrll	find . -type d -name "CVS" -print | xargs rm -r
1061.1Sskrll)
1071.1Sskrllecho done
1081.1Sskrll
1091.1Sskrll### Fixing file and directory permissions.
1101.1Sskrllecho "Fixing file/directory permissions."
1111.1Sskrll(
1121.1Sskrll	cd $d
1131.1Sskrll	find . -type f -print | xargs chmod u+rw,go+r
1141.1Sskrll	find . -type d -print | xargs chmod u+rwx,go+rx
1151.1Sskrll)
1161.1Sskrllecho done
1171.1Sskrll
1181.1Sskrllexit 0
119