#!/bin/sh # $NetBSD: amdgpu2netbsd,v 1.4 2021/12/19 10:20:31 riastradh Exp $ # # $ /path/to/amdgpu2netbsd > /path/to/files.amdgpu.new # # Run from the top-level dist/amd/amdgpu source directory, ideally # before import. set -Ceu : ${GMAKE:=gmake} : ${MV:=mv} # Location of amdgpu sources relative to $NETBSDSOURCEDIR. amdgpu_top=external/bsd/drm2/dist/drm/amd/amdgpu # config(5) flag for the amdgpu driver. amdgpu_flag=amdgpu { printf 'show-amdgpu-y:\n' printf '\t@echo $(amdgpu-y)\n' printf 'include Makefile\n' } | env \ env CONFIG_ACPI=y \ env CONFIG_DRM_AMDGPU=y \ env CONFIG_DRM_AMDGPU_CIK=y \ env CONFIG_DRM_AMDGPU_SI=y \ env CONFIG_DRM_AMD_ACP=y \ env CONFIG_DRM_AMD_DC=y \ env CONFIG_DRM_AMD_DC_DCN=y \ env CONFIG_DRM_AMD_DC_HDCP=y \ env srctree="`pwd`" \ env src=. \ ${GMAKE} -f - -s show-amdgpu-y \ | tr ' ' '\n' \ | grep -v '^$' \ | 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 ~ "^amdgpu_" ? "" : "amdgpu_") 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' "$amdgpu_top/$to" "$amdgpu_flag" done \ | sort -u