Skip to content

Commit

Permalink
Fix compilation of the new test case on Travis
Browse files Browse the repository at this point in the history
The new test case is compiled into a self-contained executable. Thus,
this now has to link against the right Lua libraries. This commit adds
that information to the linker invocation.

For users, this might become a bit of a problem. Right now, the Makefile
guesses -llua to link against Lua, but there are many computers out
there where this is not correct, but e.g. -llua5.2 is needed. Users will
either have to not run tests, or to provide the right value for $LUA_LIB
themselves. Sorry.

This also fixes the Lua 5.3 build so that liblua.so is linked correctly
against its dependencies

Signed-off-by: Uli Schlachter <[email protected]>
  • Loading branch information
psychon committed Feb 17, 2019
1 parent 9123703 commit 759134a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ dist: trusty
language: c
env:
matrix:
- LUA=5.1 LUANAME=luajit-2.0
- LUA=5.1 LUANAME=luajit-2.0 LUA_LIB=-lluajit-5.1
- LUA=5.1 LUANAME=lua5.1
- LUA=5.2 LUANAME=lua5.2
- LUA=5.3 LUANAME=lua5.3
- LUA=5.3 LUANAME=lua5.3 LUA_LIB=-llua

before_install:
- if [ -z $LUAINCLUDE ]; then LUAINCLUDE=/usr/include/${LUANAME}; fi
- if [ -z $LUA_LIB ]; then LUA_LIB=-l${LUANAME}; fi

install:
# Travis boilerplate: the apt-get cache might be out of date.
Expand All @@ -33,7 +34,7 @@ install:
travis_retry wget http://www.lua.org/ftp/lua-5.3.3.tar.gz -O lua.tar.gz
tar -xvzf lua.tar.gz
(cd lua-5.3.3/src \
&& make SYSCFLAGS="-DLUA_USE_LINUX -ULUA_COMPAT_5_2 -DLUA_USE_APICHECK" SYSLIBS="-Wl,-E -ldl -lreadline" LUA_A=liblua.so MYCFLAGS="-fPIC" RANLIB=: AR="gcc -shared -ldl -o" liblua.so \
&& make SYSCFLAGS="-DLUA_USE_LINUX -ULUA_COMPAT_5_2 -DLUA_USE_APICHECK" SYSLIBS="-Wl,-E -ldl -lreadline" LUA_A=liblua.so MYCFLAGS="-fPIC" RANLIB=: AR="compile() { gcc -shared -o \"\$\$@\" -ldl -lm ; } ; compile" liblua.so \
&& cd .. \
&& sudo make INSTALL_TOP=/usr/ INSTALL_INC=${LUAINCLUDE} TO_LIB=liblua.so linux install)
elif [[ "$LUANAME" == "luajit-2.0" ]]; then
Expand All @@ -53,7 +54,7 @@ script:
- sed -e 's/Gio.NetworkConnectivity.LOCAL/1/' -i tests/gobject.lua

# Build everything and run the tests
- xvfb-run -a make check LUA_CFLAGS="-I$LUAINCLUDE"
- xvfb-run -a make check LUA_CFLAGS="-I$LUAINCLUDE" LUA_LIB="${LUA_LIB}"

# Just to also check make install
- sudo make install LUA_VERSION="$LUA"
Expand Down
4 changes: 3 additions & 1 deletion lgi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ GINAME = gobject-introspection-1.0
PKGS = $(GINAME) gmodule-2.0 libffi
VERSION_FILE = version.lua

LUA_LIB = -llua

ifneq ($(filter cygwin% msys% mingw%, $(HOST_OS)),)
CORE = corelgilua51.dll
LIBFLAG = -shared
LIBS += -llua
LIBS += $(LUA_LIB)
else
ifeq ($(HOST_OS),darwin)
CORE = corelgilua51.so
Expand Down
3 changes: 2 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ endif

PKGS = gio-2.0 cairo cairo-gobject gobject-introspection-1.0 gmodule-2.0 libffi
LUA = lua
LUA_LIB = -llua
PKG_CONFIG = pkg-config

ifndef CFLAGS
Expand All @@ -35,7 +36,7 @@ CFLAGS = -Wall -g
endif
endif
ALL_CFLAGS = $(CCSHARED) $(COPTFLAGS) $(LUA_CFLAGS) $(shell $(PKG_CONFIG) --cflags $(PKGS)) $(CFLAGS) -I .
LIBS += $(shell $(PKG_CONFIG) --libs $(PKGS))
LIBS += $(shell $(PKG_CONFIG) --libs $(PKGS)) $(LUA_LIB)
ALL_LDFLAGS = $(LIBFLAG) $(LDFLAGS)
DEPCHECK = .depcheck

Expand Down

0 comments on commit 759134a

Please sign in to comment.