diff -Naur allegro-4.2.0-0001/include/allegro/platform/alosx.h allegro-4.2.0/include/allegro/platform/alosx.h --- allegro-4.2.0-0001/include/allegro/platform/alosx.h 2004-07-31 13:39:06.000000000 -0400 +++ allegro-4.2.0/include/allegro/platform/alosx.h 2005-06-15 20:57:10.000000000 -0400 @@ -62,11 +62,48 @@ extern int __crt0_argc; extern char **__crt0_argv; +/* There are differences on OS X between programs being console-oriented or + * GUI-oriented. Two issues may occur: + * + * - Programs which use GUI utilities may fail when no GUI is available, + * such as on a headless Xserve. + * + * - Programs which display an icon in the dock may run very slowly at the + * console, and may randomly crash in such a situation. + * + * There are therefore three options for programs using Allegro: + * + * 1. Use GUI utilities and display a dock icon. This is the default. + * + * 2. Use GUI utilities, but do not display a dock icon. To use this option, + * #define ALLEGRO_OSX_NO_DOCK . + * + * 3. Don't use GUI utilities or a dock icon. This is best for programs + * designed for command-line usage. To use this option, #define + * ALLEGRO_OSX_NO_GUI . + */ + #ifndef ALLEGRO_NO_MAGIC_MAIN #define ALLEGRO_MAGIC_MAIN #define main _mangled_main - #undef END_OF_MAIN - #define END_OF_MAIN() void *_mangled_main_address = (void*) _mangled_main; + #undef END_OF_MAIN + + #ifdef ALLEGRO_OSX_NO_DOCK + #define END_OF_MAIN() \ + void *_mangled_main_address = (void*) _mangled_main; \ + int allegro_osx_dock = 0; \ + int allegro_osx_gui = 1; + #elif defined(ALLEGRO_OSX_NO_GUI) + #define END_OF_MAIN() \ + void *_mangled_main_address = (void*) _mangled_main; \ + int allegro_osx_dock = 0; \ + int allegro_osx_gui = 0; + #else + #define END_OF_MAIN() \ + void *_mangled_main_address = (void*) _mangled_main; \ + int allegro_osx_dock = 1; \ + int allegro_osx_gui = 1; + #endif #else #undef END_OF_MAIN #define END_OF_MAIN() void *_mangled_main_address; diff -Naur allegro-4.2.0-0001/makefile.osx allegro-4.2.0/makefile.osx --- allegro-4.2.0-0001/makefile.osx 2005-04-23 04:22:46.000000000 -0400 +++ allegro-4.2.0/makefile.osx 2005-06-15 20:03:16.000000000 -0400 @@ -51,9 +51,9 @@ LIB_NAME = lib/macosx/lib$(VERSION)-$(shared_version).dylib LIB_MAIN_NAME = lib/macosx/lib$(VERSION)-main.a -DYLINK_FLAGS = -prebind -seg1addr 0x30000000 -dylib_compatibility_version=4.0.0 -dylib_current_version=$(shared_version) +DYLINK_FLAGS = -prebind -compatibility_version 4.0.0 -current_version $(shared_version) -INSTALL_NAME = -install_name lib$(VERSION)-$(shared_major_minor).dylib +INSTALL_NAME = -install_name @PREFIX@/lib/lib$(VERSION)-4.dylib INSTALL_NAME_EMBED = -install_name "`echo "@executable_path/../Frameworks/$(FRAMEWORK_NAME).framework/Versions/$(shared_version)/$(FRAMEWORK_NAME)" | sed 's!//*!/!g'`" ifdef EMBED diff -Naur allegro-4.2.0-0001/misc/allegro-config.in allegro-4.2.0/misc/allegro-config.in --- allegro-4.2.0-0001/misc/allegro-config.in 2005-05-14 13:58:00.000000000 -0400 +++ allegro-4.2.0/misc/allegro-config.in 2005-06-15 20:03:16.000000000 -0400 @@ -11,10 +11,10 @@ version=4.2.0 -prefix=@prefix@ +prefix=@PREFIX@ exec_prefix=$prefix exec_prefix_set=no -include_prefix=@INCLUDE_PREFIX@ +include_prefix=@PREFIX@ static_libs=@LINK_WITH_STATIC_LIBS@ lib_type=@LIB_TO_LINK@ diff -Naur allegro-4.2.0-0001/src/macosx/main.m allegro-4.2.0/src/macosx/main.m --- allegro-4.2.0-0001/src/macosx/main.m 2004-07-11 10:36:07.000000000 -0400 +++ allegro-4.2.0/src/macosx/main.m 2005-06-15 21:09:16.000000000 -0400 @@ -33,6 +33,9 @@ extern char **__crt0_argv; extern void *_mangled_main_address; +extern int allegro_osx_dock; +extern int allegro_osx_gui; + static char *arg0, *arg1 = NULL; static int refresh_rate = 70; @@ -203,16 +206,26 @@ __crt0_argc = argc; __crt0_argv = argv; + if (!allegro_osx_gui) { + int (*real_main) (int, char*[]) = + (int (*) (int, char*[])) _mangled_main_address; + + /* Call the user main() */ + exit(real_main(__crt0_argc, __crt0_argv)); + } + [NSApplication sharedApplication]; - - /* Tell the dock about us; the origins of this hack are unknown, but it's - * currently the only way to make a Cocoa app to work when started from a - * console. - */ - if ((!CPSGetCurrentProcess(&psn)) && - (!CPSEnableForegroundOperation(&psn, 0x03, 0x3C, 0x2C, 0x1103)) && - (!CPSSetFrontProcess(&psn))) - [NSApplication sharedApplication]; + + if (allegro_osx_dock) { + /* Tell the dock about us; the origins of this hack are unknown, but it's + * currently the only way to make a Cocoa app to work when started from a + * console. + */ + if ((!CPSGetCurrentProcess(&psn)) && + (!CPSEnableForegroundOperation(&psn, 0x03, 0x3C, 0x2C, 0x1103)) && + (!CPSSetFrontProcess(&psn))) + [NSApplication sharedApplication]; + } /* Creates a custom application menu */ [NSApp setMainMenu: [[NSMenu allocWithZone: [NSMenu menuZone]] initWithTitle: @"temp"]];