radeon2netbsd revision 1.3
11.1Sriastrad#!/bin/sh 21.1Sriastrad 31.3Sriastrad# $NetBSD: radeon2netbsd,v 1.3 2021/12/19 00:25:26 riastradh Exp $ 41.1Sriastrad# 51.1Sriastrad# $ /path/to/radeon2netbsd > /path/to/files.radeon.new 61.1Sriastrad# 71.1Sriastrad# Run from the top-level Radeon source directory. 81.1Sriastrad 91.1Sriastradset -Ceu 101.1Sriastrad 111.2Sriastrad: ${MV:=mv} 121.2Sriastrad 131.1Sriastrad# Location of the Radeon sources relative to $NETBSDSRCDIR. 141.1Sriastradradeon_top=external/bsd/drm2/dist/drm/radeon 151.1Sriastrad 161.1Sriastrad# config(5) flag for the Radeon driver. 171.1Sriastradradeon_flag=radeon 181.1Sriastrad 191.1Sriastradenv CONFIG_ACPI=y \ 201.1Sriastradenv src=. \ 211.1Sriastradmake -f Makefile -V '$(radeon-y)' \ 221.1Sriastrad| tr ' ' '\n' \ 231.3Sriastrad| grep -v -e '^[[:space:]]*$' \ 241.1Sriastrad| sed -e 's,\.o$,.c,' \ 251.1Sriastrad| sort -u \ 261.2Sriastrad| awk ' 271.2Sriastrad BEGIN { 281.2Sriastrad duplicates = 0 291.2Sriastrad } 301.2Sriastrad { 311.2Sriastrad if (index($1, "/")) { 321.2Sriastrad dir = $1 331.2Sriastrad sub("/[^/]*$", "/", dir) 341.2Sriastrad base = $1 351.2Sriastrad sub("^.*/", "", base) 361.2Sriastrad } else { 371.2Sriastrad dir = "" 381.2Sriastrad base = $1 391.2Sriastrad } 401.2Sriastrad fqbase = (base ~ "^radeon_" ? "" : "radeon_") base 411.2Sriastrad if (seen[fqbase]) { 421.2Sriastrad printf("Duplicate basename: %s %s\n", fqbase, 431.2Sriastrad seen[fqbase]) >"/dev/stderr" 441.2Sriastrad duplicates = 1 451.2Sriastrad } 461.2Sriastrad if (duplicates) 471.2Sriastrad next 481.2Sriastrad printf("%s %s\n", $1, dir fqbase) 491.2Sriastrad } 501.2Sriastrad END { 511.2Sriastrad if (duplicates) { 521.2Sriastrad printf("Time to rewite me!\n") > "/dev/stderr" 531.2Sriastrad exit 1 541.2Sriastrad } 551.2Sriastrad } 561.2Sriastrad' \ 571.2Sriastrad| while read from to; do 581.2Sriastrad # If the move already happened, that's fine: the makefile 591.2Sriastrad # detects duplicates. 601.2Sriastrad if [ "x$from" != "x$to" -a \! -f "$to" ]; then 611.2Sriastrad ${MV} -f -- "$from" "$to" 621.2Sriastrad fi 631.2Sriastrad printf 'file\t%s\t%s\n' "$radeon_top/$to" "$radeon_flag" 641.2Sriastraddone \ 651.2Sriastrad| sort -u 66