| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #!/bin/sh | | 1 | #!/bin/sh |
2 | | | 2 | |
3 | # $NetBSD: nouveau2netbsd,v 1.3 2018/08/27 00:46:04 riastradh Exp $ | | 3 | # $NetBSD: nouveau2netbsd,v 1.4 2018/08/27 00:46:10 riastradh Exp $ |
4 | # | | 4 | # |
5 | # $ /path/to/nouveau2netbsd > /path/to/files.nouveau.new | | 5 | # $ /path/to/nouveau2netbsd > /path/to/files.nouveau.new |
6 | # | | 6 | # |
7 | # Run from the top-level Nouveau source directory. This stupid kludge | | 7 | # Run from the top-level Nouveau source directory. This stupid kludge |
8 | # reinterprets the GNU makefile as a BSD makefile to extract the source | | 8 | # reinterprets the GNU makefile as a BSD makefile to extract the source |
9 | # file names, renames the ones that have obscure and/or colliding | | 9 | # file names, renames the ones that have obscure and/or colliding |
10 | # basenames to be less obscure and unlikely (though not guaranteed) to | | 10 | # basenames to be less obscure and unlikely (though not guaranteed) to |
11 | # collide, and spits out config(5) directives for all of them. | | 11 | # collide, and spits out config(5) directives for all of them. |
12 | | | 12 | |
13 | set -Ceu | | 13 | set -Ceu |
14 | | | 14 | |
15 | : ${MV:=mv} | | 15 | : ${MV:=mv} |
16 | | | 16 | |
| @@ -20,31 +20,31 @@ nouveau_top=external/bsd/drm2/dist/drm/n | | | @@ -20,31 +20,31 @@ nouveau_top=external/bsd/drm2/dist/drm/n |
20 | # config(5) flag for the Nouveau driver. | | 20 | # config(5) flag for the Nouveau driver. |
21 | nouveau_flag=nouveau | | 21 | nouveau_flag=nouveau |
22 | | | 22 | |
23 | filemap= | | 23 | filemap= |
24 | | | 24 | |
25 | clean () | | 25 | clean () |
26 | { | | 26 | { |
27 | [ -z "$filemap" ] || rm -f -- "$filemap" || : | | 27 | [ -z "$filemap" ] || rm -f -- "$filemap" || : |
28 | } | | 28 | } |
29 | trap clean EXIT HUP INT TERM | | 29 | trap clean EXIT HUP INT TERM |
30 | | | 30 | |
31 | filemap="$(mktemp -t ${0##*/})" | | 31 | filemap="$(mktemp -t ${0##*/})" |
32 | | | 32 | |
33 | cat Makefile \ | | 33 | cat Kbuild \ |
34 | | sed -e 's,^include \(.*\)$,.include "\1",' \ | | 34 | | sed -e 's,^include \(.*\)$,.include "\1",' \ |
35 | | sed -e 's,^ifdef \(.*\)$,.if !empty(\1:M[yY][eE][sS]),' \ | | 35 | | sed -e 's,^ifdef \(.*\)$,.if !empty(\1:M[yY][eE][sS]),' \ |
36 | | sed -e 's,^endif$,.endif,' \ | | 36 | | sed -e 's,^endif$,.endif,' \ |
37 | | make -f /dev/stdin -V nouveau-y src=. \ | | 37 | | make -f /dev/stdin -V '$(nouveau-y)' src=. \ |
38 | | tr ' ' '\n' \ | | 38 | | tr ' ' '\n' \ |
39 | | sed -e 's,^$,,' \ | | 39 | | sed -e 's,^$,,' \ |
40 | | sort -u \ | | 40 | | sort -u \ |
41 | | sed -e 's,\.o$,.c,' \ | | 41 | | sed -e 's,\.o$,.c,' \ |
42 | | awk ' | | 42 | | awk ' |
43 | BEGIN { | | 43 | BEGIN { |
44 | duplicates = 0 | | 44 | duplicates = 0 |
45 | } | | 45 | } |
46 | $1 ~ "nouveau_[^/]*$" { | | 46 | $1 ~ "nouveau_[^/]*$" { |
47 | if (seen[$1]) | | 47 | if (seen[$1]) |
48 | printf("Duplicate basename: %s\n", $1) | | 48 | printf("Duplicate basename: %s\n", $1) |
49 | seen[$1] = $1 | | 49 | seen[$1] = $1 |
50 | printf("%s %s\n", $1, $1) | | 50 | printf("%s %s\n", $1, $1) |