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