| Summary: | iOS compilation via configure/make [patch] | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Gabriel Jacobo <gabomdq> |
| Component: | build | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | iOS (All) | ||
| Attachments: | Allows SDL for iOS compilation via configure/make | ||
I tried this, but it's not using the right API headers and so forth. Do you have a complete command line that works? I set up the adequate environment variables as in any cross compilation using a Python function:
def prepare_ios_env(sdk=None, target='3.0'):
""" Set up the environment variables for iOS compilation"""
env = deepcopy(os.environ)
global XCODE_ROOT, BEST_IOS_SDK
if XCODE_ROOT is None:
XCODE_ROOT = find_xcode()
if BEST_IOS_SDK is None:
BEST_IOS_SDK = find_ios_sdk()
if sdk is None:
sdk = BEST_IOS_SDK
env['DEVROOT'] = join(XCODE_ROOT, 'Platforms/iPhoneOS.platform/Developer')
env['SDKROOT'] = env['DEVROOT'] + '/SDKs/iPhoneOS%s.sdk' % sdk
env['CFLAGS'] = env['CXXFLAGS'] = "-g -O2 -pipe -no-cpp-precomp -isysroot %s -miphoneos-version-min=%s -I%s/usr/include/" % (env['SDKROOT'], target, env['SDKROOT'])
env['CXXCPP'] = env['CPP'] = env['DEVROOT'] + "/usr/bin/llvm-cpp-4.2"
env['CXX'] = env['DEVROOT'] + "/usr/bin/llvm-g++-4.2"
env['CC'] = env['DEVROOT'] + "/usr/bin/llvm-gcc-4.2"
env['LD'] = env['DEVROOT'] + "/usr/bin/ld"
env['AR'] = env['DEVROOT'] + "/usr/bin/ar"
env['AS'] = env['DEVROOT'] + "/usr/bin/ls"
env['NM'] = env['DEVROOT'] + "/usr/bin/nm"
env['RANLIB'] = env['DEVROOT'] + "/usr/bin/ranlib"
env['STRIP'] = env['DEVROOT'] + "/usr/bin/strip"
env['LDFLAGS'] = "-L%s/usr/lib/ -isysroot %s -miphoneos-version-min=%s" % (env['SDKROOT'], env['SDKROOT'], target)
return env
I configure with something like this:
./configure --host=armv6-apple-darwin CFLAGS="-arch armv6" LDFLAGS="-arch armv6 -static-libgcc" --disable-shared --enable-static --prefix="some/path"
After running configure, I overwrite SDL_config.h with SDL_config_iphoneos.h, and run make.
I actually run the process twice, once with -arch armv6 another with -arch armv7 (and you could do it a third time for simulator support with -arch i386), then lipo all versions together. The source code for the SDL/iOS compilation code is here: https://bitbucket.org/gabomdq/ignifuga/src/27af5d22dbe8/tools/modules/sdl/ios.py but as I said, it's no different than cross compiling for other platforms really. Sam, you merged a few changes from this patch already, is there anything more needed to merge the rest (basically the configure/configure.in changes) ? This patch was accepted (see iosbuild.sh) |
Created attachment 853 [details] Allows SDL for iOS compilation via configure/make I've attached a small patch that allows to compile SDL for iOS using configure/make by providing the --host=arm-apple-darwin parameter. It's not a complete solution because you still have to copy SDL_config_iphoneos.h over SDL_config.h, but it may be useful for others anyway as it produces a static library that you can just throw into XCode projects without having to set up anything else.