lua-02-shared-libs-for-lua.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. Add the compilation of a shared library.
  2. Compile the lua binary with the shared library.
  3. And install the shared library.
  4. Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
  5. Index: b/Makefile
  6. ===================================================================
  7. --- a/Makefile
  8. +++ b/Makefile
  9. @@ -42,6 +42,7 @@
  10. TO_BIN= lua luac
  11. TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
  12. TO_LIB= liblua.a
  13. +TO_SOLIB = liblua.so.$(R)
  14. TO_MAN= lua.1 luac.1
  15. # Lua version and release.
  16. @@ -60,6 +61,8 @@
  17. install: dummy
  18. cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
  19. cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
  20. + cd src && $(INSTALL_EXEC) $(TO_SOLIB) $(INSTALL_LIB)
  21. + ln -sf $(TO_SOLIB) $(INSTALL_LIB)/liblua.so
  22. cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
  23. cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
  24. cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
  25. Index: b/src/Makefile
  26. ===================================================================
  27. --- a/src/Makefile
  28. +++ b/src/Makefile
  29. @@ -29,6 +29,7 @@
  30. PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
  31. LUA_A= liblua.a
  32. +LUA_SO= liblua.so
  33. CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
  34. lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
  35. ltm.o lundump.o lvm.o lzio.o
  36. @@ -43,8 +44,9 @@
  37. LUAC_O= luac.o
  38. ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
  39. -ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
  40. +ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
  41. ALL_A= $(LUA_A)
  42. +ALL_SO= $(LUA_SO)
  43. # Targets start here.
  44. default: $(PLAT)
  45. @@ -55,12 +57,18 @@
  46. a: $(ALL_A)
  47. +so: $(ALL_SO)
  48. +
  49. $(LUA_A): $(BASE_O)
  50. $(AR) $@ $(BASE_O)
  51. $(RANLIB) $@
  52. -$(LUA_T): $(LUA_O) $(LUA_A)
  53. - $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
  54. +$(LUA_SO): $(CORE_O) $(LIB_O)
  55. + $(CC) -o $@.$(PKG_VERSION) -shared -Wl,-soname="$@.$(PKG_VERSION)" $?
  56. + ln -fs $@.$(PKG_VERSION) $@
  57. +
  58. +$(LUA_T): $(LUA_O) $(LUA_SO)
  59. + $(CC) -o $@ -L. $(LDFLAGS) $(LUA_O) -llua $(LIBS)
  60. $(LUAC_T): $(LUAC_O) $(LUA_A)
  61. $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)