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
#
SUBDIRS = buildscripts python scripts \
elisp \
- flower ttftool lily \
+ flower kpath-guile ttftool lily \
mf ly tex ps scm \
po make \
cygwin debian stepmake \
/* 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@"
--- /dev/null
+# 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)
+
+
--- /dev/null
+/*
+ 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
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=
#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
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;
}
{
/* 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;
}
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;
/*
#include <cctype>
#include <libintl.h> // gettext on macos x
+#include "config.hh"
#include "version.hh"
#include "lily-guile.hh"
#include "libc-extension.hh"
{
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"));
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;
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:
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
notice ()
{
identify (stdout);
- printf (_f (NOTICE, PROGRAM_NAME).to_str0 ());
+ puts (_f (NOTICE, PROGRAM_NAME).to_str0 ());
printf ("\n");
copyright ();
}
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;
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 ();
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 += ")";
setup_paths ();
parse_argv (argc, argv);
identify (stderr);
- initialize_kpathsea (argv[0]);
scm_boot_guile (argc, argv, main_with_guile, 0);
{
int o = (-octave_) - 1;
while (o--)
- s += ::to_string (', ');
+ s += ::to_string (',');
}
return s;
(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)