Updated some stuff.
authorMark Sibly <marksibly@ubuntu.(none)>
Wed, 29 Jan 2014 00:11:47 +0000 (13:11 +1300)
committerMark Sibly <marksibly@ubuntu.(none)>
Wed, 29 Jan 2014 00:11:47 +0000 (13:11 +1300)
.gitignore
_src/linux_x86/bin/bmk
src/bmk/bmk_util.bmx

index e359f8a4e9b80b719b3da5fedd4f35342dfed6c3..b357e117f19489064e67694c662ed5004dd9109c 100644 (file)
@@ -3,6 +3,7 @@
 /cfg/*
 /tmp/*
 /doc/*
+/src/createrelease/BlitzMax/*
 !/doc/bmxstyle.css
 /docs/html
 *.x86.s
index 7cc20f968710b6b5694f1d314b15be8b5e3baa29..1ca2d5ee41b811ae378297f1b633a504800f8bd8 100644 (file)
Binary files a/_src/linux_x86/bin/bmk and b/_src/linux_x86/bin/bmk differ
index 5c122d85c9c5c714c77394b99398a3cf834a405e..0e1274b3f1f85c944d0129116a73d4068a185d6c 100644 (file)
-
-Strict
-
-Import "bmk_config.bmx"
-
-'OS X Nasm doesn't work? Used to produce incorrect reloc offsets - haven't checked for a while 
-Const USE_NASM=False
-
-Const CC_WARNINGS=False'True
-
-Type TModOpt ' BaH
-       Field cc_opts:String = ""
-       Field ld_opts:TList = New TList
-       
-       Method addOption(qval:String)
-               If qval.startswith("CC_OPTS") Then
-                       cc_opts:+ " " + qval[qval.find(":") + 1..].Trim()
-               ElseIf qval.startswith("LD_OPTS") Then
-                       Local opt:String = qval[qval.find(":") + 1..].Trim()
-                       
-                       If opt.startsWith("-L") Then
-                               opt = "-L" + CQuote(opt[2..])
-                       End If
-                       
-                       ld_opts.addLast opt
-               End If
-       End Method
-       
-       Method hasCCopt:Int(value:String)
-               Return cc_opts.find(value) >= 0
-       End Method
-
-       Method hasLDopt:Int(value:String)
-               For Local opt:String = EachIn ld_opts
-                       If opt.find(value) >= 0 Then
-                               Return True
-                       End If
-               Next
-               Return False
-       End Method
-
-       Function setPath:String(value:String, path:String)
-               Return value.Replace("%PWD%", path)
-       End Function
-       
-End Type
-
-Global mod_opts:TModOpt ' BaH
-
-Function Match( ext$,pat$ )
-       Return (";"+pat+";").Find( ";"+ext+";" )<>-1
-End Function
-
-Function HTTPEsc$( t$ )
-       t=t.Replace( " ","%20" )
-       Return t
-End Function
-
-Function Sys( cmd$ )
-       If opt_verbose
-               Print cmd
-       Else If opt_dumpbuild
-               Local p$=cmd
-               p=p.Replace( BlitzMaxPath()+"/","./" )
-               WriteStdout p+"~n"
-               Local t$="mkdir "
-               If cmd.StartsWith( t ) And FileType( cmd[t.length..] ) Return
-       EndIf
-       Return system_( cmd )
-End Function
-
-Function CQuote$( t$ )
-       If t And t[0]=Asc("-") Return t
-       For Local i=0 Until t.length
-               If t[i]=Asc(".") Continue
-               If t[i]=Asc("/") Continue
-?Win32
-               If t[i]=Asc("\") Continue
-?
-               If t[i]=Asc("_") Or t[i]=Asc("-") Continue
-               If t[i]>=Asc("0") And t[i]<=Asc("9") Continue
-               If t[i]>=Asc("A") And t[i]<=Asc("Z") Continue
-               If t[i]>=Asc("a") And t[i]<=Asc("z") Continue
-               Return "~q"+t+"~q"
-       Next
-       Return t
-End Function
-
-Function Ranlib( dir$ )
-       '
-?MacOS
-       If macos_version>=$1040 Return
-?
-       '
-       For Local f$=EachIn LoadDir( dir )
-               Local p$=dir+"/"+f
-               Select FileType( p )
-               Case FILETYPE_DIR
-                       Ranlib p
-               Case FILETYPE_FILE
-                       If ExtractExt(f).ToLower()="a" Sys "ranlib "+p
-               End Select
-       Next
-End Function
-
-Function Assemble( src$,obj$ )
-       DeleteFile obj
-       Local cmd$
-?MacOS
-       If opt_arch="ppc" 
-               cmd="as -arch ppc"
-       Else
-               If USE_NASM
-                       cmd="nasm -f macho"
-               Else
-                       cmd="as -arch i386"
-               EndIf
-       EndIf
-       cmd:+" -W -o "+CQuote(obj)+" "+CQuote(src);
-?Win32
-       cmd$=CQuote(BlitzMaxPath()+"/bin/fasm")+" "+CQuote(src)+" "+CQuote(obj)
-?Linux
-       cmd$=CQuote(BlitzMaxPath()+"/bin/fasm")+" -m32768 "+CQuote(src)+" "+CQuote(obj)
-?
-       If Sys( cmd )
-               Throw "Build Error: Failed to assemble "+src
-       EndIf
-End Function
-
-Function CompileC( src$,obj$,opts$ )
-       DeleteFile obj
-
-       Local t$=getenv_( "BMK_CC_OPTS" )
-       If t opts:+" "+t
-
-       Local cmd$="gcc"
-       If ExtractExt(src)="cpp" Or ExtractExt(src)="cc" Or ExtractExt(src)="cxx" Or ExtractExt(src)="mm"
-               cmd="g++"
-       Else
-               If CC_WARNINGS opts:+" -Wimplicit-function-declaration"
-       EndIf
-
-       If Not CC_WARNINGS opts:+" -w"
-
-?MacOS
-       If opt_arch="ppc" 
-               opts:+" -arch ppc"
-       Else
-               opts:+" -arch i386"
-       EndIf
-       If macos_version>=$1070                                 'Lion?
-               opts:+" -mmacosx-version-min=10.4"      '...can build for Tiger++
-       Else If macos_version>=$1040                    'Tiger?
-               opts:+" -mmacosx-version-min=10.3"      '...can build for Panther++
-       EndIf
-?Win32
-       If Not mod_opts Or Not mod_opts.hasCCopt("-march")
-               opts:+" -march=pentium"
-       EndIf
-       opts:+" -ffast-math"
-?Linux
-       opts:+" -m32 -mfancy-math-387 -fno-strict-aliasing"
-?
-       If mod_opts
-               If Not mod_opts.hasCCopt("-fexceptions")
-                       opts:+" -fno-exceptions"
-               EndIf
-               opts:+ " " + mod_opts.cc_opts ' BaH
-       Else
-               opts:+" -fno-exceptions"
-       EndIf
-
-       cmd:+opts+" -c -o "+CQuote(obj)+" "+CQuote(src)
-
-       If Sys( cmd )
-               Throw "Build Error: failed to compile "+src
-       EndIf
-End Function
-
-Function CompileBMX( src$,obj$,opts$ )
-       DeleteFile obj
-
-       Local azm$=StripExt(obj)+".s"
-?MacOs
-       Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)
-?Win32
-       Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)
-?Linux 
-       Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)
-?
-       If Sys( cmd )
-               Throw "Build Error: failed to compile "+src
-       EndIf
-?MacOs
-       If opt_arch="x86"
-               If Not USE_NASM
-                       Local cmd$=CQuote(BlitzMaxPath()+"/bin/fasm2as")+" "+CQuote(azm)
-                       If Sys( cmd ) Throw "Fasm2as failed - please contact BRL!"
-               EndIf
-       EndIf
-?
-       Assemble azm,obj
-
-End Function
-
-Function CreateArc( path$ , oobjs:TList )
-       DeleteFile path
-       Local cmd$,t$
-?Win32
-       For t$=EachIn oobjs
-               If Len(cmd)+Len(t)>1000
-                       If Sys( cmd )
-                               DeleteFile path
-                               Throw "Build Error: Failed to create archive "+path
-                       EndIf
-                       cmd=""
-               EndIf
-               If Not cmd cmd="ar -r "+CQuote(path)
-               cmd:+" "+CQuote(t)
-       Next
-?MacOS
-       cmd="libtool -o "+CQuote(path)
-       For Local t$=EachIn oobjs
-               cmd:+" "+CQuote(t)
-       Next
-?Linux
-       For Local t$=EachIn oobjs
-               If Len(cmd)+Len(t)>1000
-                       If Sys( cmd )
-                               DeleteFile path
-                               Throw "Build Error: Failed to create archive "+path
-                       EndIf
-                       cmd=""
-               EndIf
-               If Not cmd cmd="ar -r "+CQuote(path)
-               cmd:+" "+CQuote(t)
-       Next
-?
-       If cmd And Sys( cmd )
-               DeleteFile path
-               Throw "Build Error: Failed to create archive "+path
-       EndIf
-End Function
-
-Function LinkApp( path$,lnk_files:TList,makelib )
-       DeleteFile path
-
-       Local cmd$
-       Local files$
-       Local tmpfile$=BlitzMaxPath()+"/tmp/ld.tmp"
-?MacOS
-       cmd="g++"
-       
-       If opt_arch="ppc" 
-               cmd:+" -arch ppc" 
-       Else
-               cmd:+" -arch i386 -read_only_relocs suppress"
-       EndIf
-
-       If macos_version>=$1070                                 'Lion?
-               cmd:+" -mmacosx-version-min=10.4"       '...can build for Tiger++
-       Else If macos_version>=$1040                    'Tiger?
-               cmd:+" -mmacosx-version-min=10.3"       '...can build for Panther++
-       EndIf
-
-       cmd:+" -o "+CQuote( path )
-       cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib" ) )
-
-       If Not opt_dumpbuild cmd:+" -filelist "+CQuote( tmpfile )
-       
-       For Local t$=EachIn lnk_files
-               If opt_dumpbuild Or (t[..1]="-")
-                       cmd:+" "+t 
-               Else
-                       files:+t+Chr(10)
-               EndIf
-       Next
-       cmd:+" -lSystem -framework CoreServices -framework CoreFoundation"
-?Win32
-       cmd=CQuote(BlitzMaxPath()+"/bin/ld.exe")+" -s -stack 4194304"   'symbol stripping enabled
-       If opt_apptype="gui" cmd:+" -subsystem windows"
-       If makelib cmd:+" -shared"
-       
-       cmd:+" -o "+CQuote( path )
-       cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib" ) )
-
-       If makelib
-               Local imp$=StripExt(path)+".a"
-               Local def$=StripExt(path)+".def"
-               If FileType( def )<>FILETYPE_FILE Throw "Cannot locate .def file"
-               cmd:+" "+def
-               cmd:+" --out-implib "+imp
-               files:+"~n"+CQuote( BlitzMaxPath()+"/lib/dllcrt2.o" )
-       Else
-               files:+"~n"+CQuote( BlitzMaxPath()+"/lib/crtbegin.o" )
-               files:+"~n"+CQuote( BlitzMaxPath()+"/lib/crt2.o" )
-       EndIf
-
-       'Unholy!!!!!
-       Local xpmanifest$
-       For Local f$=EachIn lnk_files
-               Local t$=CQuote( f )
-               If opt_dumpbuild Or (t[..1]="-" And t[..2]<>"-l")
-                       cmd:+" "+t
-               Else
-                       If f.EndsWith( "/win32maxguiex.mod/xpmanifest.o" )
-                               xpmanifest=t
-                       Else
-                               files:+"~n"+t
-                       EndIf
-               EndIf
-       Next
-
-       If xpmanifest files:+"~n"+xpmanifest
-       
-       cmd:+" "+CQuote( tmpfile )
-
-       files:+"~n-lgdi32 -lwsock32 -lwinmm -ladvapi32"
-       files:+" -lstdc++ -lgcc -lmingwex -lmingw32 -lmoldname -lmsvcrt -luser32 -lkernel32"
-       
-       If Not makelib
-               files:+" "+CQuote( BlitzMaxPath()+"/lib/crtend.o" )
-       EndIf
-       
-       files="INPUT("+files+")"
-?Linux
-
-       cmd="g++"
-       cmd:+" -m32 -s -Os -pthread"
-       cmd:+" -o "+CQuote( path )
-       cmd:+" "+CQuote( tmpfile )
-       cmd:+" -L/usr/lib32"
-       cmd:+" -L/usr/X11R6/lib"
-       cmd:+" -L/usr/lib"
-       cmd:+" -L"+CQuote( BlitzMaxPath()+"/lib" )
-
-       For Local t$=EachIn lnk_files
-               t=CQuote(t)
-               If opt_dumpbuild Or (t[..1]="-" And t[..2]<>"-l")
-                       cmd:+" "+t
-               Else
-                       files:+" "+t
-               EndIf
-       Next
-
-       files="INPUT("+files+")"
-?
-       Local t$=getenv_( "BMK_LD_OPTS" )
-       If t 
-               cmd:+" "+t
-       EndIf
-
-       Local stream:TStream=WriteStream( tmpfile )
-       stream.WriteBytes files.ToCString(),files.length
-       stream.Close
-       
-       If Sys( cmd ) Throw "Build Error: Failed to link "+path
-
-End Function
+\r
+Strict\r
+\r
+Import "bmk_config.bmx"\r
+\r
+'OS X Nasm doesn't work? Used to produce incorrect reloc offsets - haven't checked for a while \r
+Const USE_NASM=False\r
+\r
+Const CC_WARNINGS=False'True\r
+\r
+Type TModOpt ' BaH\r
+       Field cc_opts:String = ""\r
+       Field ld_opts:TList = New TList\r
+       \r
+       Method addOption(qval:String)\r
+               If qval.startswith("CC_OPTS") Then\r
+                       cc_opts:+ " " + qval[qval.find(":") + 1..].Trim()\r
+               ElseIf qval.startswith("LD_OPTS") Then\r
+                       Local opt:String = qval[qval.find(":") + 1..].Trim()\r
+                       \r
+                       If opt.startsWith("-L") Then\r
+                               opt = "-L" + CQuote(opt[2..])\r
+                       End If\r
+                       \r
+                       ld_opts.addLast opt\r
+               End If\r
+       End Method\r
+       \r
+       Method hasCCopt:Int(value:String)\r
+               Return cc_opts.find(value) >= 0\r
+       End Method\r
+\r
+       Method hasLDopt:Int(value:String)\r
+               For Local opt:String = EachIn ld_opts\r
+                       If opt.find(value) >= 0 Then\r
+                               Return True\r
+                       End If\r
+               Next\r
+               Return False\r
+       End Method\r
+\r
+       Function setPath:String(value:String, path:String)\r
+               Return value.Replace("%PWD%", path)\r
+       End Function\r
+       \r
+End Type\r
+\r
+Global mod_opts:TModOpt ' BaH\r
+\r
+Function Match( ext$,pat$ )\r
+       Return (";"+pat+";").Find( ";"+ext+";" )<>-1\r
+End Function\r
+\r
+Function HTTPEsc$( t$ )\r
+       t=t.Replace( " ","%20" )\r
+       Return t\r
+End Function\r
+\r
+Function Sys( cmd$ )\r
+       If opt_verbose\r
+               Print cmd\r
+       Else If opt_dumpbuild\r
+               Local p$=cmd\r
+               p=p.Replace( BlitzMaxPath()+"/","./" )\r
+               WriteStdout p+"~n"\r
+               Local t$="mkdir "\r
+               If cmd.StartsWith( t ) And FileType( cmd[t.length..] ) Return\r
+       EndIf\r
+       Return system_( cmd )\r
+End Function\r
+\r
+Function CQuote$( t$ )\r
+       If t And t[0]=Asc("-") Return t\r
+       For Local i=0 Until t.length\r
+               If t[i]=Asc(".") Continue\r
+               If t[i]=Asc("/") Continue\r
+?Win32\r
+               If t[i]=Asc("\") Continue\r
+?\r
+               If t[i]=Asc("_") Or t[i]=Asc("-") Continue\r
+               If t[i]>=Asc("0") And t[i]<=Asc("9") Continue\r
+               If t[i]>=Asc("A") And t[i]<=Asc("Z") Continue\r
+               If t[i]>=Asc("a") And t[i]<=Asc("z") Continue\r
+               Return "~q"+t+"~q"\r
+       Next\r
+       Return t\r
+End Function\r
+\r
+Function Ranlib( dir$ )\r
+       '\r
+?MacOS\r
+       If macos_version>=$1040 Return\r
+?\r
+       '\r
+       For Local f$=EachIn LoadDir( dir )\r
+               Local p$=dir+"/"+f\r
+               Select FileType( p )\r
+               Case FILETYPE_DIR\r
+                       Ranlib p\r
+               Case FILETYPE_FILE\r
+                       If ExtractExt(f).ToLower()="a" Sys "ranlib "+p\r
+               End Select\r
+       Next\r
+End Function\r
+\r
+Function Assemble( src$,obj$ )\r
+       DeleteFile obj\r
+       Local cmd$\r
+?MacOS\r
+       If opt_arch="ppc" \r
+               cmd="as -arch ppc"\r
+       Else\r
+               If USE_NASM\r
+                       cmd="nasm -f macho"\r
+               Else\r
+                       cmd="as -arch i386"\r
+               EndIf\r
+       EndIf\r
+       cmd:+" -W -o "+CQuote(obj)+" "+CQuote(src);\r
+?Win32\r
+       cmd$=CQuote(BlitzMaxPath()+"/bin/fasm")+" "+CQuote(src)+" "+CQuote(obj)\r
+?Linux\r
+       Local opts$=getenv_( "BMK_FASM_OPTS" )\r
+       If opts="" opts="-m1048560"\r
+       cmd$=CQuote(BlitzMaxPath()+"/bin/fasm")+" "+opts+" "+CQuote(src)+" "+CQuote(obj)\r
+?\r
+       If Sys( cmd )\r
+               Throw "Build Error: Failed to assemble "+src\r
+       EndIf\r
+End Function\r
+\r
+Function CompileC( src$,obj$,opts$ )\r
+       DeleteFile obj\r
+\r
+       Local t$=getenv_( "BMK_CC_OPTS" )\r
+       If t opts:+" "+t\r
+\r
+       Local cmd$="gcc"\r
+       If ExtractExt(src)="cpp" Or ExtractExt(src)="cc" Or ExtractExt(src)="cxx" Or ExtractExt(src)="mm"\r
+               cmd="g++"\r
+       Else\r
+               If CC_WARNINGS opts:+" -Wimplicit-function-declaration"\r
+       EndIf\r
+\r
+       If Not CC_WARNINGS opts:+" -w"\r
+\r
+?MacOS\r
+       If opt_arch="ppc" \r
+               opts:+" -arch ppc"\r
+       Else\r
+               opts:+" -arch i386"\r
+       EndIf\r
+       If macos_version>=$1070                                 'Lion?\r
+               opts:+" -mmacosx-version-min=10.4"      '...can build for Tiger++\r
+       Else If macos_version>=$1040                    'Tiger?\r
+               opts:+" -mmacosx-version-min=10.3"      '...can build for Panther++\r
+       EndIf\r
+?Win32\r
+       If Not mod_opts Or Not mod_opts.hasCCopt("-march")\r
+               opts:+" -march=pentium"\r
+       EndIf\r
+       opts:+" -ffast-math"\r
+?Linux\r
+       opts:+" -m32 -mfancy-math-387 -fno-strict-aliasing"\r
+?\r
+       If mod_opts\r
+               If Not mod_opts.hasCCopt("-fexceptions")\r
+                       opts:+" -fno-exceptions"\r
+               EndIf\r
+               opts:+ " " + mod_opts.cc_opts ' BaH\r
+       Else\r
+               opts:+" -fno-exceptions"\r
+       EndIf\r
+\r
+       cmd:+opts+" -c -o "+CQuote(obj)+" "+CQuote(src)\r
+\r
+       If Sys( cmd )\r
+               Throw "Build Error: failed to compile "+src\r
+       EndIf\r
+End Function\r
+\r
+Function CompileBMX( src$,obj$,opts$ )\r
+       DeleteFile obj\r
+\r
+       Local azm$=StripExt(obj)+".s"\r
+?MacOs\r
+       Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)\r
+?Win32\r
+       Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)\r
+?Linux \r
+       Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)\r
+?\r
+       If Sys( cmd )\r
+               Throw "Build Error: failed to compile "+src\r
+       EndIf\r
+?MacOs\r
+       If opt_arch="x86"\r
+               If Not USE_NASM\r
+                       Local cmd$=CQuote(BlitzMaxPath()+"/bin/fasm2as")+" "+CQuote(azm)\r
+                       If Sys( cmd ) Throw "Fasm2as failed - please contact BRL!"\r
+               EndIf\r
+       EndIf\r
+?\r
+       Assemble azm,obj\r
+\r
+End Function\r
+\r
+Function CreateArc( path$ , oobjs:TList )\r
+       DeleteFile path\r
+       Local cmd$,t$\r
+?Win32\r
+       For t$=EachIn oobjs\r
+               If Len(cmd)+Len(t)>1000\r
+                       If Sys( cmd )\r
+                               DeleteFile path\r
+                               Throw "Build Error: Failed to create archive "+path\r
+                       EndIf\r
+                       cmd=""\r
+               EndIf\r
+               If Not cmd cmd="ar -r "+CQuote(path)\r
+               cmd:+" "+CQuote(t)\r
+       Next\r
+?MacOS\r
+       cmd="libtool -o "+CQuote(path)\r
+       For Local t$=EachIn oobjs\r
+               cmd:+" "+CQuote(t)\r
+       Next\r
+?Linux\r
+       For Local t$=EachIn oobjs\r
+               If Len(cmd)+Len(t)>1000\r
+                       If Sys( cmd )\r
+                               DeleteFile path\r
+                               Throw "Build Error: Failed to create archive "+path\r
+                       EndIf\r
+                       cmd=""\r
+               EndIf\r
+               If Not cmd cmd="ar -r "+CQuote(path)\r
+               cmd:+" "+CQuote(t)\r
+       Next\r
+?\r
+       If cmd And Sys( cmd )\r
+               DeleteFile path\r
+               Throw "Build Error: Failed to create archive "+path\r
+       EndIf\r
+End Function\r
+\r
+Function LinkApp( path$,lnk_files:TList,makelib )\r
+       DeleteFile path\r
+\r
+       Local cmd$\r
+       Local files$\r
+       Local tmpfile$=BlitzMaxPath()+"/tmp/ld.tmp"\r
+?MacOS\r
+       cmd="g++"\r
+       \r
+       If opt_arch="ppc" \r
+               cmd:+" -arch ppc" \r
+       Else\r
+               cmd:+" -arch i386 -read_only_relocs suppress"\r
+       EndIf\r
+\r
+       If macos_version>=$1070                                 'Lion?\r
+               cmd:+" -mmacosx-version-min=10.4"       '...can build for Tiger++\r
+       Else If macos_version>=$1040                    'Tiger?\r
+               cmd:+" -mmacosx-version-min=10.3"       '...can build for Panther++\r
+       EndIf\r
+\r
+       cmd:+" -o "+CQuote( path )\r
+       cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib" ) )\r
+\r
+       If Not opt_dumpbuild cmd:+" -filelist "+CQuote( tmpfile )\r
+       \r
+       For Local t$=EachIn lnk_files\r
+               If opt_dumpbuild Or (t[..1]="-")\r
+                       cmd:+" "+t \r
+               Else\r
+                       files:+t+Chr(10)\r
+               EndIf\r
+       Next\r
+       cmd:+" -lSystem -framework CoreServices -framework CoreFoundation"\r
+?Win32\r
+       cmd=CQuote(BlitzMaxPath()+"/bin/ld.exe")+" -s -stack 4194304"   'symbol stripping enabled\r
+       If opt_apptype="gui" cmd:+" -subsystem windows"\r
+       If makelib cmd:+" -shared"\r
+       \r
+       cmd:+" -o "+CQuote( path )\r
+       cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib" ) )\r
+\r
+       If makelib\r
+               Local imp$=StripExt(path)+".a"\r
+               Local def$=StripExt(path)+".def"\r
+               If FileType( def )<>FILETYPE_FILE Throw "Cannot locate .def file"\r
+               cmd:+" "+def\r
+               cmd:+" --out-implib "+imp\r
+               files:+"~n"+CQuote( BlitzMaxPath()+"/lib/dllcrt2.o" )\r
+       Else\r
+               files:+"~n"+CQuote( BlitzMaxPath()+"/lib/crtbegin.o" )\r
+               files:+"~n"+CQuote( BlitzMaxPath()+"/lib/crt2.o" )\r
+       EndIf\r
+\r
+       'Unholy!!!!!\r
+       Local xpmanifest$\r
+       For Local f$=EachIn lnk_files\r
+               Local t$=CQuote( f )\r
+               If opt_dumpbuild Or (t[..1]="-" And t[..2]<>"-l")\r
+                       cmd:+" "+t\r
+               Else\r
+                       If f.EndsWith( "/win32maxguiex.mod/xpmanifest.o" )\r
+                               xpmanifest=t\r
+                       Else\r
+                               files:+"~n"+t\r
+                       EndIf\r
+               EndIf\r
+       Next\r
+\r
+       If xpmanifest files:+"~n"+xpmanifest\r
+       \r
+       cmd:+" "+CQuote( tmpfile )\r
+\r
+       files:+"~n-lgdi32 -lwsock32 -lwinmm -ladvapi32"\r
+       files:+" -lstdc++ -lgcc -lmingwex -lmingw32 -lmoldname -lmsvcrt -luser32 -lkernel32"\r
+       \r
+       If Not makelib\r
+               files:+" "+CQuote( BlitzMaxPath()+"/lib/crtend.o" )\r
+       EndIf\r
+       \r
+       files="INPUT("+files+")"\r
+?Linux\r
+\r
+       cmd="g++"\r
+       cmd:+" -m32 -s -Os -pthread"\r
+       cmd:+" -o "+CQuote( path )\r
+       cmd:+" "+CQuote( tmpfile )\r
+       cmd:+" -L/usr/lib32"\r
+       cmd:+" -L/usr/X11R6/lib"\r
+       cmd:+" -L/usr/lib"\r
+       cmd:+" -L"+CQuote( BlitzMaxPath()+"/lib" )\r
+\r
+       For Local t$=EachIn lnk_files\r
+               t=CQuote(t)\r
+               If opt_dumpbuild Or (t[..1]="-" And t[..2]<>"-l")\r
+                       cmd:+" "+t\r
+               Else\r
+                       files:+" "+t\r
+               EndIf\r
+       Next\r
+\r
+       files="INPUT("+files+")"\r
+?\r
+       Local t$=getenv_( "BMK_LD_OPTS" )\r
+       If t \r
+               cmd:+" "+t\r
+       EndIf\r
+\r
+       Local stream:TStream=WriteStream( tmpfile )\r
+       stream.WriteBytes files.ToCString(),files.length\r
+       stream.Close\r
+       \r
+       If Sys( cmd ) Throw "Build Error: Failed to link "+path\r
+\r
+End Function\r