Home | History | Annotate | Line # | Download | only in amdgpu
amdgpu2netbsd revision 1.3.6.2
      1  1.3.6.2  christos #!/bin/sh
      2  1.3.6.2  christos 
      3  1.3.6.2  christos #	$NetBSD: amdgpu2netbsd,v 1.3.6.2 2019/06/10 22:07:56 christos Exp $
      4  1.3.6.2  christos #
      5  1.3.6.2  christos # $ /path/to/amdgpu2netbsd > /path/to/files.amdgpu.new
      6  1.3.6.2  christos #
      7  1.3.6.2  christos # Run from the top-level dist/amd/amdgpu source directory, ideally
      8  1.3.6.2  christos # before import.
      9  1.3.6.2  christos 
     10  1.3.6.2  christos set -Ceu
     11  1.3.6.2  christos 
     12  1.3.6.2  christos : ${MV:=mv}
     13  1.3.6.2  christos 
     14  1.3.6.2  christos # Location of amdgpu sources relative to $NETBSDSOURCEDIR.
     15  1.3.6.2  christos amdgpu_top=external/bsd/drm2/dist/drm/amd/amdgpu
     16  1.3.6.2  christos 
     17  1.3.6.2  christos # config(5) flag for the amdgpu driver.
     18  1.3.6.2  christos amdgpu_flag=amdgpu
     19  1.3.6.2  christos 
     20  1.3.6.2  christos env CONFIG_ACPI=y \
     21  1.3.6.2  christos env CONFIG_DRM_AMDGPU_CIK=y \
     22  1.3.6.2  christos env src=. \
     23  1.3.6.2  christos make -f Makefile -V '$(amdgpu-y)' \
     24  1.3.6.2  christos | tr ' ' '\n' \
     25  1.3.6.2  christos | grep -v '^$' \
     26  1.3.6.2  christos | sed -e 's,\.o$,.c,' \
     27  1.3.6.2  christos | sort -u \
     28  1.3.6.2  christos | awk '
     29  1.3.6.2  christos 	BEGIN {
     30  1.3.6.2  christos 		duplicates = 0
     31  1.3.6.2  christos 	}
     32  1.3.6.2  christos 	{
     33  1.3.6.2  christos 		if (index($1, "/")) {
     34  1.3.6.2  christos 			dir = $1
     35  1.3.6.2  christos 			sub("/[^/]*$", "/", dir)
     36  1.3.6.2  christos 			base = $1
     37  1.3.6.2  christos 			sub("^.*/", "", base)
     38  1.3.6.2  christos 		} else {
     39  1.3.6.2  christos 			dir = ""
     40  1.3.6.2  christos 			base = $1
     41  1.3.6.2  christos 		}
     42  1.3.6.2  christos 		fqbase = (base ~ "^amdgpu_" ? "" : "amdgpu_") base
     43  1.3.6.2  christos 		if (seen[fqbase]) {
     44  1.3.6.2  christos 			printf("Duplicate basename: %s %s\n", fqbase,
     45  1.3.6.2  christos 			    seen[fqbase]) >"/dev/stderr"
     46  1.3.6.2  christos 			duplicates = 1
     47  1.3.6.2  christos 		}
     48  1.3.6.2  christos 		if (duplicates)
     49  1.3.6.2  christos 			next
     50  1.3.6.2  christos 		printf("%s %s\n", $1, dir fqbase)
     51  1.3.6.2  christos 	}
     52  1.3.6.2  christos 	END {
     53  1.3.6.2  christos 		if (duplicates) {
     54  1.3.6.2  christos 			printf("Time to rewite me!\n") > "/dev/stderr"
     55  1.3.6.2  christos 			exit 1
     56  1.3.6.2  christos 		}
     57  1.3.6.2  christos 	}
     58  1.3.6.2  christos ' \
     59  1.3.6.2  christos | while read from to; do
     60  1.3.6.2  christos 	# If the move already happened, that's fine: the makefile
     61  1.3.6.2  christos 	# detects duplicates.
     62  1.3.6.2  christos 	if [ "x$from" != "x$to" -a \! -f "$to" ]; then
     63  1.3.6.2  christos 		${MV} -f -- "$from" "$to"
     64  1.3.6.2  christos 	fi
     65  1.3.6.2  christos 	printf 'file\t%s\t%s\n' "$amdgpu_top/$to" "$amdgpu_flag"
     66  1.3.6.2  christos done \
     67  1.3.6.2  christos | sort -u
     68