From 13647e28f553f04b79b84f460cad595e9a5e7af2 Mon Sep 17 00:00:00 2001 From: Nicolas Thill Date: Tue, 9 Jan 2007 14:46:19 +0000 Subject: [PATCH] fix shared build: since 5.1, lua libraries (liblua & liblualib) have been merged, so instead of building 2 distincts libraries from the same sources, just symlink liblualib to liblua. storage-class specifiers have been changed for some functions to link the lua compiler (luac) against the shared library and save space. rename the patch to follow our patch naming scheme. SVN-Revision: 6046 --- lang/lua/Makefile | 19 +-- lang/lua/patches/010-shared_liblua.patch | 140 +++++++++++++++++++++++ lang/lua/patches/lua-5.1.1-so.patch | 63 ---------- 3 files changed, 145 insertions(+), 77 deletions(-) create mode 100644 lang/lua/patches/010-shared_liblua.patch delete mode 100644 lang/lua/patches/lua-5.1.1-so.patch diff --git a/lang/lua/Makefile b/lang/lua/Makefile index 0905da427..d360fc931 100644 --- a/lang/lua/Makefile +++ b/lang/lua/Makefile @@ -87,17 +87,6 @@ define Build/Compile MYLDFLAGS="-L$(STAGING_DIR)/usr/lib" \ PKG_VERSION=$(PKG_VERSION) \ all linux - # remove statically linked binaries, so that they will get linked against shlib this time - rm -f $(PKG_BUILD_DIR)/bin/lua{,c} - $(MAKE) -C $(PKG_BUILD_DIR) \ - CC="$(TARGET_CROSS)gcc" \ - LD="$(TARGET_CROSS)ld" \ - AR="$(TARGET_CROSS)ar rcu" \ - RANLIB="$(TARGET_CROSS)ranlib" \ - INSTALL_ROOT=/usr \ - MYCFLAGS="-I$(STAGING_DIR)/usr/include $(TARGET_CFLAGS)" \ - MYLDFLAGS="-L$(STAGING_DIR)/usr/lib" \ - all linux rm -rf $(PKG_INSTALL_DIR) mkdir -p $(PKG_INSTALL_DIR) $(MAKE) -C $(PKG_BUILD_DIR) \ @@ -110,19 +99,21 @@ define Build/InstallDev $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(STAGING_DIR)/usr/include/ $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(STAGING_DIR)/usr/include/ mkdir -p $(STAGING_DIR)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua{,lib}.{a,so*} $(STAGING_DIR)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so.*} $(STAGING_DIR)/usr/lib/ + ln -sf liblua.so.$(PKG_VERSION) $(STAGING_DIR)/usr/lib/liblua.so + ln -sf liblua.so.$(PKG_VERSION) $(STAGING_DIR)/usr/lib/liblualib.so endef define Build/UninstallDev rm -rf \ $(STAGING_DIR)/usr/include/lua{,lib,conf}.h \ $(STAGING_DIR)/usr/include/lauxlib.h \ - $(STAGING_DIR)/usr/lib/liblua{,lib}.{a,so*} + $(STAGING_DIR)/usr/lib/liblua.{a,so*} endef define Package/liblua/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua{,lib}.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/ endef define Package/lua/install diff --git a/lang/lua/patches/010-shared_liblua.patch b/lang/lua/patches/010-shared_liblua.patch new file mode 100644 index 000000000..5e041512f --- /dev/null +++ b/lang/lua/patches/010-shared_liblua.patch @@ -0,0 +1,140 @@ +# +# Copyright (C) 2006 OpenWrt.org +# + +diff -ruN lua-5.1.1-old/Makefile lua-5.1.1-new/Makefile +--- lua-5.1.1-old/Makefile 2006-06-02 12:53:38.000000000 +0200 ++++ lua-5.1.1-new/Makefile 2007-01-09 02:10:39.000000000 +0100 +@@ -42,7 +42,7 @@ + # What to install. + TO_BIN= lua luac + TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp +-TO_LIB= liblua.a ++TO_LIB= liblua.a liblua.so liblua.so.$R + TO_MAN= lua.1 luac.1 + + # Lua version and release. +diff -ruN lua-5.1.1-old/src/Makefile lua-5.1.1-new/src/Makefile +--- lua-5.1.1-old/src/Makefile 2006-03-22 01:41:49.000000000 +0100 ++++ lua-5.1.1-new/src/Makefile 2007-01-09 02:10:45.000000000 +0100 +@@ -23,6 +23,7 @@ + PLATS= aix ansi bsd generic linux macosx mingw posix solaris + + LUA_A= liblua.a ++LUA_SO= liblua.so + CORE_O= lapi.o lcode.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 +@@ -33,11 +34,12 @@ + LUA_O= lua.o + + LUAC_T= luac +-LUAC_O= luac.o print.o ++LUAC_O= luac.o print.o lopcodes.o + + ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) ++ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T) + ALL_A= $(LUA_A) ++ALL_SO= $(LUA_SO) + + default: $(PLAT) + +@@ -47,15 +49,21 @@ + + a: $(ALL_A) + ++so: $(ALL_SO) ++ + $(LUA_A): $(CORE_O) $(LIB_O) + $(AR) $@ $? + $(RANLIB) $@ + +-$(LUA_T): $(LUA_O) $(LUA_A) +- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) ++$(LUA_SO): $(CORE_O) $(LIB_O) ++ $(LD) -o $@.$(PKG_VERSION) -shared -soname="$@.$(PKG_VERSION)" $? ++ ln -fs $@.$(PKG_VERSION) $@ ++ ++$(LUA_T): $(LUA_O) $(LUA_SO) ++ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS) + +-$(LUAC_T): $(LUAC_O) $(LUA_A) +- $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) ++$(LUAC_T): $(LUAC_O) $(LUA_SO) ++ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS) + + clean: + $(RM) $(ALL_T) $(ALL_O) +@@ -92,7 +100,7 @@ + $(MAKE) all MYCFLAGS= + + linux: +- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" ++ $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" + + macosx: + $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX +diff -ruN lua-5.1.1-old/src/ldo.h lua-5.1.1-new/src/ldo.h +--- lua-5.1.1-old/src/ldo.h 2005-08-24 18:15:49.000000000 +0200 ++++ lua-5.1.1-new/src/ldo.h 2007-01-09 02:10:45.000000000 +0100 +@@ -46,7 +46,7 @@ + LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); + LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); + LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +-LUAI_FUNC void luaD_growstack (lua_State *L, int n); ++LUA_API void luaD_growstack (lua_State *L, int n); + + LUAI_FUNC void luaD_throw (lua_State *L, int errcode); + LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); +diff -ruN lua-5.1.1-old/src/lfunc.h lua-5.1.1-new/src/lfunc.h +--- lua-5.1.1-old/src/lfunc.h 2005-04-25 21:24:10.000000000 +0200 ++++ lua-5.1.1-new/src/lfunc.h 2007-01-09 02:10:45.000000000 +0100 +@@ -18,7 +18,7 @@ + cast(int, sizeof(TValue *)*((n)-1))) + + +-LUAI_FUNC Proto *luaF_newproto (lua_State *L); ++LUA_API Proto *luaF_newproto (lua_State *L); + LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); + LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); + LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +diff -ruN lua-5.1.1-old/src/lmem.h lua-5.1.1-new/src/lmem.h +--- lua-5.1.1-old/src/lmem.h 2005-04-25 21:24:10.000000000 +0200 ++++ lua-5.1.1-new/src/lmem.h 2007-01-09 02:10:45.000000000 +0100 +@@ -38,9 +38,9 @@ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, ++LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +-LUAI_FUNC void *luaM_toobig (lua_State *L); ++LUA_API void *luaM_toobig (lua_State *L); + LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); +diff -ruN lua-5.1.1-old/src/lstring.h lua-5.1.1-new/src/lstring.h +--- lua-5.1.1-old/src/lstring.h 2005-04-25 21:24:10.000000000 +0200 ++++ lua-5.1.1-new/src/lstring.h 2007-01-09 02:10:45.000000000 +0100 +@@ -25,7 +25,7 @@ + + LUAI_FUNC void luaS_resize (lua_State *L, int newsize); + LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); ++LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + + #endif +diff -ruN lua-5.1.1-old/src/lundump.h lua-5.1.1-new/src/lundump.h +--- lua-5.1.1-old/src/lundump.h 2005-11-11 15:03:13.000000000 +0100 ++++ lua-5.1.1-new/src/lundump.h 2007-01-09 02:10:45.000000000 +0100 +@@ -17,7 +17,7 @@ + LUAI_FUNC void luaU_header (char* h); + + /* dump one chunk; from ldump.c */ +-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); ++LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + + #ifdef luac_c + /* print one chunk; from print.c */ diff --git a/lang/lua/patches/lua-5.1.1-so.patch b/lang/lua/patches/lua-5.1.1-so.patch deleted file mode 100644 index fe6147e7f..000000000 --- a/lang/lua/patches/lua-5.1.1-so.patch +++ /dev/null @@ -1,63 +0,0 @@ -diff -urN lua-5.1.1/Makefile lua-5.1.1.new/Makefile ---- lua-5.1.1/Makefile 2006-06-02 12:53:38.000000000 +0200 -+++ lua-5.1.1.new/Makefile 2006-12-28 01:40:18.000000000 +0100 -@@ -42,7 +42,7 @@ - # What to install. - TO_BIN= lua luac - TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp --TO_LIB= liblua.a -+TO_LIB= liblua.a liblualib.a liblua.so liblua.so.$R liblualib.so.$R - TO_MAN= lua.1 luac.1 - - # Lua version and release. -diff -urN lua-5.1.1/src/Makefile lua-5.1.1.new/src/Makefile ---- lua-5.1.1/src/Makefile 2006-03-22 01:41:49.000000000 +0100 -+++ lua-5.1.1.new/src/Makefile 2006-12-28 01:39:29.000000000 +0100 -@@ -23,6 +23,7 @@ - PLATS= aix ansi bsd generic linux macosx mingw posix solaris - - LUA_A= liblua.a -+LUA_SO= liblua.so - CORE_O= lapi.o lcode.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 -@@ -36,8 +37,9 @@ - LUAC_O= luac.o print.o - - ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) --ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) -+ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T) - ALL_A= $(LUA_A) -+ALL_SO= $(LUA_SO) - - default: $(PLAT) - -@@ -47,10 +49,19 @@ - - a: $(ALL_A) - -+so: $(ALL_SO) -+ - $(LUA_A): $(CORE_O) $(LIB_O) - $(AR) $@ $? -+ $(AR) liblualib.a $? - $(RANLIB) $@ -+ $(RANLIB) liblualib.a - -+$(LUA_SO): $(CORE_O) $(LIB_O) -+ $(LD) -o $@.$(PKG_VERSION) -shared -soname="$@.$(PKG_VERSION)" $? -+ $(LD) -o liblualib.so.$(PKG_VERSION) -shared -soname="liblualib.so.$(PKG_VERSION)" $? -+ ln -fs $@.$(PKG_VERSION) $@; ln -fs liblualib.so.$(PKG_VERSION) liblualib.so -+ - $(LUA_T): $(LUA_O) $(LUA_A) - $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) - -@@ -92,7 +103,7 @@ - $(MAKE) all MYCFLAGS= - - linux: -- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" -+ $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" - - macosx: - $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX -- 2.30.2