README.MacOSX
author Sam Lantinga <slouken@libsdl.org>
Thu, 06 May 2004 15:55:06 +0000
changeset 886 05c551e5bc64
parent 869 ae4ab3ac89a9
child 1006 3d9a199d2a70
permissions -rw-r--r--
Date: Sat, 24 Apr 2004 15:13:32 +0300
From: "Mike Gorchak"
Subject: SDL updates for the QNX6

1. Updated the README.QNX
2. Updated libtool scripts, which are shipped with SDL for QNX6 support.
3. Added some code to support the new QNX 6.3.0, which is in beta now.
4. Added code to detect the hw features, which driver supports.
5. Added hw alpha blits code.
6. Fixed bug when application switches to fullscreen more the 2 times. (afte\
r that window becames always stay on top).
7. Updated a bit README for the tests.
8. Added information about acceleration show in the testalpha.c test.
9. Added small fixes to the testoverlay2.c test.
10. Added alpha and cc+alpha blits benchmarks to the testvidinfo.c test.
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@869
    12
To build SDL 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@869
    17
	sudo 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@869
    22
use the traditional autoconf/automake/make method, or use 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@221
    28
An existing autoconf/automake build system for your SDL app has good chances
slouken@221
    29
to work almost unchanged on OS X. However, to produce a "real" MacOS X binary
slouken@221
    30
that you can distribute to users, you need to put the generated binary into a
slouken@221
    31
so called "bundle", which basically is a fancy folder with a name like
slouken@221
    32
"MyCoolGame.app".
slouken@172
    33
slouken@221
    34
To get this build automatically, add something like the following rule to
slouken@221
    35
your Makefile.am:
slouken@172
    36
slouken@199
    37
bundle_contents = APP_NAME.app/Contents
slouken@199
    38
APP_NAME_bundle: EXE_NAME
slouken@199
    39
	mkdir -p $(bundle_contents)/MacOS
slouken@199
    40
	mkdir -p $(bundle_contents)/Resources
slouken@199
    41
	echo "APPL????" > $(bundle_contents)/PkgInfo
slouken@199
    42
	$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
slouken@172
    43
slouken@221
    44
You should replace EXE_NAME with the name of the executable. APP_NAME is what
slouken@221
    45
will be visible to the user in the Finder. Usually it will be the same
slouken@221
    46
as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME 
slouken@221
    47
usually is "TestGame". You might also want to use @PACKAGE@ to use the package
slouken@221
    48
name as specified in your configure.in file.
slouken@172
    49
slouken@221
    50
If your project builds more than one application, you will have to do a bit
slouken@221
    51
more.  For each of your target applications, you need a seperate rule.
slouken@172
    52
slouken@221
    53
If you want the created bundles to be installed, you may want to add this
slouken@221
    54
rule to your Makefile.am:
slouken@172
    55
slouken@199
    56
install-exec-hook: APP_NAME_bundle
slouken@199
    57
	rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
slouken@199
    58
	mkdir -p $(DESTDIR)$(prefix)/Applications/
slouken@199
    59
	cp -r $< /$(DESTDIR)$(prefix)Applications/
slouken@172
    60
slouken@221
    61
This rule takes the Bundle created by the rule from step 3 and installs them
slouken@221
    62
into $(DESTDIR)$(prefix)/Applications/.
slouken@172
    63
slouken@221
    64
Again, if you want to install multiple applications, you will have to augment
slouken@221
    65
the make rule accordingly.
slouken@172
    66
slouken@0
    67
slouken@869
    68
But beware! That is only part of the story! With the above, you end up with
slouken@869
    69
a bare bone .app bundle, which is double clickable from the Finder. But
slouken@869
    70
there are some  more things you should do before shipping yor product...
slouken@869
    71
slouken@869
    72
1) The bundle right now probably is dynamically linked against SDL. That 
slouken@869
    73
   means that when you copy it to another computer, *it will not run*,
slouken@869
    74
   unless you also install SDL on that other computer. A good solution
slouken@869
    75
   for this dilemma is to static link against SDL. On OS X, you can
slouken@869
    76
   achieve that by linkinag against the libraries listed by
slouken@869
    77
     sdl-config --static-libs
slouken@869
    78
   instead of those listed by
slouken@869
    79
     sdl-config --libs
slouken@869
    80
   Depending on how exactly SDL is integrated into your build systems, the
slouken@869
    81
   way to achieve that varies, so I won't describe it here in detail
slouken@869
    82
2) Add an 'Info.plist' to your application. That is a special XML file which
slouken@869
    83
   contains some meta-information about your application (like some copyright
slouken@869
    84
   information, the version of your app, the name of an optional icon file,
slouken@869
    85
   and other things). Part of that information is displayed by the Finder
slouken@869
    86
   when you click on the .app, or if you look at the "Get Info" window.
slouken@869
    87
   More information about Info.plist files can be found on Apple's homepage.
slouken@869
    88
slouken@869
    89
slouken@869
    90
As a final remark, let me add that I use some of the techniques (and some
slouken@869
    91
variations of them) in Exult and ScummVM; both are available in source on
slouken@869
    92
the net, so feel free to take a peek at them for inspiration!
slouken@869
    93
slouken@869
    94
slouken@47
    95
==============================================================================
slouken@47
    96
Using the Simple DirectMedia Layer with Project Builder
slouken@47
    97
==============================================================================
slouken@0
    98
slouken@221
    99
These instructions are for using Apple's Project Builder IDE to build SDL
slouken@221
   100
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@207
   146
    * Add src/main/macosx/SDLMain.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@207
   151
    * Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
slouken@207
   152
    * Set the "Main Nib File" under "Application Settings" to "SDLMain.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@207
   177
	
slouken@207
   178
slouken@0
   179
Known bugs are listed in the file "BUGS"