LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 UGH : this is a complete mess. | 158 UGH : this is a complete mess. |
159 */ | 159 */ |
160 void | 160 void |
161 setup_paths (char const *argv0_ptr) | 161 setup_paths (char const *argv0_ptr) |
162 { | 162 { |
163 File_name argv0_filename (argv0_ptr); | 163 File_name argv0_filename (argv0_ptr); |
164 | 164 |
165 if (relocate_binary) | 165 if (relocate_binary) |
166 { | 166 { |
167 string prefix_directory; | 167 string prefix_directory; |
168 if (getenv ("LILYPOND_RELOCATE_PREFIX")) | 168 string argv0_abs; |
169 { | 169 if (argv0_filename.is_absolute ()) |
170 prefix_directory = getenv ("LILYPOND_RELOCATE_PREFIX"); | 170 { |
171 #ifdef __MINGW32__ | 171 argv0_abs = argv0_filename.to_string (); |
172 /* Normalize file name. */ | 172 debug_output (_f ("Relocation: is absolute: argv0=%s\n", argv0_ptr)); |
173 prefix_directory = File_name (prefix_directory).to_string (); | 173 } |
| 174 else if (argv0_filename.dir_.length ()) |
| 175 { |
| 176 argv0_abs = get_working_directory () |
| 177 + "/" + string (argv0_filename.to_string ()); |
| 178 debug_output (_f ("Relocation : from cwd: argv0=%s\n", argv0_ptr)); |
| 179 } |
| 180 else |
| 181 { |
| 182 /* Find absolute ARGV0 name, using PATH. */ |
| 183 File_path path; |
| 184 path.parse_path (getenv ("PATH")); |
| 185 |
| 186 #ifndef __MINGW32__ |
| 187 argv0_abs = path.find (argv0_filename.to_string ()); |
| 188 #else /* __MINGW32__ */ |
| 189 path.prepend (get_working_directory ()); |
| 190 char const *ext[] = {"exe", "", 0 }; |
| 191 argv0_abs = path.find (argv0_filename.to_string (), ext); |
174 #endif /* __MINGW32__ */ | 192 #endif /* __MINGW32__ */ |
175 | 193 |
176 prefix_relocation (prefix_directory); | 194 debug_output (_f ("Relocation: from PATH=%s\nargv0=%s\n", |
177 string bindir = prefix_directory + "/bin"; | 195 path.to_string ().c_str (), argv0_ptr), true); |
178 framework_relocation (bindir); | 196 |
179 } | 197 if (argv0_abs.empty ()) |
180 else if (relocate_binary) | 198 programming_error ("cannot find absolute argv0"); |
181 { | 199 } |
182 string argv0_abs; | 200 |
183 if (argv0_filename.is_absolute ()) | 201 string bindir = dir_name (argv0_abs); |
184 { | 202 string argv0_prefix = dir_name (bindir); |
185 argv0_abs = argv0_filename.to_string (); | 203 string compile_prefix = dir_name (dir_name (dir_name (lilypond_datadir))); |
186 debug_output (_f ("Relocation: is absolute: argv0=%s\n", argv0_ptr
)); | 204 if (argv0_prefix != compile_prefix) |
187 } | 205 { |
188 else if (argv0_filename.dir_.length ()) | 206 prefix_relocation (argv0_prefix); |
189 { | 207 prefix_directory = argv0_prefix; |
190 argv0_abs = get_working_directory () | 208 } |
191 + "/" + string (argv0_filename.to_string ()); | 209 if (argv0_prefix != compile_prefix || string (FRAMEWORKDIR) != "..") |
192 debug_output (_f ("Relocation: from cwd: argv0=%s\n", argv0_ptr)); | 210 { |
193 } | 211 framework_relocation (bindir + "/" + FRAMEWORKDIR); |
194 else | 212 prefix_directory = bindir + "/" + FRAMEWORKDIR; |
195 { | |
196 /* Find absolute ARGV0 name, using PATH. */ | |
197 File_path path; | |
198 path.parse_path (getenv ("PATH")); | |
199 | |
200 #ifndef __MINGW32__ | |
201 argv0_abs = path.find (argv0_filename.to_string ()); | |
202 #else /* __MINGW32__ */ | |
203 path.prepend (get_working_directory ()); | |
204 char const *ext[] = {"exe", "", 0 }; | |
205 argv0_abs = path.find (argv0_filename.to_string (), ext); | |
206 #endif /* __MINGW32__ */ | |
207 | |
208 debug_output (_f ("Relocation: from PATH=%s\nargv0=%s", | |
209 path.to_string ().c_str (), argv0_ptr), true); | |
210 | |
211 if (argv0_abs.empty ()) | |
212 programming_error ("cannot find absolute argv0"); | |
213 } | |
214 | |
215 string bindir = dir_name (argv0_abs); | |
216 string argv0_prefix = dir_name (bindir); | |
217 string compile_prefix = dir_name (dir_name (dir_name (lilypond_datadir
))); | |
218 if (argv0_prefix != compile_prefix) | |
219 { | |
220 prefix_relocation (argv0_prefix); | |
221 prefix_directory = argv0_prefix; | |
222 } | |
223 if (argv0_prefix != compile_prefix || string (FRAMEWORKDIR) != "..") | |
224 { | |
225 framework_relocation (bindir + "/" + FRAMEWORKDIR); | |
226 prefix_directory = bindir + "/" + FRAMEWORKDIR; | |
227 } | |
228 } | 213 } |
229 | 214 |
230 lilypond_datadir = prefix_directory | 215 lilypond_datadir = prefix_directory |
231 + "/share/lilypond/" TOPLEVEL_VERSION; | 216 + "/share/lilypond/" TOPLEVEL_VERSION; |
232 } | 217 } |
233 | 218 |
234 if (getenv ("LILYPONDPREFIX")) | 219 if (getenv ("LILYPONDPREFIX")) |
235 error (_ ("LILYPONDPREFIX is obsolete, use LILYPOND_DATADIR")); | 220 error (_ ("LILYPONDPREFIX is obsolete, use LILYPOND_DATADIR")); |
236 | 221 |
237 if (char const *env = getenv ("LILYPOND_DATADIR")) | 222 if (char const *env = getenv ("LILYPOND_DATADIR")) |
(...skipping 21 matching lines...) Expand all Loading... |
259 vector<string> dirs; | 244 vector<string> dirs; |
260 for (char const **s = suffixes; *s; s++) | 245 for (char const **s = suffixes; *s; s++) |
261 { | 246 { |
262 string path = lilypond_datadir + to_string ('/') + string (*s); | 247 string path = lilypond_datadir + to_string ('/') + string (*s); |
263 dirs.push_back (path); | 248 dirs.push_back (path); |
264 } | 249 } |
265 | 250 |
266 dirs.push_back (lilypond_datadir + "/fonts/otf/"); | 251 dirs.push_back (lilypond_datadir + "/fonts/otf/"); |
267 dirs.push_back (lilypond_datadir + "/fonts/type1/"); | 252 dirs.push_back (lilypond_datadir + "/fonts/type1/"); |
268 dirs.push_back (lilypond_datadir + "/fonts/svg/"); | 253 dirs.push_back (lilypond_datadir + "/fonts/svg/"); |
269 dirs.push_back (lilypond_datadir + "/fonts/"); | |
270 | 254 |
271 for (vsize i = 0; i < dirs.size (); i++) | 255 for (vsize i = 0; i < dirs.size (); i++) |
272 global_path.prepend (dirs[i]); | 256 global_path.prepend (dirs[i]); |
273 } | 257 } |
274 | 258 |
275 string | 259 string |
276 expand_environment_variables (string orig) | 260 expand_environment_variables (string orig) |
277 { | 261 { |
278 char const *start_ptr = orig.c_str (); | 262 char const *start_ptr = orig.c_str (); |
279 char const *ptr = orig.c_str (); | 263 char const *ptr = orig.c_str (); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 read_relocation_dir (string dirname) | 386 read_relocation_dir (string dirname) |
403 { | 387 { |
404 if (DIR *dir = opendir (dirname.c_str ())) | 388 if (DIR *dir = opendir (dirname.c_str ())) |
405 while (struct dirent *ent = readdir (dir)) | 389 while (struct dirent *ent = readdir (dir)) |
406 { | 390 { |
407 File_name name (ent->d_name); | 391 File_name name (ent->d_name); |
408 if (name.ext_ == "reloc") | 392 if (name.ext_ == "reloc") |
409 read_relocation_file (dirname + "/" + name.to_string ()); | 393 read_relocation_file (dirname + "/" + name.to_string ()); |
410 } | 394 } |
411 } | 395 } |
LEFT | RIGHT |