diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/extlib.lua | 99 | ||||
-rw-r--r-- | scripts/genie.lua | 55 | ||||
-rw-r--r-- | scripts/src/3rdparty.lua | 52 | ||||
-rw-r--r-- | scripts/src/devices.lua | 24 | ||||
-rw-r--r-- | scripts/src/emu.lua | 15 | ||||
-rw-r--r-- | scripts/src/lib.lua | 19 | ||||
-rw-r--r-- | scripts/src/main.lua | 51 | ||||
-rw-r--r-- | scripts/src/netlist.lua | 7 | ||||
-rw-r--r-- | scripts/src/tests.lua | 6 | ||||
-rw-r--r-- | scripts/src/tools.lua | 296 |
10 files changed, 196 insertions, 428 deletions
diff --git a/scripts/extlib.lua b/scripts/extlib.lua new file mode 100644 index 00000000000..6231ebbf8e1 --- /dev/null +++ b/scripts/extlib.lua @@ -0,0 +1,99 @@ +-- license:BSD-3-Clause +-- copyright-holders:MAMEdev Team,Jeffrey Clark + +local extlibs = { +-- +-- 3rdparty system 3rdparty +-- lib name: lib name, include dir +-- + expat = { "expat", "3rdparty/expat/lib" }, + zlib = { "z", "3rdparty/zlib" }, + jpeg = { "jpeg", "3rdparty/libjpeg" }, + flac = { "FLAC", "3rdparty/libflac/include/FLAC" }, + sqlite3 = { "sqlite3", "3rdparty/sqlite3" }, + portmidi = { "portmidi", "3rdparty/portmidi/pm_common" }, + portaudio = { "portaudio", "3rdparty/portaudio/include" }, + lua = { "lua", "3rdparty/lua/src" }, + uv = { "uv" , "3rdparty/libuv/include" }, +} + +-- system lib options +newoption { + trigger = 'with-system-expat', + description = 'Use system Expat library', +} + +newoption { + trigger = 'with-system-zlib', + description = 'Use system Zlib library', +} + +newoption { + trigger = 'with-system-jpeg', + description = 'Use system JPEG library', +} + +newoption { + trigger = 'with-system-flac', + description = 'Use system FLAC library', +} + +newoption { + trigger = 'with-system-sqlite3', + description = 'Use system SQLite library', +} + +newoption { + trigger = 'with-system-portmidi', + description = 'Use system PortMidi library', +} + +newoption { + trigger = 'with-system-portaudio', + description = 'Use system PortAudio library', +} + +newoption { + trigger = "with-system-lua", + description = "Use system LUA library", +} + +newoption { + trigger = 'with-system-uv', + description = 'Use system uv library', +} + +-- build helpers +function ext_lib(lib) + local opt = _OPTIONS["with-system-" .. lib] + if (opt~=nil and opt=="1") then + default = extlibs[lib][1] + else + default = lib + end + return ext_best(lib, default, 1) +end + +function ext_includedir(lib) + local opt = _OPTIONS["with-system-" .. lib] + if (opt==nil or opt=="0") then + -- using bundled, prepend MAME_DIR + default = MAME_DIR .. extlibs[lib][2] + else + default = "/usr/include/" .. lib + end + return ext_best(lib, default, 2) +end + +function ext_best(lib, default, idx) + local opt = _OPTIONS["with-system-" .. lib] + local found = default + if (opt~=nil and opt~="0" and opt~="1") then + -- override default if provided (format <libname:includedir>) + local x = opt:explode(":") + if x[idx]~=nil then + found = x[idx] + end + end + return found +end diff --git a/scripts/genie.lua b/scripts/genie.lua index 219b493f135..645bf99ed8f 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -120,56 +120,11 @@ newoption { } newoption { - trigger = 'with-bundled-expat', - description = 'Build bundled Expat library', -} - -newoption { - trigger = 'with-bundled-zlib', - description = 'Build bundled Zlib library', -} - -newoption { - trigger = 'with-bundled-jpeg', - description = 'Build bundled JPEG library', -} - -newoption { - trigger = 'with-bundled-flac', - description = 'Build bundled FLAC library', -} - -newoption { - trigger = 'with-bundled-lua', - description = 'Build bundled LUA library', -} - -newoption { - trigger = 'with-bundled-sqlite3', - description = 'Build bundled SQLite library', -} - -newoption { - trigger = 'with-bundled-portmidi', - description = 'Build bundled PortMidi library', -} - -newoption { - trigger = 'with-bundled-portaudio', - description = 'Build bundled PortAudio library', -} - -newoption { trigger = 'with-bundled-sdl2', description = 'Build bundled SDL2 library', } newoption { - trigger = 'with-bundled-libuv', - description = 'Build bundled libuv library', -} - -newoption { trigger = "distro", description = "Choose distribution", allowed = { @@ -411,6 +366,8 @@ newoption { } } +dofile("extlib.lua") + if _OPTIONS["SHLIB"]=="1" then LIBTYPE = "SharedLib" else @@ -666,25 +623,25 @@ else end -- need to ensure FLAC functions are statically linked -if _OPTIONS["with-bundled-flac"] then +if not _OPTIONS["with-system-flac"] then defines { "FLAC__NO_DLL", } end -if not _OPTIONS["with-bundled-jpeg"] then +if _OPTIONS["with-system-jpeg"] then defines { "USE_SYSTEM_JPEGLIB", } end -if not _OPTIONS["with-bundled-portmidi"] then +if _OPTIONS["with-system-portmidi"] then defines { "USE_SYSTEM_PORTMIDI", } end -if not _OPTIONS["with-bundled-sqlite3"] then +if _OPTIONS["with-system-sqlite3"] then defines { "USE_SYSTEM_SQLITE", } diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index 688615cbbc3..5819eb54b2a 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -13,7 +13,7 @@ -- expat library objects -------------------------------------------------- -if _OPTIONS["with-bundled-expat"] then +if not _OPTIONS["with-system-expat"] then project "expat" uuid "f4cd40b1-c37c-452d-9785-640f26f0bf54" kind "StaticLib" @@ -45,7 +45,7 @@ end } else links { - "expat", + ext_lib("expat"), } end @@ -53,7 +53,7 @@ end -- zlib library objects -------------------------------------------------- -if _OPTIONS["with-bundled-zlib"] then +if not _OPTIONS["with-system-zlib"] then project "zlib" uuid "3d78bd2a-2bd0-4449-8087-42ddfaef7ec9" kind "StaticLib" @@ -110,7 +110,7 @@ end } else links { - "z", + ext_lib("zlib"), } end @@ -152,7 +152,7 @@ end -- libJPEG library objects -------------------------------------------------- -if _OPTIONS["with-bundled-jpeg"] then +if not _OPTIONS["with-system-jpeg"] then project "jpeg" uuid "447c6800-dcfd-4c48-b72a-a8223bb409ca" kind "StaticLib" @@ -221,7 +221,7 @@ end } else links { - "jpeg", + ext_lib("jpeg"), } end @@ -229,7 +229,7 @@ end -- libflac library objects -------------------------------------------------- -if _OPTIONS["with-bundled-flac"] then +if not _OPTIONS["with-system-flac"] then project "flac" uuid "b6fc19e8-073a-4541-bb7b-d24b548d424a" kind "StaticLib" @@ -312,7 +312,7 @@ end } else links { - "FLAC", + ext_lib("flac"), } end @@ -370,7 +370,7 @@ end -- LUA library objects -------------------------------------------------- -if _OPTIONS["with-bundled-lua"] then +if not _OPTIONS["with-system-lua"] then project "lua" uuid "d9e2eed1-f1ab-4737-a6ac-863700b1a5a9" kind "StaticLib" @@ -460,7 +460,7 @@ end } else links { - "lua", + ext_lib("lua"), } end @@ -493,16 +493,10 @@ project "lualibs" includedirs { MAME_DIR .. "3rdparty", } - if _OPTIONS["with-bundled-lua"] then - includedirs { - MAME_DIR .. "3rdparty/lua/src", - } - end - if _OPTIONS["with-bundled-zlib"] then - includedirs { - MAME_DIR .. "3rdparty/zlib", - } - end + includedirs { + ext_includedir("lua"), + ext_includedir("zlib"), + } files { MAME_DIR .. "3rdparty/lsqlite3/lsqlite3.c", @@ -514,7 +508,7 @@ project "lualibs" -- SQLite3 library objects -------------------------------------------------- -if _OPTIONS["with-bundled-sqlite3"] then +if not _OPTIONS["with-system-sqlite3"] then project "sqllite3" uuid "5cb3d495-57ed-461c-81e5-80dc0857517d" kind "StaticLib" @@ -565,7 +559,7 @@ end } else links { - "sqlite3", + ext_lib("sqlite3"), } end @@ -573,7 +567,7 @@ end -- portmidi library objects -------------------------------------------------- if _OPTIONS["NO_USE_MIDI"]~="1" then -if _OPTIONS["with-bundled-portmidi"] then +if not _OPTIONS["with-system-portmidi"] then project "portmidi" uuid "587f2da6-3274-4a65-86a2-f13ea315bb98" kind "StaticLib" @@ -652,7 +646,7 @@ end end else links { - "portmidi", + ext_lib("portmidi"), } end end @@ -808,7 +802,7 @@ end -- PortAudio library objects -------------------------------------------------- -if _OPTIONS["with-bundled-portaudio"] then +if not _OPTIONS["with-system-portaudio"] then project "portaudio" uuid "0755c5f5-eccf-47f3-98a9-df67018a94d4" kind "StaticLib" @@ -953,7 +947,7 @@ end else links { - "portaudio", + ext_lib("portaudio"), } end @@ -961,7 +955,7 @@ end -- libuv library objects -------------------------------------------------- if _OPTIONS["USE_LIBUV"]=="1" then -if _OPTIONS["with-bundled-libuv"] then +if not _OPTIONS["with-system-uv"] then project "uv" uuid "cd2afe7f-139d-49c3-9000-fc9119f3cea0" kind "StaticLib" @@ -1173,7 +1167,7 @@ project "http-parser" else links { - "libuv", + ext_lib("uv"), } end -------------------------------------------------- @@ -1671,4 +1665,4 @@ end MAME_DIR .. "3rdparty/SDL2/include", } -end
\ No newline at end of file +end diff --git a/scripts/src/devices.lua b/scripts/src/devices.lua index c4a6c9fe0ac..3922d3328ac 100644 --- a/scripts/src/devices.lua +++ b/scripts/src/devices.lua @@ -37,17 +37,9 @@ function devicesProject(_target, _subtarget) MAME_DIR .. "3rdparty", GEN_DIR .. "emu", GEN_DIR .. "emu/layout", + ext_includedir("expat"), + ext_includedir("lua"), } - if _OPTIONS["with-bundled-expat"] then - includedirs { - MAME_DIR .. "3rdparty/expat/lib", - } - end - if _OPTIONS["with-bundled-lua"] then - includedirs { - MAME_DIR .. "3rdparty/lua/src", - } - end dofile(path.join("src", "cpu.lua")) @@ -75,17 +67,9 @@ if #disasm_files > 0 then MAME_DIR .. "src/lib/util", MAME_DIR .. "3rdparty", GEN_DIR .. "emu", + ext_includedir("expat"), + ext_includedir("lua"), } - if _OPTIONS["with-bundled-expat"] then - includedirs { - MAME_DIR .. "3rdparty/expat/lib", - } - end - if _OPTIONS["with-bundled-lua"] then - includedirs { - MAME_DIR .. "3rdparty/lua/src", - } - end files { disasm_files diff --git a/scripts/src/emu.lua b/scripts/src/emu.lua index a2983d4bd78..7e39c71e357 100644 --- a/scripts/src/emu.lua +++ b/scripts/src/emu.lua @@ -30,16 +30,11 @@ includedirs { GEN_DIR .. "emu", GEN_DIR .. "emu/layout", } -if _OPTIONS["with-bundled-expat"] then - includedirs { - MAME_DIR .. "3rdparty/expat/lib", - } -end -if _OPTIONS["with-bundled-lua"] then - includedirs { - MAME_DIR .. "3rdparty/lua/src", - } -end + +includedirs { + ext_includedir("expat"), + ext_includedir("lua"), +} if (_OPTIONS["targetos"] == "windows" and _OPTIONS["osd"] ~= "osdmini") then defines { diff --git a/scripts/src/lib.lua b/scripts/src/lib.lua index 6890bceb5bc..18d6563edfa 100644 --- a/scripts/src/lib.lua +++ b/scripts/src/lib.lua @@ -19,17 +19,9 @@ project "utils" MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", MAME_DIR .. "3rdparty", + ext_includedir("expat"), + ext_includedir("zlib"), } - if _OPTIONS["with-bundled-expat"] then - includedirs { - MAME_DIR .. "3rdparty/expat/lib", - } - end - if _OPTIONS["with-bundled-zlib"] then - includedirs { - MAME_DIR .. "3rdparty/zlib", - } - end files { MAME_DIR .. "src/lib/util/bitstream.h", @@ -119,14 +111,9 @@ project "formats" MAME_DIR .. "src/lib", MAME_DIR .. "src/lib/util", MAME_DIR .. "3rdparty", + ext_includedir("zlib"), } - if _OPTIONS["with-bundled-zlib"] then - includedirs { - MAME_DIR .. "3rdparty/zlib", - } - end - files { MAME_DIR .. "src/lib/formats/2d_dsk.cpp", MAME_DIR .. "src/lib/formats/2d_dsk.h", diff --git a/scripts/src/main.lua b/scripts/src/main.lua index 9914509184e..52211bf92fe 100644 --- a/scripts/src/main.lua +++ b/scripts/src/main.lua @@ -192,53 +192,29 @@ if #disasm_files > 0 then end links { "utils", - "expat", + ext_lib("expat"), "softfloat", - "jpeg", + ext_lib("jpeg"), "7z", - "lua", + ext_lib("lua"), "lualibs", } if _OPTIONS["USE_LIBUV"]=="1" then links { - "uv", + ext_lib("uv"), "http-parser", } end - if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } - else - links { - "z", - } - end - - if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } - else - links { - "FLAC", - } - end - - if _OPTIONS["with-bundled-sqlite3"] then - links { - "sqllite3", - } - else - links { - "sqlite3", - } - end + links { + ext_lib("zlib"), + ext_lib("flac"), + ext_lib("sqlite3"), + } if _OPTIONS["NO_USE_MIDI"]~="1" then links { - "portmidi", + ext_lib("portmidi"), } end links { @@ -260,14 +236,9 @@ end MAME_DIR .. "3rdparty", GEN_DIR .. _target .. "/layout", GEN_DIR .. "resource", + ext_includedir("zlib"), } - if _OPTIONS["with-bundled-zlib"] then - includedirs { - MAME_DIR .. "3rdparty/zlib", - } - end - if _OPTIONS["targetos"]=="macosx" and (not override_resources) then linkoptions { "-sectcreate __TEXT __info_plist " .. _MAKE.esc(GEN_DIR) .. "resource/" .. _subtarget .. "-Info.plist" diff --git a/scripts/src/netlist.lua b/scripts/src/netlist.lua index 917a450d511..95d0371e414 100644 --- a/scripts/src/netlist.lua +++ b/scripts/src/netlist.lua @@ -19,13 +19,8 @@ project "netlist" MAME_DIR .. "src/lib/netlist", MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", + -- ext_includedir("expat"), } - -- if _OPTIONS["with-bundled-expat"] then - -- includedirs { - -- MAME_DIR .. "3rdparty/expat/lib", - -- } - --end - files { MAME_DIR .. "src/lib/netlist/nl_config.h", diff --git a/scripts/src/tests.lua b/scripts/src/tests.lua index e69888d53a4..b6a01efdd02 100644 --- a/scripts/src/tests.lua +++ b/scripts/src/tests.lua @@ -62,8 +62,8 @@ project("mametests") links { "gtest", "utils", - "expat", - "zlib", + ext_lib("expat"), + ext_lib("zlib"), "ocore_" .. _OPTIONS["osd"], } @@ -72,6 +72,8 @@ project("mametests") MAME_DIR .. "src/osd", MAME_DIR .. "src/emu", MAME_DIR .. "src/lib/util", + ext_includedir("expat"), + ext_includedir("zlib"), } files { diff --git a/scripts/src/tools.lua b/scripts/src/tools.lua index 0339e9920b2..95710ad9799 100644 --- a/scripts/src/tools.lua +++ b/scripts/src/tools.lua @@ -27,21 +27,12 @@ end links { "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -77,31 +68,13 @@ end links { "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -139,20 +112,11 @@ end links { "utils", - "expat", + ext_lib("expat"), "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -189,31 +153,13 @@ end links { "dasm", "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/emu", @@ -251,31 +197,13 @@ end links { "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -312,31 +240,13 @@ end links { "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -373,20 +283,11 @@ end links { "utils", - "expat", + ext_lib("expat"), "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -422,20 +323,11 @@ end links { "utils", - "expat", + ext_lib("expat"), "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -471,20 +363,11 @@ end links { "utils", - "expat", + ext_lib("expat"), "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -520,31 +403,13 @@ end links { "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -580,20 +445,11 @@ end links { "utils", - "expat", + ext_lib("expat"), "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -629,32 +485,14 @@ end links { "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], "netlist", + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib/util", @@ -732,31 +570,13 @@ end links { "formats", "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib", @@ -795,31 +615,13 @@ links { "formats", "emu", "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib", @@ -858,36 +660,18 @@ links { "formats", "emu", "utils", - "expat", + ext_lib("expat"), "7z", "ocore_" .. _OPTIONS["osd"], + ext_lib("zlib"), + ext_lib("flac"), } -if _OPTIONS["with-bundled-zlib"] then - links { - "zlib", - } -else - links { - "z", - } -end - -if _OPTIONS["with-bundled-flac"] then - links { - "flac", - } -else - links { - "FLAC", - } -end - includedirs { MAME_DIR .. "src/osd", MAME_DIR .. "src/lib", MAME_DIR .. "src/lib/util", - MAME_DIR .. "3rdparty/zlib", + ext_includedir("zlib"), MAME_DIR .. "src/tools/imgtool", } |