From 267663b95166c1ea68b33cd2570da2b46485a87a Mon Sep 17 00:00:00 2001
From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Date: Mon, 30 May 2016 15:04:34 +1000
Subject: [PATCH 1/2] add support for canadian cross build

A mingw-w64 -> arm-linux-musleabi canadian cross compiler can be built
by setting the following variables in config.mak:

TARGET = arm-linux-musleabi
GCC_CONFIG += --host=x86_64-w64-mingw32
CANADIAN := y

Note that this requires both build->host (x86_64-w64-mingw32) and
build->target (arm-linux-musleabi) toolchains to already exist on the
build machine.
---
 litecross/Makefile | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/litecross/Makefile b/litecross/Makefile
index d3c065a..9b4de6f 100644
--- a/litecross/Makefile
+++ b/litecross/Makefile
@@ -61,16 +61,22 @@ FULL_TOOLCHAIN_CONFIG = --enable-languages=c,c++ \
 FULL_MUSL_CONFIG = $(MUSL_CONFIG) \
 	--prefix= --host=$(TARGET)
 
-ifeq ($(NATIVE),)
+ifneq ($(NATIVE),)
+SYSROOT = /
+FULL_TOOLCHAIN_CONFIG += --host=$(TARGET)
+MUSL_VARS =
+else ifneq ($(CANADIAN),)
+SYSROOT = /$(TARGET)
+FULL_MUSL_CONFIG += CROSS_COMPILE=$(TARGET)- LIBCC="../obj_toolchain/$(TARGET)/libgcc/libgcc.a"
+MUSL_VARS =
+obj_musl/.lc_built: | obj_toolchain/$(TARGET)/libgcc/libgcc.a
+obj_toolchain/.lc_built: | obj_sysroot/.lc_libs obj_sysroot/.lc_headers
+else
 SYSROOT = /$(TARGET)
 FULL_MUSL_CONFIG += CC="$(XGCC)" LIBCC="../obj_toolchain/$(TARGET)/libgcc/libgcc.a" 
 MUSL_VARS = AR=../obj_toolchain/binutils/ar RANLIB=../obj_toolchain/binutils/ranlib
 obj_musl/.lc_built: | obj_toolchain/$(TARGET)/libgcc/libgcc.a
 obj_toolchain/.lc_built: | obj_sysroot/.lc_libs obj_sysroot/.lc_headers
-else
-SYSROOT = /
-FULL_TOOLCHAIN_CONFIG += --host=$(TARGET)
-MUSL_VARS = 
 endif
 
 ifeq ($(TARGET),)

From d1e1be7064b09dc7a4dc55079f471a6000ebd29a Mon Sep 17 00:00:00 2001
From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Date: Tue, 19 Jul 2016 11:27:05 +1000
Subject: [PATCH 2/2] remove #es from comment text

---
 config.mak.dist | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/config.mak.dist b/config.mak.dist
index ccbc194..8dd6463 100644
--- a/config.mak.dist
+++ b/config.mak.dist
@@ -41,11 +41,11 @@
 # ISL_VER =
 # LINUX_VER =
 
-# Something like the following can be used to produce a static-linked
-# toolchain that's deployable to any system with matching arch, using
-# an existing musl-targeted cross compiler. This only # works if the
-# system you build on can natively (or via binfmt_misc and # qemu) run
-# binaries produced by the existing toolchain (in this example, i486).
+# Something like the following can be used to produce a static-linked toolchain
+# that's deployable to any system with matching arch, using an existing
+# musl-targeted cross compiler. This only works if the system you build on can
+# natively (or via binfmt_misc and qemu) run binaries produced by the existing
+# toolchain (in this example, i486).
 
 # COMMON_CONFIG += CC="i486-linux-musl-gcc -static --static" CXX="i486-linux-musl-g++ -static --static"