[luatex] include a new library in the executable file

Taco Hoekwater taco at elvenkind.com
Wed Jul 7 15:21:43 CEST 2010


Hi,


Patrick Gundlach wrote:
> Hi,
> 
> for the sake of easy distribution of the binary, I would like to
> include an xml parser (lua-xmlreader, for libxml2) into the
> executable, if it is not too complicated. I am rather inexperienced
> when it comes to autotools, but I guess I need to use them.
> 
> Can someone help me out? I guess I need to patch luamisc.am and
> include lua-xmlreader in a subdirectory there. Which steps are needed
> after that?

It is not overly complex, but there are few extra steps. I'll try
to explain (but note that this is a hackish way of doing things,
nicer would be a dedicated .am file for lua-xmlreader only).

-1. Install the libxml2-devel package.

0. Extract lua-xmlreader-0.1.tar.gz below luatexdir/.

1. Add three source files and an include dir to
luatexdir/am/luamisc.am:

Index: texk/web2c/luatexdir/am/luamisc.am
===================================================================
--- texk/web2c/luatexdir/am/luamisc.am  (revision 3735)
+++ texk/web2c/luatexdir/am/luamisc.am  (working copy)
@@ -15,7 +15,8 @@
 libluamisc_a_CPPFLAGS = \
        $(ZLIB_INCLUDES) \
        $(ZZIPLIB_INCLUDES) \
-       -I$(top_srcdir)/luatexdir/lua51
+       -I$(top_srcdir)/luatexdir/lua51 \
+       -I/usr/include/libxml2
 libluamisc_a_CFLAGS = # $(WARNING_CFLAGS)

 libluamisc_a_SOURCES = \
@@ -26,6 +27,9 @@
        luatexdir/luamd5/md5lib.c \
        luatexdir/luamd5/md5_lua.c \
        luatexdir/luapeg/lpeg.c \
+       luatexdir/lua-xmlreader-0.1/error.c \
+       luatexdir/lua-xmlreader-0.1/error.h \
+       luatexdir/lua-xmlreader-0.1/xmlreader.c \
        luatexdir/luaprofiler/clocks.c \
        luatexdir/luaprofiler/clocks.h \
        luatexdir/luaprofiler/core_profiler.c \

2. Add -lxml2  to luatexdir/am/luatex.am

===================================================================
--- texk/web2c/luatexdir/am/luatex.am   (revision 3735)
+++ texk/web2c/luatexdir/am/luatex.am   (working copy)
@@ -26,7 +26,7 @@

 luatex_LDFLAGS = -export-dynamic

-luatex_LDADD = $(luatex_ldadd) $(LDADD) $(LIBADD_DLOPEN) $(lua_socketlibs)
+luatex_LDADD = $(luatex_ldadd) $(LDADD) $(LIBADD_DLOPEN)
$(lua_socketlibs) -lxml2

 luatex_DEPENDENCIES = $(proglib) $(KPATHSEA_DEPEND) libluatex.a
 luatex_DEPENDENCIES += $(LIBPNG_DEPEND) $(ZLIB_DEPEND) $(XPDF_DEPEND)

3. Run 'autoreconf' in source/texk/web2c.  Actually this is the
tricky bit because you need the right versions of autoconf (>=2.65)
and automake (>=1.11.1).

4. Add the prototype of luaopen_xmlreader in xmlreader.c to
luatexdir/lua/luatex-api.h:

Index: texk/web2c/luatexdir/lua/luatex-api.h
===================================================================
--- texk/web2c/luatexdir/lua/luatex-api.h       (revision 3735)
+++ texk/web2c/luatexdir/lua/luatex-api.h       (working copy)
@@ -60,6 +60,8 @@
 extern int luaopen_md5(lua_State * L);
 extern int luatex_md5_lua_open(lua_State * L);

+extern int luaopen_xmlreader(lua_State * L);
+
 extern int luaopen_zlib(lua_State * L);
 extern int luaopen_gzip(lua_State * L);
 extern int luaopen_ff(lua_State * L);

5. Add the call to luaopen_xmlreader() to the array in
luatexdir/lua/luastuff.w:

Index: texk/web2c/luatexdir/lua/luastuff.w
===================================================================
--- texk/web2c/luatexdir/lua/luastuff.w (revision 3735)
+++ texk/web2c/luatexdir/lua/luastuff.w (working copy)
@@ -105,6 +105,7 @@
     {"unicode", luaopen_unicode},
     {"zip", luaopen_zip},
     {"lpeg", luaopen_lpeg},
+    {"xmlreader", luaopen_xmlreader},
     {"md5", luaopen_md5},
     {"lfs", luaopen_lfs},
     {"profiler", luaopen_profiler},

6. run build.sh

Attached is a patch based on current trunk. It is fairly long simply
because of the modification to Makefile.in that happens thanks to
autoreconf.

Best wishes,
Taco
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: luaxmlreader.patch
URL: <http://tug.org/pipermail/luatex/attachments/20100707/58a6bbd5/attachment.pl>


More information about the luatex mailing list