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