@@ -88,6 +88,7 @@ type FBCCTX
8888 '' are multiple lists necessary to allow each module to start fresh
8989 '' with the same input libs)
9090 finallibs as TSTRSET
91+ finalframeworks as TSTRSET
9192 finallibpaths as TSTRSET
9293
9394 outname as zstring * FB_MAXPATHLEN+ 1
@@ -214,6 +215,7 @@ private sub fbcInit( )
214215 strsetInit( @fbc.excludedlibs, FBC_INITFILES\ 4 )
215216
216217 strsetInit( @fbc.finallibs, FBC_INITFILES\ 2 )
218+ strsetInit( @fbc.finalframeworks, FBC_INITFILES\ 2 )
217219 strsetInit( @fbc.finallibpaths, FBC_INITFILES\ 2 )
218220
219221 fbGlobalInit()
@@ -1162,9 +1164,9 @@ private function hLinkFiles( ) as integer
11621164 ldcline += hFindLib( "crt0.o" )
11631165 end if
11641166
1165- case FB_COMPTARGET_LINUX, FB_COMPTARGET_DARWIN , _
1166- FB_COMPTARGET_FREEBSD, FB_COMPTARGET_OPENBSD , _
1167- FB_COMPTARGET_NETBSD, FB_COMPTARGET_DRAGONFLY, FB_COMPTARGET_SOLARIS
1167+ case FB_COMPTARGET_LINUX, FB_COMPTARGET_FREEBSD , _,
1168+ FB_COMPTARGET_OPENBSD, FB_COMPTARGET_NETBSD , _,
1169+ FB_COMPTARGET_DRAGONFLY, FB_COMPTARGET_SOLARIS
11681170
11691171 if ( fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_EXECUTABLE) then
11701172 if ( fbGetOption( FB_COMPOPT_PROFILE ) ) then
@@ -1286,6 +1288,15 @@ private function hLinkFiles( ) as integer
12861288 wend
12871289 end scope
12881290
1291+ '' Add frameworks for Darwin
1292+ scope
1293+ dim as TSTRSETITEM ptr i = listGetHead( @fbc.finalframeworks.list)
1294+ while (i)
1295+ ldcline += " -framework " + i->s
1296+ i = listGetNext(i)
1297+ wend
1298+ end scope
1299+
12891300 if (fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_DARWIN) then
12901301 if ( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) then
12911302 '' End of lib group
@@ -1322,18 +1333,13 @@ private function hLinkFiles( ) as integer
13221333
13231334 end select
13241335
1325- if ( fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DARWIN ) then
1326- ldcline += " -macosx_version_min 10.4"
1327- end if
1328-
13291336 '' This is required for 64-bit modules on *nix-y platforms
13301337 '' for the unwind tables to have any effect
13311338 '' Windows doesn't need this option
13321339 select case as const fbGetOption( FB_COMPOPT_TARGET )
13331340 case FB_COMPTARGET_LINUX, FB_COMPTARGET_FREEBSD, _
13341341 FB_COMPTARGET_OPENBSD, FB_COMPTARGET_NETBSD, _
1335- FB_COMPTARGET_DRAGONFLY, FB_COMPTARGET_SOLARIS, _
1336- FB_COMPTARGET_DARWIN
1342+ FB_COMPTARGET_DRAGONFLY, FB_COMPTARGET_SOLARIS
13371343 dim as long outtype = fbGetOption( FB_COMPOPT_OUTTYPE )
13381344 if outtype = FB_OUTTYPE_EXECUTABLE OrElse outtype = FB_OUTTYPE_DYNAMICLIB Then
13391345 dim as long cpufamily = fbGetCpuFamily( )
@@ -1404,6 +1410,12 @@ private function hLinkFiles( ) as integer
14041410 end if
14051411 # endif
14061412
1413+ if fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DARWIN then
1414+ dim as string sdkpath = hGet1stOutputLineFromCommand( "xcrun --show-sdk-path" )
1415+ ldcline += " -L" + sdkpath + "/usr/lib"
1416+ ldcline += " -F" + sdkpath + "/System/Library/Frameworks"
1417+ end if
1418+
14071419 '' invoke ld
14081420 var ld = FBCTOOL_LD
14091421 if ( fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_JS ) then
@@ -4201,7 +4213,9 @@ private sub hSetDefaultLibPaths( )
42014213 case FB_COMPTARGET_JS
42024214 '' We let emcc handle linking
42034215 case else
4204- fbcAddLibPathFor( "libgcc.a" )
4216+ if fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_DARWIN then
4217+ fbcAddLibPathFor( "libgcc.a" )
4218+ end if
42054219
42064220 #ifndef DISABLE_STDCXX_PATH
42074221 '' we don't specifically need c++, but for some users that do want to
@@ -4212,6 +4226,8 @@ private sub hSetDefaultLibPaths( )
42124226 fbcAddLibPathFor( "libc++.so" )
42134227 case FB_COMPTARGET_DOS
42144228 fbcAddLibPathFor( "libstdcx.a" )
4229+ case FB_COMPTARGET_DARWIN
4230+ fbcAddLibPathFor( "libc++.dylib" )
42154231 case else
42164232 fbcAddLibPathFor( "libstdc++.so" )
42174233 end select
@@ -4237,6 +4253,10 @@ private sub fbcAddDefLib(byval libname as zstring ptr)
42374253 strsetAdd( @fbc.finallibs, *libname, TRUE )
42384254end sub
42394255
4256+ private sub fbcAddDefFramework( byref framework as string )
4257+ strsetAdd( @fbc.finalframeworks, framework, TRUE )
4258+ end sub
4259+
42404260private function hGetFbLibNameSuffix( ) as string
42414261 dim s as string
42424262 if ( fbGetOption( FB_COMPOPT_MULTITHREADED ) ) then
@@ -4279,7 +4299,14 @@ private sub hAddDefaultLibs( )
42794299 # endif
42804300
42814301 # if defined(__FB_DARWIN__) and defined(ENABLE_XQUARTZ)
4282- fbcAddDefLibPAth( "/opt/X11/lib" )
4302+ fbcAddDefLibPath( "/opt/X11/lib" )
4303+ # else
4304+ if fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DARWIN then
4305+ fbcAddDefFramework( "Foundation" )
4306+ fbcAddDefFramework( "AppKit" )
4307+ fbcAddDefFramework( "OpenGL" )
4308+ fbcAddDefFramework( "Cocoa" )
4309+ end if
42834310 # endif
42844311
42854312 # if ( not defined(__FB_DARWIN__)) or defined(ENABLE_XQUARTZ)
@@ -4289,7 +4316,6 @@ private sub hAddDefaultLibs( )
42894316 fbcAddDefLib( "Xrandr" )
42904317 fbcAddDefLib( "Xrender" )
42914318 # endif
4292-
42934319 case FB_COMPTARGET_ANDROID
42944320 errReportEx( FB_ERRMSG_GFXLIBNOTSUPPORTEDFORTARGET, "" , - 1 )
42954321
@@ -4309,7 +4335,6 @@ private sub hAddDefaultLibs( )
43094335 end if
43104336
43114337 case FB_COMPTARGET_DARWIN
4312- fbcAddDefLib( "gcc" )
43134338 fbcAddDefLib( "System" )
43144339 fbcAddDefLib( "pthread" )
43154340 fbcAddDefLib( "ncurses" )
0 commit comments