Home | History | Annotate | Line # | Download | only in drm2
      1  1.1  riastrad #!/bin/sh
      2  1.1  riastrad 
      3  1.2  riastrad #	$NetBSD: prepare-import.sh,v 1.2 2021/12/19 10:20:38 riastradh Exp $
      4  1.1  riastrad #
      5  1.1  riastrad # $ /path/to/prepare-import.sh
      6  1.1  riastrad #
      7  1.1  riastrad # Run from the directory that will be imported as
      8  1.1  riastrad # sys/external/bsd/drm2/dist.  Be sure to also run drm/drm2netbsd and
      9  1.1  riastrad # nouveau/nouveau2netbsd in their respective directories.
     10  1.1  riastrad 
     11  1.1  riastrad set -Ceu
     12  1.1  riastrad 
     13  1.1  riastrad find . -name '*.h' \
     14  1.1  riastrad | while read f; do
     15  1.1  riastrad 	cleantags "$f"
     16  1.2  riastrad 	(printf '/*\t%c%s%c\t*/\n\n' '$' NetBSD '$' && cat -- "$f") > "$f".tmp
     17  1.1  riastrad 	mv -f -- "$f".tmp "$f"
     18  1.1  riastrad done
     19  1.1  riastrad 
     20  1.1  riastrad find . -name '*.c' \
     21  1.1  riastrad | while read f; do
     22  1.1  riastrad         # Probably not necessary -- Linux tends not to have RCS ids --
     23  1.1  riastrad         # but a precaution out of paranoia.
     24  1.1  riastrad 	cleantags "$f"
     25  1.1  riastrad 	# Heuristically apply NetBSD RCS ids: a comment at the top of
     26  1.1  riastrad 	# the file, and a __KERNEL_RCSID before the first cpp line,
     27  1.1  riastrad 	# which, with any luck, should be the first non-comment line
     28  1.1  riastrad 	# and lie between the copyright notice and the header.
     29  1.1  riastrad 	awk '
     30  1.1  riastrad 		BEGIN {
     31  1.1  riastrad 			done = 0
     32  1.1  riastrad 			printf("/*\t%c%s%c\t*/\n\n", "$","NetBSD","$")
     33  1.1  riastrad 		}
     34  1.1  riastrad 		/^#/ && !done {
     35  1.1  riastrad 			printf("#include <sys/cdefs.h>\n")
     36  1.1  riastrad 			printf("__KERNEL_RCSID(0, \"%c%s%c\");\n",
     37  1.1  riastrad 			    "$","NetBSD","$")
     38  1.1  riastrad 			printf("\n")
     39  1.1  riastrad 			done = 1
     40  1.1  riastrad 		}
     41  1.1  riastrad 		{
     42  1.1  riastrad 			print
     43  1.1  riastrad 		}
     44  1.1  riastrad 	' < "$f" > "$f".tmp
     45  1.1  riastrad 	mv -f -- "$f".tmp "$f"
     46  1.1  riastrad done
     47