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