README.MacOSX
author Sam Lantinga <slouken@libsdl.org>
Sun, 23 Sep 2001 20:42:00 +0000
changeset 191 c151cfc43c07
parent 172 37e3ca9254c7
child 199 2ad0957f6265
permissions -rw-r--r--
Changed SDLMain to SDL_main for MacOS X stuff
     1 ==============================================================================
     2 Using the Simple DirectMedia Layer with Mac OS X
     3 ==============================================================================
     4 
     5 These instructions are for people using Apple's Mac OS X (pronounced
     6 "ten").
     7 
     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 ProjectBuilder (PB).
    11 
    12 To build using the command line, use the standard configure and make
    13 process:
    14 
    15 	./configure
    16 	make
    17 	make install
    18 
    19 (You may need to create the subdirs of /usr/local manually.)
    20 
    21 /*
    22 To use the library once it's built, you need to use the "Carbon
    23 framework", which is the port of the old Mac Toolbox to OS X.
    24 To do this, use the -F and -framework arguments for compiling
    25 and linking, respectively:
    26 
    27 	cc -c myprog.c -I/usr/local/include/SDL -F/System/Library/Frameworks/Carbon.framework
    28 	cc myprog.o -L/usr/local/lib -lSDL -framework Carbon
    29 
    30 sdl-config knows about the linking path and -framework, so it's
    31 recommended to use it to fill in your Makefile variables.
    32 */
    33 
    34 To use the library once it's built, you essential have two possibilities:
    35 use the traditional autoconf/automake/make method, or use Apple's Project Builder.
    36 
    37 ==============================================================================
    38 Using the Simple DirectMedia Layer with a traditional Makefile
    39 ==============================================================================
    40 
    41 In the following, it will be mostly assumed that you are using autoconf and
    42 automake to setup your SDL project, and furthermore that you use the AM_PATH_SDL
    43 macro provided by SDL in sdl.m4. If you are not using these tools, you can
    44 still use SDL but it will be somewhat hard to get running.
    45 
    46 Only step 1) is really required to get started, but for full OS X support you
    47 will want to do the other steps, too.
    48 
    49 1) Update your acinclude.m4 file in case you have copied an older version of
    50    sdl.m4 into it. This is essential as AM_PATH_SDL now performs some additional
    51    tasks when used on MacOS X
    52 
    53    Rationale: AM_PATH_SDL copies /usr/local/share/sdl/Info.plist and the folder
    54    /usr/local/share/sdl/SDL_main.nib/ into the directory where configure is invoked.
    55    This is essential for the configure script to be able to run the test code
    56    that detects SDL.
    57 
    58 2) Copy SDL's Info.plist.in file (from src/main/macosx) into your project's main
    59    folder (the same spot that your configure.in sits), and edit it to suite your
    60    needs. Then add it to your AC_OUTPUT list in configure.in
    61 
    62    Rationale: The Info.plist file can be used to specify an icon file for
    63    your app, and also to provide a human readable version/copyright string
    64    and other meta-information to the user via the Finder's Get Info dialog.
    65 
    66 3) Add something like the following rule to your Makefile.am:
    67 
    68 APP_NAME.app: EXE_NAME
    69 	mkdir -p $@/Contents/MacOS
    70 	mkdir -p $@/Contents/Resources
    71 	mkdir -p $@/Contents/Resources/SDL_main.nib
    72 	echo "APPL????" > $@/Contents/PkgInfo
    73 	$(INSTALL_DATA) Info.plist $@/Contents/
    74 	$(INSTALL_DATA) SDL_main.nib/*.nib $@/Contents/Resources/
    75 	$(INSTALL_PROGRAM) $< $@/Contents/MacOS/
    76 
    77    You should replace EXE_NAME with the name of the executable. APP_NAME is what
    78    will be visible to the user in the Finder. Usually it will be the same
    79    as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME 
    80    usually is "TestGame"
    81 
    82    If your project builds more than one application, you will have to do a bit more.
    83    For each of your target applications, you need a seperate rule. Furthermore, each
    84    needs its own Info.plist file, since that has to contain the exact name of the 
    85    executable (i.e. EXE_NAME above). One way to do that is to use sed in your make rules
    86    and modify a single master Info.plist.
    87 
    88    Rationale: on Mac OS X, executables have to be put into so-called "bundles".
    89    The make rule given above will construct such a bundle around the executable
    90    for you. You need to make a copy of it for each target application.
    91 
    92 4) If you want the create bundles to be installed, you may want to add this
    93    rule to your Makefile.am:
    94 
    95 install-exec-local: Exult.app
    96 	mkdir -p /Applications/
    97 	cp -r $< /Applications/
    98 
    99    This rule takes the Bundle created by the rule from step 3 and installs them
   100    into /Applications/. An alternate installation place would be $HOME/Applications/
   101 
   102    Again, if you want to install multiple applications, you will have to augment
   103    the make rule accordingly.
   104 
   105 
   106 ==============================================================================
   107 Using the Simple DirectMedia Layer with Project Builder
   108 ==============================================================================
   109 
   110 These instructions are for using Apple's Project Builder IDE to build SDL applications.
   111 
   112 - First steps
   113 
   114 The first thing to do is to unpack the PBProjects.tar.gz archive in the
   115 top level SDL directory (where the PBProjects.tar.gz archive resides).
   116 Because Stuffit Expander will unpack the archive into a subdirectory,
   117 you should unpack the archive manually from the command line:
   118 	cd [path_to_SDL_source]
   119 	tar zxf PBProjects.tar.gz
   120 This will create a new folder called PBProjects, which you can browse
   121 normally from the Finder.
   122 
   123 - Building the Framework
   124 
   125 The SDL Library is packaged as a framework bundle, an organized
   126 relocatable folder heirarchy of executible code, interface headers, 
   127 and additional resources. For practical purposes, you can think of a 
   128 framework as a more user and system-friendly shared library, whose library
   129 file behaves more or less like a standard UNIX shared library.
   130 
   131 To build the framework, simply open the framework project and build it. 
   132 By default, the framework bundle "SDL.framework" is installed in 
   133 ~/Library/Frameworks. Therefore, the testers and project stationary expect
   134 it to be located there. However, it will function the same in any of the
   135 following locations:
   136 
   137     ~/Library/Frameworks
   138     /Local/Library/Frameworks
   139     /System/Library/Frameworks
   140 
   141 - Build Options
   142     There are two "Build Styles" (See the "Targets" tab) for SDL.
   143     "Deployment" should be used if you aren't tweaking the SDL library.
   144     "Development" should be used to debug SDL apps or the library itself.
   145 
   146 - Building the Testers
   147     Open the SDLTest project and build away!
   148 
   149 - Using the Project Stationary
   150     Copy the stationary to the indicated folders to access it from
   151     the "New Project" and "Add target" menus. What could be easier?
   152 
   153 - Setting up a new project by hand
   154     Some of you won't want to use the Stationary so I'll give some tips:
   155     * Create a new "Cocoa Application"
   156     * Add src/main/macosx/SDL_main.m , .h and .nib to your project
   157     * Remove "main.c" from your project
   158     * Remove "MainMenu.nib" from your project
   159     * Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
   160     * Add "$(HOME)/Library/Frameworks" to the frameworks search path
   161     * Add "-framework SDL" to the "OTHER_LDFLAGS" variable
   162     * Set the "Main Nib File" under "Application Settings" to "SDL_main.nib"
   163     * Add your files
   164     * Clean and build
   165 
   166 - Building from command line
   167     Use pbxbuild in the same directory as your .pbproj file
   168          
   169 - Running your app
   170     You can send command line args to your app by either invoking it from
   171     the command line (in *.app/Contents/MacOS) or by entering them in the
   172     "Executibles" panel of the target settings.
   173     
   174 - Implementation Notes
   175     Some things that may be of interest about how it all works...
   176     * Working directory
   177         As defined in the SDL_main.m file, the working directory of your SDL app
   178         is by default set to its parent. You may wish to change this to better
   179         suit your needs.
   180     * You have a Cocoa App!
   181         Your SDL app is essentially a Cocoa application. When your app
   182         starts up and the libraries finish loading, a Cocoa procedure is called,
   183         which sets up the working directory and calls your main() method.
   184         You are free to modify your Cocoa app with generally no consequence 
   185         to SDL. You cannot, however, easily change the SDL window itself.
   186         Functionality may be added in the future to help this.
   187     * My development setup:
   188         I am using version 1.0.1 (v63.0) of Project Builder on MacOS X 10.0.3,
   189         from the Developer Tools CD for May 2001.
   190         As of May 31 2001, Apple hasn't released this version of the tools to the public, 
   191         but I expect that things will still work on older versions.
   192         
   193 Known bugs are listed in the file "BUGS"
   194  LocalWords:  Stuffit