Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

#!/bin/sh

#	$NetBSD: amdgpu2netbsd,v 1.3 2018/08/27 14:22:47 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

: ${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

env CONFIG_ACPI=y \
env CONFIG_DRM_AMDGPU_CIK=y \
env src=. \
make -f Makefile -V '$(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