Home | History | Annotate | Line # | Download | only in radeon
      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 
      9 set -Ceu
     10 
     11 : ${MV:=mv}
     12 
     13 # Location of the Radeon sources relative to $NETBSDSRCDIR.
     14 radeon_top=external/bsd/drm2/dist/drm/radeon
     15 
     16 # config(5) flag for the Radeon driver.
     17 radeon_flag=radeon
     18 
     19 env CONFIG_ACPI=y \
     20 env CONFIG_DRM_FBDEV_EMULATION=y \
     21 env CONFIG_DRM_RADEON=y \
     22 env CONFIG_MMU_NOTIFIER=y \
     23 env CONFIG_VGA_SWITCHEROO=y \
     24 env src=. \
     25 make -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"
     68 done \
     69 | sort -u
     70