Bladeren bron

Use g++ instead of ld for linking on win32.

git-svn-id: http://bmkng.googlecode.com/svn/trunk@24 2a3afde7-ceff-d69e-269d-2b6c215c828a
[email protected] 14 jaren geleden
bovenliggende
commit
e96b6e2f7a
5 gewijzigde bestanden met toevoegingen van 79 en 20 verwijderingen
  1. 1 0
      bmk.bmx
  2. 1 1
      bmk_config.bmx
  3. 10 1
      bmk_ng.bmx
  4. 60 15
      bmk_util.bmx
  5. 7 3
      config.bmk

+ 1 - 0
bmk.bmx

@@ -1,5 +1,6 @@
 '
 ' Change History :
+' 2.11 27/02/2011 - Use g++ instead of ld for linking on win32.
 ' 2.10 24/02/2011 - Added option for skipping module builds.
 ' 2.09 30/04/2010 - Fixed loadBMK to work for local app folder.
 ' 2.08 05/04/2010 - Added Tommo's include speedup fix.

+ 1 - 1
bmk_config.bmx

@@ -5,7 +5,7 @@ Import BRL.MaxUtil
 
 Import Pub.MacOS
 
-Const BMK_VERSION:String = "2.10"
+Const BMK_VERSION:String = "2.11"
 
 Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s;cc"
 

+ 10 - 1
bmk_ng.bmx

@@ -362,11 +362,18 @@ Type TBMK
 	
 	Method GCCVersion:Int()
 '?win32
+		Global version:String
+		
+		If version Then
+			Return version.toInt()
+		End If
+	
 		Local process:TProcess = CreateProcess("gcc -v")
 		Local s:String
 		
 		While True
-		
+			Delay 10
+			
 			Local line:String = process.err.ReadLine()
 		
 			If Not process.Status() And Not line Then
@@ -385,6 +392,8 @@ Type TBMK
 			
 		Wend
 		
+		version = s
+		
 		Return s.toInt()
 '?
 	End Method

+ 60 - 15
bmk_util.bmx

@@ -189,18 +189,51 @@ Function LinkApp( path$,lnk_files:TList,makelib )
 	End If
 	
 	If processor.Platform() = "win32"
-		cmd=CQuote(processor.Option("path_to_ld", BlitzMaxPath()+"/bin/ld.exe"))+" -s -stack 4194304"
-		If opt_apptype="gui" cmd:+" -subsystem windows"
+		Local version:Int = processor.GCCVersion()
+		Local usingLD:Int = False
+	
+		' always use g++ instead of LD...
+		' uncomment if we want to change to only use LD for GCC's < 4.x
+		'If version < 40000 Then
+		'	usingLD = True
+		'End If
+		' or we can override in the config...
+		If globals.Get("link_with_ld") Then
+			usingLD = True
+		End If
+		
+		If usingLD
+			cmd=CQuote(processor.Option("path_to_ld", BlitzMaxPath()+"/bin/ld.exe"))+" -s -stack 4194304"
+			If opt_apptype="gui" cmd:+" -subsystem windows"
+		Else
+			cmd=CQuote(processor.Option("path_to_gpp", "g++"))+" -s --stack=4194304"
+			If opt_apptype="gui"
+				cmd:+" --subsystem,windows -mwindows"
+			Else
+				If Not makelib
+					cmd:+" -mconsole"
+				End If
+			End If
+			
+			If opt_threaded Then
+				cmd:+" -mthread"
+			End If
+		End If
 		If makelib cmd:+" -shared"
 		
 		cmd:+" -o "+CQuote( path )
-		cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib") ) ' the BlitzMax lib folder 
-		cmd:+" "+CQuote( "-L"+CQuote( processor.Option("path_to_mingw_lib", BlitzMaxPath()+"/lib") ) )
-		If globals.Get("path_to_mingw_lib2") Then
-			cmd:+" "+CQuote( "-L"+CQuote( processor.Option("path_to_mingw_lib2", BlitzMaxPath()+"/lib") ) )
-		End If
-		If globals.Get("path_to_mingw_lib3") Then
-			cmd:+" "+CQuote( "-L"+CQuote( processor.Option("path_to_mingw_lib3", BlitzMaxPath()+"/lib") ) )
+		If usingLD Then
+			cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib") ) ' the BlitzMax lib folder 
+
+			If globals.Get("path_to_mingw_lib") Then
+				cmd:+" "+CQuote( "-L"+CQuote( processor.Option("path_to_mingw_lib", BlitzMaxPath()+"/lib") ) )
+			End If
+			If globals.Get("path_to_mingw_lib2") Then
+				cmd:+" "+CQuote( "-L"+CQuote( processor.Option("path_to_mingw_lib2", BlitzMaxPath()+"/lib") ) )
+			End If
+			If globals.Get("path_to_mingw_lib3") Then
+				cmd:+" "+CQuote( "-L"+CQuote( processor.Option("path_to_mingw_lib3", BlitzMaxPath()+"/lib") ) )
+			End If
 		End If
 	
 		If makelib
@@ -209,10 +242,14 @@ Function LinkApp( path$,lnk_files:TList,makelib )
 			If FileType( def )<>FILETYPE_FILE Throw "Cannot locate .def file"
 			cmd:+" "+def
 			cmd:+" --out-implib "+imp
-			files:+"~n"+CQuote( processor.Option("path_to_mingw_lib", BlitzMaxPath()+"/lib") + "/dllcrt2.o" )
+			If usingLD Then
+				files:+"~n"+CQuote( processor.Option("path_to_mingw_lib", BlitzMaxPath()+"/lib") + "/dllcrt2.o" )
+			End If
 		Else
-			files:+"~n"+CQuote( processor.Option("path_to_mingw_lib2", BlitzMaxPath()+"/lib") + "/crtbegin.o" )
-			files:+"~n"+CQuote( processor.Option("path_to_mingw_lib", BlitzMaxPath()+"/lib") + "/crt2.o" )
+			If usingLD
+				files:+"~n"+CQuote( processor.Option("path_to_mingw_lib2", BlitzMaxPath()+"/lib") + "/crtbegin.o" )
+				files:+"~n"+CQuote( processor.Option("path_to_mingw_lib", BlitzMaxPath()+"/lib") + "/crt2.o" )
+			End If
 		EndIf
 	
 		Local xpmanifest$
@@ -233,23 +270,31 @@ Function LinkApp( path$,lnk_files:TList,makelib )
 		cmd:+" "+CQuote( tmpfile )
 	
 		files:+"~n-lgdi32 -lwsock32 -lwinmm -ladvapi32"
-		files:+" -lstdc++ -lmingwex"
+		If usingLD
+			files:+" -lstdc++ -lmingwex"
 		
 		' for a native Win32 runtiime of mingw 3.4.5, this needs to appear early.
 		'If Not processor.Option("path_to_mingw", "") Then
 			files:+" -lmingw32"
 		'End If
 
-		files:+" -lgcc -lmoldname -lmsvcrt -luser32 -lkernel32 "
+			files:+" -lgcc -lmoldname -lmsvcrt "
+		End If
+
+		files :+ " -luser32 -lkernel32 "
 
 		'If processor.Option("path_to_mingw", "") Then
 			' for a non-native Win32 runtime, this needs to appear last.
 			' (Actually, also for native gcc 4.x, but I dunno how we'll handle that yet!)
+		If usingLD
 			files:+"-lmingw32 "
+		End If
 		'End If
 		
 		If Not makelib
-			files:+" "+CQuote( processor.Option("path_to_mingw_lib2", BlitzMaxPath()+"/lib") + "/crtend.o" )
+			If usingLD
+				files:+" "+CQuote( processor.Option("path_to_mingw_lib2", BlitzMaxPath()+"/lib") + "/crtend.o" )
+			End If
 		EndIf
 		
 		files="INPUT("+files+")"

+ 7 - 3
config.bmk

@@ -10,7 +10,9 @@
 # Please edit the following paths and filenames
 #
 
-# The full path to the mingw32 folder
+# The full path to the location of mingw
+#
+# for MacPorts, this is usually /opt/local
 #
 path_to_mingw=/usr/local/i386-mingw32-3.4.5
 
@@ -34,8 +36,10 @@ path_to_mingw_lib2=%path_to_mingw%/lib/gcc/i386-mingw32/3.4.5
 
 # The path to Wine executable
 #
-path_to_wine=/usr/bin/wine
-
+# typical on Linux
+#path_to_wine=/usr/bin/wine
+# typical on Mac
+path_to_wine=/Applications/Darwine/Wine.bundle/Contents/bin/wine
 
 # ----------------------
 #