README.MacOSX
changeset 221 50620ec9c86a
parent 207 c03846dd489b
child 869 ae4ab3ac89a9
equal deleted inserted replaced
220:7861d904fb77 221:50620ec9c86a
    23 
    23 
    24 ==============================================================================
    24 ==============================================================================
    25 Using the Simple DirectMedia Layer with a traditional Makefile
    25 Using the Simple DirectMedia Layer with a traditional Makefile
    26 ==============================================================================
    26 ==============================================================================
    27 
    27 
    28 In the following, it will be mostly assumed that you are using autoconf and
    28 An existing autoconf/automake build system for your SDL app has good chances
    29 automake to setup your SDL project, and furthermore that you use the AM_PATH_SDL
    29 to work almost unchanged on OS X. However, to produce a "real" MacOS X binary
    30 macro provided by SDL in sdl.m4. If you are not using these tools, you can
    30 that you can distribute to users, you need to put the generated binary into a
    31 still use SDL but it will be somewhat hard to get running.
    31 so called "bundle", which basically is a fancy folder with a name like
       
    32 "MyCoolGame.app".
    32 
    33 
    33 Only step 1) is really required to get started, but for full OS X support you
    34 To get this build automatically, add something like the following rule to
    34 will want to do the other steps, too.
    35 your Makefile.am:
    35 
       
    36 1) Update your acinclude.m4 file in case you have copied an older version of
       
    37    sdl.m4 into it. This is essential as AM_PATH_SDL now performs some additional
       
    38    tasks when used on MacOS X
       
    39 
       
    40    Rationale: AM_PATH_SDL copies /usr/local/share/sdl/Info.plist and the folder
       
    41    /usr/local/share/sdl/SDL_main.nib/ into the directory where configure is invoked.
       
    42    This is essential for the configure script to be able to run the test code
       
    43    that detects SDL.
       
    44 
       
    45 2) Copy SDL's Info.plist.in file (from src/main/macosx) into your project's main
       
    46    folder (the same spot that your configure.in sits), and edit it to suite your
       
    47    needs. Then add it to your AC_OUTPUT list in configure.in
       
    48 
       
    49    Rationale: The Info.plist file can be used to specify an icon file for
       
    50    your app, and also to provide a human readable version/copyright string
       
    51    and other meta-information to the user via the Finder's Get Info dialog.
       
    52 
       
    53 3) Add something like the following rule to your Makefile.am:
       
    54 
    36 
    55 bundle_contents = APP_NAME.app/Contents
    37 bundle_contents = APP_NAME.app/Contents
    56 APP_NAME_bundle: EXE_NAME
    38 APP_NAME_bundle: EXE_NAME
    57 	mkdir -p $(bundle_contents)/MacOS
    39 	mkdir -p $(bundle_contents)/MacOS
    58 	mkdir -p $(bundle_contents)/Resources
    40 	mkdir -p $(bundle_contents)/Resources
    59 	mkdir -p $(bundle_contents)/Resources/SDL_main.nib
       
    60 	echo "APPL????" > $(bundle_contents)/PkgInfo
    41 	echo "APPL????" > $(bundle_contents)/PkgInfo
    61 	$(INSTALL_DATA) Info.plist $(bundle_contents)/
       
    62 	$(INSTALL_DATA) SDL_main.nib/*.nib $(bundle_contents)/Resources/SDLMain.nib
       
    63 	$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
    42 	$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
    64 
    43 
    65    You should replace EXE_NAME with the name of the executable. APP_NAME is what
    44 You should replace EXE_NAME with the name of the executable. APP_NAME is what
    66    will be visible to the user in the Finder. Usually it will be the same
    45 will be visible to the user in the Finder. Usually it will be the same
    67    as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME 
    46 as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME 
    68    usually is "TestGame". You might also want to use @PACKAGE@ to use the package
    47 usually is "TestGame". You might also want to use @PACKAGE@ to use the package
    69    name as specified in your configure.in file.
    48 name as specified in your configure.in file.
    70 
    49 
    71    If your project builds more than one application, you will have to do a bit more.
    50 If your project builds more than one application, you will have to do a bit
    72    For each of your target applications, you need a seperate rule. Furthermore, each
    51 more.  For each of your target applications, you need a seperate rule.
    73    needs its own Info.plist file, since that has to contain the exact name of the 
       
    74    executable (i.e. EXE_NAME above). One way to do that is to use sed in your make rules
       
    75    and modify a single master Info.plist.
       
    76 
    52 
    77    Rationale: on Mac OS X, executables have to be put into so-called "bundles".
    53 If you want the created bundles to be installed, you may want to add this
    78    The make rule given above will construct such a bundle around the executable
    54 rule to your Makefile.am:
    79    for you. You need to make a copy of it for each target application.
       
    80 
       
    81 4) If you want the create bundles to be installed, you may want to add this
       
    82    rule to your Makefile.am:
       
    83 
    55 
    84 install-exec-hook: APP_NAME_bundle
    56 install-exec-hook: APP_NAME_bundle
    85 	rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
    57 	rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
    86 	mkdir -p $(DESTDIR)$(prefix)/Applications/
    58 	mkdir -p $(DESTDIR)$(prefix)/Applications/
    87 	cp -r $< /$(DESTDIR)$(prefix)Applications/
    59 	cp -r $< /$(DESTDIR)$(prefix)Applications/
    88 
    60 
    89    This rule takes the Bundle created by the rule from step 3 and installs them
    61 This rule takes the Bundle created by the rule from step 3 and installs them
    90    into $(DESTDIR)$(prefix)/Applications/.
    62 into $(DESTDIR)$(prefix)/Applications/.
    91 
    63 
    92    Again, if you want to install multiple applications, you will have to augment
    64 Again, if you want to install multiple applications, you will have to augment
    93    the make rule accordingly.
    65 the make rule accordingly.
    94 
    66 
    95 
    67 
    96 ==============================================================================
    68 ==============================================================================
    97 Using the Simple DirectMedia Layer with Project Builder
    69 Using the Simple DirectMedia Layer with Project Builder
    98 ==============================================================================
    70 ==============================================================================
    99 
    71 
   100 These instructions are for using Apple's Project Builder IDE to build SDL applications.
    72 These instructions are for using Apple's Project Builder IDE to build SDL
       
    73 applications.
   101 
    74 
   102 - First steps
    75 - First steps
   103 
    76 
   104 The first thing to do is to unpack the PBProjects.tar.gz archive in the
    77 The first thing to do is to unpack the PBProjects.tar.gz archive in the
   105 top level SDL directory (where the PBProjects.tar.gz archive resides).
    78 top level SDL directory (where the PBProjects.tar.gz archive resides).