@@ -649,6 +649,9 @@ def add_options_to_version_suffix(self):
649
649
if opts .no_readline :
650
650
options .append (("readline" , "false" ))
651
651
652
+ if opts .shared :
653
+ options .append (("shared" , "true" ))
654
+
652
655
if options :
653
656
self .version_suffix += " (" + (", " .join (
654
657
opt + ": " + value for opt , value in options )) + ")"
@@ -1042,14 +1045,17 @@ def __init__(self, version):
1042
1045
1043
1046
if opts .target == "mingw" or using_cl ():
1044
1047
self .dll_file = "lua5" + self .major_version [2 ] + ".dll"
1048
+ self .so_file = None
1045
1049
else :
1046
1050
self .dll_file = None
1051
+ self .so_file = "liblua5" + self .major_version [2 ] + ".so"
1047
1052
1048
1053
def set_identifiers (self ):
1049
1054
super (RioLua , self ).set_identifiers ()
1050
1055
1051
1056
self .identifiers ["readline" ] = str (not opts .no_readline ).lower ()
1052
1057
self .identifiers ["patched" ] = str (opts .patch ).lower ()
1058
+ self .identifiers ["shared" ] = str (not opts .shared ).lower ()
1053
1059
1054
1060
def major_version_from_version (self ):
1055
1061
return self .version [:3 ]
@@ -1191,6 +1197,8 @@ def make(self):
1191
1197
cc = ["cl" , "/nologo" , "/MD" , "/O2" , "/W3" , "/c" , "/D_CRT_SECURE_NO_DEPRECATE" ]
1192
1198
else :
1193
1199
cflags = ["-O2" , "-Wall" , "-Wextra" ] + cflags
1200
+ if not opts .shared :
1201
+ cflags = ["-fPIC" ] + cflags
1194
1202
1195
1203
lflags .append ("-lm" )
1196
1204
static_cflags = list (cflags )
@@ -1230,6 +1238,11 @@ def make(self):
1230
1238
run ("ar" , "rcu" , self .arch_file , lib_objs )
1231
1239
run ("ranlib" , self .arch_file )
1232
1240
run (cc , "-o" , self .luac_file , luac_objs , self .arch_file , lflags )
1241
+ if not opts .shared :
1242
+ so_lflags = ["-ldl" ,
1243
+ "-Wl,--whole-archive,--soname={}" .format (self .so_file ),
1244
+ "-Wl,--no-as-needed" ] + lflags + [self .arch_file , "-Wl,--no-whole-archive" ]
1245
+ run (cc , "-o" , self .so_file , "-shared" , so_lflags )
1233
1246
1234
1247
if opts .target == "mingw" :
1235
1248
run (cc , "-shared" , "-o" , self .dll_file , lib_objs )
@@ -1265,6 +1278,8 @@ def make_install(self):
1265
1278
"lua.h" , "luaconf.h" , "lualib.h" , "lauxlib.h" , lua_hpp )
1266
1279
1267
1280
copy_files (os .path .join (opts .location , "lib" ), self .arch_file )
1281
+ if self .so_file and not opts .shared :
1282
+ copy_files (os .path .join (opts .location , "lib" ), self .so_file )
1268
1283
1269
1284
class LuaJIT (Lua ):
1270
1285
name = "LuaJIT"
@@ -1792,6 +1807,8 @@ def main(argv=None):
1792
1807
"vs13_32" , "vs13_64" , "vs15_32" , "vs15_64"
1793
1808
], metavar = "{linux,macosx,freebsd,mingw,posix,generic,mingw,vs,vs_XX,vsXX_YY}" ,
1794
1809
default = get_default_lua_target ())
1810
+ parser .add_argument ("--shared" , help = "Don't make a shared library when building standard Lua." ,
1811
+ action = "store_true" , default = False )
1795
1812
parser .add_argument ("--no-readline" , help = "Don't use readline library when building standard Lua." ,
1796
1813
action = "store_true" , default = False )
1797
1814
parser .add_argument ("--downloads" ,
0 commit comments