Mon Aug 27 00:46:10 2018 UTC ()
Makefile got moved to Kbuild.  Make sure variables expand.


(riastradh)
diff -r1.3 -r1.4 src/sys/external/bsd/drm2/nouveau/nouveau2netbsd

cvs diff -r1.3 -r1.4 src/sys/external/bsd/drm2/nouveau/nouveau2netbsd (switch to unified diff)

--- src/sys/external/bsd/drm2/nouveau/nouveau2netbsd 2018/08/27 00:46:04 1.3
+++ src/sys/external/bsd/drm2/nouveau/nouveau2netbsd 2018/08/27 00:46:10 1.4
@@ -1,119 +1,119 @@ @@ -1,119 +1,119 @@
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
13set -Ceu 13set -Ceu
14 14
15: ${MV:=mv} 15: ${MV:=mv}
16 16
17# Location of the Nouveau sources relative to $NETBSDSRCDIR. 17# Location of the Nouveau sources relative to $NETBSDSRCDIR.
18nouveau_top=external/bsd/drm2/dist/drm/nouveau 18nouveau_top=external/bsd/drm2/dist/drm/nouveau
19 19
20# config(5) flag for the Nouveau driver. 20# config(5) flag for the Nouveau driver.
21nouveau_flag=nouveau 21nouveau_flag=nouveau
22 22
23filemap= 23filemap=
24 24
25clean () 25clean ()
26{ 26{
27 [ -z "$filemap" ] || rm -f -- "$filemap" || : 27 [ -z "$filemap" ] || rm -f -- "$filemap" || :
28} 28}
29trap clean EXIT HUP INT TERM 29trap clean EXIT HUP INT TERM
30 30
31filemap="$(mktemp -t ${0##*/})" 31filemap="$(mktemp -t ${0##*/})"
32 32
33cat Makefile \ 33cat 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)
51 next 51 next
52 } 52 }
53 { 53 {
54 if (index($1, "/")) { 54 if (index($1, "/")) {
55 dir = $1 55 dir = $1
56 sub("/[^/]*$", "/", dir) 56 sub("/[^/]*$", "/", dir)
57 } else { 57 } else {
58 dir = "" 58 dir = ""
59 } 59 }
60 base = $1 60 base = $1
61 sub("^core/", "", base) 61 sub("^core/", "", base)
62 gsub("/", "_", base) 62 gsub("/", "_", base)
63 if (seen[base]) { 63 if (seen[base]) {
64 printf("Duplicate basename: %s %s\n", seen[base], $1) \ 64 printf("Duplicate basename: %s %s\n", seen[base], $1) \
65 > "/dev/stderr" 65 > "/dev/stderr"
66 duplicates = 1 66 duplicates = 1
67 } 67 }
68 if (duplicates) 68 if (duplicates)
69 next 69 next
70 seen[base] = $1 70 seen[base] = $1
71 printf("%s %s\n", $1, dir "nouveau_" base) 71 printf("%s %s\n", $1, dir "nouveau_" base)
72 } 72 }
73 END { 73 END {
74 if (duplicates) { 74 if (duplicates) {
75 printf("Time to rewite me!\n") > "/dev/stderr" 75 printf("Time to rewite me!\n") > "/dev/stderr"
76 exit 1 76 exit 1
77 } 77 }
78 } 78 }
79' >> "$filemap" 79' >> "$filemap"
80 80
81while read from to; do 81while read from to; do
82 if [ "x$from" != "x$to" ]; then 82 if [ "x$from" != "x$to" ]; then
83 ${MV} -f -- "$from" "$to" 83 ${MV} -f -- "$from" "$to"
84 fi 84 fi
85 # Probably not necessary -- Linux tends not to have RCS ids -- 85 # Probably not necessary -- Linux tends not to have RCS ids --
86 # but a precaution out of paranoia. 86 # but a precaution out of paranoia.
87 cleantags "$to" 87 cleantags "$to"
88 case $to in 88 case $to in
89 *.c) 89 *.c)
90 # Heuristically apply NetBSD RCS ids: a comment at the 90 # Heuristically apply NetBSD RCS ids: a comment at the
91 # top of the file, and a __KERNEL_RCSID before the 91 # top of the file, and a __KERNEL_RCSID before the
92 # first cpp line, which, with any luck, should be the 92 # first cpp line, which, with any luck, should be the
93 # first non-comment line and lie between the copyright 93 # first non-comment line and lie between the copyright
94 # notice and the header. 94 # notice and the header.
95 awk ' 95 awk '
96 BEGIN { 96 BEGIN {
97 done = 0 97 done = 0
98 printf("/*\t%c%s%c\t*/\n\n", "$","NetBSD","$") 98 printf("/*\t%c%s%c\t*/\n\n", "$","NetBSD","$")
99 } 99 }
100 /^#/ && !done { 100 /^#/ && !done {
101 printf("#include <sys/cdefs.h>\n") 101 printf("#include <sys/cdefs.h>\n")
102 printf("__KERNEL_RCSID(0, \"%c%s%c\");\n", 102 printf("__KERNEL_RCSID(0, \"%c%s%c\");\n",
103 "$","NetBSD","$") 103 "$","NetBSD","$")
104 printf("\n") 104 printf("\n")
105 done = 1 105 done = 1
106 } 106 }
107 { 107 {
108 print 108 print
109 } 109 }
110 ' < "$to" > "$to".tmp 110 ' < "$to" > "$to".tmp
111 ;; 111 ;;
112 esac 112 esac
113 mv -f -- "$to".tmp "$to" 113 mv -f -- "$to".tmp "$to"
114 printf 'file\t%s\t%s\n' "$nouveau_top/$to" "$nouveau_flag" 114 printf 'file\t%s\t%s\n' "$nouveau_top/$to" "$nouveau_flag"
115done < "$filemap" | sort 115done < "$filemap" | sort
116 116
117# We sort the output again at the end because we renamed some files but 117# We sort the output again at the end because we renamed some files but
118# left $TOP/nouveau_* unchanged, so their sort order relative to the 118# left $TOP/nouveau_* unchanged, so their sort order relative to the
119# ones that got renamed may have changed. 119# ones that got renamed may have changed.