From 6549e25c0867af570fa8d806054aa0d68437281f Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Fri, 2 May 2014 09:18:41 +0200
Subject: [PATCH 01/28] Added openssl script

---
 tools/build-openssl.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 tools/build-openssl.sh

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
new file mode 100644
index 0000000..b77cfdd
--- /dev/null
+++ b/tools/build-openssl.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+. $(dirname $0)/environment.sh
+
+if [ ! -d $TMPROOT/openssl ] ; then
+    mkdir $TMPROOT/openssl
+fi
+
+if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
+    try pushd $TMPROOT/openssl
+    try git clone -b master https://github.com/zen-code/ios-openssl
+    cd $TMPROOT/openssl/ios-openssl
+    build.sh
+    try popd
+fi
+
+# copy to buildroot
+#cp $TMPROOT/SDL_ttf-$SDLTTF_VERSION/.libs/libSDL_ttf.a $BUILDROOT/lib/libSDL_ttf.a
+#cp -a $TMPROOT/SDL_ttf-$SDLTTF_VERSION/SDL_ttf.h $BUILDROOT/include

From 372a5fe02e0927776c62476f4e50f1084932343d Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Fri, 2 May 2014 09:21:59 +0200
Subject: [PATCH 02/28] Added commented OpenSSL inclusion

---
 tools/build-all.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/build-all.sh b/tools/build-all.sh
index 067147c..2d333fc 100755
--- a/tools/build-all.sh
+++ b/tools/build-all.sh
@@ -14,6 +14,8 @@ try $(dirname $0)/build-libjpeg.sh
 try $(dirname $0)/build-pil.sh
 try $(dirname $0)/build-kivy.sh
 try $(dirname $0)/build-pyobjus.sh
+# Uncomment the line below to add OpenSSL support libraries
+#try $(dirname $0)/build-openssl.sh
 
 echo '== Build done'
 echo "Available libraries in $BUILDROOT/lib"

From b3fb9ec62bda5e7517e4f08a247597d7f88f81ce Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Fri, 2 May 2014 09:42:47 +0200
Subject: [PATCH 03/28] Tweaked build inclusion

---
 tools/build-openssl.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 tools/build-openssl.sh

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
old mode 100644
new mode 100755
index b77cfdd..3be492d
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -6,9 +6,17 @@ if [ ! -d $TMPROOT/openssl ] ; then
     mkdir $TMPROOT/openssl
 fi
 
+# Check we have a cloned repo
 if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
-    try pushd $TMPROOT/openssl
+    try pushd .
+    cd $TMPROOT/openssl
     try git clone -b master https://github.com/zen-code/ios-openssl
+    try popd
+fi
+
+# Build the required binaries
+if [ -d $TMPROOT/openssl/ios-openssl ] ; then
+    try pushd .
     cd $TMPROOT/openssl/ios-openssl
     build.sh
     try popd

From fc8715c3a9c416d6189e900ea352824cad18f64a Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Fri, 2 May 2014 09:58:42 +0200
Subject: [PATCH 04/28] Added sh prefix fir building

---
 tools/build-openssl.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 3be492d..075d82f 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -18,7 +18,7 @@ fi
 if [ -d $TMPROOT/openssl/ios-openssl ] ; then
     try pushd .
     cd $TMPROOT/openssl/ios-openssl
-    build.sh
+    sh build.sh
     try popd
 fi
 

From ddf78cfbbae707a8d4116b745704ca787b63627e Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Fri, 2 May 2014 10:46:15 +0200
Subject: [PATCH 05/28] Added copying of built binaries

---
 tools/build-openssl.sh | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 075d82f..3d65b0e 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -15,13 +15,17 @@ if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
 fi
 
 # Build the required binaries
-if [ -d $TMPROOT/openssl/ios-openssl ] ; then
-    try pushd .
-    cd $TMPROOT/openssl/ios-openssl
-    sh build.sh
-    try popd
+if [ $TMPROOT/openssl/ios-openssl ] ; then
+    if [ ! $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
+        try pushd .
+        cd $TMPROOT/openssl/ios-openssl
+        sh build.sh
+        try popd
+    fi
 fi
 
-# copy to buildroot
-#cp $TMPROOT/SDL_ttf-$SDLTTF_VERSION/.libs/libSDL_ttf.a $BUILDROOT/lib/libSDL_ttf.a
-#cp -a $TMPROOT/SDL_ttf-$SDLTTF_VERSION/SDL_ttf.h $BUILDROOT/include
+# Copy the binaries to the appropriate places.
+if [ $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
+    cp $TMPROOT/openssl/ios-openssl/lib/libssl.a $BUILDROOT/lib/libssl.a
+    cp $TMPROOT/openssl/ios-openssl/lib/libcrypto.a $BUILDROOT/lib/libcrypto.a
+fi

From 0aa737daec59111177e187766557c4504f8a7745 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Fri, 2 May 2014 22:59:34 +0200
Subject: [PATCH 06/28] Added folder creation

---
 tools/build-openssl.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 3d65b0e..652c0f8 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -17,6 +17,7 @@ fi
 # Build the required binaries
 if [ $TMPROOT/openssl/ios-openssl ] ; then
     if [ ! $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
+        try mkdir $TMPROOT/openssl/ios-openssl/lib
         try pushd .
         cd $TMPROOT/openssl/ios-openssl
         sh build.sh

From e8a229cca2b90801144085ad9374ce95af76df65 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Fri, 2 May 2014 23:13:31 +0200
Subject: [PATCH 07/28] Added directory flag

---
 tools/build-openssl.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 652c0f8..cc3fb75 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -15,7 +15,7 @@ if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
 fi
 
 # Build the required binaries
-if [ $TMPROOT/openssl/ios-openssl ] ; then
+if [ -d $TMPROOT/openssl/ios-openssl ] ; then
     if [ ! $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
         try mkdir $TMPROOT/openssl/ios-openssl/lib
         try pushd .

From dcebc31d3545c5f571496024d6577598f81caa1d Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Sat, 3 May 2014 08:55:16 +0200
Subject: [PATCH 08/28] Added comment

---
 tools/build-openssl.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index cc3fb75..29aafb7 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -15,11 +15,15 @@ if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
 fi
 
 # Build the required binaries
+echo "About to test ..."
 if [ -d $TMPROOT/openssl/ios-openssl ] ; then
+    echo "ios-openssl folder found. Looking for binary..."
     if [ ! $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
+        echo "Binary not found. Building..."
         try mkdir $TMPROOT/openssl/ios-openssl/lib
         try pushd .
         cd $TMPROOT/openssl/ios-openssl
+        # Please refer to the script below for details of the OPenSSL build
         sh build.sh
         try popd
     fi

From 3ee6ed46e9c41b123fec6cc9a78ba8d7500494b6 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Sat, 3 May 2014 08:56:53 +0200
Subject: [PATCH 09/28] Fixed typo

---
 tools/build-openssl.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 29aafb7..73484ed 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -23,7 +23,7 @@ if [ -d $TMPROOT/openssl/ios-openssl ] ; then
         try mkdir $TMPROOT/openssl/ios-openssl/lib
         try pushd .
         cd $TMPROOT/openssl/ios-openssl
-        # Please refer to the script below for details of the OPenSSL build
+        # Please refer to the script below for details of the OpenSSL build
         sh build.sh
         try popd
     fi

From d11db8854e18ca667df76ae2831b44965b87bfa3 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Mon, 5 May 2014 21:40:05 +0200
Subject: [PATCH 10/28] Corrected file check

---
 tools/build-openssl.sh | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 73484ed..17d0195 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -18,19 +18,30 @@ fi
 echo "About to test ..."
 if [ -d $TMPROOT/openssl/ios-openssl ] ; then
     echo "ios-openssl folder found. Looking for binary..."
-    if [ ! $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
+    if [ ! -e $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
         echo "Binary not found. Building..."
-        try mkdir $TMPROOT/openssl/ios-openssl/lib
+        if [ ! -d $TMPROOT/openssl/ios-openssl/lib ] ; then
+            try mkdir $TMPROOT/openssl/ios-openssl/lib
+        fi
         try pushd .
         cd $TMPROOT/openssl/ios-openssl
         # Please refer to the script below for details of the OpenSSL build
         sh build.sh
         try popd
+    else
+        echo "Binaries found. Skipping build..."
     fi
+else
+    echo "Folder found. Pulling latest..."
+    try pushd .
+    cd $TMPROOT/openssl/ios-openssl
+    git pull
+    try popd 
 fi
 
 # Copy the binaries to the appropriate places.
 if [ $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
+    echo "Copying built OpenSSL binaries..."
     cp $TMPROOT/openssl/ios-openssl/lib/libssl.a $BUILDROOT/lib/libssl.a
     cp $TMPROOT/openssl/ios-openssl/lib/libcrypto.a $BUILDROOT/lib/libcrypto.a
 fi

From a07f830ed7b54119dd5e1e80e2a08f3419a49ad5 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Mon, 5 May 2014 22:06:42 +0200
Subject: [PATCH 11/28] Neatened script

---
 tools/build-openssl.sh | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 17d0195..a412e7f 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -8,6 +8,7 @@ fi
 
 # Check we have a cloned repo
 if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
+    echo "ios-openssl repo not found. Pulling latest..."
     try pushd .
     cd $TMPROOT/openssl
     try git clone -b master https://github.com/zen-code/ios-openssl
@@ -15,9 +16,8 @@ if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
 fi
 
 # Build the required binaries
-echo "About to test ..."
 if [ -d $TMPROOT/openssl/ios-openssl ] ; then
-    echo "ios-openssl folder found. Looking for binary..."
+    echo "ios-openssl repo found. Looking for binary..."
     if [ ! -e $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
         echo "Binary not found. Building..."
         if [ ! -d $TMPROOT/openssl/ios-openssl/lib ] ; then
@@ -31,12 +31,6 @@ if [ -d $TMPROOT/openssl/ios-openssl ] ; then
     else
         echo "Binaries found. Skipping build..."
     fi
-else
-    echo "Folder found. Pulling latest..."
-    try pushd .
-    cd $TMPROOT/openssl/ios-openssl
-    git pull
-    try popd 
 fi
 
 # Copy the binaries to the appropriate places.

From 6f4e0b476d30c60b2cc6e6306fc604b1ed28b3ad Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Thu, 8 May 2014 10:13:16 +0200
Subject: [PATCH 12/28] A rebuild of all binaries is now forced

---
 tools/build-openssl.sh | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index a412e7f..5dd3975 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -17,25 +17,17 @@ fi
 
 # Build the required binaries
 if [ -d $TMPROOT/openssl/ios-openssl ] ; then
-    echo "ios-openssl repo found. Looking for binary..."
-    if [ ! -e $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
-        echo "Binary not found. Building..."
-        if [ ! -d $TMPROOT/openssl/ios-openssl/lib ] ; then
-            try mkdir $TMPROOT/openssl/ios-openssl/lib
-        fi
-        try pushd .
-        cd $TMPROOT/openssl/ios-openssl
-        # Please refer to the script below for details of the OpenSSL build
-        sh build.sh
-        try popd
-    else
-        echo "Binaries found. Skipping build..."
+    echo "ios-openssl repo found. Building now..."
+    if [ ! -d $TMPROOT/openssl/ios-openssl/lib ] ; then
+        try mkdir $TMPROOT/openssl/ios-openssl/lib
     fi
+    try pushd .
+    cd $TMPROOT/openssl/ios-openssl
+    # Please refer to the script below for details of the OpenSSL build
+    sh build.sh
+    try popd
 fi
 
-# Copy the binaries to the appropriate places.
-if [ $TMPROOT/openssl/ios-openssl/lib/libssl.a ] ; then
-    echo "Copying built OpenSSL binaries..."
-    cp $TMPROOT/openssl/ios-openssl/lib/libssl.a $BUILDROOT/lib/libssl.a
-    cp $TMPROOT/openssl/ios-openssl/lib/libcrypto.a $BUILDROOT/lib/libcrypto.a
-fi
+echo "Copying built OpenSSL binaries..."
+cp $TMPROOT/openssl/ios-openssl/lib/libssl.a $BUILDROOT/lib/libssl.a
+cp $TMPROOT/openssl/ios-openssl/lib/libcrypto.a $BUILDROOT/lib/libcrypto.a

From 0723fc81ed897ae3da6b037941bdb2ce3a4eea87 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Tue, 13 May 2014 12:54:23 +0200
Subject: [PATCH 13/28] Moved the ssl building to before python to prepare for
 link building

---
 tools/build-all.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/build-all.sh b/tools/build-all.sh
index 2d333fc..dd5af68 100755
--- a/tools/build-all.sh
+++ b/tools/build-all.sh
@@ -3,6 +3,8 @@
 . $(dirname $0)/environment.sh
 
 try $(dirname $0)/build-libffi.sh
+# Uncomment the line below to add OpenSSL support libraries
+# try $(dirname $0)/build-openssl.sh
 try $(dirname $0)/build-python.sh
 try $(dirname $0)/reduce-python.sh
 try $(dirname $0)/build-ios.sh
@@ -14,8 +16,6 @@ try $(dirname $0)/build-libjpeg.sh
 try $(dirname $0)/build-pil.sh
 try $(dirname $0)/build-kivy.sh
 try $(dirname $0)/build-pyobjus.sh
-# Uncomment the line below to add OpenSSL support libraries
-#try $(dirname $0)/build-openssl.sh
 
 echo '== Build done'
 echo "Available libraries in $BUILDROOT/lib"

From 6abc36e923dc5153959ac64693818782843e66f6 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Tue, 13 May 2014 15:12:54 +0200
Subject: [PATCH 14/28] Added script including rebuild of Python with ssl links

---
 tools/build-ssllink.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100755 tools/build-ssllink.sh

diff --git a/tools/build-ssllink.sh b/tools/build-ssllink.sh
new file mode 100755
index 0000000..78e4b57
--- /dev/null
+++ b/tools/build-ssllink.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+. $(dirname $0)/environment.sh
+
+echo "Modifying Python Setup.dist..."
+cp $TMPROOT/Python-2.7.1/Modules/Setup.dist $KIVYIOSROOT/src/python_files
+
+SETUP_DIST=$KIVYIOSROOT/src/python_files/Setup.dist
+echo "" >> $SETUP_DIST
+echo "# Adding SSL Links" >> $SETUP_DIST
+echo "# Socket module helper for sockets" >> $SETUP_DIST
+echo "_socket socketmodule.c" >> $SETUP_DIST
+echo "SSL=/usr" >> $SETUP_DIST
+echo "_ssl _ssl.c \\" >> $SETUP_DIST
+echo "       -DUSE_SSL -I\$(SSL)/include -I\$(SSL)/include/openssl \\" >> $SETUP_DIST
+echo "       -L\$(SSL)/lib -lssl -lcrypto" >> $SETUP_DIST
+
+echo "Cleaning and rebuilding Python to inlcude SSL links..."
+sh $KIVYIOSROOT/tools/clean_python.sh
+sh $KIVYIOSROOT/tools/build-python.sh

From 0b9328143d474e6392add310075adc197d613eed Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Tue, 13 May 2014 16:11:03 +0200
Subject: [PATCH 15/28] Included ssl linking script

---
 tools/build-openssl.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 5dd3975..7fd1e43 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -31,3 +31,5 @@ fi
 echo "Copying built OpenSSL binaries..."
 cp $TMPROOT/openssl/ios-openssl/lib/libssl.a $BUILDROOT/lib/libssl.a
 cp $TMPROOT/openssl/ios-openssl/lib/libcrypto.a $BUILDROOT/lib/libcrypto.a
+
+sh $KIVYIOSROOT/tools/build-ssllink.sh
\ No newline at end of file

From 167fc914e3cf4175f5506a115df5f1ad5de087d1 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 12:45:10 +0200
Subject: [PATCH 16/28] Renamed ssl link file

---
 tools/{build-ssllink.sh => build-openssl-link.sh} | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 rename tools/{build-ssllink.sh => build-openssl-link.sh} (91%)

diff --git a/tools/build-ssllink.sh b/tools/build-openssl-link.sh
similarity index 91%
rename from tools/build-ssllink.sh
rename to tools/build-openssl-link.sh
index 78e4b57..7e6850d 100755
--- a/tools/build-ssllink.sh
+++ b/tools/build-openssl-link.sh
@@ -10,7 +10,7 @@ echo "" >> $SETUP_DIST
 echo "# Adding SSL Links" >> $SETUP_DIST
 echo "# Socket module helper for sockets" >> $SETUP_DIST
 echo "_socket socketmodule.c" >> $SETUP_DIST
-echo "SSL=/usr" >> $SETUP_DIST
+echo "SSL=$TMPROOT/openssel/ios-openssl/openssl" >> $SETUP_DIST
 echo "_ssl _ssl.c \\" >> $SETUP_DIST
 echo "       -DUSE_SSL -I\$(SSL)/include -I\$(SSL)/include/openssl \\" >> $SETUP_DIST
 echo "       -L\$(SSL)/lib -lssl -lcrypto" >> $SETUP_DIST

From 46157cda7c25f6330179f64b50ac3fbb8f1dafcd Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 12:46:47 +0200
Subject: [PATCH 17/28] Added line to copy Setup.dist for openssl

---
 tools/build-python.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/build-python.sh b/tools/build-python.sh
index 22afd42..bdcfad4 100755
--- a/tools/build-python.sh
+++ b/tools/build-python.sh
@@ -25,6 +25,7 @@ try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-static-
 # Copy our setup for modules
 try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
 try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
+#try cp $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
 
 echo "Building for native machine ============================================"
 
@@ -54,6 +55,7 @@ export MACOSX_DEPLOYMENT_TARGET=
 try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
 try cat $KIVYIOSROOT/src/python_files/ModulesSetup.mobile >> Modules/Setup.local
 try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
+try cp $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
 
 try ./configure CC="$ARM_CC" LD="$ARM_LD" \
     CFLAGS="$ARM_CFLAGS" \

From 6bf1d25d71193df07ad0fcdb62fae0957ba963bf Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 12:49:09 +0200
Subject: [PATCH 18/28] Added extr line for linking

---
 tools/build-all.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/build-all.sh b/tools/build-all.sh
index dd5af68..1d05f6a 100755
--- a/tools/build-all.sh
+++ b/tools/build-all.sh
@@ -3,8 +3,9 @@
 . $(dirname $0)/environment.sh
 
 try $(dirname $0)/build-libffi.sh
-# Uncomment the line below to add OpenSSL support libraries
+# Uncomment the lines below to add OpenSSL support libraries
 # try $(dirname $0)/build-openssl.sh
+# try $(dirname $0)/build-openssl-link.sh
 try $(dirname $0)/build-python.sh
 try $(dirname $0)/reduce-python.sh
 try $(dirname $0)/build-ios.sh

From c839c06e0917945f574632db257554ea48909982 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 12:51:20 +0200
Subject: [PATCH 19/28] Corrected indent

---
 tools/build-all.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/build-all.sh b/tools/build-all.sh
index 1d05f6a..b1191e4 100755
--- a/tools/build-all.sh
+++ b/tools/build-all.sh
@@ -4,8 +4,8 @@
 
 try $(dirname $0)/build-libffi.sh
 # Uncomment the lines below to add OpenSSL support libraries
-# try $(dirname $0)/build-openssl.sh
-# try $(dirname $0)/build-openssl-link.sh
+#try $(dirname $0)/build-openssl.sh
+#try $(dirname $0)/build-openssl-link.sh
 try $(dirname $0)/build-python.sh
 try $(dirname $0)/reduce-python.sh
 try $(dirname $0)/build-ios.sh

From 15ed8fb0def6515dad04e06181e5ef9d93c9bcf3 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 13:44:27 +0200
Subject: [PATCH 20/28] Corrected placement of openssl script

---
 tools/build-all.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/build-all.sh b/tools/build-all.sh
index b1191e4..3e312f2 100755
--- a/tools/build-all.sh
+++ b/tools/build-all.sh
@@ -3,10 +3,9 @@
 . $(dirname $0)/environment.sh
 
 try $(dirname $0)/build-libffi.sh
-# Uncomment the lines below to add OpenSSL support libraries
-#try $(dirname $0)/build-openssl.sh
-#try $(dirname $0)/build-openssl-link.sh
 try $(dirname $0)/build-python.sh
+# Uncomment the line below to add OpenSSL support libraries
+#try $(dirname $0)/build-openssl.sh
 try $(dirname $0)/reduce-python.sh
 try $(dirname $0)/build-ios.sh
 try $(dirname $0)/build-sdl.sh

From 436f0ef21b752982ad0a6d5e54f12d39a1182042 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 13:59:35 +0200
Subject: [PATCH 21/28] Corrected file name link

---
 tools/build-openssl.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 7fd1e43..4859f1c 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -32,4 +32,4 @@ echo "Copying built OpenSSL binaries..."
 cp $TMPROOT/openssl/ios-openssl/lib/libssl.a $BUILDROOT/lib/libssl.a
 cp $TMPROOT/openssl/ios-openssl/lib/libcrypto.a $BUILDROOT/lib/libcrypto.a
 
-sh $KIVYIOSROOT/tools/build-ssllink.sh
\ No newline at end of file
+sh $KIVYIOSROOT/tools/build-openssl-link.sh

From 06fa93c6e797cd5768205c7b50d927d4de55a063 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 14:06:38 +0200
Subject: [PATCH 22/28] Check for existence of Setup.dist

---
 tools/build-python.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/build-python.sh b/tools/build-python.sh
index bdcfad4..04a31a6 100755
--- a/tools/build-python.sh
+++ b/tools/build-python.sh
@@ -25,7 +25,6 @@ try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-static-
 # Copy our setup for modules
 try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
 try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
-#try cp $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
 
 echo "Building for native machine ============================================"
 
@@ -55,7 +54,10 @@ export MACOSX_DEPLOYMENT_TARGET=
 try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
 try cat $KIVYIOSROOT/src/python_files/ModulesSetup.mobile >> Modules/Setup.local
 try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
-try cp $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
+if [ -f $KIVYIOSROOT/src/python_files/Setup.dist ]; then
+    # Used by build-openssl.sh to insert links 
+    $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
+fi
 
 try ./configure CC="$ARM_CC" LD="$ARM_LD" \
     CFLAGS="$ARM_CFLAGS" \

From ac260a760ae135608b91929de62964a32e67ba9d Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Wed, 14 May 2014 14:27:19 +0200
Subject: [PATCH 23/28] Added link to ios-openssl source site

---
 tools/build-all.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/build-all.sh b/tools/build-all.sh
index 3e312f2..3647d07 100755
--- a/tools/build-all.sh
+++ b/tools/build-all.sh
@@ -4,7 +4,8 @@
 
 try $(dirname $0)/build-libffi.sh
 try $(dirname $0)/build-python.sh
-# Uncomment the line below to add OpenSSL support libraries
+# Uncomment the "try" line below to add OpenSSL support libraries
+# For more detail: https://github.com/zen-code/ios-openssl
 #try $(dirname $0)/build-openssl.sh
 try $(dirname $0)/reduce-python.sh
 try $(dirname $0)/build-ios.sh

From c8cc6d73dc6f12f3d296b19ce364c73ad332094a Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Thu, 15 May 2014 08:31:21 +0200
Subject: [PATCH 24/28] Added duplicate copy following existing code

---
 tools/build-python.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/build-python.sh b/tools/build-python.sh
index 04a31a6..140a482 100755
--- a/tools/build-python.sh
+++ b/tools/build-python.sh
@@ -25,6 +25,10 @@ try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-static-
 # Copy our setup for modules
 try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
 try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
+if [ -f $KIVYIOSROOT/src/python_files/Setup.dist ]; then
+    # Used by build-openssl.sh to insert links 
+    $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
+fi
 
 echo "Building for native machine ============================================"
 

From 03dd1a494b1d128f847d116e8011a13766d72db8 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Thu, 15 May 2014 11:47:38 +0200
Subject: [PATCH 25/28] Skip building if binaries exist

---
 tools/build-openssl.sh | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/tools/build-openssl.sh b/tools/build-openssl.sh
index 4859f1c..e147b42 100755
--- a/tools/build-openssl.sh
+++ b/tools/build-openssl.sh
@@ -15,17 +15,21 @@ if [ ! -d $TMPROOT/openssl/ios-openssl ] ; then
     try popd
 fi
 
-# Build the required binaries
-if [ -d $TMPROOT/openssl/ios-openssl ] ; then
-    echo "ios-openssl repo found. Building now..."
-    if [ ! -d $TMPROOT/openssl/ios-openssl/lib ] ; then
-        try mkdir $TMPROOT/openssl/ios-openssl/lib
+# Build the required binaries if not found (long process)
+if [ ! -f $BUILDROOT/lib/libssl.a ] ; then
+    if [ -d $TMPROOT/openssl/ios-openssl ] ; then
+        echo "ios-openssl repo found. Building now..."
+        if [ ! -d $TMPROOT/openssl/ios-openssl/lib ] ; then
+            try mkdir $TMPROOT/openssl/ios-openssl/lib
+        fi
+        try pushd .
+        cd $TMPROOT/openssl/ios-openssl
+        # Please refer to the script below for details of the OpenSSL build
+        sh build.sh
+        try popd
     fi
-    try pushd .
-    cd $TMPROOT/openssl/ios-openssl
-    # Please refer to the script below for details of the OpenSSL build
-    sh build.sh
-    try popd
+else
+    echo "Skipping build. Binary found: $BUILDROOT/lib/libssl.a"
 fi
 
 echo "Copying built OpenSSL binaries..."

From 4e29cb4bd62e5c8f122abefbc780f34c147ee1d5 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Thu, 15 May 2014 16:32:20 +0200
Subject: [PATCH 26/28] Added missing cp command

---
 tools/build-python.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/build-python.sh b/tools/build-python.sh
index 140a482..3dd293c 100755
--- a/tools/build-python.sh
+++ b/tools/build-python.sh
@@ -27,9 +27,10 @@ try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
 try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
 if [ -f $KIVYIOSROOT/src/python_files/Setup.dist ]; then
     # Used by build-openssl.sh to insert links 
-    $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
+    try cp $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
 fi
 
+read -p "Pausing for check, Corrent = $(pwd)"
 echo "Building for native machine ============================================"
 
 OSX_SDK_ROOT=`xcrun --sdk macosx --show-sdk-path`
@@ -60,7 +61,7 @@ try cat $KIVYIOSROOT/src/python_files/ModulesSetup.mobile >> Modules/Setup.local
 try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
 if [ -f $KIVYIOSROOT/src/python_files/Setup.dist ]; then
     # Used by build-openssl.sh to insert links 
-    $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
+    try cp $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
 fi
 
 try ./configure CC="$ARM_CC" LD="$ARM_LD" \

From f4287f11f6279bfef76817bd287c07009ceb35c0 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Thu, 15 May 2014 16:33:15 +0200
Subject: [PATCH 27/28] Corrected spelling

---
 tools/build-openssl-link.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build-openssl-link.sh b/tools/build-openssl-link.sh
index 7e6850d..fd5cf48 100755
--- a/tools/build-openssl-link.sh
+++ b/tools/build-openssl-link.sh
@@ -10,7 +10,7 @@ echo "" >> $SETUP_DIST
 echo "# Adding SSL Links" >> $SETUP_DIST
 echo "# Socket module helper for sockets" >> $SETUP_DIST
 echo "_socket socketmodule.c" >> $SETUP_DIST
-echo "SSL=$TMPROOT/openssel/ios-openssl/openssl" >> $SETUP_DIST
+echo "SSL=$TMPROOT/openssl/ios-openssl/openssl" >> $SETUP_DIST
 echo "_ssl _ssl.c \\" >> $SETUP_DIST
 echo "       -DUSE_SSL -I\$(SSL)/include -I\$(SSL)/include/openssl \\" >> $SETUP_DIST
 echo "       -L\$(SSL)/lib -lssl -lcrypto" >> $SETUP_DIST

From ce0f1e5d223219f65f74bcd6890fb16e94a369b1 Mon Sep 17 00:00:00 2001
From: Richard Larkin <richard@camiweb.com>
Date: Thu, 15 May 2014 16:57:14 +0200
Subject: [PATCH 28/28] Removed prompt

---
 tools/build-python.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/build-python.sh b/tools/build-python.sh
index 3dd293c..61e69f9 100755
--- a/tools/build-python.sh
+++ b/tools/build-python.sh
@@ -30,7 +30,6 @@ if [ -f $KIVYIOSROOT/src/python_files/Setup.dist ]; then
     try cp $KIVYIOSROOT/src/python_files/Setup.dist Modules/Setup.dist
 fi
 
-read -p "Pausing for check, Corrent = $(pwd)"
 echo "Building for native machine ============================================"
 
 OSX_SDK_ROOT=`xcrun --sdk macosx --show-sdk-path`