0002-shared-libs-for-lua.patch 2.3 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. @@ -42,6 +42,7 @@
  12. TO_BIN= lua luac
  13. TO_INC= lua.h luaconf.h lualib.h lauxlib.h 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. @@ -60,6 +61,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. @@ -29,6 +29,7 @@
  32. PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
  33. LUA_A= liblua.a
  34. +LUA_SO= liblua.so
  35. CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
  36. lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
  37. ltm.o lundump.o lvm.o lzio.o
  38. @@ -43,8 +44,13 @@
  39. LUAC_O= luac.o
  40. ALL_O= $(BASE_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. # Targets start here.
  49. default: $(PLAT)
  50. @@ -55,12 +61,23 @@
  51. a: $(ALL_A)
  52. +so: $(ALL_SO)
  53. +
  54. $(LUA_A): $(BASE_O)
  55. $(AR) $@ $(BASE_O)
  56. $(RANLIB) $@
  57. +$(LUA_SO): $(CORE_O) $(LIB_O)
  58. + $(CC) -o $@.$(PKG_VERSION) -shared -Wl,-soname="$@.$(PKG_VERSION)" $?
  59. + ln -fs $@.$(PKG_VERSION) $@
  60. +
  61. +ifneq (dynamic,$(BUILDMODE))
  62. $(LUA_T): $(LUA_O) $(LUA_A)
  63. $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
  64. +else
  65. +$(LUA_T): $(LUA_O) $(LUA_SO)
  66. + $(CC) -o $@ -L. $(LDFLAGS) $(LUA_O) -llua $(LIBS)
  67. +endif
  68. $(LUAC_T): $(LUAC_O) $(LUA_A)
  69. $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)