mirror of
https://github.com/golang/go
synced 2024-10-04 04:31:21 -06:00
55889409f8
This is like the ill-fated CL 5493063 except that I have written a shell script (autogen.sh) instead of thinking I could possibly write a correct Makefile. R=golang-dev, r CC=golang-dev https://golang.org/cl/5496075
60 lines
993 B
Bash
Executable File
60 lines
993 B
Bash
Executable File
#!/bin/sh
|
|
# Copyright 2011 The Go Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style
|
|
# license that can be found in the LICENSE file.
|
|
|
|
set -e
|
|
|
|
SYS=$1
|
|
export GOOS=$(echo $SYS | sed 's/_.*//')
|
|
export GOARCH=$(echo $SYS | sed 's/.*_//')
|
|
shift
|
|
|
|
case "$GOARCH" in
|
|
386) CC=8c;;
|
|
amd64) CC=6c;;
|
|
arm) CC=5c;;
|
|
esac
|
|
export CC
|
|
|
|
export CFLAGS="-DGOOS_$GOOS -DGOARCH_$GOARCH"
|
|
|
|
cp arch_$GOARCH.h arch_GOARCH.h
|
|
cp defs_${GOOS}_$GOARCH.h defs_GOOS_GOARCH.h
|
|
cp os_$GOOS.h os_GOOS.h
|
|
cp signals_$GOOS.h signals_GOOS.h
|
|
|
|
cat <<EOF
|
|
// Go definitions for C variables and types.
|
|
// AUTO-GENERATED by autogen.sh; DO NOT EDIT
|
|
|
|
package runtime
|
|
import "unsafe"
|
|
var _ unsafe.Pointer
|
|
|
|
EOF
|
|
|
|
for i in "$@"; do
|
|
$CC $CFLAGS -q $i
|
|
done | awk '
|
|
/^func/ { next }
|
|
/^const/ { next }
|
|
/^\/\/.*type/ { next }
|
|
|
|
/^(const|func|type|var) / {
|
|
if(seen[$2]++) {
|
|
skip = /{[^}]*$/;
|
|
next;
|
|
}
|
|
}
|
|
|
|
skip {
|
|
skip = !/^}/
|
|
next;
|
|
}
|
|
|
|
{print}
|
|
'
|
|
|
|
rm -f arch_GOARCH.h defs_GOOS_GOARCH.h os_GOOS.h signals_GOOS.h
|