From 4e7f9e86e81af80de19f90b50632a1b579d9e4c3 Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Wed, 9 Dec 2015 09:41:34 -0600 Subject: [PATCH] Refactor MACOSX_USE_LIBSDL to USE_LIBSDL for windows and linux static library support (nw) --- makefile | 6 ++--- scripts/src/osd/sdl.lua | 54 ++++++++++++++++++++++--------------- scripts/src/osd/sdl_cfg.lua | 2 +- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/makefile b/makefile index 3f33bca63b3..88efddeb946 100644 --- a/makefile +++ b/makefile @@ -69,7 +69,7 @@ # SDL_INSTALL_ROOT = /opt/sdl2 # SDL_FRAMEWORK_PATH = $(HOME)/Library/Frameworks # SDL_LIBVER = sdl -# MACOSX_USE_LIBSDL = 1 +# USE_LIBSDL = 1 # CYGWIN_BUILD = 1 # BUILDDIR = build @@ -627,8 +627,8 @@ ifdef SDL_FRAMEWORK_PATH PARAMS += --SDL_FRAMEWORK_PATH='$(SDL_FRAMEWORK_PATH)' endif -ifdef MACOSX_USE_LIBSDL -PARAMS += --MACOSX_USE_LIBSDL='$(MACOSX_USE_LIBSDL)' +ifdef USE_LIBSDL +PARAMS += --USE_LIBSDL='$(USE_LIBSDL)' endif ifdef LDOPTS diff --git a/scripts/src/osd/sdl.lua b/scripts/src/osd/sdl.lua index 6acb5a2d262..fd8cf22b026 100644 --- a/scripts/src/osd/sdl.lua +++ b/scripts/src/osd/sdl.lua @@ -54,14 +54,20 @@ function maintargetosdoptions(_target,_subtarget) end if _OPTIONS["targetos"]=="windows" then - if _OPTIONS["SDL_LIBVER"]=="sdl2" then - links { - "SDL2.dll", - } + if _OPTIONS["USE_LIBSDL"]~="1" then + if _OPTIONS["SDL_LIBVER"]=="sdl2" then + links { + "SDL2.dll", + } + else + links { + "SDL.dll", + } + end else - links { - "SDL.dll", - } + local str = backtick(sdlconfigcmd() .. " --libs | sed 's/ -lSDLmain//'") + addlibfromstring(str) + addoptionsfromstring(str) end links { "psapi", @@ -192,16 +198,16 @@ if not _OPTIONS["SDL_FRAMEWORK_PATH"] then end newoption { - trigger = "MACOSX_USE_LIBSDL", - description = "Use SDL library on OS (rather than framework)", + trigger = "USE_LIBSDL", + description = "Use SDL library on OS (rather than framework/dll)", allowed = { - { "0", "Use framework" }, + { "0", "Use framework/dll" }, { "1", "Use library" }, }, } -if not _OPTIONS["MACOSX_USE_LIBSDL"] then - _OPTIONS["MACOSX_USE_LIBSDL"] = "0" +if not _OPTIONS["USE_LIBSDL"] then + _OPTIONS["USE_LIBSDL"] = "0" end @@ -255,7 +261,7 @@ if BASE_TARGETOS=="unix" then "-weak_framework Metal", } end - if _OPTIONS["MACOSX_USE_LIBSDL"]~="1" then + if _OPTIONS["USE_LIBSDL"]~="1" then linkoptions { "-F" .. _OPTIONS["SDL_FRAMEWORK_PATH"], } @@ -269,7 +275,7 @@ if BASE_TARGETOS=="unix" then } end else - local str = backtick(sdlconfigcmd() .. " --libs | sed 's/-lSDLmain//'") + local str = backtick(sdlconfigcmd() .. " --libs --static | sed 's/-lSDLmain//'") addlibfromstring(str) addoptionsfromstring(str) end @@ -529,14 +535,20 @@ if _OPTIONS["with-tools"] then } if _OPTIONS["targetos"] == "windows" then - if _OPTIONS["SDL_LIBVER"] == "sdl2" then - links { - "SDL2.dll", - } + if _OPTIONS["USE_LIBSDL"]~="1" then + if _OPTIONS["SDL_LIBVER"] == "sdl2" then + links { + "SDL2.dll", + } + else + links { + "SDL.dll", + } + end else - links { - "SDL.dll", - } + local str = backtick(sdlconfigcmd() .. " --libs | sed 's/ -lSDLmain//'") + addlibfromstring(str) + addoptionsfromstring(str) end links { "psapi", diff --git a/scripts/src/osd/sdl_cfg.lua b/scripts/src/osd/sdl_cfg.lua index dd902d1fe60..431443ac059 100644 --- a/scripts/src/osd/sdl_cfg.lua +++ b/scripts/src/osd/sdl_cfg.lua @@ -81,7 +81,7 @@ if BASE_TARGETOS=="unix" then "SDLMAME_UNIX", } if _OPTIONS["targetos"]=="macosx" then - if _OPTIONS["MACOSX_USE_LIBSDL"]~="1" then + if _OPTIONS["USE_LIBSDL"]~="1" then buildoptions { "-F" .. _OPTIONS["SDL_FRAMEWORK_PATH"], }