diff options
author | 2016-03-28 12:09:19 -0500 | |
---|---|---|
committer | 2016-03-28 22:26:52 -0500 | |
commit | 9d9c8fad6a0e5ff433fd6a97b4921af10e074f96 (patch) | |
tree | a7382cf895f9dd372061d8bf3094ed59046fe1ce /scripts/extlib.lua | |
parent | 6cb951b7c42d87e4b52604ecbd5317b6fc8f9665 (diff) |
Extend system library support (nw)
Extend USE_SYSTEM_LIB_* to support providing the library name and include directory.
To link against system specific lib names and header path: (ref #711)
USE_SYSTEM_LIB_LUA=lua5.3:/usr/include/lua5.3
Diffstat (limited to 'scripts/extlib.lua')
-rw-r--r-- | scripts/extlib.lua | 99 |
1 files changed, 99 insertions, 0 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 |