From f21b1a61e37a057525029e96ed6e16d6b72ee530 Mon Sep 17 00:00:00 2001
From: Mathieu Virbel <mat@kivy.org>
Date: Thu, 1 Dec 2011 17:41:27 +0100
Subject: [PATCH 1/4] add environment.sh to create initial build directory, and
 set common env var KIVYIOSROOT represent the root of this project. It can be
 used in external project to refer of this project (like using build/lib
 directory, or build/include) + change current build_* to copy include and lib
 in a common build/ directory

---
 build_freetype.sh | 11 +++++------
 build_python.sh   |  5 ++++-
 build_sdl.sh      |  5 +++++
 build_sdlttf.sh   | 14 +++++++-------
 environment.sh    | 25 +++++++++++++++++++++++++
 5 files changed, 46 insertions(+), 14 deletions(-)
 create mode 100755 environment.sh

diff --git a/build_freetype.sh b/build_freetype.sh
index b081900..3ab8bba 100755
--- a/build_freetype.sh
+++ b/build_freetype.sh
@@ -1,11 +1,8 @@
 #!/bin/bash
 
-set -x
+. environment.sh
 
 FT_VERSION=2.4.8
-SDKVER=5.0
-DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
-SDKROOT=$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk
 
 if [ ! -d freetype-$FT_VERSION ]; then
 	curl -L http://download.savannah.gnu.org/releases/freetype/freetype-$FT_VERSION.tar.bz2 > freetype-$FT_VERSION.tar.bz2
@@ -19,8 +16,10 @@ fi
 # lib not found, compile it
 pushd .
 cd freetype-$FT_VERSION
-./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=$DEVROOT/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 AR=$DEVROOT/usr/bin/ar LDFLAGS="-isysroot $SDKROOT -miphoneos-version-min=$SDKVER" CFLAGS="-O2 -miphoneos-version-min=$SDKVER -isysroot $SDKROOT"
+./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=$DEVROOT/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 AR=$DEVROOT/usr/bin/ar LDFLAGS="-isysroot $SDKROOT -miphoneos-version-min=$SDKVER" CFLAGS="-O0 -g -miphoneos-version-min=$SDKVER -isysroot $SDKROOT"
 make clean
 make
-cp objs/.libs/libfreetype.a libfreetype-arm7.a
 
+# copy to buildroot
+cp objs/.libs/libfreetype.a $BUILDROOT/lib/libfreetype.a
+cp -a include $BUILDROOT/include/freetype
diff --git a/build_python.sh b/build_python.sh
index 52a5230..ab46907 100755
--- a/build_python.sh
+++ b/build_python.sh
@@ -1,4 +1,7 @@
 #!/bin/zsh
+
+. ./environment.sh
+
 set -o errexit
 set -x
 
@@ -164,4 +167,4 @@ lipo $PATH_DEV/lib/libpython2.7-arm.a $PATH_SIMU/lib/libpython2.7-i386.a -create
 find python2.7 | grep -E '*\.(py|pyc|so\.o|so\.a|so\.libs)$' | xargs rm
 find python2.7 | grep -E '*test*' | xargs rm -rdf
 
-
+cp $PATH_DEV/libpython2.7-arm.a $BUILDROOT/build/lib/
diff --git a/build_sdl.sh b/build_sdl.sh
index 3ae93a8..8f7de61 100755
--- a/build_sdl.sh
+++ b/build_sdl.sh
@@ -1,3 +1,8 @@
+#!/bin/bash
+. ./environmnent.sh
 pushd sdl/sdl1.3/Xcode-iPhoneOS/SDL
 xcodebuild -project SDLiPhoneOS.xcodeproj -alltargets
+popd
 #the binarie is under sdl/sdl1.3/Xcode-iPhoneOS/SDL/build/Release-Universal/
+cp sdl/sdl1.3/Xcode-iPhoneOS/SDL/build/Release-iPhoneOS/libSDL.a $BUILDROOT/lib
+cp -a sdl/sdl1.3/include $BUILDROOT/include/SDL 
diff --git a/build_sdlttf.sh b/build_sdlttf.sh
index 202fa8b..47058b5 100755
--- a/build_sdlttf.sh
+++ b/build_sdlttf.sh
@@ -1,11 +1,8 @@
 #!/bin/bash
 
-set -x
+. environment.sh
 
 SDLTTF_VERSION=2.0.10
-SDKVER=5.0
-DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
-SDKROOT=$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk
 
 if [ ! -d SDL_ttf-$SDLTTF_VERSION ]; then
 	curl -L http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-$SDLTTF_VERSION.tar.gz > SDL_ttf-$SDLTTF_VERSION.tar.gz
@@ -17,12 +14,15 @@ if [ -f SDL_ttf-$SDLTTF_VERSION/libSDL_ttf-arm7.a ]; then
 fi
 
 
-cd SDL_ttf-2.0.10
+cd SDL_ttf-$SDLTTF_VERSION
 rm libSDL_ttf.la
 ./configure --prefix=/usr/local/iphone --host=arm-apple-darwin \
 	--enable-static=yes --enable-shared=no \
 	--without-x \
-	CC=$DEVROOT/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 AR=$DEVROOT/usr/bin/ar LDFLAGS="-isysroot $SDKROOT -miphoneos-version-min=$SDKVER" CFLAGS="-O2 -miphoneos-version-min=$SDKVER -isysroot $SDKROOT"
+	CC=$DEVROOT/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 AR=$DEVROOT/usr/bin/ar LDFLAGS="-isysroot $SDKROOT -miphoneos-version-min=$SDKVER" CFLAGS="-O0 -g -miphoneos-version-min=$SDKVER -isysroot $SDKROOT"
 make clean
 make libSDL_ttf.la
-cp .libs/libSDL_ttf.a libSDL_ttf-arm7.a
+
+# copy to buildroot
+cp .libs/libSDL_ttf.a $BUILDROOT/lib/libSDL_ttf.a
+cp -a SDL_ttf.h $BUILDROOT/include
diff --git a/environment.sh b/environment.sh
new file mode 100755
index 0000000..414f6fc
--- /dev/null
+++ b/environment.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+try () {
+	"$@" || exit -1
+}
+
+# iOS SDK Environmnent
+SDKVER=5.0
+DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
+SDKROOT=$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk
+
+# where the build will be located
+ROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+BUILDROOT="$ROOT/build"
+
+# for external project
+export KIVYIOSROOT="$ROOT"
+
+# create build directory if not found
+set -x
+if [ ! -d $BUILDROOT ]; then
+	try mkdir $BUILDROOT
+	try mkdir $BUILDROOT/include
+	try mkdir $BUILDROOT/lib
+fi

From 46b062cf160ec4ec5c2041e1b760cb6f0cf656e8 Mon Sep 17 00:00:00 2001
From: Mathieu Virbel <mat@kivy.org>
Date: Thu, 1 Dec 2011 17:41:42 +0100
Subject: [PATCH 2/4] add gitignore to remove checkout from project

---
 .gitignore | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ee3e9e9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+*.swo
+*.swp
+Python-*
+python_files/Python-*
+freetype-*
+SDL_*
+build/*
+sdl/sdl1.3/Xcode-iPhoneOS/SDL/build/

From e9eb8a6f5fd8cdbff027fc250b68fc5855dbc5f6 Mon Sep 17 00:00:00 2001
From: Mathieu Virbel <mat@kivy.org>
Date: Thu, 1 Dec 2011 17:42:14 +0100
Subject: [PATCH 3/4] add a script to compile kivy (wip), and the whole project

---
 build_all.sh  |  9 +++++++++
 build_kivy.sh | 24 ++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100755 build_all.sh
 create mode 100755 build_kivy.sh

diff --git a/build_all.sh b/build_all.sh
new file mode 100755
index 0000000..f9fe316
--- /dev/null
+++ b/build_all.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+. environment.sh
+
+try ./build_python.sh
+try ./build_sdl.sh
+try ./build_freetype.sh
+try ./build_sdlttf.sh
+try ./build_kivy.sh
diff --git a/build_kivy.sh b/build_kivy.sh
new file mode 100755
index 0000000..7b1dc37
--- /dev/null
+++ b/build_kivy.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+. ./environment.sh
+
+set -x
+
+if [ ! -d kivy ]; then
+	try git clone https://github.com/tito/kivy
+	try cd kivy
+	try git checkout ios-support
+	try cd ..
+fi
+
+if [ "X$1" == "X-f" ]; then
+	try cd kivy
+	try git clean -dxf
+	try git fetch
+	try git checkout ios-support
+	try cd ..
+fi
+
+cd kivy
+make ios
+

From c2e49b6f681cdd371af6454d20b21f46c6e0fef6 Mon Sep 17 00:00:00 2001
From: Mathieu Virbel <mat@kivy.org>
Date: Thu, 1 Dec 2011 17:44:16 +0100
Subject: [PATCH 4/4] update gitignore to not take care of kivy

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index ee3e9e9..a13d637 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ freetype-*
 SDL_*
 build/*
 sdl/sdl1.3/Xcode-iPhoneOS/SDL/build/
+kivy/*