vmwgfx2netbsd revision 1.1 1 1.1 riastrad #!/bin/sh
2 1.1 riastrad
3 1.1 riastrad # $NetBSD: vmwgfx2netbsd,v 1.1 2022/02/17 01:21:03 riastradh Exp $
4 1.1 riastrad #
5 1.1 riastrad # $ /path/to/vmwgfx2netbsd > /path/to/files.vmwgfx.new
6 1.1 riastrad #
7 1.1 riastrad # Run from the top-level vmwgfx source directory.
8 1.1 riastrad
9 1.1 riastrad set -Ceu
10 1.1 riastrad
11 1.1 riastrad : ${MV:=mv}
12 1.1 riastrad
13 1.1 riastrad # Location of the vmwgfx sources relative to $NETBSDSRCDIR.
14 1.1 riastrad vmwgfx_top=external/bsd/drm2/dist/drm/vmwgfx
15 1.1 riastrad
16 1.1 riastrad # config(5) flag for the vmwgfx driver.
17 1.1 riastrad vmwgfx_flag=vmwgfx
18 1.1 riastrad
19 1.1 riastrad env CONFIG_ACPI=y \
20 1.1 riastrad env src=. \
21 1.1 riastrad make -f Makefile -V '$(vmwgfx-y)' \
22 1.1 riastrad | tr ' ' '\n' \
23 1.1 riastrad | grep -v -e '^[[:space:]]*$' \
24 1.1 riastrad | sed -e 's,\.o$,.c,' \
25 1.1 riastrad | sort -u \
26 1.1 riastrad | awk '
27 1.1 riastrad BEGIN {
28 1.1 riastrad duplicates = 0
29 1.1 riastrad }
30 1.1 riastrad {
31 1.1 riastrad if (index($1, "/")) {
32 1.1 riastrad dir = $1
33 1.1 riastrad sub("/[^/]*$", "/", dir)
34 1.1 riastrad base = $1
35 1.1 riastrad sub("^.*/", "", base)
36 1.1 riastrad } else {
37 1.1 riastrad dir = ""
38 1.1 riastrad base = $1
39 1.1 riastrad }
40 1.1 riastrad fqbase = (base ~ "^vmwgfx_" ? "" : "vmwgfx_") base
41 1.1 riastrad if (seen[fqbase]) {
42 1.1 riastrad printf("Duplicate basename: %s %s\n", fqbase,
43 1.1 riastrad seen[fqbase]) >"/dev/stderr"
44 1.1 riastrad duplicates = 1
45 1.1 riastrad }
46 1.1 riastrad if (duplicates)
47 1.1 riastrad next
48 1.1 riastrad printf("%s %s\n", $1, dir fqbase)
49 1.1 riastrad }
50 1.1 riastrad END {
51 1.1 riastrad if (duplicates) {
52 1.1 riastrad printf("Time to rewite me!\n") > "/dev/stderr"
53 1.1 riastrad exit 1
54 1.1 riastrad }
55 1.1 riastrad }
56 1.1 riastrad ' \
57 1.1 riastrad | while read from to; do
58 1.1 riastrad # If the move already happened, that's fine: the makefile
59 1.1 riastrad # detects duplicates.
60 1.1 riastrad if [ "x$from" != "x$to" -a \! -f "$to" ]; then
61 1.1 riastrad ${MV} -f -- "$from" "$to"
62 1.1 riastrad fi
63 1.1 riastrad printf 'file\t%s\t%s\n' "$vmwgfx_top/$to" "$vmwgfx_flag"
64 1.1 riastrad done \
65 1.1 riastrad | sort -u
66