lua: Build a shared library (#6008)
Patch is inspired by Arch Linux and Homebrew.
This commit is contained in:
parent
f3af8272f5
commit
0d624eac55
64
var/spack/repos/builtin/packages/lua/liblua-shared.patch
Normal file
64
var/spack/repos/builtin/packages/lua/liblua-shared.patch
Normal file
@ -0,0 +1,64 @@
|
||||
diff -ru a/Makefile b/Makefile
|
||||
--- a/Makefile 2017-10-27 23:49:02.821830453 +0200
|
||||
+++ b/Makefile 2017-10-27 23:50:45.697634413 +0200
|
||||
@@ -41,7 +41,7 @@
|
||||
# What to install.
|
||||
TO_BIN= lua luac
|
||||
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
|
||||
-TO_LIB= liblua.a
|
||||
+TO_LIB= liblua.a $(LUA_DSO).$(R)
|
||||
TO_MAN= lua.1 luac.1
|
||||
|
||||
# Lua version and release.
|
||||
@@ -52,7 +52,7 @@
|
||||
all: $(PLAT)
|
||||
|
||||
$(PLATS) clean:
|
||||
- cd src && $(MAKE) $@
|
||||
+ cd src && $(MAKE) $@ V=$(V) R=$(R)
|
||||
|
||||
test: dummy
|
||||
src/lua -v
|
||||
@@ -63,6 +63,8 @@
|
||||
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
|
||||
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
|
||||
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
|
||||
+ ln -sf $(LUA_DSO).$(R) $(INSTALL_LIB)/$(LUA_DSO).$(V)
|
||||
+ ln -sf $(LUA_DSO).$(R) $(INSTALL_LIB)/$(LUA_DSO)
|
||||
|
||||
uninstall:
|
||||
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
|
||||
diff -ru a/src/Makefile b/src/Makefile
|
||||
--- a/src/Makefile 2017-10-27 23:49:02.823830467 +0200
|
||||
+++ b/src/Makefile 2017-10-27 23:50:01.923284014 +0200
|
||||
@@ -29,6 +29,8 @@
|
||||
PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
|
||||
|
||||
LUA_A= liblua.a
|
||||
+LUA_SO= liblua.so
|
||||
+LUA_DYLIB= liblua.dylib
|
||||
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
|
||||
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
|
||||
ltm.o lundump.o lvm.o lzio.o
|
||||
@@ -43,7 +45,7 @@
|
||||
LUAC_O= luac.o
|
||||
|
||||
ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
|
||||
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
|
||||
+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_DSO)
|
||||
ALL_A= $(LUA_A)
|
||||
|
||||
# Targets start here.
|
||||
@@ -59,6 +61,12 @@
|
||||
$(AR) $@ $(BASE_O)
|
||||
$(RANLIB) $@
|
||||
|
||||
+$(LUA_SO): $(CORE_O) $(LIB_O)
|
||||
+ $(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $^ -lm $(MYLDFLAGS)
|
||||
+
|
||||
+$(LUA_DYLIB): $(CORE_O) $(LIB_O)
|
||||
+ $(CC) -dynamiclib -install_name @LUA_PREFIX@/lib/$(LUA_DYLIB).$(V) -compatibility_version $(V) -current_version $(R) -o $@.$(R) $^
|
||||
+
|
||||
$(LUA_T): $(LUA_O) $(LUA_A)
|
||||
$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|
||||
|
@ -58,24 +58,37 @@ class Lua(Package):
|
||||
destination="luarocks",
|
||||
placement='luarocks')
|
||||
|
||||
# Based on patches from Arch Linux and Homebrew:
|
||||
# https://git.archlinux.org/svntogit/packages.git/tree/trunk/liblua.so.patch?h=packages/lua
|
||||
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/lua.rb
|
||||
patch('liblua-shared.patch')
|
||||
|
||||
def install(self, spec, prefix):
|
||||
if spec.satisfies("platform=darwin"):
|
||||
target = 'macosx'
|
||||
else:
|
||||
target = 'linux'
|
||||
make('INSTALL_TOP=%s' % prefix,
|
||||
'MYCFLAGS=%s' % (
|
||||
self.compiler.pic_flag),
|
||||
'MYLDFLAGS=-L%s -L%s' % (
|
||||
spec['readline'].prefix.lib,
|
||||
spec['ncurses'].prefix.lib),
|
||||
'MYLIBS=-lncursesw',
|
||||
'CC=%s -std=gnu99' % spack_cc,
|
||||
'LUA_DSO=liblua.%s' % (
|
||||
dso_suffix),
|
||||
target)
|
||||
make('INSTALL_TOP=%s' % prefix,
|
||||
'MYCFLAGS=%s' % (
|
||||
self.compiler.pic_flag),
|
||||
'MYLDFLAGS=-L%s -L%s' % (
|
||||
spec['readline'].prefix.lib,
|
||||
spec['ncurses'].prefix.lib),
|
||||
'MYLIBS=-lncursesw',
|
||||
'CC=%s -std=gnu99' % spack_cc,
|
||||
'LUA_DSO=liblua.%s' % (
|
||||
dso_suffix),
|
||||
'install')
|
||||
|
||||
with working_dir(os.path.join('luarocks', 'luarocks')):
|
||||
|
Loading…
Reference in New Issue
Block a user