Transfer 'lv2_bundled_search_path()' into 'libs/ardour/search_paths.cc'
[ardour.git] / libs / ardour / search_paths.cc
1 /*
2     Copyright (C) 2011 Tim Mayberry 
3     Copyright (C) 2013 Paul Davis 
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #include <glibmm/miscutils.h>
22
23 #include "pbd/pathexpand.h"
24
25 #include "ardour/search_paths.h"
26 #include "ardour/directory_names.h"
27 #include "ardour/filesystem_paths.h"
28
29 namespace {
30         const char * const backend_env_variable_name = "ARDOUR_BACKEND_PATH";
31         const char * const surfaces_env_variable_name = "ARDOUR_SURFACES_PATH";
32         const char * const export_env_variable_name = "ARDOUR_EXPORT_FORMATS_PATH";
33         const char * const ladspa_env_variable_name = "LADSPA_PATH";
34 } // anonymous
35
36 using namespace PBD;
37
38 namespace ARDOUR {
39
40 Searchpath
41 backend_search_path ()
42 {
43         Searchpath spath(user_config_directory ());
44         spath += ardour_dll_directory ();
45         spath.add_subdirectory_to_paths(backend_dir_name);
46
47         spath += Searchpath(Glib::getenv(backend_env_variable_name));
48         return spath;
49 }
50
51 Searchpath
52 control_protocol_search_path ()
53 {
54         Searchpath spath(user_config_directory ());
55         spath += ardour_dll_directory ();
56         spath.add_subdirectory_to_paths (surfaces_dir_name);
57         
58         spath += Searchpath(Glib::getenv(surfaces_env_variable_name));
59         return spath;
60 }
61
62 Searchpath
63 export_formats_search_path ()
64 {
65         Searchpath spath (ardour_data_search_path());
66         spath.add_subdirectory_to_paths (export_formats_dir_name);
67
68         bool export_formats_path_defined = false;
69         Searchpath spath_env (Glib::getenv(export_env_variable_name, export_formats_path_defined));
70
71         if (export_formats_path_defined) {
72                 spath += spath_env;
73         }
74
75         return spath;
76 }
77
78 Searchpath
79 ladspa_search_path ()
80 {
81         Searchpath spath_env (Glib::getenv(ladspa_env_variable_name));
82
83         Searchpath spath (user_config_directory ());
84
85         spath += ardour_dll_directory ();
86         spath.add_subdirectory_to_paths (ladspa_dir_name);
87
88 #ifndef PLATFORM_WINDOWS
89         spath.push_back ("/usr/local/lib64/ladspa");
90         spath.push_back ("/usr/local/lib/ladspa");
91         spath.push_back ("/usr/lib64/ladspa");
92         spath.push_back ("/usr/lib/ladspa");
93 #endif
94
95 #ifdef __APPLE__
96         spath.push_back (path_expand ("~/Library/Audio/Plug-Ins/LADSPA"));
97         spath.push_back ("/Library/Audio/Plug-Ins/LADSPA");
98 #endif
99
100         return spath_env + spath;
101 }
102
103 Searchpath
104 lv2_bundled_search_path ()
105 {
106         Searchpath spath( ardour_dll_directory () );
107         spath.add_subdirectory_to_paths ("LV2");
108
109         return spath;
110 }
111
112 } // namespace ARDOUR