amdgpu2netbsd revision 1.3
11.1Sriastrad#!/bin/sh 21.1Sriastrad 31.1Sriastrad# $NetBSD: amdgpu2netbsd,v 1.3 2018/08/27 14:22:47 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.3Sriastradenv CONFIG_DRM_AMDGPU_CIK=y \ 221.1Sriastradenv src=. \ 231.1Sriastradmake -f Makefile -V '$(amdgpu-y)' \ 241.1Sriastrad| tr ' ' '\n' \ 251.1Sriastrad| grep -v '^$' \ 261.1Sriastrad| sed -e 's,\.o$,.c,' \ 271.1Sriastrad| sort -u \ 281.2Sriastrad| awk ' 291.2Sriastrad BEGIN { 301.2Sriastrad duplicates = 0 311.2Sriastrad } 321.2Sriastrad { 331.2Sriastrad if (index($1, "/")) { 341.2Sriastrad dir = $1 351.2Sriastrad sub("/[^/]*$", "/", dir) 361.2Sriastrad base = $1 371.2Sriastrad sub("^.*/", "", base) 381.2Sriastrad } else { 391.2Sriastrad dir = "" 401.2Sriastrad base = $1 411.2Sriastrad } 421.2Sriastrad fqbase = (base ~ "^amdgpu_" ? "" : "amdgpu_") base 431.2Sriastrad if (seen[fqbase]) { 441.2Sriastrad printf("Duplicate basename: %s %s\n", fqbase, 451.2Sriastrad seen[fqbase]) >"/dev/stderr" 461.2Sriastrad duplicates = 1 471.2Sriastrad } 481.2Sriastrad if (duplicates) 491.2Sriastrad next 501.2Sriastrad printf("%s %s\n", $1, dir fqbase) 511.2Sriastrad } 521.2Sriastrad END { 531.2Sriastrad if (duplicates) { 541.2Sriastrad printf("Time to rewite me!\n") > "/dev/stderr" 551.2Sriastrad exit 1 561.2Sriastrad } 571.2Sriastrad } 581.2Sriastrad' \ 591.2Sriastrad| while read from to; do 601.3Sriastrad # If the move already happened, that's fine: the makefile 611.3Sriastrad # detects duplicates. 621.3Sriastrad if [ "x$from" != "x$to" -a \! -f "$to" ]; then 631.2Sriastrad ${MV} -f -- "$from" "$to" 641.2Sriastrad fi 651.2Sriastrad printf 'file\t%s\t%s\n' "$amdgpu_top/$to" "$amdgpu_flag" 661.2Sriastraddone \ 671.2Sriastrad| sort -u 68