]> git.donarmstrong.com Git - lilypond.git/blob - lily/kpath.cc
07fcbc62b89c7ff47e952cb81885cd57bcd24a43
[lilypond.git] / lily / kpath.cc
1 /*   
2   kpath.cc -- glue kpathsea to lily. Need some ugly kludges for gcc 2.96
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include <stdio.h>
10 #include <string.h>
11
12 /*
13
14 The problem, as far as I can tell, is that MacOS X has its getopt
15 prototype in <unistd.h>, while I think other operating systems have it
16 in other places. <unistd.h> is included by kpathsea.h, so you end up
17 renaming both conflicting prototypes to YAKLUDGE.
18
19 I found a somewhat more elegant patch for this: Just #include
20 <unistd.h> before defining YAKLUDGE.
21
22 */
23 #include <unistd.h>     
24 #include "config.h"
25
26 #define popen REALLYUGLYKLUDGE
27 #define pclose ANOTHERREALLYUGLYKLUDGE
28 #define getopt YAKLUDGE
29
30 #if HAVE_KPATHSEA_KPATHSEA_H
31 extern "C" {
32 #include <kpathsea/kpathsea.h>
33 #include <kpathsea/tex-file.h>
34 }
35 #endif
36
37 #include "file-path.hh"
38 #include "string.hh"
39 #include "main.hh"
40 #include "kpath.hh"
41 #include "warn.hh"
42
43 String
44 kpathsea_find_afm (char const * name)
45 {
46 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
47   char * name_ptr =  kpse_find_file (name, kpse_afm_format, true);
48
49   if(!name_ptr)
50     {
51   /*
52     don't mutter about afms, since we try to find them first, and lots of
53     TFMs don't have AFMs. 
54    */
55       //      warning (_f("kpathsea couldn't find AFM file `%s'", name));
56     }
57   else
58     return name_ptr;
59   
60 #endif
61   return "";
62 }
63
64 String
65 kpathsea_find_tfm (char const * name)
66 {
67   String p = global_path.find (String (name) + ".tfm");
68
69   if (p.length ())
70     return p;
71   
72 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
73   char * name_ptr =  kpse_find_file (name, kpse_tfm_format, true);
74   if(!name_ptr)
75     {
76       warning (_f("Kpathsea couldn't find TFM file `%s'", name));
77     }
78   else
79     return name_ptr;
80   
81 #endif
82   return "";
83 }
84
85
86 void
87 init_kpath (char *av0)
88 {
89 #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
90   /*
91     We take two pronged approach to tfms:
92
93     * the lilypond tfms (feta*.tfm) are found through our own routines.
94
95     * the TeX tfms are found through vanilla kpathsea.
96
97     (* other TFMs are not found, i.e. don't use them. )
98
99     PRO:
100  
101     - TFM and AFM checksums always match in Lily.
102
103     - less hassle, no kpathsea spaghetti
104
105     CON:
106
107     - feta PK files are often recreated, locally
108     Solution: cache PK files locally?
109
110     - need env. vars to make sure that TeX finds the TFMs
111
112     - Outdated PK (TFM?) font files are not automatically removed,
113     since VERSION is not part of the standard location.
114
115
116     ALTERNATIVE
117
118     we have tried to come up with schemes that leave this kind of work
119     to kpathsea with objective of fixing the CONs, but miserably
120     failed. TeX installations and kpathsea itself form a buggy,
121     inconsistent, and unorderly mess.
122     
123   */
124
125   /*
126    initialize kpathsea
127    */
128   kpse_set_program_name (av0, NULL);
129   kpse_maketex_option ("tfm", TRUE);
130 #endif
131 }
132
133