gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

mkall.sh (8304B)


      1 #!/usr/bin/env bash
      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.
      5 
      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.
      9 
     10 GOOSARCH="${GOOS}_${GOARCH}"
     11 
     12 # defaults
     13 mksyscall="go run mksyscall.go"
     14 mkerrors="./mkerrors.sh"
     15 zerrors="zerrors_$GOOSARCH.go"
     16 mksysctl=""
     17 zsysctl="zsysctl_$GOOSARCH.go"
     18 mksysnum=
     19 mktypes=
     20 mkasm=
     21 run="sh"
     22 cmd=""
     23 
     24 case "$1" in
     25 -syscalls)
     26 	for i in zsyscall*go
     27 	do
     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
     31 		rm _$i
     32 	done
     33 	exit 0
     34 	;;
     35 -n)
     36 	run="cat"
     37 	cmd="echo"
     38 	shift
     39 esac
     40 
     41 case "$#" in
     42 0)
     43 	;;
     44 *)
     45 	echo 'usage: mkall.sh [-n]' 1>&2
     46 	exit 2
     47 esac
     48 
     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 $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
     54 	exit
     55 fi
     56 
     57 GOOSARCH_in=syscall_$GOOSARCH.go
     58 case "$GOOSARCH" in
     59 _* | *_ | _)
     60 	echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
     61 	exit 1
     62 	;;
     63 aix_ppc)
     64 	mkerrors="$mkerrors -maix32"
     65 	mksyscall="go run mksyscall_aix_ppc.go -aix"
     66 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
     67 	;;
     68 aix_ppc64)
     69 	mkerrors="$mkerrors -maix64"
     70 	mksyscall="go run mksyscall_aix_ppc64.go -aix"
     71 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
     72 	;;
     73 darwin_amd64)
     74 	mkerrors="$mkerrors -m64"
     75 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
     76 	mkasm="go run mkasm.go"
     77 	;;
     78 darwin_arm64)
     79 	mkerrors="$mkerrors -m64"
     80 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
     81 	mkasm="go run mkasm.go"
     82 	;;
     83 dragonfly_amd64)
     84 	mkerrors="$mkerrors -m64"
     85 	mksyscall="go run mksyscall.go -dragonfly"
     86 	mksysnum="go run mksysnum.go 'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'"
     87 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
     88 	;;
     89 freebsd_386)
     90 	mkerrors="$mkerrors -m32"
     91 	mksyscall="go run mksyscall.go -l32"
     92 	mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
     93 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
     94 	;;
     95 freebsd_amd64)
     96 	mkerrors="$mkerrors -m64"
     97 	mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
     98 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
     99 	;;
    100 freebsd_arm)
    101 	mkerrors="$mkerrors"
    102 	mksyscall="go run mksyscall.go -l32 -arm"
    103 	mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
    104 	# Let the type of C char be signed for making the bare syscall
    105 	# API consistent across platforms.
    106 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    107 	;;
    108 freebsd_arm64)
    109 	mkerrors="$mkerrors -m64"
    110 	mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
    111 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    112 	;;
    113 freebsd_riscv64)
    114 	mkerrors="$mkerrors -m64"
    115 	mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
    116 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    117 	;;
    118 netbsd_386)
    119 	mkerrors="$mkerrors -m32"
    120 	mksyscall="go run mksyscall.go -l32 -netbsd"
    121 	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
    122 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
    123 	;;
    124 netbsd_amd64)
    125 	mkerrors="$mkerrors -m64"
    126 	mksyscall="go run mksyscall.go -netbsd"
    127 	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
    128 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
    129 	;;
    130 netbsd_arm)
    131 	mkerrors="$mkerrors"
    132 	mksyscall="go run mksyscall.go -l32 -netbsd -arm"
    133 	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
    134 	# Let the type of C char be signed for making the bare syscall
    135 	# API consistent across platforms.
    136 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    137 	;;
    138 netbsd_arm64)
    139 	mkerrors="$mkerrors -m64"
    140 	mksyscall="go run mksyscall.go -netbsd"
    141 	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
    142 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
    143 	;;
    144 openbsd_386)
    145 	mkasm="go run mkasm.go"
    146 	mkerrors="$mkerrors -m32"
    147 	mksyscall="go run mksyscall.go -l32 -openbsd -libc"
    148 	mksysctl="go run mksysctl_openbsd.go"
    149 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
    150 	;;
    151 openbsd_amd64)
    152 	mkasm="go run mkasm.go"
    153 	mkerrors="$mkerrors -m64"
    154 	mksyscall="go run mksyscall.go -openbsd -libc"
    155 	mksysctl="go run mksysctl_openbsd.go"
    156 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
    157 	;;
    158 openbsd_arm)
    159 	mkasm="go run mkasm.go"
    160 	mkerrors="$mkerrors"
    161 	mksyscall="go run mksyscall.go -l32 -openbsd -arm -libc"
    162 	mksysctl="go run mksysctl_openbsd.go"
    163 	# Let the type of C char be signed for making the bare syscall
    164 	# API consistent across platforms.
    165 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    166 	;;
    167 openbsd_arm64)
    168 	mkasm="go run mkasm.go"
    169 	mkerrors="$mkerrors -m64"
    170 	mksyscall="go run mksyscall.go -openbsd -libc"
    171 	mksysctl="go run mksysctl_openbsd.go"
    172 	# Let the type of C char be signed for making the bare syscall
    173 	# API consistent across platforms.
    174 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    175 	;;
    176 openbsd_mips64)
    177 	mkasm="go run mkasm.go"
    178 	mkerrors="$mkerrors -m64"
    179 	mksyscall="go run mksyscall.go -openbsd -libc"
    180 	mksysctl="go run mksysctl_openbsd.go"
    181 	# Let the type of C char be signed for making the bare syscall
    182 	# API consistent across platforms.
    183 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    184 	;;
    185 openbsd_ppc64)
    186 	mkasm="go run mkasm.go"
    187 	mkerrors="$mkerrors -m64"
    188 	mksyscall="go run mksyscall.go -openbsd -libc"
    189 	mksysctl="go run mksysctl_openbsd.go"
    190 	# Let the type of C char be signed for making the bare syscall
    191 	# API consistent across platforms.
    192 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    193 	;;
    194 openbsd_riscv64)
    195 	mkasm="go run mkasm.go"
    196 	mkerrors="$mkerrors -m64"
    197 	mksyscall="go run mksyscall.go -openbsd -libc"
    198 	mksysctl="go run mksysctl_openbsd.go"
    199 	# Let the type of C char be signed for making the bare syscall
    200 	# API consistent across platforms.
    201 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
    202 	;;
    203 solaris_amd64)
    204 	mksyscall="go run mksyscall_solaris.go"
    205 	mkerrors="$mkerrors -m64"
    206 	mksysnum=
    207 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
    208 	;;
    209 illumos_amd64)
    210         mksyscall="go run mksyscall_solaris.go"
    211 	mkerrors=
    212 	mksysnum=
    213 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
    214 	;;
    215 *)
    216 	echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
    217 	exit 1
    218 	;;
    219 esac
    220 
    221 (
    222 	if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
    223 	case "$GOOS" in
    224 	*)
    225 		syscall_goos="syscall_$GOOS.go"
    226 		case "$GOOS" in
    227 		darwin | dragonfly | freebsd | netbsd | openbsd)
    228 			syscall_goos="syscall_bsd.go $syscall_goos"
    229 			;;
    230 		esac
    231 		if [ -n "$mksyscall" ]; then
    232 			if [ "$GOOSARCH" == "aix_ppc64" ]; then
    233 				# aix/ppc64 script generates files instead of writing to stdin.
    234 				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 " ;
    235 			elif [ "$GOOS" == "illumos" ]; then
    236 			        # illumos code generation requires a --illumos switch
    237 			        echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go";
    238 			        # illumos implies solaris, so solaris code generation is also required
    239 				echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go";
    240 			else
    241 				echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
    242 			fi
    243 		fi
    244 	esac
    245 	if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
    246 	if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
    247 	if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
    248 	if [ -n "$mkasm" ]; then echo "$mkasm $GOOS $GOARCH"; fi
    249 ) | $run