From 7792bc72305eda3a7bac52c4461fe11119595bb3 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Fri, 21 Jan 2022 12:48:10 -0500 Subject: [PATCH] [build] meson -Dlua_version=... to specify lua ver (thx herbmillerjr) x-ref: https://github.com/gentoo/gentoo/pull/23857 --- meson_options.txt | 5 +++++ src/meson.build | 42 +++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 3b9f366b..320a6df9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -166,3 +166,8 @@ option('moduledir', value: 'lib/lighttpd', description: 'Location to install modules to (relative to prefix)', ) + +option('lua_version', + type: 'string', + description: 'Look for a specific lua version', +) diff --git a/src/meson.build b/src/meson.build index b35c1037..b192e6f2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -396,32 +396,32 @@ endif liblua = [] if get_option('with_lua') - found_lua = false - foreach l: ['lua5.4', 'lua-5.4', 'lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua'] - if not(found_lua) + lua_version = get_option('lua_version') + if (lua_version != '') + liblua = dependency(lua_version, required: true) + else + found_lua = false + foreach l: ['lua5.4', 'lua-5.4', 'lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua'] liblua = dependency(l, required: false) - if (liblua.found()) - found_lua = true - else + if not(liblua.found()) liblua = compiler.find_library(l, required: false) - if (liblua.found()) - found_lua = true - liblua_found_header = false - foreach ib: include_base_paths - if not(liblua_found_header) - i = join_paths(ib, l) - if compiler.has_header(join_paths(i, 'lua.h')) - liblua_found_header = true - liblua += [ declare_dependency(include_directories: include_directories(i)) ] - endif - endif - endforeach + if not(liblua.found()) + continue endif + foreach ib: include_base_paths + i = join_paths(ib, l) + if compiler.has_header(join_paths(i, 'lua.h')) + liblua += [ declare_dependency(include_directories: include_directories(i)) ] + break + endif + endforeach endif + found_lua = true + break + endforeach + if not(found_lua) + error('Couldn\'t find any lua library') endif - endforeach - if not(found_lua) - error('Couldn\'t find any lua library') endif liblua = [ liblua ] conf_data.set('HAVE_LUA_H', true)