lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Luiz wrote:
> There are no portable ways to build shared libraries, except perhaps
> relying on libtool, which we'd rather not.
> So we stay away from building shared libraries in the stock makefiles.
> This can and is done by third-party binary distributions such as
> LuaBinaries (

There is an "aix" target in the Lua makefile which requires the xlc
compiler, but we wouldn't say that the Lua build relies on xlc.
Likewise libtool can be made an option without making the build depend
on it.

Attached is a simple patch which lets you add "USE_LIBTOOL=1" on top of
any existing target.  Then, in addition to the static library, it
produces a dynamic library.  The command line tools are linked against
the static library as normal.

I don't have much interest in this getting accepted, but it may be
something to think about for future releases.

diff -urN lua-5.1/src/Makefile lua-5.1_patched/src/Makefile
--- lua-5.1/src/Makefile	2006-02-16 10:45:09.000000000 -0500
+++ lua-5.1_patched/src/Makefile	2006-03-04 10:22:56.000000000 -0500
@@ -13,6 +13,7 @@
 RANLIB= ranlib
 RM= rm -f
 LIBS= -lm $(MYLIBS)
+LIBTOOL = libtool --quiet
@@ -38,6 +39,7 @@
 ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
 ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
 ALL_A= $(LUA_A)
+ALL_LO = $(CORE_O:.o=.lo) $(LIB_O:.o=.lo)
 default: $(PLAT)
@@ -47,9 +49,18 @@
 a:	$(ALL_A)
+%.lo: %.c
+	$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
 $(LUA_A): $(CORE_O) $(LIB_O)
 	$(AR) $@ $?
 	$(RANLIB) $@
+$(LUA_A): $(ALL_LO)
+	$(LIBTOOL) --mode=link $(CC) -rpath / -o $( $(ALL_LO)
+	cp .libs/$(LUA_A) .libs/$( .
 $(LUA_T): $(LUA_O) $(LUA_A)
 	$(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
@@ -59,6 +70,7 @@
 	$(RM) $(ALL_T) $(ALL_O)
+	$(RM) -r .libs/ $(ALL_LO) $( $(
 	@$(CC) $(CFLAGS) -MM l*.c print.c