xref: /netbsd-src/sys/external/bsd/drm2/radeon/radeon2netbsd (revision 53d1339bf7f9c7367b35a9e1ebe693f9b047a47b)
1#!/bin/sh
2
3#	$NetBSD: radeon2netbsd,v 1.2 2018/08/27 14:38:20 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 src=. \
21make -f Makefile -V '$(radeon-y)' \
22| tr ' ' '\n' \
23| grep -v '^$' \
24| sed -e 's,\.o$,.c,' \
25| sort -u \
26| awk '
27	BEGIN {
28		duplicates = 0
29	}
30	{
31		if (index($1, "/")) {
32			dir = $1
33			sub("/[^/]*$", "/", dir)
34			base = $1
35			sub("^.*/", "", base)
36		} else {
37			dir = ""
38			base = $1
39		}
40		fqbase = (base ~ "^radeon_" ? "" : "radeon_") base
41		if (seen[fqbase]) {
42			printf("Duplicate basename: %s %s\n", fqbase,
43			    seen[fqbase]) >"/dev/stderr"
44			duplicates = 1
45		}
46		if (duplicates)
47			next
48		printf("%s %s\n", $1, dir fqbase)
49	}
50	END {
51		if (duplicates) {
52			printf("Time to rewite me!\n") > "/dev/stderr"
53			exit 1
54		}
55	}
56' \
57| while read from to; do
58	# If the move already happened, that's fine: the makefile
59	# detects duplicates.
60	if [ "x$from" != "x$to" -a \! -f "$to" ]; then
61		${MV} -f -- "$from" "$to"
62	fi
63	printf 'file\t%s\t%s\n' "$radeon_top/$to" "$radeon_flag"
64done \
65| sort -u
66