#!/bin/sh # $NetBSD: vmwgfx2netbsd,v 1.1 2022/02/17 01:21:03 riastradh Exp $ # # $ /path/to/vmwgfx2netbsd > /path/to/files.vmwgfx.new # # Run from the top-level vmwgfx source directory. set -Ceu : ${MV:=mv} # Location of the vmwgfx sources relative to $NETBSDSRCDIR. vmwgfx_top=external/bsd/drm2/dist/drm/vmwgfx # config(5) flag for the vmwgfx driver. vmwgfx_flag=vmwgfx env CONFIG_ACPI=y \ env src=. \ make -f Makefile -V '$(vmwgfx-y)' \ | tr ' ' '\n' \ | grep -v -e '^[[:space:]]*$' \ | sed -e 's,\.o$,.c,' \ | sort -u \ | awk ' BEGIN { duplicates = 0 } { if (index($1, "/")) { dir = $1 sub("/[^/]*$", "/", dir) base = $1 sub("^.*/", "", base) } else { dir = "" base = $1 } fqbase = (base ~ "^vmwgfx_" ? "" : "vmwgfx_") base if (seen[fqbase]) { printf("Duplicate basename: %s %s\n", fqbase, seen[fqbase]) >"/dev/stderr" duplicates = 1 } if (duplicates) next printf("%s %s\n", $1, dir fqbase) } END { if (duplicates) { printf("Time to rewite me!\n") > "/dev/stderr" exit 1 } } ' \ | while read from to; do # If the move already happened, that's fine: the makefile # detects duplicates. if [ "x$from" != "x$to" -a \! -f "$to" ]; then ${MV} -f -- "$from" "$to" fi printf 'file\t%s\t%s\n' "$vmwgfx_top/$to" "$vmwgfx_flag" done \ | sort -u