diff options
author | Tamas TEVESZ <ice@extreme.hu> | 2023-01-21 12:00:33 +0100 |
---|---|---|
committer | Tamas TEVESZ <ice@extreme.hu> | 2023-01-21 12:00:33 +0100 |
commit | 5c2e0a19e26a99e899751f72f9715fd35f3131eb (patch) | |
tree | 53b1b000590a2874ac52e3cb62249dd65d59eeaf | |
parent | b4cfc3fef326f78b8c683707f0819886ddcd82bd (diff) |
Attempt to fix the Lua version situation
Drawing heavily on #589 by @dlbeer, attempt to fix the utter
nonsense pkg-config and all various distributors brought on the
world by
- Normalising 'lua-X.Y' and 'luaXY' notations to mean the same thing
- Handle both notations existing on the system correctly
- Picking the numerically highest version
There is also an option to override this autodetection mechanism by
setting the `LUA_PKGNAME` environment variable prior to kicking a
build off, resulting in the specified Lua package to be used.
Tested to be working on FreeBSD 13.1, Ubuntu 22.04 and Debian 11.
-rwxr-xr-x | src/Makefile | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Makefile b/src/Makefile index defd77a..0915f41 100755 --- a/src/Makefile +++ b/src/Makefile @@ -134,12 +134,13 @@ ifneq (, $(shell which pkg-config)) endif # NOTE: lua support - ifneq ($(shell pkg-config --exists lua || echo 'no'),no) # Check for user's default lua - CFLAGS += -DXLUA $(shell pkg-config --cflags lua) + LUA_PKGNAME ?= $(shell pkg-config --list-all | awk '/^lua-?[0-9.]+[[:space:]]/ { p=$$1; gsub("[^[0-9]", "", p); print p " " $$1; }' | LC_ALL=C sort -nrk1 | uniq | head -n 1 | awk '{print $$2}') + ifneq ($(LUA_PKGNAME),) + CFLAGS += -DXLUA $(shell pkg-config --cflags $(LUA_PKGNAME)) ifneq ($(shell uname -s),Darwin) - LDLIBS += $(shell pkg-config --libs lua) -Wl,--export-dynamic + LDLIBS += $(shell pkg-config --libs $(LUA_PKGNAME)) -Wl,--export-dynamic else - LDLIBS += $(shell pkg-config --libs lua) -rdynamic + LDLIBS += $(shell pkg-config --libs $(LUA_PKGNAME)) -rdynamic endif else ifneq ($(shell pkg-config --exists luajit || echo 'no'),no) # If not found, check for luajit CFLAGS += -DXLUA $(shell pkg-config --cflags luajit) |