unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Included libraries in the Windows binary distribution
@ 2012-01-03 23:55 Lars Magne Ingebrigtsen
  2012-01-04  1:09 ` Juanma Barranquero
  2012-01-04  5:09 ` Eli Zaretskii
  0 siblings, 2 replies; 20+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-01-03 23:55 UTC (permalink / raw)
  To: emacs-devel

There's been a lot of discussion about including libgnutls with the
Emacs binaries, and I'm obviously all for that.  But nobody has
mentioned libxml2.  I'd rather like to have that included, too, so that
people can read HTML in Emacs.

So what are the "guidelines", if any, about what libraries get included
in the binary Windows builds?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-01-03 23:55 Included libraries in the Windows binary distribution Lars Magne Ingebrigtsen
@ 2012-01-04  1:09 ` Juanma Barranquero
  2012-01-04  3:10   ` Lars Magne Ingebrigtsen
  2012-01-04  5:09 ` Eli Zaretskii
  1 sibling, 1 reply; 20+ messages in thread
From: Juanma Barranquero @ 2012-01-04  1:09 UTC (permalink / raw)
  To: emacs-devel

On Wed, Jan 4, 2012 at 00:55, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:

> But nobody has mentioned libxml2.  I'd rather like to have that included, too, so that
> people can read HTML in Emacs.

Is the Windows port able to use libxml2?

> So what are the "guidelines", if any, about what libraries get included
> in the binary Windows builds?

"None that is not strictly required" seems like a good start IMHO.

    Juanma



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-01-04  1:09 ` Juanma Barranquero
@ 2012-01-04  3:10   ` Lars Magne Ingebrigtsen
  2012-01-04  5:10     ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-01-04  3:10 UTC (permalink / raw)
  To: emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> Is the Windows port able to use libxml2?

http://xmlsoft.org/ claims that libxml2 can be used on most operating
systems.

> "None that is not strictly required" seems like a good start IMHO.

ed is the standard editor!

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-01-03 23:55 Included libraries in the Windows binary distribution Lars Magne Ingebrigtsen
  2012-01-04  1:09 ` Juanma Barranquero
@ 2012-01-04  5:09 ` Eli Zaretskii
  2012-02-04 13:42   ` Eli Zaretskii
  1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2012-01-04  5:09 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: emacs-devel

> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 04 Jan 2012 00:55:08 +0100
> 
> There's been a lot of discussion about including libgnutls with the
> Emacs binaries, and I'm obviously all for that.  But nobody has
> mentioned libxml2.  I'd rather like to have that included, too, so that
> people can read HTML in Emacs.

Making it possible to build Emacs on Windows with libxml2 is a
standing todo item that I hope will be done soon.

> So what are the "guidelines", if any, about what libraries get included
> in the binary Windows builds?

Like Juanma said: only those that are absolutely necessary for Emacs
to run.  For now, that's only libxpm (needed to display the tool-bar
icons).



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-01-04  3:10   ` Lars Magne Ingebrigtsen
@ 2012-01-04  5:10     ` Eli Zaretskii
  0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2012-01-04  5:10 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: emacs-devel

> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 04 Jan 2012 04:10:28 +0100
> 
> Juanma Barranquero <lekktu@gmail.com> writes:
> 
> > Is the Windows port able to use libxml2?
> 
> http://xmlsoft.org/ claims that libxml2 can be used on most operating
> systems.

That's not what Juanma asked.  He asked whether _Emacs_ can use
libxml2 on Windows.  And the answer is "not yet".



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-01-04  5:09 ` Eli Zaretskii
@ 2012-02-04 13:42   ` Eli Zaretskii
  2012-02-05  0:37     ` Juanma Barranquero
                       ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Eli Zaretskii @ 2012-02-04 13:42 UTC (permalink / raw)
  To: larsi, Stefan Monnier, Chong Yidong; +Cc: emacs-devel

> Date: Wed, 04 Jan 2012 00:09:51 -0500
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> > Date: Wed, 04 Jan 2012 00:55:08 +0100
> > 
> > There's been a lot of discussion about including libgnutls with the
> > Emacs binaries, and I'm obviously all for that.  But nobody has
> > mentioned libxml2.  I'd rather like to have that included, too, so that
> > people can read HTML in Emacs.
> 
> Making it possible to build Emacs on Windows with libxml2 is a
> standing todo item that I hope will be done soon.

The changes to support libxml2 in the Windows build are below.  Would
people who build Emacs on Windows please try them?  Precompiled
Windows binaries of libxml2 can be found here:

    http://sourceforge.net/projects/ezwinports/files/

Note that if you install the binaries from the above site, you need to
use "--cflags -I/path/to/include/libxml2" when invoking configure.bat,
because libxml2 headers are installed into the include/libxml2
directory.  Other distributions may use other directories.  (I could
have used pkg-config to figure that out automatically, but I'm
reluctant to request users to install pkg-config as prerequisite for
building Emacs.  Besides, at least one binary distro of libxml2 for
Windows I saw doesn't include the libxml-2.0.pc file that pkg-config
needs to do its job.)

Stefan and Chong: assuming that these changes are reported to work
well, is it safe to install them now, or do we want to postpone them
until after 24.1?


=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog	2012-02-04 13:25:57 +0000
+++ b/lisp/ChangeLog	2012-02-04 13:27:51 +0000
@@ -1,3 +1,7 @@
+2012-02-04  Eli Zaretskii  <eliz@gnu.org>
+
+	* term/w32-win.el (dynamic-library-alist): Add libxml2 DLLs.
+
 2012-02-04  Lars Ljung  <lars@matholka.se>  (tiny change)
 
 	* eshell/esh-ext.el (eshell-windows-shell-file): Match "cmdproxy"

=== modified file 'lisp/term/w32-win.el'
--- a/lisp/term/w32-win.el	2012-02-04 13:25:57 +0000
+++ b/lisp/term/w32-win.el	2012-02-04 13:27:51 +0000
@@ -210,7 +210,8 @@
        '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
        '(glib "libglib-2.0-0.dll")
        '(gobject "libgobject-2.0-0.dll")
-       '(gnutls "libgnutls-28.dll" "libgnutls-26.dll")))
+       '(gnutls "libgnutls-28.dll" "libgnutls-26.dll")
+       '(libxml2 "libxml2-2.dll" "libxml2.dll")))
 
 ;;; multi-tty support
 (defvar w32-initialized nil

=== modified file 'nt/ChangeLog'
--- a/nt/ChangeLog	2012-02-04 13:25:57 +0000
+++ b/nt/ChangeLog	2012-02-04 13:27:51 +0000
@@ -1,5 +1,10 @@
 2012-02-04  Eli Zaretskii  <eliz@gnu.org>
 
+	* configure.bat: Support building with libxml2.
+
+	* INSTALL:
+	* README.W32: Add information about libxml2.
+
 	* inc/sys/stat.h (_STAT_DEFINED): Define, to prevent redefinitions
 	by other headers.
 

=== modified file 'nt/INSTALL'
--- a/nt/INSTALL	2012-02-04 13:25:57 +0000
+++ b/nt/INSTALL	2012-02-04 13:27:51 +0000
@@ -367,6 +367,20 @@
   You can get pre-built binaries (including any required DLL and the
   header files) at http://sourceforge.net/projects/ezwinports/files/.
 
+* Optional libxml2 support
+
+  If configure.bat finds the libxml/HTMLparser.h file in the include path,
+  Emacs is built with libxml2 support by default; to avoid that you can
+  pass the argument --without-libxml2.
+
+  In order to support libxml2 at runtime, a libxml2-enabled Emacs must
+  be able to find the relevant DLLs during startup; failure to do so
+  is not an error, but libxml2 features won't be available to the
+  running session.
+
+  You can get pre-built binaries (including any required DLL and the
+  header files) at http://sourceforge.net/projects/ezwinports/files/.
+
 * Experimental SVG support
 
   SVG support is currently experimental, and not built by default.

=== modified file 'nt/README.W32'
--- a/nt/README.W32	2012-02-04 13:25:57 +0000
+++ b/nt/README.W32	2012-02-04 13:27:51 +0000
@@ -169,6 +169,16 @@
   You can get pre-built binaries (including any required DLL and the
   header files) at http://sourceforge.net/projects/ezwinports/files/.
 
+* libxml2 support
+
+  In order to support libxml2 at runtime, a libxml2-enabled Emacs must
+  be able to find the relevant DLLs during startup; failure to do so
+  is not an error, but libxml2 features won't be available to the
+  running session.
+
+  You can get pre-built binaries (including any required DLL and the
+  header files) at http://sourceforge.net/projects/ezwinports/files/.
+
 * Uninstalling Emacs
 
   If you should need to uninstall Emacs, simply delete all the files

=== modified file 'nt/configure.bat'
--- a/nt/configure.bat	2012-02-04 13:25:57 +0000
+++ b/nt/configure.bat	2012-02-04 13:27:51 +0000
@@ -131,6 +131,7 @@
 if "%1" == "--without-gif" goto withoutgif
 if "%1" == "--without-tiff" goto withouttiff
 if "%1" == "--without-gnutls" goto withoutgnutls
+if "%1" == "--without-libxml2" goto withoutlibxml2
 if "%1" == "--without-xpm" goto withoutxpm
 if "%1" == "--with-svg" goto withsvg
 if "%1" == "--distfiles" goto distfiles
@@ -156,6 +157,7 @@
 echo.   --without-tiff          do not use TIFF library even if it is installed
 echo.   --without-xpm           do not use XPM library even if it is installed
 echo.   --without-gnutls        do not use GnuTLS library even if it is installed
+echo.   --without-libxml2       do not use libxml2 library even if it is installed
 echo.   --with-svg              use the RSVG library (experimental)
 echo.   --distfiles             path to files for make dist, e.g. libXpm.dll
 if "%use_extensions%" == "0" goto end
@@ -317,6 +319,14 @@
 
 rem ----------------------------------------------------------------------
 
+:withoutlibxml2
+set libxml2support=N
+set HAVE_LIBXML2=
+shift
+goto again
+
+rem ----------------------------------------------------------------------
+
 :withouttiff
 set tiffsupport=N
 set HAVE_TIFF=
@@ -569,6 +579,28 @@
 :tlsDone
 rm -f junk.c junk.obj
 
+if (%libxml2support%) == (N) goto xml2Done
+
+echo Checking for libxml2....
+echo #include "libxml/HTMLparser.h" >junk.c
+echo main(){} >>junk.c
+echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
+%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
+if exist junk.obj goto havelibxml2
+
+echo ...libxml/HTMLparser.h not found, building without libxml2 support
+echo The failed program was: >>config.log
+type junk.c >>config.log
+set HAVE_LIBXML2=
+goto xml2Done
+
+:havelibxml2
+echo ...libxml2 header available, building with libxml2 support
+set HAVE_LIBXML2=1
+
+:xml2Done
+rm -f junk.c junk.obj
+
 if (%jpegsupport%) == (N) goto jpegDone
 
 echo Checking for jpeg-6b...
@@ -757,6 +789,7 @@
 if (%profile%) == (Y) echo #define PROFILING 1 >>config.tmp
 if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp
 if not "(%HAVE_GNUTLS%)" == "()" echo #define HAVE_GNUTLS 1 >>config.tmp
+if not "(%HAVE_LIBXML2%)" == "()" echo #define HAVE_LIBXML2 1 >>config.tmp
 if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>config.tmp
 if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>config.tmp
 if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>config.tmp
@@ -896,6 +929,7 @@
 set distFilesOk=
 set pngsupport=
 set tlssupport=
+set libxml2support=
 set jpegsupport=
 set gifsupport=
 set tiffsupport=

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog	2012-02-04 13:25:57 +0000
+++ b/src/ChangeLog	2012-02-04 13:27:51 +0000
@@ -1,3 +1,29 @@
+2012-02-04  Eli Zaretskii  <eliz@gnu.org>
+
+	Support building on MS-Windows with libxml2.
+
+	* makefile.w32-in (OBJ2): Add xml.$(O).
+	(GLOBAL_SOURCES): Add xml.c.
+	($(BLD)/xml.$(O)): New dependency list.
+
+	* xml.c (DEF_XML2_FN, LOAD_XML2_FN) [WINDOWSNT]: New macros.
+	(fn_htmlReadMemory, fn_xmlReadMemory, fn_xmlDocGetRootElement)
+	(fn_xmlFreeDoc, fn_xmlCleanupParser, fn_xmlCheckVersion)
+	[!WINDOWSNT]: New macros.
+	(init_libxml2_functions): New function.
+	(parse_region): Call fn_xmlCheckVersion instead of using the macro
+	LIBXML_TEST_VERSION.  Call libxml2 functions via the fn_* macros.
+	(xml_cleanup_parser): New function, export for fn_xmlCleanupParser.
+	(Flibxml_parse_html_region, Flibxml_parse_xml_region): Call
+	init_libxml2_functions before calling libxml2 functions.
+	(syms_of_xml) <Qlibxml2_dll>: DEFSYM it.
+
+	* emacs.c: Don't include libxml/parser.h.
+	(shut_down_emacs): Call xml_cleanup_parser, instead of calling
+	xmlCleanupParser directly.
+
+	* lisp.h [HAVE_LIBXML2]: Add prototype for xml_cleanup_parser.
+
 2012-02-04  Martin Rudalics  <rudalics@gmx.at>
 
 	* dispnew.c (change_frame_size_1): Calculate new_frame_total_cols

=== modified file 'src/emacs.c'
--- a/src/emacs.c	2012-02-04 13:25:57 +0000
+++ b/src/emacs.c	2012-02-04 13:27:51 +0000
@@ -82,10 +82,6 @@
 #include <sys/personality.h>
 #endif
 
-#ifdef HAVE_LIBXML2
-#include <libxml/parser.h>
-#endif
-
 #ifndef O_RDWR
 #define O_RDWR 2
 #endif
@@ -2124,7 +2120,7 @@
 #endif
 
 #ifdef HAVE_LIBXML2
-  xmlCleanupParser ();
+  xml_cleanup_parser ();
 #endif
 }
 

=== modified file 'src/lisp.h'
--- a/src/lisp.h	2012-02-04 13:25:57 +0000
+++ b/src/lisp.h	2012-02-04 13:27:51 +0000
@@ -3542,6 +3542,7 @@
 #ifdef HAVE_LIBXML2
 /* Defined in xml.c */
 extern void syms_of_xml (void);
+extern void xml_cleanup_parser (void);
 #endif
 
 #ifdef HAVE_MENUS

=== modified file 'src/makefile.w32-in'
--- a/src/makefile.w32-in	2012-02-04 13:25:57 +0000
+++ b/src/makefile.w32-in	2012-02-04 13:27:51 +0000
@@ -128,6 +128,7 @@
 	$(BLD)/image.$(O)		\
 	$(BLD)/terminal.$(O)            \
 	$(BLD)/menu.$(O)		\
+	$(BLD)/xml.$(O)			\
 	$(BLD)/w32term.$(O)		\
 	$(BLD)/w32xfns.$(O)		\
 	$(BLD)/w32fns.$(O)		\
@@ -225,7 +226,7 @@
 	process.c callproc.c unexw32.c \
 	region-cache.c sound.c atimer.c \
 	doprnt.c intervals.c textprop.c composite.c \
-	gnutls.c
+	gnutls.c xml.c
 SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
 	xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o dbusbind.o
 obj = $(GLOBAL_SOURCES:.c=.o)
@@ -940,6 +941,13 @@
 	$(LISP_H) \
 	$(PROCESS_H)
 
+$(BLD)/xml.$(O) : \
+	$(SRC)/xml.c \
+	$(SRC)/w32.h \
+	$(CONFIG_H) \
+	$(LISP_H) \
+	$(SRC)/buffer.h
+
 $(BLD)/image.$(O) : \
 	$(SRC)/image.c \
 	$(SRC)/epaths.h \

=== modified file 'src/xml.c'
--- a/src/xml.c	2012-02-04 13:25:57 +0000
+++ b/src/xml.c	2012-02-04 13:27:51 +0000
@@ -28,6 +28,83 @@
 #include "lisp.h"
 #include "buffer.h"
 
+\f
+#ifdef WINDOWSNT
+
+#include <windows.h>
+#include "w32.h"
+
+/* Macro for defining functions that will be loaded from the libxml2 DLL.  */
+#define DEF_XML2_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args
+
+/* Macro for loading libxml2 functions from the library.  */
+#define LOAD_XML2_FN(lib,func) {					\
+    fn_##func = (void *) GetProcAddress (lib, #func);			\
+    if (!fn_##func) goto bad_library;					\
+  }
+
+DEF_XML2_FN (htmlDocPtr, htmlReadMemory,
+	     (const char *, int, const char *, const char *, int));
+DEF_XML2_FN (xmlDocPtr, xmlReadMemory,
+	     (const char *, int, const char *, const char *, int));
+DEF_XML2_FN (xmlNodePtr, xmlDocGetRootElement, (xmlDocPtr));
+DEF_XML2_FN (void, xmlFreeDoc, (xmlDocPtr));
+DEF_XML2_FN (void, xmlCleanupParser, (void));
+DEF_XML2_FN (void, xmlCheckVersion, (int));
+
+#else  /* !WINDOWSNT */
+
+#define fn_htmlReadMemory       htmlReadMemory
+#define fn_xmlReadMemory        xmlReadMemory
+#define fn_xmlDocGetRootElement xmlDocGetRootElement
+#define fn_xmlFreeDoc           xmlFreeDoc
+#define fn_xmlCleanupParser     xmlCleanupParser
+#define fn_xmlCheckVersion      xmlCheckVersion
+
+#endif	/* !WINDOWSNT */
+
+static Lisp_Object Qlibxml2_dll;
+
+static int
+init_libxml2_functions (Lisp_Object libraries)
+{
+#ifdef WINDOWSNT
+  Lisp_Object found = Fassq (Qlibxml2_dll, Vlibrary_cache);
+
+  if (CONSP (found))
+    return EQ (XCDR (found), Qt) ? 1 : 0;
+  else
+    {
+      HMODULE library;
+
+      if (!(library = w32_delayed_load (libraries, Qlibxml2_dll)))
+	{
+	  message ("%s", "libxml2 library not found");
+	  return 0;
+	}
+
+      /* LOAD_XML2_FN jumps to bad_library if it fails to find the
+	 named function.  */
+      LOAD_XML2_FN (library, htmlReadMemory);
+      LOAD_XML2_FN (library, xmlReadMemory);
+      LOAD_XML2_FN (library, xmlDocGetRootElement);
+      LOAD_XML2_FN (library, xmlFreeDoc);
+      LOAD_XML2_FN (library, xmlCleanupParser);
+      LOAD_XML2_FN (library, xmlCheckVersion);
+
+      Vlibrary_cache = Fcons (Fcons (Qlibxml2_dll, Qt), Vlibrary_cache);
+      return 1;
+    }
+
+ bad_library:
+  Vlibrary_cache = Fcons (Fcons (Qlibxml2_dll, Qnil), Vlibrary_cache);
+
+  return 0;
+#else  /* !WINDOWSNT */
+  return 1;
+#endif	/* !WINDOWSNT */
+}
+
 static Lisp_Object
 make_dom (xmlNode *node)
 {
@@ -92,7 +169,7 @@
   EMACS_INT bytes;
   EMACS_INT istart, iend;
 
-  LIBXML_TEST_VERSION;
+  fn_xmlCheckVersion (LIBXML_VERSION);
 
   validate_region (&start, &end);
 
@@ -111,16 +188,16 @@
   bytes = CHAR_TO_BYTE (iend) - CHAR_TO_BYTE (istart);
 
   if (htmlp)
-    doc = htmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)),
-			  bytes, burl, "utf-8",
-			  HTML_PARSE_RECOVER|HTML_PARSE_NONET|
-			  HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR|
-			  HTML_PARSE_NOBLANKS);
+    doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)),
+			     bytes, burl, "utf-8",
+			     HTML_PARSE_RECOVER|HTML_PARSE_NONET|
+			     HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR|
+			     HTML_PARSE_NOBLANKS);
   else
-    doc = xmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)),
-			 bytes, burl, "utf-8",
-			 XML_PARSE_NONET|XML_PARSE_NOWARNING|
-			 XML_PARSE_NOBLANKS |XML_PARSE_NOERROR);
+    doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)),
+			    bytes, burl, "utf-8",
+			    XML_PARSE_NONET|XML_PARSE_NOWARNING|
+			    XML_PARSE_NOBLANKS |XML_PARSE_NOERROR);
 
   if (doc != NULL)
     {
@@ -139,19 +216,26 @@
       if (NILP (result)) {
 	/* The document isn't just comments, so get the tree the
 	   proper way. */
-	xmlNode *node = xmlDocGetRootElement (doc);
+	xmlNode *node = fn_xmlDocGetRootElement (doc);
 	if (node != NULL)
 	  result = make_dom (node);
       } else
 	result = Fcons (intern ("top"),
 			Fcons (Qnil, Fnreverse (Fcons (r, result))));
 
-      xmlFreeDoc (doc);
+      fn_xmlFreeDoc (doc);
     }
 
   return result;
 }
 
+void
+xml_cleanup_parser (void)
+{
+  if (init_libxml2_functions (Vdynamic_library_alist))
+    fn_xmlCleanupParser ();
+}
+
 DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region,
        Slibxml_parse_html_region,
        2, 3, 0,
@@ -159,7 +243,9 @@
 If BASE-URL is non-nil, it is used to expand relative URLs.  */)
   (Lisp_Object start, Lisp_Object end, Lisp_Object base_url)
 {
-  return parse_region (start, end, base_url, 1);
+  if (init_libxml2_functions (Vdynamic_library_alist))
+    return parse_region (start, end, base_url, 1);
+  return Qnil;
 }
 
 DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region,
@@ -169,7 +255,9 @@
 If BASE-URL is non-nil, it is used to expand relative URLs.  */)
   (Lisp_Object start, Lisp_Object end, Lisp_Object base_url)
 {
-  return parse_region (start, end, base_url, 0);
+  if (init_libxml2_functions (Vdynamic_library_alist))
+    return parse_region (start, end, base_url, 0);
+  return Qnil;
 }
 
 \f
@@ -181,6 +269,8 @@
 {
   defsubr (&Slibxml_parse_html_region);
   defsubr (&Slibxml_parse_xml_region);
+
+  DEFSYM (Qlibxml2_dll, "libxml2");
 }
 
 #endif /* HAVE_LIBXML2 */




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-04 13:42   ` Eli Zaretskii
@ 2012-02-05  0:37     ` Juanma Barranquero
  2012-02-05 16:32       ` Eli Zaretskii
  2012-02-05  3:00     ` Christoph Scholtes
  2012-02-08  4:02     ` Eli Zaretskii
  2 siblings, 1 reply; 20+ messages in thread
From: Juanma Barranquero @ 2012-02-05  0:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Chong Yidong, larsi, Stefan Monnier, emacs-devel

On Sat, Feb 4, 2012 at 14:42, Eli Zaretskii <eliz@gnu.org> wrote:

> The changes to support libxml2 in the Windows build are below.  Would
> people who build Emacs on Windows please try them?

Builds and works OK.

The only additional change needed is to add

=== modified file 'lib-src/makefile.w32-in'
--- lib-src/makefile.w32-in	2012-01-19 07:21:25 +0000
+++ lib-src/makefile.w32-in	2012-02-05 00:34:04 +0000
@@ -141,5 +141,5 @@
 	region-cache.o sound.o atimer.o \
 	doprnt.o intervals.o textprop.o composite.o \
-	gnutls.o
+	gnutls.o xml.o

 #


so xml.c functions are in DOC.

    Juanma



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-04 13:42   ` Eli Zaretskii
  2012-02-05  0:37     ` Juanma Barranquero
@ 2012-02-05  3:00     ` Christoph Scholtes
  2012-02-05 16:32       ` Eli Zaretskii
  2012-02-08  4:02     ` Eli Zaretskii
  2 siblings, 1 reply; 20+ messages in thread
From: Christoph Scholtes @ 2012-02-05  3:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs-Devel devel

On 2/4/2012 6:42 AM, Eli Zaretskii wrote:

>> Making it possible to build Emacs on Windows with libxml2 is a
>> standing todo item that I hope will be done soon.
>
> The changes to support libxml2 in the Windows build are below.  Would
> people who build Emacs on Windows please try them?  Precompiled
> Windows binaries of libxml2 can be found here:
>
>      http://sourceforge.net/projects/ezwinports/files/

Thanks Eli!

I downloaded the files from your site, applied the patches and 
configure.bat fails with the following error:

In file included from 
D:/devel/emacs/libs/libxml2-2.7.8/include/libxml2/libxml/parser.h:807:0,
                  from 
D:/devel/emacs/libs/libxml2-2.7.8/include/libxml2/libxml/HTMLparser.h:16,
                  from junk.c:1:
D:/devel/emacs/libs/libxml2-2.7.8/include/libxml2/libxml/encoding.h:28:19: 
fatal error: iconv.h: No such file or directory
compilation terminated.

Looks like there is an dependency on libiconv, which I don't have 
installed. Should these dependencies be included in your libxml2 download?

Thanks,
Christoph



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05  3:00     ` Christoph Scholtes
@ 2012-02-05 16:32       ` Eli Zaretskii
  2012-02-05 19:27         ` Christoph Scholtes
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2012-02-05 16:32 UTC (permalink / raw)
  To: Christoph Scholtes; +Cc: emacs-devel

> Date: Sat, 04 Feb 2012 20:00:23 -0700
> From: Christoph Scholtes <cschol2112@googlemail.com>
> CC: Emacs-Devel devel <emacs-devel@gnu.org>
> 
> I downloaded the files from your site, applied the patches and 
> configure.bat fails with the following error:
> 
> In file included from 
> D:/devel/emacs/libs/libxml2-2.7.8/include/libxml2/libxml/parser.h:807:0,
>                   from 
> D:/devel/emacs/libs/libxml2-2.7.8/include/libxml2/libxml/HTMLparser.h:16,
>                   from junk.c:1:
> D:/devel/emacs/libs/libxml2-2.7.8/include/libxml2/libxml/encoding.h:28:19: 
> fatal error: iconv.h: No such file or directory
> compilation terminated.
> 
> Looks like there is an dependency on libiconv, which I don't have 
> installed.

Right.  Please install this:

  http://sourceforge.net/projects/mingw/files/MinGW/Base/libiconv/libiconv-1.13.1-1/libiconv-1.13.1-1-mingw32-dev.tar.lzma/download

> Should these dependencies be included in your libxml2 download?

I'd rather not.  As much as I hate requesting users to download
dependencies, I'll have to punt in this case: the above tarball
includes more than just one header file, and is really needed if one
wants to link against libxml2.  (Emacs doesn't link against the
library, but that's not the usual case for library users.)

I will add this requirement to the relevant README files, including in
Emacs.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05  0:37     ` Juanma Barranquero
@ 2012-02-05 16:32       ` Eli Zaretskii
  0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2012-02-05 16:32 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: cyd, larsi, monnier, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Sun, 5 Feb 2012 01:37:43 +0100
> Cc: larsi@gnus.org, Stefan Monnier <monnier@iro.umontreal.ca>, 
> 	Chong Yidong <cyd@stupidchicken.com>, emacs-devel@gnu.org
> 
> On Sat, Feb 4, 2012 at 14:42, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > The changes to support libxml2 in the Windows build are below.  Would
> > people who build Emacs on Windows please try them?
> 
> Builds and works OK.
> 
> The only additional change needed is to add
> 
> === modified file 'lib-src/makefile.w32-in'
> --- lib-src/makefile.w32-in	2012-01-19 07:21:25 +0000
> +++ lib-src/makefile.w32-in	2012-02-05 00:34:04 +0000
> @@ -141,5 +141,5 @@
>  	region-cache.o sound.o atimer.o \
>  	doprnt.o intervals.o textprop.o composite.o \
> -	gnutls.o
> +	gnutls.o xml.o
> 
>  #
> 
> 
> so xml.c functions are in DOC.

Thanks, I will fix this.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05 16:32       ` Eli Zaretskii
@ 2012-02-05 19:27         ` Christoph Scholtes
  2012-02-05 19:52           ` Juanma Barranquero
  0 siblings, 1 reply; 20+ messages in thread
From: Christoph Scholtes @ 2012-02-05 19:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> Right.  Please install this:
>
>   http://sourceforge.net/projects/mingw/files/MinGW/Base/libiconv/libiconv-1.13.1-1/libiconv-1.13.1-1-mingw32-dev.tar.lzma/download

OK.

>> Should these dependencies be included in your libxml2 download?
>
> I'd rather not.  As much as I hate requesting users to download
> dependencies, I'll have to punt in this case: the above tarball
> includes more than just one header file, and is really needed if one
> wants to link against libxml2.  (Emacs doesn't link against the
> library, but that's not the usual case for library users.)

No problem. It is not that big of a deal.

> I will add this requirement to the relevant README files, including in
> Emacs.

Thanks.

So I successfully compiled with the patch and the libraries, however
during bootstrap I got "libxml2 library not found" all over the place
during compilation of elisp files. It shows up after compilation of
every single .elc file. Is this expected? I don't have the
binaries on the path anywhere. Just wondering where this output is
generated.

Example output during compilation:
"./../src/oo/i386/emacs.exe" -batch --no-site-file --no-site-lisp -f batch-byte-
compile quail/greek.el
Wrote d:/devel/emacs/emacs-bzr/libxml2/leim/quail/greek.elc
libxml2 library not found
"./../src/oo/i386/emacs.exe" -batch --no-site-file --no-site-lisp -f batch-byte-
compile quail/cyril-jis.el
Wrote d:/devel/emacs/emacs-bzr/libxml2/leim/quail/cyril-jis.elc
libxml2 library not found

Also, once I have compiled support in, how can I test it?

Thanks.

Christoph



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05 19:27         ` Christoph Scholtes
@ 2012-02-05 19:52           ` Juanma Barranquero
  2012-02-05 20:54             ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Juanma Barranquero @ 2012-02-05 19:52 UTC (permalink / raw)
  To: Christoph Scholtes; +Cc: Eli Zaretskii, emacs-devel

On Sun, Feb 5, 2012 at 20:27, Christoph Scholtes
<cschol2112@googlemail.com> wrote:

> So I successfully compiled with the patch and the libraries, however
> during bootstrap I got "libxml2 library not found" all over the place
> during compilation of elisp files. It shows up after compilation of
> every single .elc file. Is this expected? I don't have the
> binaries on the path anywhere. Just wondering where this output is
> generated.

Here.

+      if (!(library = w32_delayed_load (libraries, Qlibxml2_dll)))
+       {
+         message ("%s", "libxml2 library not found");
+         return 0;
+       }

Every .el compiled is one instance of emacs (in batch mode) that fails
to find the library and outputs the message. I think the message is
not necessary (we don't warn if we don't find libpng3 or GnuTLS, for
example).

> Also, once I have compiled support in, how can I test it?

Use libxml-parse-(xml|html)-region.

    Juanma



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05 19:52           ` Juanma Barranquero
@ 2012-02-05 20:54             ` Eli Zaretskii
  2012-02-05 21:21               ` Juanma Barranquero
  2012-02-05 21:45               ` Christoph Scholtes
  0 siblings, 2 replies; 20+ messages in thread
From: Eli Zaretskii @ 2012-02-05 20:54 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: cschol2112, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Sun, 5 Feb 2012 20:52:27 +0100
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> 
> On Sun, Feb 5, 2012 at 20:27, Christoph Scholtes
> <cschol2112@googlemail.com> wrote:
> 
> > So I successfully compiled with the patch and the libraries, however
> > during bootstrap I got "libxml2 library not found" all over the place
> > during compilation of elisp files. It shows up after compilation of
> > every single .elc file. Is this expected? I don't have the
> > binaries on the path anywhere. Just wondering where this output is
> > generated.
> 
> Here.
> 
> +      if (!(library = w32_delayed_load (libraries, Qlibxml2_dll)))
> +       {
> +         message ("%s", "libxml2 library not found");
> +         return 0;
> +       }
> 
> Every .el compiled is one instance of emacs (in batch mode) that fails
> to find the library and outputs the message.

The question is: why does it even try to find it?  And the answer is
that Emacs unconditionally calls xmlCleanupParser on exit, and that
call tries to load the library.

I will fix that.

> I think the message is not necessary (we don't warn if we don't find
> libpng3 or GnuTLS, for example).

Oh, yes, we do:

  static int
  init_gnutls_functions (Lisp_Object libraries)
  {
    HMODULE library;
    int max_log_level = 1;

    if (!(library = w32_delayed_load (libraries, Qgnutls_dll)))
      {
	GNUTLS_LOG (1, max_log_level, "GnuTLS library not found");
	return 0;
      }

> > Also, once I have compiled support in, how can I test it?
> 
> Use libxml-parse-(xml|html)-region.

Yes, that's how I tested it.

These functions are slow, btw.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05 20:54             ` Eli Zaretskii
@ 2012-02-05 21:21               ` Juanma Barranquero
  2012-02-05 21:45               ` Christoph Scholtes
  1 sibling, 0 replies; 20+ messages in thread
From: Juanma Barranquero @ 2012-02-05 21:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: cschol2112, emacs-devel

On Sun, Feb 5, 2012 at 21:54, Eli Zaretskii <eliz@gnu.org> wrote:

> The question is: why does it even try to find it?  And the answer is
> that Emacs unconditionally calls xmlCleanupParser on exit, and that
> call tries to load the library.

Ah, curious :-)

> Oh, yes, we do:

>        GNUTLS_LOG (1, max_log_level, "GnuTLS library not found");
>        return 0;

Well, yes. I suppose if we call GnuTLS functions in batch mode we will
get the message too.

    Juanma



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05 20:54             ` Eli Zaretskii
  2012-02-05 21:21               ` Juanma Barranquero
@ 2012-02-05 21:45               ` Christoph Scholtes
  2012-02-06 13:10                 ` Ted Zlatanov
  1 sibling, 1 reply; 20+ messages in thread
From: Christoph Scholtes @ 2012-02-05 21:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Juanma Barranquero, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> The question is: why does it even try to find it?  And the answer is
> that Emacs unconditionally calls xmlCleanupParser on exit, and that
> call tries to load the library.
>
> I will fix that.

Aha! Something else I noticed that seemed odd. Sometimes during
compilation the output looked like this:

Call to emacs to compile el file
Wrote blabla.elc
libxml2 library not found
libxml2 library not found
libxml2 library not found

I.e. there were multiple calls to find the library right after
another. If the call to the library was on Emacs exit, I am wondering
why it was even started after the first call, since it did not report
that any elc file was written. Just thought I bring it up. Perhaps we
have some unnecessary invocations of the executable during bootstrap?

>> Use libxml-parse-(xml|html)-region.
>
> Yes, that's how I tested it.
>
> These functions are slow, btw.

I tried it and it seems to work fine.

Are there any real-world applications for this? Can I read HTML email
with gnus now?! :)

Some test case like that would be nice. Other than that I am ready to
ship the libxml2 support with the weekly snapshots after the patch
hits the trunk.

Christoph



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-05 21:45               ` Christoph Scholtes
@ 2012-02-06 13:10                 ` Ted Zlatanov
  2012-02-07  2:48                   ` Christoph Scholtes
  0 siblings, 1 reply; 20+ messages in thread
From: Ted Zlatanov @ 2012-02-06 13:10 UTC (permalink / raw)
  To: emacs-devel

On Sun, 05 Feb 2012 14:45:19 -0700 Christoph Scholtes <cschol2112@googlemail.com> wrote: 

CS> Eli Zaretskii <eliz@gnu.org> writes:
>>> Use libxml-parse-(xml|html)-region.
>> 
>> These functions are slow, btw.

CS> I tried it and it seems to work fine.

CS> Are there any real-world applications for this? Can I read HTML email
CS> with gnus now?! :)

Yes, see shr.el.  It's a very good HTML viewer that preserves images and
the useful CSS and layout in Gnus.  Just set `mm-text-html-renderer' to
'mm-shr (it is the default now, I think, but most people customized it
in the past).

Ted




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-06 13:10                 ` Ted Zlatanov
@ 2012-02-07  2:48                   ` Christoph Scholtes
  0 siblings, 0 replies; 20+ messages in thread
From: Christoph Scholtes @ 2012-02-07  2:48 UTC (permalink / raw)
  To: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> Yes, see shr.el.  It's a very good HTML viewer that preserves images and
> the useful CSS and layout in Gnus.  Just set `mm-text-html-renderer' to
> 'mm-shr (it is the default now, I think, but most people customized it
> in the past).

Cool. I'll give that a try. Thanks.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-04 13:42   ` Eli Zaretskii
  2012-02-05  0:37     ` Juanma Barranquero
  2012-02-05  3:00     ` Christoph Scholtes
@ 2012-02-08  4:02     ` Eli Zaretskii
  2012-02-08 19:16       ` Stefan Monnier
  2 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2012-02-08  4:02 UTC (permalink / raw)
  To: monnier, cyd; +Cc: emacs-devel

> Date: Sat, 04 Feb 2012 15:42:18 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> Stefan and Chong: assuming that these changes are reported to work
> well, is it safe to install them now, or do we want to postpone them
> until after 24.1?

Ping!  What's the word on this?



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-08  4:02     ` Eli Zaretskii
@ 2012-02-08 19:16       ` Stefan Monnier
  2012-02-10 10:32         ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2012-02-08 19:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: cyd, emacs-devel

>> Stefan and Chong: assuming that these changes are reported to work
>> well, is it safe to install them now, or do we want to postpone them
>> until after 24.1?
> Ping!  What's the word on this?

The changes to non-w32 code seem not completely trivial (tho mostly
mechanical), so I'm a bit reluctant to have it be included so late in
the pretest.


        Stefan



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Included libraries in the Windows binary distribution
  2012-02-08 19:16       ` Stefan Monnier
@ 2012-02-10 10:32         ` Eli Zaretskii
  0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2012-02-10 10:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: cyd, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: cyd@stupidchicken.com,  emacs-devel@gnu.org
> Date: Wed, 08 Feb 2012 14:16:16 -0500
> 
> >> Stefan and Chong: assuming that these changes are reported to work
> >> well, is it safe to install them now, or do we want to postpone them
> >> until after 24.1?
> > Ping!  What's the word on this?
> 
> The changes to non-w32 code seem not completely trivial (tho mostly
> mechanical), so I'm a bit reluctant to have it be included so late in
> the pretest.

Fair enough.  I've created a wishlist bug report for these changes,
including the diffs (bug #10777).



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-02-10 10:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03 23:55 Included libraries in the Windows binary distribution Lars Magne Ingebrigtsen
2012-01-04  1:09 ` Juanma Barranquero
2012-01-04  3:10   ` Lars Magne Ingebrigtsen
2012-01-04  5:10     ` Eli Zaretskii
2012-01-04  5:09 ` Eli Zaretskii
2012-02-04 13:42   ` Eli Zaretskii
2012-02-05  0:37     ` Juanma Barranquero
2012-02-05 16:32       ` Eli Zaretskii
2012-02-05  3:00     ` Christoph Scholtes
2012-02-05 16:32       ` Eli Zaretskii
2012-02-05 19:27         ` Christoph Scholtes
2012-02-05 19:52           ` Juanma Barranquero
2012-02-05 20:54             ` Eli Zaretskii
2012-02-05 21:21               ` Juanma Barranquero
2012-02-05 21:45               ` Christoph Scholtes
2012-02-06 13:10                 ` Ted Zlatanov
2012-02-07  2:48                   ` Christoph Scholtes
2012-02-08  4:02     ` Eli Zaretskii
2012-02-08 19:16       ` Stefan Monnier
2012-02-10 10:32         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).