Last active
December 19, 2020 22:58
-
-
Save fudanchii/9bdbc0d94c29c57475cc5df37bc8387c to your computer and use it in GitHub Desktop.
generic Makefile for Go cross compilation to ios/arm64 from linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC = $(IOS_TOOLCHAIN_BIN)/arm64-apple-darwin14-clang | |
CGO_ENABLED = 1 | |
IOS_SDK_FLAGS = -isysroot $(IOS_SDK_PATH)/iPhoneOS11.2.sdk | |
USE_LD_FLAG = -fuse-ld=$(IOS_TOOLCHAIN_BIN)/arm64-apple-darwin14-ld | |
TARGET_ARCH = -arch arm64 | |
CGO_CFLAGS = $(IOS_SDK_FLAGS) $(TARGET_ARCH) | |
CGO_LDFLAGS = $(USE_LD_FLAGS) $(IOS_SDK_FLAGS) $(TARGET_ARCH) | |
GOOS = ios | |
GOARCH = arm64 | |
GO = go1.16beta1 | |
.PHONY: check | |
$(notdir $(PWD)).ios: check | |
CGO_ENABLED="$(CGO_ENABLED)" CC="$(CC)" CGO_CFLAGS="$(CGO_CFLAGS)" \ | |
CGO_LDFLAGS="$(CGO_LDFLAGS)" GOOS="$(GOOS)" GOARCH="$(GOARCH)" \ | |
$(GO) build \ | |
--ldflags "-extld '$(CC)' -extldflags '$(CGO_LDFLAGS)'" \ | |
-o $@ | |
check: | |
ifndef IOS_TOOLCHAIN_BIN | |
$(error IOS_TOOLCHAIN_BIN is not set) | |
endif | |
ifndef IOS_SDK_PATH | |
$(error IOS_SDK_PATH is not set) | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
toolchain and sdk can be obtained from: