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