0002-shared-libs-for-lua.patch 2.4 KB

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