🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
9.6 KiB

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