2 # Copyright 2009 The Go Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
6 # This script runs or (given -n) prints suggested commands to generate files for
7 # the Architecture/OS specified by the GOARCH and GOOS environment variables.
8 # See README.md for more information about how the build system works.
10 GOOSARCH
="${GOOS}_${GOARCH}"
13 mksyscall
="go run mksyscall.go"
14 mkerrors
="./mkerrors.sh"
15 zerrors
="zerrors_$GOOSARCH.go"
17 zsysctl
="zsysctl_$GOOSARCH.go"
28 # Run the command line that appears in the first line
29 # of the generated file to regenerate it.
30 sed 1q
$i | sed 's;^// ;;' | sh
> _
$i && gofmt
< _
$i > $i
45 echo 'usage: mkall.sh [-n]' 1>&2
49 if [[ "$GOOS" = "linux" ]]; then
50 # Use the Docker-based build system
51 # Files generated through docker (use $cmd so you can Ctl-C the build or run)
52 $cmd docker build
--tag generate
:$GOOS $GOOS
53 $cmd docker run
--interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
57 GOOSARCH_in=syscall_$GOOSARCH.go
60 echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
64 mkerrors="$mkerrors -maix32"
65 mksyscall="go run mksyscall_aix_ppc.go
-aix"
66 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
69 mkerrors="$mkerrors -maix64"
70 mksyscall="go run mksyscall_aix_ppc64.go
-aix"
71 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
74 mkerrors="$mkerrors -m32"
75 mksyscall="go run mksyscall.go
-l32"
76 mksysnum="go run mksysnum.go
$(xcrun --show-sdk-path --sdk macosx)/usr
/include
/sys
/syscall.h
"
77 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
78 mkasm="go run mkasm_darwin.go
"
81 mkerrors="$mkerrors -m64"
82 mksysnum="go run mksysnum.go
$(xcrun --show-sdk-path --sdk macosx)/usr
/include
/sys
/syscall.h
"
83 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
84 mkasm="go run mkasm_darwin.go
"
88 mksyscall="go run mksyscall.go
-l32"
89 mksysnum="go run mksysnum.go
$(xcrun --show-sdk-path --sdk iphoneos)/usr
/include
/sys
/syscall.h
"
90 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
91 mkasm="go run mkasm_darwin.go
"
94 mkerrors="$mkerrors -m64"
95 mksysnum="go run mksysnum.go
$(xcrun --show-sdk-path --sdk iphoneos)/usr
/include
/sys
/syscall.h
"
96 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
97 mkasm="go run mkasm_darwin.go
"
100 mkerrors="$mkerrors -m64"
101 mksyscall="go run mksyscall.go
-dragonfly"
102 mksysnum="go run mksysnum.go
'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'"
103 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
106 mkerrors="$mkerrors -m32"
107 mksyscall="go run mksyscall.go
-l32"
108 mksysnum="go run mksysnum.go
'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
109 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
112 mkerrors="$mkerrors -m64"
113 mksysnum="go run mksysnum.go
'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
114 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
118 mksyscall="go run mksyscall.go
-l32 -arm"
119 mksysnum="go run mksysnum.go
'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
120 # Let the type of C char be signed for making the bare syscall
121 # API consistent across platforms.
122 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs -- -fsigned-char"
125 mkerrors="$mkerrors -m64"
126 mksysnum="go run mksysnum.go
'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
127 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
130 mkerrors="$mkerrors -m32"
131 mksyscall="go run mksyscall.go
-l32 -netbsd"
132 mksysnum="go run mksysnum.go
'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
133 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
136 mkerrors="$mkerrors -m64"
137 mksyscall="go run mksyscall.go
-netbsd"
138 mksysnum="go run mksysnum.go
'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
139 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
143 mksyscall="go run mksyscall.go
-l32 -netbsd -arm"
144 mksysnum="go run mksysnum.go
'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
145 # Let the type of C char be signed for making the bare syscall
146 # API consistent across platforms.
147 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs -- -fsigned-char"
150 mkerrors="$mkerrors -m64"
151 mksyscall="go run mksyscall.go
-netbsd"
152 mksysnum="go run mksysnum.go
'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
153 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
156 mkerrors="$mkerrors -m32"
157 mksyscall="go run mksyscall.go
-l32 -openbsd"
158 mksysctl="go run mksysctl_openbsd.go
"
159 mksysnum="go run mksysnum.go
'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
160 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
163 mkerrors="$mkerrors -m64"
164 mksyscall="go run mksyscall.go
-openbsd"
165 mksysctl="go run mksysctl_openbsd.go
"
166 mksysnum="go run mksysnum.go
'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
167 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
171 mksyscall="go run mksyscall.go
-l32 -openbsd -arm"
172 mksysctl="go run mksysctl_openbsd.go
"
173 mksysnum="go run mksysnum.go
'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
174 # Let the type of C char be signed for making the bare syscall
175 # API consistent across platforms.
176 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs -- -fsigned-char"
179 mkerrors="$mkerrors -m64"
180 mksyscall="go run mksyscall.go
-openbsd"
181 mksysctl="go run mksysctl_openbsd.go
"
182 mksysnum="go run mksysnum.go
'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
183 # Let the type of C char be signed for making the bare syscall
184 # API consistent across platforms.
185 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs -- -fsigned-char"
188 mksyscall="go run mksyscall_solaris.go
"
189 mkerrors="$mkerrors -m64"
191 mktypes="GOARCH
=$GOARCH go tool cgo
-godefs"
194 echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
200 if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt
>$zerrors"; fi
203 syscall_goos="syscall_
$GOOS.go
"
205 darwin | dragonfly | freebsd | netbsd | openbsd)
206 syscall_goos="syscall_bsd.go
$syscall_goos"
209 if [ -n "$mksyscall" ]; then
210 if [ "$GOOSARCH" == "aix_ppc64
" ]; then
211 # aix/ppc64 script generates files instead of writing to stdin.
212 echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt
-w zsyscall_
$GOOSARCH.go
&& gofmt
-w zsyscall_
"$GOOSARCH"_gccgo.go
&& gofmt
-w zsyscall_
"$GOOSARCH"_gc.go
" ;
213 elif [ "$GOOS" == "darwin
" ]; then
214 # pre-1.12, direct syscalls
215 echo "$mksyscall -tags $GOOS,$GOARCH,!go1.12
$syscall_goos $GOOSARCH_in |gofmt
>zsyscall_
$GOOSARCH.1_11.go
";
216 # 1.12 and later, syscalls via libSystem
217 echo "$mksyscall -tags $GOOS,$GOARCH,go1.12
$syscall_goos $GOOSARCH_in |gofmt
>zsyscall_
$GOOSARCH.go
";
219 echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt
>zsyscall_
$GOOSARCH.go
";
223 if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt
>$zsysctl"; fi
224 if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt
>zsysnum_
$GOOSARCH.go
"; fi
225 if [ -n "$mktypes" ]; then echo "$mktypes types_
$GOOS.go
| go run mkpost.go
> ztypes_
$GOOSARCH.go
"; fi
226 if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi