Browse code

app_lua: Makefile - reworked detection of lua version with support for 5.3 and 5.4

Daniel-Constantin Mierla authored on 24/01/2022 12:36:59
Showing 1 changed files
... ...
@@ -5,6 +5,8 @@ include ../../Makefile.defs
5 5
 auto_gen=
6 6
 NAME=app_lua.so
7 7
 
8
+LUALIB=lua
9
+
8 10
 ifeq ($(LUAJIT),)
9 11
 	ifeq ($(CROSS_COMPILE),)
10 12
 		BUILDER = $(shell which lua-config)
... ...
@@ -15,78 +17,53 @@ ifeq ($(LUAJIT),)
15 17
 			BUILDER = $(shell which pkg-config)
16 18
 		endif
17 19
 		ifeq ($(BUILDER),)
18
-			LUA51 = $(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.1)
19
-			DEFS+= -I$(LOCALBASE)/include
20
-			LIBS+= -L$(LOCALBASE)/lib -lm
21
-			ifneq ($(LUA51),)
22
-				DEFS+= -I$(LOCALBASE)/include/lua5.1
23
-				LIBS+= -llua5.1
24
-			else
25
-				LUA52 = $(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.2)
26
-				ifneq ($(LUA52),)
27
-					DEFS+= -DLUA_COMPAT_MODULE -I$(LOCALBASE)/include/lua5.2
28
-					LIBS+= -llua5.2
29
-				else
30
-					DEFS+= -DLUA_COMPAT_MODULE -I$(LOCALBASE)/include/lua
31
-					LIBS+= -llua
32
-				endif
20
+			ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.1),)
21
+				LUALIB=lua5.1
22
+			else ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.2),)
23
+				LUALIB=lua5.2
24
+			else ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.3),)
25
+				LUALIB=lua5.3
26
+			else ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.4),)
27
+				LUALIB=lua5.4
33 28
 			endif
29
+			DEFS+= -I$(LOCALBASE)/include -DLUA_COMPAT_MODULE -I$(LOCALBASE)/include/$(LUALIB)
30
+			LIBS+= -L$(LOCALBASE)/lib -l$(LUALIB) -lm
34 31
 		else
35
-			LUAVER=XX
36
-			LUALIBS = $(shell pkg-config --silence-errors --libs lua-5.1)
37
-			ifeq ($(LUALIBS),)
38
-				LUALIBS = $(shell pkg-config --silence-errors --libs lua5.1)
39
-				ifeq ($(LUALIBS),)
40
-					LUALIBS = $(shell pkg-config --silence-errors --libs lua5.2)
41
-					ifeq ($(LUALIBS),)
42
-						LUALIBS = $(shell pkg-config --silence-errors --libs lua)
43
-						ifneq ($(LUALIBS),)
44
-							LUAVER=5X
45
-						endif
46
-					else
47
-						LUAVER=52
48
-					endif
49
-				else
50
-					LUAVER=51
51
-				endif
32
+			ifneq ($(shell pkg-config --silence-errors --libs lua-5.1),)
33
+				LUALIB=lua-5.1
34
+			else ifneq ($(shell pkg-config --silence-errors --libs lua5.1),)
35
+				LUALIB=lua5.1
36
+			else ifneq ($(shell pkg-config --silence-errors --libs lua5.2),)
37
+				LUALIB=lua5.2
38
+			else ifneq ($(shell pkg-config --silence-errors --libs lua5.3),)
39
+				LUALIB=lua5.3
40
+			else ifneq ($(shell pkg-config --silence-errors --libs lua5.4),)
41
+				LUALIB=lua5.4
42
+			else ifneq ($(shell pkg-config --silence-errors --libs lua),)
43
+				LUALIB=lua
52 44
 			else
53
-				LUAVER=51X
45
+				LUALIB=
54 46
 			endif
55
-			ifeq ($(LUAVER),XX)
56
-				LUA51 = $(shell ls /usr/lib/liblua* | grep liblua5.1)
57
-				ifneq ($(LUA51),)
58
-					DEFS+= -I/usr/include/lua5.1
59
-					LIBS = -llua5.1 -lm
60
-				else
61
-					LUA52 = $(shell ls /usr/lib/liblua* | grep liblua5.2)
62
-					ifneq ($(LUA51),)
63
-						DEFS+= -DLUA_COMPAT_MODULE -I/usr/include/lua5.2
64
-						LIBS = -llua5.2 -lm
65
-					else
66
-						DEFS+= -DLUA_COMPAT_MODULE -I/usr/include/lua
67
-						LIBS = -llua -lm
68
-					endif
69
-				endif
47
+			ifeq ($(LUALIB),lua5.1)
48
+				DEFS+= $(shell pkg-config --cflags lua5.1 | sed -e "s/\\\\/'/" -e "s/\\\\\"/\"'/")
49
+				LIBS = $(shell pkg-config --libs lua5.1)
50
+			else ifneq ($(LUALIB),)
51
+				DEFS+= -DLUA_COMPAT_MODULE
52
+				DEFS+= $(shell pkg-config --cflags $(LUALIB))
53
+				LIBS = $(shell pkg-config --libs $(LUALIB))
70 54
 			else
71
-				ifeq ($(LUAVER),51)
72
-					DEFS+= $(shell pkg-config --cflags lua5.1 | sed -e "s/\\\\/'/" -e "s/\\\\\"/\"'/")
73
-					LIBS = $(shell pkg-config --libs lua5.1)
74
-				else
75
-					ifeq ($(LUAVER),51X)
76
-						DEFS+= $(shell pkg-config --cflags lua-5.1)
77
-						LIBS = $(shell pkg-config --libs lua-5.1)
78
-					else
79
-						ifeq ($(LUAVER),52)
80
-							DEFS+= -DLUA_COMPAT_MODULE
81
-							DEFS+= $(shell pkg-config --cflags lua5.2)
82
-							LIBS = $(shell pkg-config --libs lua5.2)
83
-						else
84
-							DEFS+= -DLUA_COMPAT_MODULE
85
-							DEFS+= $(shell pkg-config --cflags lua)
86
-							LIBS = $(shell pkg-config --libs lua)
87
-						endif
88
-					endif
55
+				LUALIB=lua
56
+				ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.1),)
57
+					LUALIB=lua5.1
58
+				else ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.2),)
59
+					LUALIB=lua5.2
60
+				else ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.3),)
61
+					LUALIB=lua5.3
62
+				else ifneq ($(shell ls $(LOCALBASE)/lib/liblua* | grep liblua5.4),)
63
+					LUALIB=lua5.4
89 64
 				endif
65
+				DEFS+= -I$(LOCALBASE)/include -DLUA_COMPAT_MODULE -I$(LOCALBASE)/include/$(LUALIB)
66
+				LIBS+= -L$(LOCALBASE)/lib -l$(LUALIB) -lm
90 67
 			endif
91 68
 		endif
92 69
 	else