]> git.donarmstrong.com Git - lilypond.git/commitdiff
(open_library): dlopen libkpathsea.so
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 6 Mar 2005 19:30:25 +0000 (19:30 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 6 Mar 2005 19:30:25 +0000 (19:30 +0000)
ChangeLog
VERSION
config.hh.in
config.make.in
kpath-guile/kpath.c

index d3409d655a09a3dc69d0e47f5516b7b7ad09b446..115564af53f000d7d12d9bf2122893f0695a1b91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-03-06  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * kpath-guile/kpath.c (open_library): dlopen libkpathsea.so
+
 2005-03-06  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        Drop run-time dependency on teTeX.
@@ -40,8 +44,6 @@
 
        * lily/font-config.cc (init_fontconfig): add cff/ too.
 
-       * mf/GNUmakefile: generate .commonff to not confuse fontconfig.
-
        * ly/generate-embedded-cff.ly: capitalize.
 
        * lily/pango-select.cc (select_pango_font): use ::find_pango_font,
@@ -53,9 +55,6 @@
        * lily/main.cc: only look at one prefix directory, LILYPONDPREFIX
        overrides all. 
 
-       * config.make (package_suffix): use lilypond/MAJOR.MINOR as install
-       directory.
-
        * configure.in (gui_b): remove ec mftrace check
 
        * config.hh.in: use lilypond-Major.Minor as data directory.
diff --git a/VERSION b/VERSION
index b54a42ecf3f3d4d29b41ac46c9b07747d317b0ee..f2bd041d8b00b99ba720fe1b1f0df77f96f5d59f 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,5 +1,4 @@
 PACKAGE_NAME=LilyPond
-
 MAJOR_VERSION=2
 MINOR_VERSION=5
 PATCH_LEVEL=14
index 759ad72f0b03e9be4090668543f24ea3c124c070..9e482eab0b4f4c3703065e6fec9597fc1406cc5c 100644 (file)
@@ -5,9 +5,11 @@
 /* datadir */
 #define DATADIR "@DATADIR@"
 
+#define TOPLEVEL_VERSION "@TOPLEVEL_VERSION@"
+
 /* LilyPond init and input base directory */
 
-#define PACKAGE_DATADIR DATADIR "/" PACKAGE / "@TOPLEVEL_VERSION@"
+#define PACKAGE_DATADIR DATADIR "/" PACKAGE "/" TOPLEVEL_VERSION
 #define LILYPOND_DATADIR PACKAGE_DATADIR
 
 /* default lilypond locale dir */
index 553f291aa93b2e39259b3181de332340f93eb1ff..4508b2a92ea0aa33a7b1566a516c5c571565c9d8 100644 (file)
@@ -43,7 +43,7 @@ elispdir = $(datadir)/emacs/site-lisp
 # forced instead of $(datadir)/vim
 
 # move out of config.make.in?
-package_suffix = $(package)$(MAJOR_VERSION).$(MINOR_VERSION)
+package_suffix = $(package)/$(TOPLEVEL_VERSION)
 package_datadir = $(datadir)/$(package_suffix)
 package_infodir = $(infodir)/$(package_suffix)
 package_libdir = $(libdir)/$(package_suffix)
index 01f3fde5581e5318eb00ca93e5e03c5477f8ee81..5e6e9155eb25dfcb7760c7db42d7fa9cb355f6ca 100644 (file)
@@ -12,8 +12,7 @@
 #include "config.hh"
 #include "guile-compatibility.hh"
 
-#if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
-
+#include <dlfcn.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -42,7 +41,16 @@ I found a somewhat more elegant patch for this: Just #include
 
 
 #if KPATHSEA
-/* FIXME: this should be part of kpathsea */
+
+
+#if HAVE_KPATHSEA_KPATHSEA_H
+static  void *kpathsea_handle = 0;
+static  char *(*dl_kpse_find_file) (char const*, kpse_file_format_type, boolean) = 0;
+static  void (*dl_kpse_maketex_option) (char const*, boolean) = 0;
+static  void (*dl_kpse_set_program_name) (char const*) = 0;
+static  char const *(*dl_kpse_init_format) (kpse_file_format_type) = 0;
+static  char *(*dl_kpse_var_expand) (char const*) = 0;
+static  kpse_format_info_type (*dl_kpse_format_info)[kpse_last_format] = 0;
 
 kpse_file_format_type
 kpathsea_find_format (const char* name)
@@ -51,12 +59,12 @@ kpathsea_find_format (const char* name)
   int len = strlen (name);
   for (i = 0; i < kpse_last_format; i++)
     {
-      if (!kpse_format_info[i].type)
-        kpse_init_format ((kpse_file_format_type) i);
+       if (!(*dl_kpse_format_info)[i].type)
+        (*dl_kpse_init_format) ((kpse_file_format_type) i);
 
-      char const **suffixes[] = { kpse_format_info[i].suffix,
-                                 kpse_format_info[i].alt_suffix };
-      for (int j = 0; j < 2; j++)
+       char const **suffixes[] = { (*dl_kpse_format_info)[i].suffix,
+                                  (*dl_kpse_format_info)[i].alt_suffix };
+       for (int j = 0; j < 2; j++)
        for (char const **p = suffixes[j]; p && *p; p++)
          {
            int suflen = strlen (*p);
@@ -69,11 +77,6 @@ kpathsea_find_format (const char* name)
 }
 #endif
 
-
-
-
-
-
 //        "Return the absolute file name of @var{name}, "
 //        "or @code{#f} if not found.")
 SCM
@@ -82,8 +85,8 @@ ly_kpathsea_find_file(SCM name)
   SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
 
   char const * nm = scm_i_string_chars (name);
-  char *p = kpse_find_file (nm, kpathsea_find_format (nm),
-                           true);
+  char *p = (*dl_kpse_find_file) (nm, kpathsea_find_format (nm),
+                                 true);
   if (p)
     return scm_makfrom0str (p);
   return SCM_BOOL_F;
@@ -103,16 +106,71 @@ SCM ly_kpathsea_expand_variable(SCM var)
 }
 
 
+static char const* LIBKPATHSEA = "libkpathsea.so";
+
+int
+open_library ()
+{
+#if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
+  struct
+  {
+    void **func_pointer;
+    char const *name; 
+  } symbols[] = {
+    {(void*)&dl_kpse_find_file, "kpse_find_file"},
+    {(void*)&dl_kpse_set_program_name, "kpse_set_program_name"},
+    {(void*)&dl_kpse_format_info, "kpse_format_info"},
+    {(void*)&dl_kpse_init_format, "kpse_init_format"},
+    {(void*)&dl_kpse_maketex_option, "kpse_maketex_option"},
+    {(void*)&dl_kpse_var_expand, "kpse_var_expand"},
+    {0,0}
+  };
+
+
+  dlerror ();
+  kpathsea_handle = dlopen (LIBKPATHSEA, RTLD_LAZY);
+  if (!kpathsea_handle)
+    {
+      /*
+       todo i18n.
+       */
+      fprintf (stderr, "can't dlopen: %s: %s", LIBKPATHSEA, dlerror ());
+      fprintf (stderr,"install package: %s or %s",
+              "libkpathsea3 (teTeX 2.x)",
+              "libkpathsea4 (teTeX 3.x)");
+
+      return 1;
+    }
+
+  for (int i = 0; symbols[i].func_pointer; i++)
+    {
+      dlerror ();
+      *symbols[i].func_pointer = dlsym (kpathsea_handle, symbols[i].name);
+      if (!symbols[i].func_pointer)
+       {
+         fprintf(stderr, "no such symbol: %s: %s",
+                 symbols[i].name,
+                 dlerror ());
+         return 1;
+       }
+    }
+
+  return 0;
+#endif
+}
 
 void
 initialize_kpathsea ()
 {
-  /*
-   initialize kpathsea
-   */
-  kpse_set_program_name ("lilypond", NULL);
-  kpse_maketex_option ("tfm", TRUE);
+  if (open_library ())
+    {
+      fprintf (stderr, "Error opening kpathsea library. Aborting");
+      exit (1);
+    }
 
+  (*dl_kpse_set_program_name) ("lilypond");
+  (*dl_kpse_maketex_option) ("tfm", TRUE);
+  
   SCM find = scm_c_define_gsubr ("ly:kpathsea-find-file", 1, 0, 0, ly_kpathsea_find_file);
   scm_c_export ("ly:kpathsea-find-file", NULL);
   SCM expand = scm_c_define_gsubr ("ly:kpathsea-expand-variable", 1, 0, 0, ly_kpathsea_find_file);