imporve hardcoded CC on cross compile

Since commit applied in moby [61a3285 Support cross-compile for arm]
it hardcoded var-CC to support cross-compile for arm

Correct it with "${parameter:-word}" format, it is helpful for user
define toolchains

(Use Default Values.  If parameter is unset or null, the expansion of
word is substituted.  Otherwise, the value of parameter is substituted.)

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
This commit is contained in:
Hongxu Jia 2019-07-17 17:34:04 +08:00
parent 880feeb3a8
commit 3c701e4db1
1 changed files with 5 additions and 5 deletions

View File

@ -44,27 +44,27 @@ if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARC
# must be cross-compiling!
case "$(go env GOOS)/$(go env GOARCH)" in
windows/amd64)
export CC=x86_64-w64-mingw32-gcc
export CC="${CC:-x86_64-w64-mingw32-gcc}"
export CGO_ENABLED=1
;;
linux/arm)
case "${GOARM}" in
5|"")
export CC=arm-linux-gnueabi-gcc
export CC="${CC:-arm-linux-gnueabi-gcc}"
export CGO_ENABLED=1
;;
7)
export CC=arm-linux-gnueabihf-gcc
export CC="${CC:-arm-linux-gnueabihf-gcc}"
export CGO_ENABLED=1
;;
esac
;;
linux/arm64)
export CC=aarch64-linux-gnu-gcc
export CC="${CC:-aarch64-linux-gnu-gcc}"
export CGO_ENABLED=1
;;
linux/amd64)
export CC=x86_64-linux-gnu-gcc
export CC="${CC:-x86_64-linux-gnu-gcc}"
export CGO_ENABLED=1
;;
esac