Skip to content

Instantly share code, notes, and snippets.

@okhowang
Last active February 16, 2019 20:42
Show Gist options
  • Select an option

  • Save okhowang/c897bbe731dfcaa3cafb97af1ba58342 to your computer and use it in GitHub Desktop.

Select an option

Save okhowang/c897bbe731dfcaa3cafb97af1ba58342 to your computer and use it in GitHub Desktop.
lua 5.2 so patch
diff -Naur lua-5.2.4.origin/Makefile lua-5.2.4/Makefile
--- lua-5.2.4.origin/Makefile 2015-02-24 09:28:54.000000000 +0800
+++ lua-5.2.4/Makefile 2017-02-04 10:08:40.000000000 +0800
@@ -47,12 +47,13 @@
# Lua version and release.
V= 5.2
R= $V.4
+TO_LIB+= liblua.so liblua.so.$(V) liblua.so.$(R)
# Targets start here.
all: $(PLAT)
$(PLATS) clean:
- cd src && $(MAKE) $@
+ cd src && $(MAKE) $@ V=$(V) R=$(R)
test: dummy
src/lua -v
diff -Naur lua-5.2.4.origin/src/Makefile lua-5.2.4/src/Makefile
--- lua-5.2.4.origin/src/Makefile 2013-11-11 19:45:49.000000000 +0800
+++ lua-5.2.4/src/Makefile 2017-02-04 10:08:03.000000000 +0800
@@ -29,12 +29,17 @@
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
+LUA_SO= liblua.so
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
LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
lmathlib.o loslib.o lstrlib.o ltablib.o loadlib.o linit.o
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
+BASE_SO_O= $(patsubst %.o, %.so.o, $(BASE_O))
+
+%.so.o: %.c
+ $(CC) -fPIC $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $<
LUA_T= lua
LUA_O= lua.o
@@ -42,8 +47,8 @@
LUAC_T= luac
LUAC_O= luac.o
-ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) $(BASE_SO_O)
+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
ALL_A= $(LUA_A)
# Targets start here.
@@ -59,6 +64,11 @@
$(AR) $@ $(BASE_O)
$(RANLIB) $@
+$(LUA_SO): $(BASE_SO_O)
+ $(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
+ ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
+ ln -sf $(LUA_SO).$(R) $(LUA_SO)
+
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
@@ -66,7 +76,7 @@
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
clean:
- $(RM) $(ALL_T) $(ALL_O)
+ $(RM) $(ALL_T) $(ALL_O) $(LUA_SO).$(V) $(LUA_SO).$(R)
depend:
@$(CC) $(CFLAGS) -MM l*.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment