Skip to content
Snippets Groups Projects
Select Git revision
  • 8a9759a3e4dc7d87c706f232aac4c90469773709
  • next default protected
  • awayview-fix2
  • expos-ability
  • offcenter
  • ringflag
  • team-height
  • skinfix
  • heart-damage
  • ring-fix
  • blockedexposed
  • expos-sphere
  • groundflip
  • exposition
  • master
  • armpit
  • canbustpeanuts
  • jinglebells
  • moremenusounds
  • uncap-palettes
  • udmf-wallscale
  • SRB2_release_2.2.8
  • SRB2_release_2.2.7
  • SRB2_release_2.2.6
  • SRB2_release_2.2.5
  • SRB2_release_2.2.4
  • SRB2_release_2.2.3
  • SRB2_release_2.2.2
  • SRB2_release_2.2.1
  • SRB2_release_2.2.0
  • SRB2_release_2.1.25
  • SRB2_release_2.1.24
  • SRB2_release_2.1.23
  • SRB2_release_2.1.22
  • SRB2_release_2.1.21
  • SRB2_release_2.1.20
  • SRB2_release_2.1.19
  • SRB2_release_2.1.18
  • td-release-v1.0.0
  • SRB2_release_2.1.17
  • SRB2_release_2.1.16a
41 results

lua_baselib.c

Blame
  • Forked from STJr / SRB2
    Source project has a limited visibility.
    README-macos.md 9.60 KiB

    Mac OS X (aka macOS).

    These instructions are for people using Apple's Mac OS X (pronounced "ten"), which in newer versions is just referred to as "macOS".

    From the developer's point of view, macOS is a sort of hybrid Mac and Unix system, and you have the option of using either traditional command line tools or Apple's IDE Xcode.

    Command Line Build

    To build SDL using the command line, use the standard configure and make process:

    mkdir build
    cd build
    ../configure
    make
    sudo make install

    CMake is also known to work, although it continues to be a work in progress:

    mkdir build
    cd build
    cmake -DCMAKE_BUILD_TYPE=Release ..
    make
    sudo make install

    You can also build SDL as a Universal library (a single binary for both 64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh script.

    mkdir build
    cd build
    CC=$PWD/../build-scripts/clang-fat.sh ../configure
    make
    sudo make install

    This script builds SDL with 10.9 ABI compatibility on 64-bit Intel and 11.0 ABI compatibility on ARM64 architectures. For best compatibility you should compile your application the same way.

    Please note that building SDL requires at least Xcode 6 and the 10.9 SDK. PowerPC support for macOS has been officially dropped as of SDL 2.0.2. 32-bit Intel and macOS 10.8 runtime support has been officially dropped as of SDL 2.24.0.

    To use the library once it's built, you essential have two possibilities: use the traditional autoconf/automake/make method, or use Xcode.

    Caveats for using SDL with Mac OS X

    If you register your own NSApplicationDelegate (using [NSApp setDelegate:]), SDL will not register its own. This means that SDL will not terminate using SDL_Quit if it receives a termination request, it will terminate like a normal app, and it will not send a SDL_DROPFILE when you request to open a file with the app. To solve these issues, put the following code in your NSApplicationDelegate implementation:

    - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
    {
        if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
            SDL_Event event;
            event.type = SDL_QUIT;
            SDL_PushEvent(&event);
        }
    
        return NSTerminateCancel;
    }
    
    - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
    {
        if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
            SDL_Event event;
            event.type = SDL_DROPFILE;
            event.drop.file = SDL_strdup([filename UTF8String]);
            return (SDL_PushEvent(&event) > 0);
        }
    
        return NO;
    }

    Using the Simple DirectMedia Layer with a traditional Makefile

    An existing autoconf/automake build system for your SDL app has good chances to work almost unchanged on macOS. However, to produce a "real" Mac binary that you can distribute to users, you need to put the generated binary into a so called "bundle", which is basically a fancy folder with a name like "MyCoolGame.app".

    To get this build automatically, add something like the following rule to your Makefile.am:

    bundle_contents = APP_NAME.app/Contents
    APP_NAME_bundle: EXE_NAME
    	mkdir -p $(bundle_contents)/MacOS
    	mkdir -p $(bundle_contents)/Resources
    	echo "APPL????" > $(bundle_contents)/PkgInfo
    	$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/

    You should replace EXE_NAME with the name of the executable. APP_NAME is what will be visible to the user in the Finder. Usually it will be the same as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME usually is "TestGame". You might also want to use @PACKAGE@ to use the package name as specified in your configure.ac file.

    If your project builds more than one application, you will have to do a bit more. For each of your target applications, you need a separate rule.

    If you want the created bundles to be installed, you may want to add this rule to your Makefile.am:

    install-exec-hook: APP_NAME_bundle
    	rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
    	mkdir -p $(DESTDIR)$(prefix)/Applications/
    	cp -r $< /$(DESTDIR)$(prefix)Applications/

    This rule takes the Bundle created by the rule from step 3 and installs them into "(DESTDIR)(prefix)/Applications/".

    Again, if you want to install multiple applications, you will have to augment the make rule accordingly.

    But beware! That is only part of the story! With the above, you end up with a barebones .app bundle, which is double-clickable from the Finder. But there are some more things you should do before shipping your product...

    1. The bundle right now probably is dynamically linked against SDL. That means that when you copy it to another computer, it will not run, unless you also install SDL on that other computer. A good solution for this dilemma is to static link against SDL. On OS X, you can achieve that by linking against the libraries listed by

      sdl-config --static-libs

      instead of those listed by

      sdl-config --libs

      Depending on how exactly SDL is integrated into your build systems, the way to achieve that varies, so I won't describe it here in detail

    2. Add an 'Info.plist' to your application. That is a special XML file which contains some meta-information about your application (like some copyright information, the version of your app, the name of an optional icon file, and other things). Part of that information is displayed by the Finder when you click on the .app, or if you look at the "Get Info" window. More information about Info.plist files can be found on Apple's homepage.

    As a final remark, let me add that I use some of the techniques (and some variations of them) in Exult and ScummVM; both are available in source on the net, so feel free to take a peek at them for inspiration!

    Using the Simple DirectMedia Layer with Xcode