On Sun, Dec 18, 2011 at 09:57:07AM +0200, Kalle Olavi Niemitalo wrote:
> Enrico Tassi <gareuselesi...@debian.org> writes:
> > On Wed, Dec 09, 2009 at 09:42:18AM +0100, Erich Schubert wrote:
> >> As far as I know (from discussion with upstream and on #debian-devel) it
> >> is currently impossible for me to re-use the Debian lua packages for 
> >> building
> >> Enigma. The main reason is that C++ exceptions and lua compiled for C use
> >> will break badly.
> >
> > I would be happy to provide a C++ version of the runtime, and would be
> > easy. What refrains me is that from the C++ interpreter you will be
> > allowed to load C modules (shipped in liblua5.1-* packages) but there
> > you will face the same problem I believe. 
> 
> I'm looking at this wishlist bug because of Bos Wars, which is
> written in C++ and uses Lua and tolua++ (but no Lua modules from

Many thanks for your analysis. To make it short, would it work for you
if the packages would ship something like liblua5.1-c++.so and
lua5.1-c++.pc the former being compiled with C++ (extern "C" is already
there IIRC) and the latter spitting out -llua5.1-c++?

I've prepared that patch a while ago (so it may not apply 100% clean).
I'm attaching it, it is for the lua5.1 package of course. 
Could you please test it?

Cheers
-- 
Enrico Tassi
Index: lua5.1/trunk/debian/control
===================================================================
--- lua5.1/trunk/debian/control	(revision 1783)
+++ lua5.1/trunk/debian/control	(working copy)
@@ -53,7 +53,8 @@
  stand-alone language through the simple command line interpreter provided.
  .
  This package contains developer resources for using the Lua library.
- Install it if you are developing programs which use the Lua C API.
+ Install it if you are developing programs which use the Lua C API, both
+ in C or C++.
 
 Package: liblua5.1-0
 Architecture: any
Index: lua5.1/trunk/debian/changelog
===================================================================
--- lua5.1/trunk/debian/changelog	(revision 1783)
+++ lua5.1/trunk/debian/changelog	(working copy)
@@ -1,8 +1,10 @@
-lua5.1 (5.1.4-11) UNRELEASED; urgency=low
+lua5.1 (5.1.4-11) unstable; urgency=low
 
   * NOT RELEASED YET
+  * Provide liblua5.1-c++.so and lua5.1-c++.pc to make it possible to C++
+    programs to link against Lua and use the C++ exception mecanism.
 
- -- Enrico Tassi <gareuselesi...@debian.org>  Mon, 25 Jul 2011 10:31:07 +0200
+ -- Enrico Tassi <gareuselesi...@debian.org>  Mon, 25 Jul 2011 22:43:14 +0200
 
 lua5.1 (5.1.4-10) unstable; urgency=low
 
Index: lua5.1/trunk/debian/patches/debian_make.patch
===================================================================
--- lua5.1/trunk/debian/patches/debian_make.patch	(revision 1783)
+++ lua5.1/trunk/debian/patches/debian_make.patch	(working copy)
@@ -1,7 +1,9 @@
 Author: John V. Belmonte <jbelmo...@debian.org>
 Description: Add support for Debian package to makefiles.
---- lua5.1-5.1.4.orig/Makefile
-+++ lua5.1-5.1.4/Makefile
+Index: lua5.1-5.1.4/Makefile
+===================================================================
+--- lua5.1-5.1.4.orig/Makefile	2008-08-12 02:40:48.000000000 +0200
++++ lua5.1-5.1.4/Makefile	2011-07-25 22:26:28.000000000 +0200
 @@ -12,7 +12,7 @@
  INSTALL_TOP= /usr/local
  INSTALL_BIN= $(INSTALL_TOP)/bin
@@ -11,7 +13,7 @@
  INSTALL_MAN= $(INSTALL_TOP)/man/man1
  #
  # You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
-@@ -126,3 +126,29 @@
+@@ -126,3 +126,31 @@
  .PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho
  
  # (end of Makefile)
@@ -20,6 +22,7 @@
 +
 +export V
 +export LIBTOOL = libtool --quiet --tag=CC
++export LIBTOOLPP = libtool --quiet --tag=CXX
 +# See libtool manual about how to set this
 +export LIB_VERSION = 0:0:0
 +
@@ -34,6 +37,7 @@
 +	cd src; $(LIBTOOL) --mode=install $(INSTALL_EXEC) lua$(V) luac$(V) $(INSTALL_BIN)
 +	cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
 +	cd src; $(LIBTOOL) --mode=install $(INSTALL_DATA) liblua$(V).la $(INSTALL_LIB)
++	cd src; $(LIBTOOLPP) --mode=install $(INSTALL_DATA) liblua$(V)-c++.la $(INSTALL_LIB)
 +	$(foreach NAME,$(TO_MAN),$(INSTALL_DATA) doc/$(NAME) $(INSTALL_MAN)/$(basename $(NAME))$(V)$(suffix $(NAME));)
 +
 +# ISSUE: MYCFLAGS not honored in the case of a CFLAGS override
@@ -41,9 +45,11 @@
 +	cd src; $(MAKE) debian_all CFLAGS+=-DLUA_USE_LINUX \
 +		CFLAGS+=-DDEB_HOST_MULTIARCH=\\\"$(DEB_HOST_MULTIARCH)\\\" \
 +		LIB_LIBS="-lm -ldl" LUA_LIBS="-lreadline" LDFLAGS="$(LDFLAGS)"
---- lua5.1-5.1.4.orig/src/Makefile
-+++ lua5.1-5.1.4/src/Makefile
-@@ -180,3 +180,29 @@
+Index: lua5.1-5.1.4/src/Makefile
+===================================================================
+--- lua5.1-5.1.4.orig/src/Makefile	2008-01-19 20:37:58.000000000 +0100
++++ lua5.1-5.1.4/src/Makefile	2011-07-25 22:25:52.000000000 +0200
+@@ -180,3 +180,36 @@
    ltm.h lzio.h lmem.h lopcodes.h lundump.h
  
  # (end of Makefile)
@@ -54,14 +60,21 @@
 +# the upstream makefile.
 +
 +LIB_NAME = liblua$(V).la
++LIBPP_NAME = liblua$(V)-c++.la
 +LIB_OBJS = $(CORE_O:.o=.lo) $(LIB_O:.o=.lo)
++LIBPP_OBJS = $(CORE_O:%.o=%-c++.lo) $(LIB_O:%.o=%-c++.lo)
 +
++%-c++.lo %-c++.o: %.c
++	$(LIBTOOLPP) --mode=compile $(CXX) -o $*-c++.lo -c $(CPPFLAGS) $(CFLAGS) $<
 +%.lo %.o: %.c
 +	$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
 +
 +$(LIB_NAME) $(LIB_NAME:.la=.a): $(LIB_OBJS)
 +	$(LIBTOOL) --mode=link $(CC) -version-info $(LIB_VERSION) \
 +            -rpath $(RPATH) -o $(LIB_NAME) $(LIB_OBJS) $(LIB_LIBS)
++$(LIBPP_NAME) $(LIBPP_NAME:.la=.a): $(LIBPP_OBJS)
++	$(LIBTOOLPP) --mode=link $(CXX) -version-info $(LIB_VERSION) \
++            -rpath $(RPATH) -o $(LIBPP_NAME) $(LIBPP_OBJS) $(LIB_LIBS)
 +
 +lua$(V): $(LUA_O) $(LIB_NAME)
 +	$(LIBTOOL) --mode=link $(CC) -static -Wl,-E -o $@ $(LUA_O) $(LIB_NAME) $(LUA_LIBS) $(LDFLAGS)
@@ -72,4 +85,4 @@
 +debian_clean:
 +	$(LIBTOOL) --mode=clean $(RM) $(ALL_O:.o=.lo) $(LIB_NAME) lua$(V) luac$(V)
 +
-+debian_all: $(LIB_NAME) lua$(V) luac$(V)
++debian_all: $(LIB_NAME) $(LIBPP_NAME) lua$(V) luac$(V)
Index: lua5.1/trunk/debian/rules
===================================================================
--- lua5.1/trunk/debian/rules	(revision 1783)
+++ lua5.1/trunk/debian/rules	(working copy)
@@ -8,7 +8,9 @@
 DEB_DESTDIR := $(shell pwd)/debian/tmp/usr
 LIB_PACKAGE_NAME = lib$(LUA)-$(SONUM)
 
-PKG_CONFIG_FILE = $(DEB_DESTDIR)/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/$(LUA).pc
+PKG_DIR = $(DEB_DESTDIR)/lib/$(DEB_HOST_MULTIARCH)/pkgconfig
+PKG_CONFIG_FILE = $(PKG_DIR)/$(LUA).pc
+PKGPP_CONFIG_FILE = $(PKG_DIR)/$(LUA)-c++.pc
 DOC_DIR = debian/$(LUA)-doc/usr/share/doc/$(LUA)-doc
 
 ifeq (hurd,$(shell dpkg-architecture -qDEB_HOST_ARCH_OS))
@@ -45,13 +47,19 @@
 endif
 
 override_dh_install:
-	mkdir -p $(dir $(PKG_CONFIG_FILE))
+	mkdir -p $(PKG_DIR)
 	echo "prefix=/usr" > $(PKG_CONFIG_FILE)
 	echo "major_version=$(LUA_V)" >> $(PKG_CONFIG_FILE)
 	echo "version=$(LUA_FULL_V)" >> $(PKG_CONFIG_FILE)
 	echo "lib_name_include=lua$(LUA_V)" >> $(PKG_CONFIG_FILE)
 	echo "deb_host_multiarch=$(DEB_HOST_MULTIARCH)" >> $(PKG_CONFIG_FILE)
 	cat debian/lua.pc.in >> $(PKG_CONFIG_FILE)
+	echo "prefix=/usr" > $(PKGPP_CONFIG_FILE)
+	echo "major_version=$(LUA_V)" >> $(PKGPP_CONFIG_FILE)
+	echo "version=$(LUA_FULL_V)" >> $(PKGPP_CONFIG_FILE)
+	echo "lib_name_include=lua$(LUA_V)" >> $(PKGPP_CONFIG_FILE)
+	echo "deb_host_multiarch=$(DEB_HOST_MULTIARCH)" >> $(PKGPP_CONFIG_FILE)
+	cat debian/lua-c++.pc.in >> $(PKGPP_CONFIG_FILE)
 	dh_install
 
 override_dh_strip:
Index: lua5.1/trunk/debian/lua-c++.pc.in
===================================================================
--- lua5.1/trunk/debian/lua-c++.pc.in	(revision 0)
+++ lua5.1/trunk/debian/lua-c++.pc.in	(revision 0)
@@ -0,0 +1,25 @@
+#prefix=/usr
+#major_version=5.1
+#version=5.1.0
+#deb_host_multiarch=x86_64-linux-gnu
+
+lib_name=lua${major_version}-c++
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+#
+# The following are intended to be used via "pkg-config --variable".
+
+# Install paths for Lua modules.  For example, if a package wants to install
+# Lua source modules to the /usr/local tree, call pkg-config with
+# "--define-variable=prefix=/usr/local" and "--variable=INSTALL_LMOD".
+INSTALL_LMOD=${prefix}/share/lua/${major_version}
+INSTALL_CMOD=${prefix}/lib/${deb_host_multiarch}/lua/${major_version}
+
+Name: Lua
+Description: Lua language engine
+Version: ${version}
+Requires:
+Libs: -L${libdir} -l${lib_name}
+Libs.private: -lm -ldl
+Cflags: -I${includedir}/${lib_name_include}

Reply via email to