]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/GNUmakefile (MODULE_LIBS): link with kpath-guile
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 6 Mar 2005 17:02:03 +0000 (17:02 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 6 Mar 2005 17:02:03 +0000 (17:02 +0000)
* lily/all-font-metrics.cc (kpathsea_find_file): wrapper around
new ly:kpathsea-find-file

* kpath-guile/kpath.c: new file. Put kpath bindings in lib.

* kpath-guile/GNUmakefile: new file

* scm/font.scm (add-music-fonts): load dynamics/numbers through
fontconfig as well.

* mf/GNUmakefile: generate .commonff to not confuse fontconfig.

* lily/main.cc: only look at one prefix directory, LILYPONDPREFIX
overrides all.

* config.hh.in: use lilypond-Major.Minor as data directory.

14 files changed:
ChangeLog
GNUmakefile.in
config.hh.in
kpath-guile/GNUmakefile [new file with mode: 0644]
kpath-guile/kpath.c [new file with mode: 0644]
lily/GNUmakefile
lily/all-font-metrics.cc
lily/include/main.hh
lily/kpath-scheme.cc [deleted file]
lily/kpath.cc [deleted file]
lily/lily-guile.cc
lily/main.cc
lily/pitch.cc
scm/font.scm

index f1437d98392b6572b303239bd0dfc5c2640a30b8..08ae07518ccdde9113f852c016da120f45b20b0a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-03-06  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/GNUmakefile (MODULE_LIBS): link with kpath-guile
+
+       * lily/all-font-metrics.cc (kpathsea_find_file): wrapper around
+       new ly:kpathsea-find-file
+
        * kpath-guile/kpath.c: new file. Put kpath bindings in lib.
 
        * kpath-guile/GNUmakefile: new file
index 45b946f3d65219982bb17b56eed3955393d78839..c603ed52eb6129b56e92a8a62f276f69d14b71da 100644 (file)
@@ -10,7 +10,7 @@ depth = .
 # 
 SUBDIRS = buildscripts python scripts \
        elisp \
-       flower ttftool lily \
+       flower kpath-guile ttftool lily \
        mf ly tex ps scm \
        po make \
        cygwin debian stepmake \
index dff59ec5b23590f1fba825e8087044e8cb4559e9..759ad72f0b03e9be4090668543f24ea3c124c070 100644 (file)
@@ -7,11 +7,8 @@
 
 /* LilyPond init and input base directory */
 
-/*
-urg.
-*/
-/* #define PACKAGE_DATADIR DATADIR "/" PACKAGE "@TOPLEVEL_MAJOR_VERSION@.@TOPLEVEL_MINOR_VERSION@" @MAJOR_VERSION@
-#define LILYPOND_DATADIR PACKAGE_DATADIR */
+#define PACKAGE_DATADIR DATADIR "/" PACKAGE / "@TOPLEVEL_VERSION@"
+#define LILYPOND_DATADIR PACKAGE_DATADIR
 
 /* default lilypond locale dir */
 #define LOCALEDIR "@LOCALEDIR@"
diff --git a/kpath-guile/GNUmakefile b/kpath-guile/GNUmakefile
new file mode 100644 (file)
index 0000000..7d6296b
--- /dev/null
@@ -0,0 +1,21 @@
+# title           top level makefile for FlowerLib
+# file    flower/Makefile
+
+# should reinstate versioning if shared libs are enabled.
+
+depth = ..
+
+NAME = kpath-guile
+MODULE_NAME = kpath-guile
+
+SCRIPTS = 
+STEPMAKE_TEMPLATES=library c po
+
+
+
+include $(depth)/make/stepmake.make 
+
+CFLAGS += -std=c99
+$(outdir)/kpath.o: $(config_hh)
+
+
diff --git a/kpath-guile/kpath.c b/kpath-guile/kpath.c
new file mode 100644 (file)
index 0000000..01f3fde
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+  kpath.c --  implement kpathsea bindings
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
+
+
+#include <libguile.h>
+
+#include "config.hh"
+#include "guile-compatibility.hh"
+
+#if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
+
+#include <stdio.h>
+#include <string.h>
+
+/*
+
+The problem, as far as I can tell, is that MacOS X has its getopt
+prototype in <unistd.h>, while I think other operating systems have it
+in other places. <unistd.h> is included by kpathsea.h, so you end up
+renaming both conflicting prototypes to YAKLUDGE.
+
+I found a somewhat more elegant patch for this: Just #include
+<unistd.h> before defining YAKLUDGE.
+
+*/
+
+#include <unistd.h>    
+
+#define popen REALLYUGLYKLUDGE
+#define pclose ANOTHERREALLYUGLYKLUDGE
+#define getopt YAKLUDGE
+
+#if HAVE_KPATHSEA_KPATHSEA_H
+#include <kpathsea/kpathsea.h>
+#include <kpathsea/tex-file.h>
+#endif
+
+
+#if KPATHSEA
+/* FIXME: this should be part of kpathsea */
+
+kpse_file_format_type
+kpathsea_find_format (const char* name)
+{
+  int i;
+  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);
+
+      char const **suffixes[] = { kpse_format_info[i].suffix,
+                                 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);
+           
+           if (!strncmp (name + len - suflen, *p, suflen))
+             return (kpse_file_format_type) i;
+         }
+    }
+  return kpse_last_format;
+}
+#endif
+
+
+
+
+
+
+//        "Return the absolute file name of @var{name}, "
+//        "or @code{#f} if not found.")
+SCM
+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);
+  if (p)
+    return scm_makfrom0str (p);
+  return SCM_BOOL_F;
+}
+
+//   "Return the expanded version  @var{var}.")
+SCM ly_kpathsea_expand_variable(SCM var)
+{
+  SCM_ASSERT_TYPE (scm_is_string (var), var, SCM_ARG1, __FUNCTION__, "string");
+
+  char const * nm = scm_i_string_chars (var);
+  char *result =  kpse_var_expand (nm);
+  SCM ret =  scm_makfrom0str (result);
+  free (result);
+
+  return ret;
+}
+
+
+
+void
+initialize_kpathsea ()
+{
+  /*
+   initialize kpathsea
+   */
+  kpse_set_program_name ("lilypond", NULL);
+  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);
+  scm_c_export ("ly:kpathsea-expand-variable", NULL);
+}
+
+#endif
index e5c1fccb023d0f743c891d14f527a26abf5dbe35..8070b6ad40dfac3c2a62e213d6a2e64a6ec7e79e 100644 (file)
@@ -4,7 +4,7 @@ depth = ..
 NAME = lilypond
 SUBDIRS = include
 
-MODULE_LIBS=$(depth)/flower  $(depth)/ttftool 
+MODULE_LIBS=$(depth)/flower  $(depth)/ttftool $(depth)/kpath-guile 
 MODULE_INCLUDES= $(depth)/flower/include $(depth)/ttftool/include 
 MODULE_CXXFLAGS= 
 
index 29949539e607a029019d1d3e43f6a1cbd4b1b9d7..2e0009a6f9f535237345434b94847ec0772cfe48 100644 (file)
@@ -97,6 +97,25 @@ All_font_metrics::find_pango_font (PangoFontDescription*description,
 
 #endif
 
+String
+kpathsea_find_file (String name, String ext)
+{
+  name += "." +  ext;
+  String path = global_path.find (name);
+  if (path.length() > 0)
+    return path;
+
+  SCM kpath = ly_lily_module_constant ("ly:kpathsea-find-file");
+  if (ly_c_procedure_p (kpath))
+    {
+      SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0()));
+      if (scm_is_string (kp_result))
+       return ly_scm2string (kp_result);
+    }
+
+  return "";
+}
+
 /*
   TODO: our AFM handling is broken: the units in an AFM file are
   relative to the design size (1000 units = 1 designsize). Hence we
@@ -119,7 +138,7 @@ All_font_metrics::find_afm (String name)
 
       if (file_name.is_empty ())
        {
-         String p = kpathsea_find_afm (name.to_str0 ());
+         String p = kpathsea_find_file (name, "afm");
          if (p.length ())
            file_name = p;
        }
@@ -225,7 +244,7 @@ All_font_metrics::find_tfm (String name)
        {
          /* FIXME: should add "cork-" prefix to lm* fonts.  How to do
             that, cleanly?  */
-         String p = kpathsea_find_tfm (name.to_str0 ());
+         String p = kpathsea_find_file (name, "tfm");
          if (p.length ())
            file_name = p;
        }
index 153c7a1b3c06650e022b2119effee8d0259e0d4f..8d12c49adbcc10360018ab40cbb0b3b2698145af 100644 (file)
@@ -33,6 +33,7 @@ extern bool be_safe_global;
 extern bool be_verbose_global;
 extern bool do_internal_type_checking_global;
 extern bool is_pango_format_global;
+extern bool is_TeX_format_global;
 extern String prefix_directory;
 
 /*
diff --git a/lily/kpath-scheme.cc b/lily/kpath-scheme.cc
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/lily/kpath.cc b/lily/kpath.cc
deleted file mode 100644 (file)
index e69de29..0000000
index 12035d65015ffc4dcf94eab9611960436c6397f9..00b71274b3520eafc68c907502432fa458a26bc6 100644 (file)
@@ -14,6 +14,7 @@
 #include <cctype>
 #include <libintl.h>           // gettext on macos x
 
+#include "config.hh"
 #include "version.hh"
 #include "lily-guile.hh"
 #include "libc-extension.hh"
@@ -196,12 +197,18 @@ ly_init_ly_module (void *)
 {
   for (int i = scm_init_funcs_->size () ; i--;)
     (scm_init_funcs_->elem (i)) ();
-
   if (be_verbose_global)
     progress_indication ("\n");
 
 #if KPATHSEA
-  initialize_kpathsea ();
+  if (is_TeX_format_global)
+    {
+      /*
+       TODO: load this dynamically
+      */
+      initialize_kpathsea ();
+    }
 #endif
   
   scm_primitive_load_path (scm_makfrom0str ("lily.scm"));
index 3ad0b6645e3da777a9316c2732466d76efe5ecd4..52e2c277109888f3e56e58d5ce765d7dafd37e0e 100644 (file)
@@ -53,6 +53,7 @@ String init_name_global;
 String output_backend_global = "ps";
 String output_format_global = "pdf";
 bool is_pango_format_global;
+bool is_TeX_format_global;
 
 /* Current output name. */
 String output_name_global;
@@ -90,25 +91,25 @@ static char const *PROGRAM_NAME = "lilypond";
 static char const *PROGRAM_URL = "http://lilypond.org";
 
 static char const *NOTICE =
-_f ("This program is free software.  It is covered by the GNU General Public\n"
-    "License and you are welcome to change it and/or distribute copies of it\n"
-    "under certain conditions.  Invoke as `%s --warranty' for more\n"
-    "information.\n", "lilypond").to_str0 ();
+"This program is free software.  It is covered by the GNU General Public\n"
+"License and you are welcome to change it and/or distribute copies of it\n"
+"under certain conditions.  Invoke as `%s --warranty' for more\n"
+"information.\n";
   
 static char const *WARRANTY =
-_i ("    This program is free software; you can redistribute it and/or\n"
-    "modify it under the terms of the GNU General Public License version 2\n"
-    "as published by the Free Software Foundation.\n"
-    "\n"
-    "    This program is distributed in the hope that it will be useful,\n"
-    "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-    "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
-    "General Public License for more details.\n"
-    "\n"
-    "    You should have received a copy (refer to the file COPYING) of the\n"
-    "GNU General Public License along with this program; if not, write to\n"
-    "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n"
-    "Boston, MA 02111-1307, USA.\n");
+"    This program is free software; you can redistribute it and/or\n"
+"modify it under the terms of the GNU General Public License version 2\n"
+"as published by the Free Software Foundation.\n"
+"\n"
+"    This program is distributed in the hope that it will be useful,\n"
+"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
+"General Public License for more details.\n"
+"\n"
+"    You should have received a copy (refer to the file COPYING) of the\n"
+"GNU General Public License along with this program; if not, write to\n"
+"the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n"
+"Boston, MA 02111-1307, USA.\n";
 
 
 /* Where the init files live.  Typically:
@@ -158,7 +159,12 @@ static void
 dir_info (FILE *out)
 {
   fputs ("\n", out);
-  fprintf (out, "Directory prefix: \"%s\"\n", prefix_directory.to_str0());
+  fprintf (out, "LILYPOND_DATADIR=\"%s\"\n", LILYPOND_DATADIR);
+  if (char const * env = getenv ("LILYPONDPREFIX"))
+    fprintf (out, "LILYPONDPREFIX=\"%s\"\n",  env);
+  fprintf (out, "LOCALEDIR=\"%s\"\n", LOCALEDIR);
+
+  fprintf (out, "\nEffective prefix: \"%s\"\n", prefix_directory.to_str0());
 }
 
 static void
@@ -181,7 +187,7 @@ static void
 notice ()
 {
   identify (stdout);
-  printf (_f (NOTICE, PROGRAM_NAME).to_str0 ());
+  puts (_f (NOTICE, PROGRAM_NAME).to_str0 ());
   printf ("\n");
   copyright ();
 }
@@ -220,7 +226,7 @@ warranty ()
 static void
 setup_paths ()
 {
-  prefix_directory = DATADIR "/lilypond/" MAJOR_VERSION "." MINOR_VERSION;
+  prefix_directory = LILYPOND_DATADIR;
   if (char const * env = getenv ("LILYPONDPREFIX"))
     prefix_directory = env;
 
@@ -351,6 +357,11 @@ main_with_guile (void *, int, char **)
 
   if (be_verbose_global)
     dir_info (stderr);
+  is_TeX_format_global = (output_backend_global == "tex"
+                         || output_backend_global == "texstr");
+
+  is_pango_format_global = !is_TeX_format_global;
+    
 
   ly_c_init_guile ();
   call_constructors ();
@@ -359,9 +370,6 @@ main_with_guile (void *, int, char **)
   
   init_freetype ();
 
-  is_pango_format_global = (output_backend_global != "tex"
-                           && output_backend_global != "texstr");
-
   all_fonts_global = new All_font_metrics (global_path.to_string ());
 
   init_scheme_code_string += ")";
@@ -527,7 +535,6 @@ main (int argc, char **argv)
   setup_paths ();
   parse_argv (argc, argv);
   identify (stderr);
-  initialize_kpathsea (argv[0]);
 
   scm_boot_guile (argc, argv, main_with_guile, 0);
 
index 28a562bdc8d6c63bb6a4e0a4bf0e5d1b0ed21c1a..9b6f7fb6d470f06c5b33a3ca7189e79feb20150f 100644 (file)
@@ -184,7 +184,7 @@ Pitch::to_string () const
     {
       int o = (-octave_) - 1;
       while (o--)
-       s += ::to_string (', ');
+       s += ::to_string (',');
     }
 
   return s;
index bede4008e233863f7dba59c11a58549b7ef0d806..a5fdf4ea85bf6b16af7859dad137950eff37b72e 100644 (file)
   (let ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
     (add-music-fonts n factor)
     (add-cmr-fonts n factor)
-    (if (ly:kpathsea-find-file "lmr10.pfb")
-       (add-cork-lm-fonts n factor))
-    (if (ly:kpathsea-find-file "ecrm10.pfa")
-       (add-ec-fonts n factor))
+    (if (defined? 'ly:kpathsea-find-file)
+       (begin
+         (if (ly:kpathsea-find-file "lmr10.pfb")
+             (add-cork-lm-fonts n factor))
+         (if (ly:kpathsea-find-file "ecrm10.pfa")
+             (add-ec-fonts n factor))))
     n))
 
 (define-public (make-century-schoolbook-tree factor)