amdgpu2netbsd revision 1.2
11.1Sriastrad#!/bin/sh 21.1Sriastrad 31.1Sriastrad# $NetBSD: amdgpu2netbsd,v 1.2 2018/08/27 14:10:42 riastradh Exp $ 41.1Sriastrad# 51.1Sriastrad# $ /path/to/amdgpu2netbsd > /path/to/files.amdgpu.new 61.1Sriastrad# 71.2Sriastrad# Run from the top-level dist/amd/amdgpu source directory, ideally 81.2Sriastrad# before import. 91.1Sriastrad 101.1Sriastradset -Ceu 111.1Sriastrad 121.2Sriastrad: ${MV:=mv} 131.2Sriastrad 141.2Sriastrad# Location of amdgpu sources relative to $NETBSDSOURCEDIR. 151.1Sriastradamdgpu_top=external/bsd/drm2/dist/drm/amd/amdgpu 161.1Sriastrad 171.1Sriastrad# config(5) flag for the amdgpu driver. 181.1Sriastradamdgpu_flag=amdgpu 191.1Sriastrad 201.1Sriastradenv CONFIG_ACPI=y \ 211.1Sriastradenv src=. \ 221.1Sriastradmake -f Makefile -V '$(amdgpu-y)' \ 231.1Sriastrad| tr ' ' '\n' \ 241.1Sriastrad| grep -v '^$' \ 251.1Sriastrad| sed -e 's,\.o$,.c,' \ 261.1Sriastrad| sort -u \ 271.2Sriastrad| awk ' 281.2Sriastrad BEGIN { 291.2Sriastrad duplicates = 0 301.2Sriastrad } 311.2Sriastrad { 321.2Sriastrad if (index($1, "/")) { 331.2Sriastrad dir = $1 341.2Sriastrad sub("/[^/]*$", "/", dir) 351.2Sriastrad base = $1 361.2Sriastrad sub("^.*/", "", base) 371.2Sriastrad } else { 381.2Sriastrad dir = "" 391.2Sriastrad base = $1 401.2Sriastrad } 411.2Sriastrad fqbase = (base ~ "^amdgpu_" ? "" : "amdgpu_") base 421.2Sriastrad if (seen[fqbase]) { 431.2Sriastrad printf("Duplicate basename: %s %s\n", fqbase, 441.2Sriastrad seen[fqbase]) >"/dev/stderr" 451.2Sriastrad duplicates = 1 461.2Sriastrad } 471.2Sriastrad if (duplicates) 481.2Sriastrad next 491.2Sriastrad printf("%s %s\n", $1, dir fqbase) 501.2Sriastrad } 511.2Sriastrad END { 521.2Sriastrad if (duplicates) { 531.2Sriastrad printf("Time to rewite me!\n") > "/dev/stderr" 541.2Sriastrad exit 1 551.2Sriastrad } 561.2Sriastrad } 571.2Sriastrad' \ 581.2Sriastrad| while read from to; do 591.2Sriastrad if [ "x$from" != "x$to" ]; then 601.2Sriastrad ${MV} -f -- "$from" "$to" 611.2Sriastrad fi 621.2Sriastrad printf 'file\t%s\t%s\n' "$amdgpu_top/$to" "$amdgpu_flag" 631.2Sriastraddone \ 641.2Sriastrad| sort -u 65