summaryrefslogtreecommitdiffstats
path: root/recipes-extended/diod/files/0001-build-Find-lua-with-pkg-config.patch
blob: 9f61792ae26f55ea605cbef6bc65693e38c1376b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From 8124eec4e59222f1c3f3dc4d7e6706e13c33755c Mon Sep 17 00:00:00 2001
From: Ola x Nilsson <olani@axis.com>
Date: Wed, 6 Mar 2024 18:40:16 +0100
Subject: [PATCH] build: Find lua with pkg-config

ax_lua.m4 does not support cross compilation.

Upstream-Status: Inappropriate (Embedded specific)

---
 configure.ac | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e8fcdb2..f3ebdc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,7 +121,31 @@ AC_ARG_ENABLE([config],
   [AS_HELP_STRING([--disable-config], [disable lua config file support])])
 
 AS_IF([test "x$enable_config" != "xno"], [
-  AX_PROG_LUA([5.1],[5.5])
+  dnl Use pkg_config to check for lua settings.  This is not standard
+  dnl as lua typically does not distribute a pc file.  The
+  dnl OpenEmbedded recipe adds one that can be used.  Reuse/replicate
+  dnl as much of AX_PROG_LUA as possible so AX_LUA_HEADERS and
+  dnl AX_LUA_LIBS are still usable.
+  PKG_CHECK_EXISTS([lua], [
+    AS_IF([
+      $PKG_CONFIG --atleast-version=5.1 lua && $PKG_CONFIG --max-version=5.5 lua
+    ],[
+      AC_ARG_VAR([LUA], [The LUA interpreter, e.g. /usr/bin/lua5.1])
+	  dnl should really check that the file exists ...
+      AC_SUBST([LUA], [${bindir}/lua])
+	  AC_CACHE_CHECK([for $LUA version], [ax_cv_lua_version], [
+	    ax_cv_lua_version=[`$PKG_CONFIG --modversion lua | $SED 's/^\([0-9]\+\.[0-9]\+\).*/\1/'`]
+      ])
+	  AS_IF([test "x$ax_cv_lua_version" = 'x'],
+       [AC_MSG_ERROR([invalid Lua version number])])
+      AC_SUBST([LUA_VERSION], [$ax_cv_lua_version])
+      AC_SUBST([LUA_SHORT_VERSION], [`echo "$LUA_VERSION" | $SED 's|\.||'`])
+    ],[
+	  AC_MSG_ERROR([Incorrect lua version])
+	])
+  ],[
+    AX_PROG_LUA([5.1],[5.5])
+  ])
   AX_LUA_HEADERS([],[
     AC_MSG_ERROR([Install lua headers or configure with --disable-config])
   ])