We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1490 - iOS compilation via configure/make [patch]
Summary: iOS compilation via configure/make [patch]
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: HG 2.0
Hardware: All iOS (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-12 07:03 UTC by Gabriel Jacobo
Modified: 2012-06-20 13:40 UTC (History)
0 users

See Also:


Attachments
Allows SDL for iOS compilation via configure/make (7.07 KB, patch)
2012-05-12 07:03 UTC, Gabriel Jacobo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gabriel Jacobo 2012-05-12 07:03:43 UTC
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.
Comment 1 Sam Lantinga 2012-06-01 11:35:16 UTC
I tried this, but it's not using the right API headers and so forth.  Do you have a complete command line that works?
Comment 2 Gabriel Jacobo 2012-06-01 11:42:32 UTC
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.
Comment 3 Gabriel Jacobo 2012-06-01 11:45:52 UTC
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.
Comment 4 Gabriel Jacobo 2012-06-05 14:55:59 UTC
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) ?
Comment 5 Gabriel Jacobo 2012-06-20 13:40:04 UTC
This patch was accepted (see iosbuild.sh)