#!/bin/sh # $NetBSD: radeon2netbsd,v 1.3 2021/12/19 00:25:26 riastradh Exp $ # # $ /path/to/radeon2netbsd > /path/to/files.radeon.new # # Run from the top-level Radeon source directory. set -Ceu : ${MV:=mv} # Location of the Radeon sources relative to $NETBSDSRCDIR. radeon_top=external/bsd/drm2/dist/drm/radeon # config(5) flag for the Radeon driver. radeon_flag=radeon env CONFIG_ACPI=y \ env src=. \ make -f Makefile -V '$(radeon-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 ~ "^radeon_" ? "" : "radeon_") 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' "$radeon_top/$to" "$radeon_flag" done \ | sort -u |