Skip to content

Commit 2d5473c

Browse files
committed
Only add "-Wl,--no-as-needed" to XLDFLAGS if building on Ubuntu
1 parent 5c77759 commit 2d5473c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lualib.mk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
CC = gcc
44
LDFLAGS ?= $(if $(ISDARWIN), -bundle -undefined dynamic_lookup, -shared)
5-
XLDFLAGS += -Wl,--no-as-needed
5+
XLDFLAGS += $(if $(ISUBUNTU), $(NOASNEEDED))
6+
NOASNEEDED = -Wl,--no-as-needed
67
PKGCONFIG ?= pkg-config --silence-errors 2>/dev/null
78
EQUAL = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
89
MKDIR ?= mkdir -p
@@ -14,7 +15,11 @@ LUA_FOUND = $(firstword $(shell which $(_LUA_PC) $(LUA_NAMES) 2>/dev/null))
1415
LUA ?= $(or $(LUA_FOUND), $(error No Lua interpreter found))
1516
PC_EXISTS = $(shell $(PKGCONFIG) --exists '$(1)' && echo 1)
1617
USE_IF = $(if $(call $(1), $(2) $(3)), $(2))
17-
ISDARWIN = $(call EQUAL, $(shell uname), Darwin)
18+
UNAME = $(shell uname)
19+
RELEASEID = $(shell awk '/^ID=/ {print substr($$0, 4)}' /etc/os-release)
20+
ISDARWIN = $(call EQUAL, $(UNAME), Darwin)
21+
ISLINUX = $(call EQUAL, $(UNAME), Linux)
22+
ISUBUNTU = $(and $(ISLINUX), $(call EQUAL, $(RELEASEID), ubuntu))
1823

1924
CCOPTIONS = $(XCFLAGS) $(CPPFLAGS) $(CFLAGS)
2025
LDOPTIONS = $(XLDFLAGS) $(LDFLAGS) $(LDLIBS)

0 commit comments

Comments
 (0)