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