author Sam Lantinga
Sat, 22 Apr 2006 19:50:23 +0000
changeset 1650 ee4f2d77206f
parent 1649 9705d5d69691
child 1659 14717b52abc0
permissions -rw-r--r--
Whoops, you can't use Project Builder anymore...
     1 ==============================================================================
     2 Using the Simple DirectMedia Layer with Mac OS X
     3 ==============================================================================
     5 These instructions are for people using Apple's Mac OS X (pronounced
     6 "ten").
     8 From the developer's point of view, OS X is a sort of hybrid Mac and
     9 Unix system, and you have the option of using either traditional
    10 command line tools or Apple's IDE Xcode.
    12 To build SDL using the command line, use the standard configure and make
    13 process:
    15 	./configure
    16 	make
    17 	sudo make install
    19 You can also build SDL as a Universal library (a single binary for both
    20 PowerPC and Intel architectures), on Mac OS X 10.4 and newer, by using
    21 the script in build-scripts:
    22 	sh build-scripts/
    23 	sudo build-scripts/ install
    25 To use the library once it's built, you essential have two possibilities:
    26 use the traditional autoconf/automake/make method, or use Xcode.
    28 ==============================================================================
    29 Using the Simple DirectMedia Layer with a traditional Makefile
    30 ==============================================================================
    32 An existing autoconf/automake build system for your SDL app has good chances
    33 to work almost unchanged on OS X. However, to produce a "real" Mac OS X binary
    34 that you can distribute to users, you need to put the generated binary into a
    35 so called "bundle", which basically is a fancy folder with a name like
    36 "".
    38 To get this build automatically, add something like the following rule to
    39 your
    41 bundle_contents =
    42 APP_NAME_bundle: EXE_NAME
    43 	mkdir -p $(bundle_contents)/MacOS
    44 	mkdir -p $(bundle_contents)/Resources
    45 	echo "APPL????" > $(bundle_contents)/PkgInfo
    46 	$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
    48 You should replace EXE_NAME with the name of the executable. APP_NAME is what
    49 will be visible to the user in the Finder. Usually it will be the same
    50 as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME 
    51 usually is "TestGame". You might also want to use @PACKAGE@ to use the package
    52 name as specified in your file.
    54 If your project builds more than one application, you will have to do a bit
    55 more.  For each of your target applications, you need a seperate rule.
    57 If you want the created bundles to be installed, you may want to add this
    58 rule to your
    60 install-exec-hook: APP_NAME_bundle
    61 	rm -rf $(DESTDIR)$(prefix)/Applications/
    62 	mkdir -p $(DESTDIR)$(prefix)/Applications/
    63 	cp -r $< /$(DESTDIR)$(prefix)Applications/
    65 This rule takes the Bundle created by the rule from step 3 and installs them
    66 into $(DESTDIR)$(prefix)/Applications/.
    68 Again, if you want to install multiple applications, you will have to augment
    69 the make rule accordingly.
    72 But beware! That is only part of the story! With the above, you end up with
    73 a bare bone .app bundle, which is double clickable from the Finder. But
    74 there are some  more things you should do before shipping yor product...
    76 1) The bundle right now probably is dynamically linked against SDL. That 
    77    means that when you copy it to another computer, *it will not run*,
    78    unless you also install SDL on that other computer. A good solution
    79    for this dilemma is to static link against SDL. On OS X, you can
    80    achieve that by linkinag against the libraries listed by
    81      sdl-config --static-libs
    82    instead of those listed by
    83      sdl-config --libs
    84    Depending on how exactly SDL is integrated into your build systems, the
    85    way to achieve that varies, so I won't describe it here in detail
    86 2) Add an 'Info.plist' to your application. That is a special XML file which
    87    contains some meta-information about your application (like some copyright
    88    information, the version of your app, the name of an optional icon file,
    89    and other things). Part of that information is displayed by the Finder
    90    when you click on the .app, or if you look at the "Get Info" window.
    91    More information about Info.plist files can be found on Apple's homepage.
    94 As a final remark, let me add that I use some of the techniques (and some
    95 variations of them) in Exult and ScummVM; both are available in source on
    96 the net, so feel free to take a peek at them for inspiration!
    99 ==============================================================================
   100 Using the Simple DirectMedia Layer with Xcode
   101 ==============================================================================
   103 These instructions are for using Apple's Xcode IDE to build SDL applications.
   105 - First steps
   107 The first thing to do is to unpack the Xcode.tar.gz archive in the
   108 top level SDL directory (where the Xcode.tar.gz archive resides).
   109 Because Stuffit Expander will unpack the archive into a subdirectory,
   110 you should unpack the archive manually from the command line:
   111 	cd [path_to_SDL_source]
   112 	tar zxf Xcode.tar.gz
   113 This will create a new folder called Xcode, which you can browse
   114 normally from the Finder.
   116 - Building the Framework
   118 The SDL Library is packaged as a framework bundle, an organized
   119 relocatable folder heirarchy of executible code, interface headers, 
   120 and additional resources. For practical purposes, you can think of a 
   121 framework as a more user and system-friendly shared library, whose library
   122 file behaves more or less like a standard UNIX shared library.
   124 To build the framework, simply open the framework project and build it. 
   125 By default, the framework bundle "SDL.framework" is installed in 
   126 /Library/Frameworks. Therefore, the testers and project stationary expect
   127 it to be located there. However, it will function the same in any of the
   128 following locations:
   130     ~/Library/Frameworks
   131     /Local/Library/Frameworks
   132     /System/Library/Frameworks
   134 - Build Options
   135     There are two "Build Styles" (See the "Targets" tab) for SDL.
   136     "Deployment" should be used if you aren't tweaking the SDL library.
   137     "Development" should be used to debug SDL apps or the library itself.
   139 - Building the Testers
   140     Open the SDLTest project and build away!
   142 - Using the Project Stationary
   143     Copy the stationary to the indicated folders to access it from
   144     the "New Project" and "Add target" menus. What could be easier?
   146 - Setting up a new project by hand
   147     Some of you won't want to use the Stationary so I'll give some tips:
   148     * Create a new "Cocoa Application"
   149     * Add src/main/macosx/SDLMain.m , .h and .nib to your project
   150     * Remove "main.c" from your project
   151     * Remove "MainMenu.nib" from your project
   152     * Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
   153     * Add "$(HOME)/Library/Frameworks" to the frameworks search path
   154     * Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
   155     * Set the "Main Nib File" under "Application Settings" to "SDLMain.nib"
   156     * Add your files
   157     * Clean and build
   159 - Building from command line
   160     Use pbxbuild in the same directory as your .pbproj file
   162 - Running your app
   163     You can send command line args to your app by either invoking it from
   164     the command line (in *.app/Contents/MacOS) or by entering them in the
   165     "Executibles" panel of the target settings.
   167 - Implementation Notes
   168     Some things that may be of interest about how it all works...
   169     * Working directory
   170         As defined in the SDL_main.m file, the working directory of your SDL app
   171         is by default set to its parent. You may wish to change this to better
   172         suit your needs.
   173     * You have a Cocoa App!
   174         Your SDL app is essentially a Cocoa application. When your app
   175         starts up and the libraries finish loading, a Cocoa procedure is called,
   176         which sets up the working directory and calls your main() method.
   177         You are free to modify your Cocoa app with generally no consequence 
   178         to SDL. You cannot, however, easily change the SDL window itself.
   179         Functionality may be added in the future to help this.
   182 Known bugs are listed in the file "BUGS"