random updates for 10.6 and iphone builds
authorkoda
Wed, 16 Dec 2009 14:58:45 +0000
changeset 2663 d53918cd22bb
parent 2662 12dc696f1c81
child 2664 949c189ba568
random updates for 10.6 and iphone builds
CMakeLists.txt
QTfrontend/CMakeLists.txt
hedgewars/CMakeLists.txt
hedgewars/SDLh.pas
hedgewars/hwengine.pas
hedgewars/uStore.pas
share/Info.plist.in
--- a/CMakeLists.txt	Mon Dec 14 20:23:51 2009 +0000
+++ b/CMakeLists.txt	Wed Dec 16 14:58:45 2009 +0000
@@ -47,9 +47,6 @@
 		else()
 			set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
 		endif()
-	ELSEIF(NOT CMAKE_OSX_ARCHITECTURES)
-		EXEC_PROGRAM("/usr/bin/uname" ARGS "-p" OUTPUT_VARIABLE ARCH_TYPE)
-		set(CMAKE_OSX_ARCHITECTURES "${ARCH_TYPE}")
 	ENDIF()	
 
 	message(STATUS "Target system: Mac OS X ${minimum_macosx} ${CMAKE_OSX_ARCHITECTURES}")	
@@ -98,7 +95,7 @@
 endif(LOWRES)
 
 if(Optz)
-	set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
+	set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Si" "-Or" ${pascal_compiler_flags_cmn})
 	set(haskell_compiler_flags_cmn "-w" "-O2")
 else(Optz)
 	set(pascal_compiler_flags_cmn "-O-" "-gl" "-dDEBUGFILE" "-pg" "-vv" ${pascal_compiler_flags_cmn})
--- a/QTfrontend/CMakeLists.txt	Mon Dec 14 20:23:51 2009 +0000
+++ b/QTfrontend/CMakeLists.txt	Wed Dec 16 14:58:45 2009 +0000
@@ -38,7 +38,7 @@
 	else()
 		set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/share/)
 	endif()
-endif(WIN32 AND NOT UNIX)
+endif()
 
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
@@ -186,7 +186,7 @@
 if(WIN32 AND NOT UNIX)
 	if(NOT SDL_LIBRARY)
 		set(HW_LINK_LIBS ${HW_LINK_LIBS} SDL)
-	endif(NOT SDL_LIBRARY)
+	endif()
 
 	set(	HW_LINK_LIBS 
 		${HW_LINK_LIBS}
@@ -195,7 +195,7 @@
 		winspool
 		uuid
 		)
-endif(WIN32 AND NOT UNIX)
+endif()
 
 
 target_link_libraries(hedgewars	${HW_LINK_LIBS})
--- a/hedgewars/CMakeLists.txt	Mon Dec 14 20:23:51 2009 +0000
+++ b/hedgewars/CMakeLists.txt	Wed Dec 16 14:58:45 2009 +0000
@@ -11,7 +11,7 @@
 set(fpc_tryexe fpc)
 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
 
-set(engine_sources
+set(	engine_sources
 	${hwengine_project}
 	SDLh.pas
 	uAI.pas
@@ -55,11 +55,11 @@
 
 find_program(fpc_executable ${fpc_tryexe})
 
-if (fpc_executable)
+if(fpc_executable)
 	 exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output)
-endif (fpc_executable)
+endif(fpc_executable)
 
-set (noexecstack_flags "-k-z" "-knoexecstack")
+set(noexecstack_flags "-k-z" "-knoexecstack")
 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
 
 exec_program(${fpc_executable} ${EXECUTABLE_OUTPUT_PATH}
@@ -68,9 +68,9 @@
 	RETURN_VALUE testnoexecstack
 	)
 
-if (${testnoexecstack})
+if(${testnoexecstack})
 	set (noexecstack_flags "")
-endif (${testnoexecstack})
+endif(${testnoexecstack})
 
 
 if(APPLE)
@@ -86,21 +86,21 @@
 #PASCAL DETECTION SECTION
 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
 
-if (fpc_version)
+if(fpc_version)
 	string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
 	string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
 	string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
 	message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}.${fpc_vers_patch}")
 	math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
 
-	if (fpc_ver LESS "020200")
+	if(fpc_ver LESS "020200")
 		message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0")
-	elseif (APPLE AND i386_build AND fpc_ver LESS "020400")
+	elseif(APPLE AND i386_build AND fpc_ver LESS "020400")
 		message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications!")
-	endif ()
+	endif()
 else()
 	message(FATAL_ERROR "No Pascal compiler found!")
-endif ()
+endif()
 
 set(pascal_compiler ${fpc_executable})
 set(pascal_compiler_flags ${noexecstack_flags} ${pascal_compiler_flags_cmn} ${hwengine_project})
@@ -111,6 +111,8 @@
 #let's build sdlmain, which is absent from the framework
 	find_package(SDL REQUIRED)
 
+	set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")	
+	
 	set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
 	include_directories(${SDL_INCLUDE_DIR})
 	link_libraries(${SDL_LIBRARY})
--- a/hedgewars/SDLh.pas	Mon Dec 14 20:23:51 2009 +0000
+++ b/hedgewars/SDLh.pas	Wed Dec 16 14:58:45 2009 +0000
@@ -21,7 +21,6 @@
 unit SDLh;
 interface
 
-
 {$IFDEF LINUX}
   {$DEFINE UNIX}
 {$ENDIF}
@@ -52,7 +51,6 @@
     {$linkframework SDL_ttf}
     {$linkframework SDL_mixer}
     {$linklib SDLmain}
-    {$linklib gcc}
   {$ENDIF}
 {$ENDIF}
 
@@ -66,19 +64,19 @@
 	SDL_ImageLibName = 'SDL_image.dll';
 	SDL_NetLibName = 'SDL_net.dll';
 {$ELSE}
-	{$IFDEF DARWIN}
-		SDLLibName = 'SDL';
-		SDL_TTFLibName = 'SDL_ttf';
-		SDL_MixerLibName = 'SDL_mixer';
-		SDL_ImageLibName = 'SDL_image';
-		SDL_NetLibName = 'SDL_net';
-        {$ELSE}
-		SDLLibName = 'libSDL.so';
-		SDL_TTFLibName = 'libSDL_ttf.so';
-		SDL_MixerLibName = 'libSDL_mixer.so';
-		SDL_ImageLibName = 'libSDL_image.so';
-		SDL_NetLibName = 'libSDL_net.so';
-        {$ENDIF}
+  {$IFDEF DARWIN}
+	SDLLibName = 'SDL';
+	SDL_TTFLibName = 'SDL_ttf';
+	SDL_MixerLibName = 'SDL_mixer';
+	SDL_ImageLibName = 'SDL_image';
+	SDL_NetLibName = 'SDL_net';
+  {$ELSE}
+	SDLLibName = 'libSDL.so';
+	SDL_TTFLibName = 'libSDL_ttf.so';
+	SDL_MixerLibName = 'libSDL_mixer.so';
+	SDL_ImageLibName = 'libSDL_image.so';
+	SDL_NetLibName = 'libSDL_net.so';
+  {$ENDIF}
 {$ENDIF}
 
 /////////////////////////////////////////////////////////////////
@@ -106,7 +104,7 @@
 	SDL_BUTTON_WHEELDUP  = 4;
 	SDL_BUTTON_WHEELDOWN = 5;
 		
-{*begin sdl_event binding*}
+{*begin SDL_Event binding*}
 	SDL_NOEVENT = 0;
 	SDL_KEYDOWN = 2;
 	SDL_KEYUP = 3;
@@ -137,7 +135,7 @@
 	SDL_QUITEV = 12;
 	SDL_VIDEORESIZE = 16; // TODO: outdated? no longer in SDL 1.3?
 {$ENDIF}
-{*end sdl_event binding*}
+{*end SDL_Event binding*}
 		
 {$IFDEF SDL13}
 	SDL_ASYNCBLIT   = $08000000;
@@ -313,38 +311,40 @@
 		end;
 
 
-{* SDL_event type definition *}
+{* SDL_Event type definition *}
 
 {$IFDEF SDL13}
 	TSDL_WindowID = LongInt;
 
 	TSDL_WindowEvent = record
+		type_: byte;
+		gain: byte;
+		state: byte;
+		windowID: TSDL_WindowID;
+		data1, data2: LongInt;
+		end;
+
+// implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
 {$ELSE}
 	TSDL_ActiveEvent = record
-{$ENDIF}
 		type_: byte;
 		gain: byte;
 		state: byte;
-{$IFDEF SDL13}
-		windowID: TSDL_WindowID;
-		data1, data2: LongInt;
+		end;
 {$ENDIF}
-		end;
-
-//SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
 
 	TSDL_MouseMotionEvent = record
-                             type_: byte;
-                             which: byte;
-                             state: byte;
+		type_: byte;
+		which: byte;
+		state: byte;
 {$IFDEF SDL13}
-                             x, y, xrel, yrel : LongInt;
-			     pressure, pressure_max, pressure_min,
-			     rotation, tilt, cursor: LongInt; 
+		x, y, xrel, yrel : LongInt;
+		pressure, pressure_max, pressure_min,
+		rotation, tilt, cursor: LongInt; 
 {$ELSE}
-                             x, y, xrel, yrel : word;
+		x, y, xrel, yrel : word;
 {$ENDIF}
-                             end;
+		end;
 
 	TSDL_KeyboardEvent = record
 		type_: Byte;
@@ -570,7 +570,6 @@
 /////////////////////  FUNCTION DEFINITIONS /////////////////////
 /////////////////////////////////////////////////////////////////
 
-{$IFDEF FPC}
 
 {* SDL *}
 function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
@@ -640,14 +639,12 @@
 function  SDL_GL_SetAttribute(attr: TSDL_GLattr; value: LongInt): LongInt; cdecl; external SDLLibName;
 procedure SDL_GL_SwapBuffers(); cdecl; external SDLLibName;
 
-{$IFDEF SDL13}
 {$IFDEF IPHONEOS}
 function  SDL_iPhoneKeyboardShow(windowID: LongInt): LongInt; cdecl; external SDLLibName;
 function  SDL_iPhoneKeyboardHide(windowID: LongInt): LongInt; cdecl; external SDLLibName;
 function  SDL_iPhoneKeyboardIsShown(windowID: LongInt): boolean; cdecl; external SDLLibName;
 function  SDL_iPhoneKeyboardToggle(windowID: LongInt): LongInt; cdecl; external SDLLibName;
 {$ENDIF}
-{$ENDIF}
 
 function  SDL_NumJoysticks: LongInt; cdecl; external SDLLibName;
 function  SDL_JoystickName(idx: LongInt): PChar; cdecl; external SDLLibName;
@@ -724,11 +721,6 @@
 function  SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName;
 function  SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
 
-{$IFDEF IPHONEOS}
-function  get_documents_path: PChar; cdecl; external 'hwutils';
-{$ENDIF}
-
-{$ELSE}{$ENDIF}
 
 procedure SDLNet_Write16(value: Word; buf: pointer);
 procedure SDLNet_Write32(value: LongWord; buf: pointer);
@@ -739,32 +731,32 @@
 
 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
 begin
-  SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
+	SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
 end;
 
 procedure SDLNet_Write16(value: Word; buf: pointer);
 begin
-  PByteArray(buf)^[1]:= value;
-  PByteArray(buf)^[0]:= value shr 8
+	PByteArray(buf)^[1]:= value;
+	PByteArray(buf)^[0]:= value shr 8
 end;
 
 procedure SDLNet_Write32(value: LongWord; buf: pointer);
 begin
-  PByteArray(buf)^[3]:= value;
-  PByteArray(buf)^[2]:= value shr  8;
-  PByteArray(buf)^[1]:= value shr 16;
-  PByteArray(buf)^[0]:= value shr 24
+	PByteArray(buf)^[3]:= value;
+	PByteArray(buf)^[2]:= value shr  8;
+	PByteArray(buf)^[1]:= value shr 16;
+	PByteArray(buf)^[0]:= value shr 24
 end;
 
 function SDLNet_Read16(buf: pointer): Word;
 begin
-  SDLNet_Read16:= PByteArray(buf)^[1] or
+	SDLNet_Read16:= PByteArray(buf)^[1] or
                  (PByteArray(buf)^[0] shl 8)
 end;
 
 function SDLNet_Read32(buf: pointer): LongWord;
 begin
-  SDLNet_Read32:=  PByteArray(buf)^[3] or
+	SDLNet_Read32:=  PByteArray(buf)^[3] or
                   (PByteArray(buf)^[2] shl  8) or
                   (PByteArray(buf)^[1] shl 16) or
                   (PByteArray(buf)^[0] shl 24)
--- a/hedgewars/hwengine.pas	Mon Dec 14 20:23:51 2009 +0000
+++ b/hedgewars/hwengine.pas	Wed Dec 16 14:58:45 2009 +0000
@@ -414,8 +414,8 @@
      end;
 {$IFDEF IPHONEOS}
   0: begin
-        PathPrefix:= 'hedgewars/Data';
-        recordFileName:= 'hedgewars/save.hws';
+        PathPrefix:= 'Data';
+        recordFileName:= 'save.hws';
         val('320', cScreenWidth);
         val('480', cScreenHeight);
         cInitWidth:= cScreenWidth;
--- a/hedgewars/uStore.pas	Mon Dec 14 20:23:51 2009 +0000
+++ b/hedgewars/uStore.pas	Wed Dec 16 14:58:45 2009 +0000
@@ -1026,7 +1026,7 @@
 
 	tmpsurf:= doSurfaceConversion(tmpsurf);
 
-{$IFDEF IPHONEOS}   
+{$IFDEF DONTUSE}   // way too slow
 {* http://bugzilla.libsdl.org/show_bug.cgi?id=868 but patched library doesn't work on ipod, so implementing workaround here *}
 	if imageFlags and (ifAlpha or ifTransparent) > 0 then
 	begin
@@ -1136,6 +1136,9 @@
 // prepare default translation/scaling
 glLoadIdentity;
 glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0);
+//{$IFDEF IPHONEOS}
+//glRotatef(90, 0, 0, 1);
+//{$ENDIF}
 glTranslatef(0, -cScreenHeight / 2, 0);
 
 // enable alpha blending
@@ -1155,6 +1158,9 @@
 	glPushMatrix; // save default scaling
 	glLoadIdentity;
 	glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0);
+//{$IFDEF IPHONEOS}
+//	glRotatef(90, 0, 0, 1);
+//{$ENDIF}
 	glTranslatef(0, -cScreenHeight / 2, 0);
 	end;
 
--- a/share/Info.plist.in	Mon Dec 14 20:23:51 2009 +0000
+++ b/share/Info.plist.in	Wed Dec 16 14:58:45 2009 +0000
@@ -24,6 +24,15 @@
 	<false/>
 	<key>LSRequiresNativeExecution</key>
         <true/>
+	<key>LSMinimumSystemVersionByArchitecture</key>
+	<dict>
+	  <key>x86_64</key>
+	  <string>10.6.0</string>
+	  <key>i386</key>
+	  <string>10.4.0</string>
+	  <key>ppc</key>
+	  <string>10.4.0</string>	    
+	</dict>
 	<key>LSArchitecturePriority</key>
 	<array>
    	  <string>x86_64</string>