1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#!/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
|